From c799ef11f7765fe6d3cb8956b7863bfaff4bbf5a Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Mon, 6 Aug 2012 00:32:57 +0000 Subject: [PATCH] --- .../Debug/Cosmos.Debug.Common/DebugModel.edmx | 8 +- .../Cosmos.Debug.Common/DebugModel.edmx.sql | 9 +- source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs | 125 +++--------------- 3 files changed, 32 insertions(+), 110 deletions(-) diff --git a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx index 9125c74c9..e578aefb7 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx +++ b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx @@ -83,8 +83,8 @@ - - + + @@ -275,8 +275,8 @@ - - + + diff --git a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx.sql b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx.sql index 1198854ab..bcdaac9f7 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx.sql +++ b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx.sql @@ -2,7 +2,7 @@ -- -------------------------------------------------- -- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure -- -------------------------------------------------- --- Date Created: 08/04/2012 19:00:46 +-- Date Created: 08/05/2012 20:29:02 -- Generated from EDMX file: D:\source\Cosmos\source2\Debug\Cosmos.Debug.Common\DebugModel.edmx -- -------------------------------------------------- @@ -17,6 +17,9 @@ GO -- Dropping existing FOREIGN KEY constraints -- -------------------------------------------------- +IF OBJECT_ID(N'[dbo].[FK_AssemblyFileMethod]', 'F') IS NOT NULL + ALTER TABLE [dbo].[Methods] DROP CONSTRAINT [FK_AssemblyFileMethod]; +GO -- -------------------------------------------------- -- Dropping existing tables @@ -111,8 +114,8 @@ CREATE TABLE [dbo].[Methods] ( [TypeToken] int NOT NULL, [MethodToken] int NOT NULL, [LabelName] nvarchar(512) NOT NULL, - [AddressStart] bigint NULL, - [AddressEnd] bigint NULL, + [AddressStartFuture] bigint NULL, + [AddressEndFuture] bigint NULL, [AssemblyFileID] uniqueidentifier NOT NULL ); GO diff --git a/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs b/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs index f39d00d91..4be82137f 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs @@ -294,26 +294,7 @@ namespace Cosmos.IL2CPU { // Start scanning, return when complete. ScanQueue(); - // It would be nice to keep DebugInfo output into assembler only but - // there is so much info that is available in scanner that is needed - // or can be used in a more efficient manner. So we output in both - // scanner and assembler as needed. - // - // -SQL Inserts are slow when done individually. - // -Assemblies can only be uniquely identified by their names or instance. ie there is no Token for example. - // -Assembly table must be written before dependent items like Method - // can be written. - var xAssemblies = new List(); - foreach (var xAsm in mUsedAssemblies) { - var xRow = new Cosmos.Debug.Common.AssemblyFile() { - ID = Guid.NewGuid(), - Pathname = xAsm.Location - }; - xAssemblies.Add(xRow); - - mAsmblr.Assemblies.Add(xAsm, xRow.ID); - } - mAsmblr.DebugInfo.AddAssemblies(xAssemblies); + UpdateAssemblies(); // Time to assemble foreach (var xItem in mItems) { @@ -1255,89 +1236,27 @@ namespace Cosmos.IL2CPU { } } - // === Old code and comments ====================================================== + protected void UpdateAssemblies() { + // It would be nice to keep DebugInfo output into assembler only but + // there is so much info that is available in scanner that is needed + // or can be used in a more efficient manner. So we output in both + // scanner and assembler as needed. + // + // -SQL Inserts are slow when done individually. + // -Assemblies can only be uniquely identified by their names or instance. ie there is no Token for example. + // -Assembly table must be written before dependent items like Method + // can be written. + var xAssemblies = new List(); + foreach (var xAsm in mUsedAssemblies) { + var xRow = new Cosmos.Debug.Common.AssemblyFile() { + ID = Guid.NewGuid(), + Pathname = xAsm.Location + }; + xAssemblies.Add(xRow); - // //TODO: These store the MethodBase which also have the IL for the body in memory - // // For large asms this could eat lot of RAM. Should convert this to remove - // // items from the list after they are processed but keep them in HashSet so we - // // know they are already done. Currently HashSet uses a reference though, so we - // // need to hash on some UID instead of the refernce. Do not use strings, they are - // // super slow. - // // TODO: We need to scan for static fields too. - - // private void ScanMethod(MethodInfo aMethodInfo) { - // var xMethodBase = aMethodInfo.MethodBase; - - - // // Assemble the method - //TODO: We have to load the opcodes twice, this might be slow, - // but loading in RAM could consume lots of RAM - // if (aMethodInfo.MethodBase.DeclaringType != mThrowHelper) { - // mAsmblr.ProcessMethod(aMethodInfo, xOpCodes); - // } - // } - // } - - // private void QueueField(object aSrc, string aSrcType, Cosmos.IL2CPU.ILOpCodes.OpField xOpField) { - // // todo: add log map thing? - // if (!mStaticFields.Contains(xOpField.Value)) { - // mStaticFields.Add(xOpField.Value); - // mAsmblr.ProcessField(xOpField.Value); - - // QueueType(xOpField.Value, "FieldType", xOpField.Value.FieldType); - // QueueType(xOpField.Value, "DeclaringType", xOpField.Value.FieldType); - // } - // } - - // // QueueMethod should only queue the method, and do no processing of the - // // body or resolution of its contents. It is called during plug resolution - // // etc and all further resolution should wait until all plugs are loaded. - // public uint QueueMethod(object aSrc, string aSrcType, MethodBase aMethodBase - // , bool aIsPlug) - // { - // uint xResult; - - // xResult = (uint)mMethodsToProcess.Count; - // mKnownMethods.Add(aMethodBase, xResult); - // MethodInfo xPlug = null; - // Type xPlugAssembler = null; - // var xMethodType = MethodInfo.TypeEnum.Normal; - // if (aIsPlug) { - // xMethodType = MethodInfo.TypeEnum.Plug; - // } else { - // xMethodType = MethodInfo.TypeEnum.Normal; - - - // if (xMethodType == MethodInfo.TypeEnum.NeedsPlug && xPlug == null && xPlugAssembler == null) { - // throw new Exception("Method [" + aMethodBase.DeclaringType + "." + aMethodBase.Name + "] needs to be plugged, but wasn't"); - // } - // } - - // var xMethod = new MethodInfo(aMethodBase, xResult, xMethodType, xPlug, xPlugAssembler); - // mMethodsToProcess.Add(xMethod); - - // if(!aIsPlug) { - // // Queue Types directly related to method - // QueueType(aMethodBase, "Declaring Type", aMethodBase.DeclaringType); - // if (aMethodBase is System.Reflection.MethodInfo) { - // QueueType(aMethodBase, "Return Type", ((System.Reflection.MethodInfo)aMethodBase).ReturnType); - // } - // foreach (var xParam in aMethodBase.GetParameters()) { - // QueueType(aMethodBase, "Parameter", xParam.ParameterType); - // } - // } - // return xResult; - // } - - // //protected void QueueStaticField(FieldInfo aFieldInfo) { - // // if (!mFieldsSet.Contains(aFieldInfo)) { - // // if (!aFieldInfo.IsStatic) { - // // throw new Exception("Cannot queue instance fields!"); - // // } - // // mFieldsSet.Add(aFieldInfo); - // // QueueType(aFieldInfo.DeclaringType); - // // QueueType(aFieldInfo.FieldType); - // // } - // //} + mAsmblr.Assemblies.Add(xAsm, xRow.ID); + } + mAsmblr.DebugInfo.AddAssemblies(xAssemblies); + } } }