From 440b8ff60ff7251b5aac2fcdfd5c3a88bec37652 Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Tue, 7 Aug 2012 02:48:32 +0000 Subject: [PATCH] --- .../Cosmos.Assembler/Cosmos.Assembler.csproj | 2 +- source2/Cosmos.Assembler/DataMember.cs | 6 ++-- source2/Cosmos.Assembler/Label.cs | 4 +-- ...thodInfoLabelGenerator.cs => LabelName.cs} | 35 ++++++++++--------- .../Debug/Cosmos.Debug.Common/DebugModel.edmx | 4 +-- .../Cosmos.Debug.Common/DebugModel.edmx.sql | 4 +-- source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs | 20 +++++------ source2/IL2CPU/Cosmos.IL2CPU/ILOp.cs | 8 ++--- source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs | 30 ++++++++-------- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Box.cs | 2 +- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Call.cs | 6 ++-- .../IL2CPU/Cosmos.IL2CPU/x86/IL/Callvirt.cs | 4 +-- .../IL2CPU/Cosmos.IL2CPU/x86/IL/Castclass.cs | 2 +- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldftn.cs | 2 +- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsfld.cs | 2 +- .../IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsflda.cs | 2 +- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newarr.cs | 4 +-- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newobj.cs | 8 ++--- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stfld.cs | 4 +-- source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stsfld.cs | 2 +- .../Plugs/NEW_PLUGS/InvokeImplAssembler.cs | 2 +- .../Assemblers/MulticastDelegate_Invoke.cs | 2 +- .../Core/Cosmos.Core.Plugs/UpdateIDT.cs | 2 +- 23 files changed, 80 insertions(+), 77 deletions(-) rename source2/Cosmos.Assembler/{MethodInfoLabelGenerator.cs => LabelName.cs} (79%) diff --git a/source2/Cosmos.Assembler/Cosmos.Assembler.csproj b/source2/Cosmos.Assembler/Cosmos.Assembler.csproj index d1af92228..d23840f14 100644 --- a/source2/Cosmos.Assembler/Cosmos.Assembler.csproj +++ b/source2/Cosmos.Assembler/Cosmos.Assembler.csproj @@ -118,7 +118,7 @@ - + diff --git a/source2/Cosmos.Assembler/DataMember.cs b/source2/Cosmos.Assembler/DataMember.cs index 70cf6d5c5..7771e3114 100644 --- a/source2/Cosmos.Assembler/DataMember.cs +++ b/source2/Cosmos.Assembler/DataMember.cs @@ -7,7 +7,6 @@ using System.IO; namespace Cosmos.Assembler { public class DataMember : BaseAssemblerElement, IComparable { - public const string IllegalIdentifierChars = "&.,+$<>{}-`\'/\\ ()[]*!="; public string Name { get; private set; } public bool IsComment { get; set; } public byte[] RawDefaultValue { get; set; } @@ -91,12 +90,15 @@ namespace Cosmos.Assembler { } public static string GetStaticFieldName(FieldInfo aField) { - return FilterStringForIncorrectChars("static_field__" + MethodInfoLabelGenerator.GetFullName(aField.DeclaringType) + "." + aField.Name); + return FilterStringForIncorrectChars("static_field__" + LabelName.GetFullName(aField.DeclaringType) + "." + aField.Name); } + public const string IllegalIdentifierChars = "&.,+$<>{}-`\'/\\ ()[]*!="; public static string FilterStringForIncorrectChars(string aName) { string xTempResult = aName; foreach (char c in IllegalIdentifierChars) { + //TODO Use empty, not _. We need shorter names, and _ can be used for explicit demarkation. + // Need to add _ to illegal chars, and cant change currently as it goofs stuff up. xTempResult = xTempResult.Replace(c, '_'); } return String.Intern(xTempResult); diff --git a/source2/Cosmos.Assembler/Label.cs b/source2/Cosmos.Assembler/Label.cs index c078b39e9..2473ab18e 100644 --- a/source2/Cosmos.Assembler/Label.cs +++ b/source2/Cosmos.Assembler/Label.cs @@ -7,12 +7,12 @@ using System.Text; namespace Cosmos.Assembler { public class Label : Instruction { public static string GetFullName(MethodBase aMethod) { - return MethodInfoLabelGenerator.GenerateLabelName(aMethod); + return LabelName.Get(aMethod); } public string Comment { get; set; } - public Label(MethodBase aMethod) : this(MethodInfoLabelGenerator.GenerateLabelName(aMethod), "") { } + public Label(MethodBase aMethod) : this(LabelName.Get(aMethod), "") { } public Label(string aName) : this(aName, "") { diff --git a/source2/Cosmos.Assembler/MethodInfoLabelGenerator.cs b/source2/Cosmos.Assembler/LabelName.cs similarity index 79% rename from source2/Cosmos.Assembler/MethodInfoLabelGenerator.cs rename to source2/Cosmos.Assembler/LabelName.cs index 55f79af3c..df8c0d5bb 100644 --- a/source2/Cosmos.Assembler/MethodInfoLabelGenerator.cs +++ b/source2/Cosmos.Assembler/LabelName.cs @@ -6,29 +6,32 @@ using System.Security.Cryptography; using System.Diagnostics; using System.Reflection.Emit; - namespace Cosmos.Assembler { - public static class MethodInfoLabelGenerator { - public static uint LabelCount { - get; - private set; - } + public static class LabelName { + public static int LabelCount { get; private set; } + // Max length of labels at 256. We use 220 here so that we still have room for suffixes + // for IL positions, etc. + public const int MaxLengthWithoutSuffix = 200; - public static string GenerateLabelName(MethodBase aMethod) { + public static string Get(MethodBase aMethod) { string xResult = DataMember.FilterStringForIncorrectChars(GenerateFullName(aMethod)); - xResult = GenerateLabelFromFullName(xResult); - LabelCount++; - return xResult; + return Final(xResult); } - public static string GenerateLabelFromFullName(string xResult) { - if (xResult.Length > 245) { + public static string Final(string xName) { + if (xName.Length > MaxLengthWithoutSuffix) { using (var xHash = MD5.Create()) { - xResult = xHash.ComputeHash( - Encoding.Default.GetBytes(xResult)).Aggregate("_", (r, x) => r + x.ToString("X2")); + var xSB = new StringBuilder(); + foreach (var xByte in xHash.ComputeHash(Encoding.Default.GetBytes(xName))) { + xSB.Append(xByte.ToString("X2")); + } + // Keep length max 200 + xName = xName.Substring(0, MaxLengthWithoutSuffix - xSB.Length) + xSB.ToString(); } } - return xResult; + + LabelCount++; + return xName; } public static string GetFullName(Type aType) { @@ -65,8 +68,6 @@ namespace Cosmos.Assembler { xSB.Append(GetFullName(xArgs.Last())); xSB.Append(">"); } - //xSB.Append(", "); - //xSB.Append(aType.Assembly.FullName); return xSB.ToString(); } diff --git a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx index 46ef50107..92e74a975 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx +++ b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx @@ -45,7 +45,7 @@ - + @@ -171,7 +171,7 @@ - + diff --git a/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx.sql b/source2/Debug/Cosmos.Debug.Common/DebugModel.edmx.sql index cc41cc299..9ecc57b21 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/06/2012 21:20:56 +-- Date Created: 08/06/2012 22:45:00 -- Generated from EDMX file: D:\source\Cosmos\source2\Debug\Cosmos.Debug.Common\DebugModel.edmx -- -------------------------------------------------- @@ -77,7 +77,7 @@ GO -- Creating table 'Labels' CREATE TABLE [dbo].[Labels] ( [ID] uniqueidentifier NOT NULL, - [Name] nvarchar(512) NOT NULL, + [Name] nvarchar(256) NOT NULL, [Address] bigint NOT NULL ); GO diff --git a/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs b/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs index 58757441f..4b43d6aac 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs @@ -49,14 +49,14 @@ namespace Cosmos.IL2CPU { new Comment("Plugged: " + (aMethod.PlugMethod == null ? "No" : "Yes")); if (aMethod.PluggedMethod != null) { - new Cosmos.Assembler.Label("PLUG_FOR___" + MethodInfoLabelGenerator.GenerateLabelName(aMethod.PluggedMethod.MethodBase)); + new Cosmos.Assembler.Label("PLUG_FOR___" + LabelName.Get(aMethod.PluggedMethod.MethodBase)); } else { new Cosmos.Assembler.Label(aMethod.MethodBase); } var xMethodLabel = Cosmos.Assembler.Label.LastFullLabel; if (aMethod.MethodBase.IsStatic && aMethod.MethodBase is ConstructorInfo) { new Comment("This is a static constructor. see if it has been called already, and if so, return."); - var xName = DataMember.FilterStringForIncorrectChars("CCTOR_CALLED__" + MethodInfoLabelGenerator.GetFullName(aMethod.MethodBase.DeclaringType)); + var xName = DataMember.FilterStringForIncorrectChars("CCTOR_CALLED__" + LabelName.GetFullName(aMethod.MethodBase.DeclaringType)); var xAsmMember = new DataMember(xName, (byte)0); Assembler.DataMembers.Add(xAsmMember); new Compare { DestinationRef = Cosmos.Assembler.ElementReference.New(xName), DestinationIsIndirect = true, Size = 8, SourceValue = 1 }; @@ -427,7 +427,7 @@ namespace Cosmos.IL2CPU { protected void Call(MethodBase aMethod) { new Cosmos.Assembler.x86.Call { - DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(aMethod) + DestinationLabel = LabelName.Get(aMethod) }; } @@ -576,9 +576,9 @@ namespace Cosmos.IL2CPU { } } if (!xType.IsInterface) { - Move("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), (int)aGetTypeID(xType)); + Move("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), (int)aGetTypeID(xType)); Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add( - new DataMember("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), new int[] { (int)aGetTypeID(xType) })); + new DataMember("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), new int[] { (int)aGetTypeID(xType) })); Push((uint)xBaseIndex.Value); xData = new byte[16 + (xEmittedMethods.Count * 4)]; xTemp = BitConverter.GetBytes(aGetTypeID(typeof(Array))); @@ -589,10 +589,10 @@ namespace Cosmos.IL2CPU { Array.Copy(xTemp, 0, xData, 8, 4); xTemp = BitConverter.GetBytes(4); // embedded array Array.Copy(xTemp, 0, xData, 12, 4); - string xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodIndexesArray"; + string xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodIndexesArray"; Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(xDataName, xData)); Push(xDataName); - xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodAddressesArray"; + xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodAddressesArray"; Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(xDataName, xData)); Push(xDataName); xData = new byte[16 + Encoding.Unicode.GetByteCount(xType.FullName + ", " + xType.Module.Assembly.GetName().FullName)]; @@ -604,7 +604,7 @@ namespace Cosmos.IL2CPU { Array.Copy(xTemp, 0, xData, 8, 4); xTemp = BitConverter.GetBytes(2); // embedded array Array.Copy(xTemp, 0, xData, 12, 4); - xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name); + xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name); Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(xDataName, xData)); Push("0" + xEmittedMethods.Count.ToString("X") + "h"); Call(xSetTypeInfoRef); @@ -675,7 +675,7 @@ namespace Cosmos.IL2CPU { } public void ProcessField(FieldInfo aField) { - string xFieldName = MethodInfoLabelGenerator.GetFullName(aField); + string xFieldName = LabelName.GetFullName(aField); xFieldName = DataMember.GetStaticFieldName(aField); if (Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Count(x => x.Name == xFieldName) == 0) { var xItemList = (from item in aField.GetCustomAttributes(false) @@ -807,7 +807,7 @@ namespace Cosmos.IL2CPU { } protected static void WriteDebug(MethodBase aMethod, uint aSize, uint aSize2) { - var xLine = String.Format("{0}\t{1}\t{2}", MethodInfoLabelGenerator.GenerateFullName(aMethod), aSize, aSize2); + var xLine = String.Format("{0}\t{1}\t{2}", LabelName.GenerateFullName(aMethod), aSize, aSize2); } // These are all temp functions until we move to the new assembler. diff --git a/source2/IL2CPU/Cosmos.IL2CPU/ILOp.cs b/source2/IL2CPU/Cosmos.IL2CPU/ILOp.cs index cebf615c3..292f76473 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/ILOp.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/ILOp.cs @@ -25,7 +25,7 @@ namespace Cosmos.IL2CPU { public abstract void Execute(MethodInfo aMethod, ILOpCode aOpCode); public static string GetTypeIDLabel(Type aType) { - return "VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(aType) + " ASM_IS__" + aType.Assembly.GetName().Name); + return "VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(aType) + " ASM_IS__" + aType.Assembly.GetName().Name); } public static uint Align(uint aSize, uint aAlign) { @@ -41,7 +41,7 @@ namespace Cosmos.IL2CPU { } public static string GetMethodLabel(MethodBase aMethod) { - return MethodInfoLabelGenerator.GenerateLabelName(aMethod); + return LabelName.Get(aMethod); } public static string GetMethodLabel(MethodInfo aMethod) { @@ -174,13 +174,13 @@ namespace Cosmos.IL2CPU { DestinationRef = Cosmos.Assembler.ElementReference.New(LdStr.GetContentsArrayName(aMessage)) }; new CPU.Call { - DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(typeof(ExceptionHelper).GetMethod("ThrowNotImplemented", BindingFlags.Static | BindingFlags.Public)) + DestinationLabel = LabelName.Get(typeof(ExceptionHelper).GetMethod("ThrowNotImplemented", BindingFlags.Static | BindingFlags.Public)) }; } protected void ThrowOverflowException() { new CPU.Call { - DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( + DestinationLabel = LabelName.Get( typeof(ExceptionHelper).GetMethod("ThrowOverflow", BindingFlags.Static | BindingFlags.Public, null, new Type[] { }, null)) }; } diff --git a/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs b/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs index 96be38d9f..d99efa7ee 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs @@ -450,7 +450,7 @@ namespace Cosmos.IL2CPU { // isn't guaranteed. for (int i = 0; i < xParams.Length; i++) { xParamTypes[i] = xParams[i].ParameterType; - Queue(xParamTypes[i], MethodInfoLabelGenerator.GenerateFullName(aMethod), "Parameter"); + Queue(xParamTypes[i], LabelName.GenerateFullName(aMethod), "Parameter"); } var xIsDynamicMethod = aMethod.DeclaringType == null; // Queue Types directly related to method @@ -458,11 +458,11 @@ namespace Cosmos.IL2CPU { // Don't queue declaring types of plugs if (!xIsDynamicMethod) { // dont queue declaring types of dynamic methods either, those dont have a declaring type - Queue(aMethod.DeclaringType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Declaring Type"); + Queue(aMethod.DeclaringType, LabelName.GenerateFullName(aMethod), "Declaring Type"); } } if (aMethod is System.Reflection.MethodInfo) { - Queue(((System.Reflection.MethodInfo)aMethod).ReturnType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Return Type"); + Queue(((System.Reflection.MethodInfo)aMethod).ReturnType, LabelName.GenerateFullName(aMethod), "Return Type"); } // Scan virtuals @@ -509,7 +509,7 @@ namespace Cosmos.IL2CPU { // If it was already in mVirtuals, then ScanType will take // care of new additions. if (xVirtMethod != null) { - Queue(xVirtMethod, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Virtual Base"); + Queue(xVirtMethod, LabelName.GenerateFullName(aMethod), "Virtual Base"); mVirtuals.Add(xVirtMethod); if (aMethod.Name == "ToString") { Console.Write(""); @@ -525,7 +525,7 @@ namespace Cosmos.IL2CPU { // We need to check IsVirtual, a non virtual could // "replace" a virtual above it? if (xNewMethod.IsVirtual) { - Queue(xNewMethod, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Virtual Downscan"); + Queue(xNewMethod, LabelName.GenerateFullName(aMethod), "Virtual Downscan"); } } } @@ -557,7 +557,7 @@ namespace Cosmos.IL2CPU { } } if (xNeedsPlug) { - throw new Exception("Native code encountered, plug required. Please see http://cosmos.codeplex.com/wikipage?title=Plugs). " + MethodInfoLabelGenerator.GenerateFullName(aMethod) + "." + Environment.NewLine + " Called from :" + Environment.NewLine + sourceItem); + throw new Exception("Native code encountered, plug required. Please see http://cosmos.codeplex.com/wikipage?title=Plugs). " + LabelName.GenerateFullName(aMethod) + "." + Environment.NewLine + " Called from :" + Environment.NewLine + sourceItem); } //TODO: As we scan each method, we could update or put in a new list @@ -581,29 +581,29 @@ namespace Cosmos.IL2CPU { ProcessInstructions(xOpCodes); foreach (var xOpCode in xOpCodes) { if (xOpCode is ILOpCodes.OpMethod) { - Queue(((ILOpCodes.OpMethod)xOpCode).Value, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Call", sourceItem); + Queue(((ILOpCodes.OpMethod)xOpCode).Value, LabelName.GenerateFullName(aMethod), "Call", sourceItem); } else if (xOpCode is ILOpCodes.OpType) { - Queue(((ILOpCodes.OpType)xOpCode).Value, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value"); + Queue(((ILOpCodes.OpType)xOpCode).Value, LabelName.GenerateFullName(aMethod), "OpCode Value"); } else if (xOpCode is ILOpCodes.OpField) { var xOpField = (ILOpCodes.OpField)xOpCode; //TODO: Need to do this? Will we get a ILOpCodes.OpType as well? - Queue(xOpField.Value.DeclaringType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value"); + Queue(xOpField.Value.DeclaringType, LabelName.GenerateFullName(aMethod), "OpCode Value"); if (xOpField.Value.IsStatic) { //TODO: Why do we add static fields, but not instance? // AW: instance fields are "added" always, as part of a type, but for static fields, we need to emit a datamember - Queue(xOpField.Value, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value"); + Queue(xOpField.Value, LabelName.GenerateFullName(aMethod), "OpCode Value"); } } else if (xOpCode is ILOpCodes.OpToken) { var xTokenOp = (ILOpCodes.OpToken)xOpCode; if (xTokenOp.ValueIsType) { - Queue(xTokenOp.ValueType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value"); + Queue(xTokenOp.ValueType, LabelName.GenerateFullName(aMethod), "OpCode Value"); } if (xTokenOp.ValueIsField) { - Queue(xTokenOp.ValueField.DeclaringType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value"); + Queue(xTokenOp.ValueField.DeclaringType, LabelName.GenerateFullName(aMethod), "OpCode Value"); if (xTokenOp.ValueField.IsStatic) { //TODO: Why do we add static fields, but not instance? // AW: instance fields are "added" always, as part of a type, but for static fields, we need to emit a datamember - Queue(xTokenOp.ValueField, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value"); + Queue(xTokenOp.ValueField, LabelName.GenerateFullName(aMethod), "OpCode Value"); } } } @@ -859,7 +859,7 @@ namespace Cosmos.IL2CPU { break; } if (xAttrib != null && xAttrib.Signature != null) { - var xName = DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GenerateFullName(aMethod)); + var xName = DataMember.FilterStringForIncorrectChars(LabelName.GenerateFullName(aMethod)); if (string.Compare(xName, xAttrib.Signature, true) == 0) { xResult = xSigMethod; break; @@ -967,7 +967,7 @@ namespace Cosmos.IL2CPU { #region Plug Caching private Orvid.Collections.SkipList ResolvedPlugs = new Orvid.Collections.SkipList(); private static string BuildMethodKeyName(MethodBase m) { - return MethodInfoLabelGenerator.GenerateFullName(m); + return LabelName.GenerateFullName(m); } #endregion diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Box.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Box.cs index db52f1994..378bd9c87 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Box.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Box.cs @@ -22,7 +22,7 @@ namespace Cosmos.IL2CPU.X86.IL uint xSize = Align(SizeOfType( xType.Value ), 4); string xTypeID = GetTypeIDLabel(xType.Value); new CPUx86.Push { DestinationValue = ( ObjectImpl.FieldDataOffset + xSize ) }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ) }; + new CPUx86.Call { DestinationLabel = LabelName.Get( GCImplementationRefs.AllocNewObjectRef ) }; new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; new CPUx86.Mov { DestinationReg = CPUx86.Registers.EBX, SourceRef = Cosmos.Assembler.ElementReference.New( xTypeID ), SourceIsIndirect = true }; new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true, SourceReg = CPUx86.Registers.EBX }; diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Call.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Call.cs index e5dd5c55c..a520621ff 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Call.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Call.cs @@ -69,7 +69,7 @@ namespace Cosmos.IL2CPU.X86.IL { public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) { var xOpMethod = aOpCode as OpMethod; - DoExecute(Assembler, aMethod, xOpMethod.Value, aOpCode, MethodInfoLabelGenerator.GenerateLabelName(aMethod.MethodBase)); + DoExecute(Assembler, aMethod, xOpMethod.Value, aOpCode, LabelName.Get(aMethod.MethodBase)); } public static void DoExecute(Cosmos.Assembler.Assembler Assembler, MethodInfo aCurrentMethod, MethodBase aTargetMethod, ILOpCode aCurrent, string currentLabel) @@ -87,9 +87,9 @@ namespace Cosmos.IL2CPU.X86.IL { // , mMethod, mMethodDescription, null, mCurrentMethodInfo.DebugMode); string xNormalAddress = ""; if (aTargetMethod.IsStatic || !aTargetMethod.IsVirtual || aTargetMethod.IsFinal) { - xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod); + xNormalAddress = LabelName.Get(aTargetMethod); } else { - xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod); + xNormalAddress = LabelName.Get(aTargetMethod); //throw new Exception("Call: non-concrete method called: '" + aTargetMethod.GetFullName() + "'"); } var xParameters = aTargetMethod.GetParameters(); diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Callvirt.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Callvirt.cs index 467f9681d..354fc7936 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Callvirt.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Callvirt.cs @@ -35,7 +35,7 @@ namespace Cosmos.IL2CPU.X86.IL // , mMethod, mMethodDescription, null, mCurrentMethodInfo.DebugMode); string xNormalAddress = ""; if (aTargetMethod.IsStatic || !aTargetMethod.IsVirtual || aTargetMethod.IsFinal) { - xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod); + xNormalAddress = LabelName.Get(aTargetMethod); } // mMethodIdentifier = GetService().GetMethodIdLabel(mMethod); @@ -118,7 +118,7 @@ namespace Cosmos.IL2CPU.X86.IL new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true }; new CPUx86.Push { DestinationValue = aTargetMethodUID }; new CPUx86.Call { - DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(VTablesImplRefs.GetMethodAddressForTypeRef) + DestinationLabel = LabelName.Get(VTablesImplRefs.GetMethodAddressForTypeRef) }; if (xExtraStackSize > 0) { diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Castclass.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Castclass.cs index 26773eef1..547e50eef 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Castclass.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Castclass.cs @@ -46,7 +46,7 @@ namespace Cosmos.IL2CPU.X86.IL new Label( mReturnNullLabel ); new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; - string xAllocInfoLabelName = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ); + string xAllocInfoLabelName = LabelName.Get( GCImplementationRefs.AllocNewObjectRef ); #warning TODO: Emit new exceptions //new Newobj( Assembler ).Execute( aMethod, aOpCode ); diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldftn.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldftn.cs index 996247a73..a25463502 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldftn.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldftn.cs @@ -16,7 +16,7 @@ namespace Cosmos.IL2CPU.X86.IL public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) { - new CPUx86.Push { DestinationRef = Cosmos.Assembler.ElementReference.New( MethodInfoLabelGenerator.GenerateLabelName(((OpMethod)aOpCode).Value ) ) }; + new CPUx86.Push { DestinationRef = Cosmos.Assembler.ElementReference.New( LabelName.Get(((OpMethod)aOpCode).Value ) ) }; Assembler.Stack.Push(new StackContents.Item(4, typeof(uint))); } } diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsfld.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsfld.cs index d0923bcd2..517ccb6c4 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsfld.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsfld.cs @@ -26,7 +26,7 @@ namespace Cosmos.IL2CPU.X86.IL var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault(); if (xCctor != null) { - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) }; ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck"); new Label(".AfterCCTorExceptionCheck"); } diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsflda.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsflda.cs index 865893269..317c2c3f4 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsflda.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Ldsflda.cs @@ -22,7 +22,7 @@ namespace Cosmos.IL2CPU.X86.IL var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault(); if (xCctor != null) { - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) }; ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck"); new Label(".AfterCCTorExceptionCheck"); } diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newarr.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newarr.cs index fc9a9a611..537588190 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newarr.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newarr.cs @@ -26,7 +26,7 @@ namespace Cosmos.IL2CPU.X86.IL string xTypeID = GetTypeIDLabel(typeof(Array)); MethodBase xCtor = typeof( Array ).GetConstructors( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance )[ 0 ]; - string xCtorName = MethodInfoLabelGenerator.GenerateLabelName( xCtor ); + string xCtorName = LabelName.Get( xCtor ); new Comment( Assembler, "Element Size = " + xSize ); // element count is on the stack @@ -42,7 +42,7 @@ namespace Cosmos.IL2CPU.X86.IL Assembler.Stack.Push( new StackContents.Item( 4, typeof( uint ) ) ); new Add( Assembler ).Execute( aMethod, aOpCode ); // the total array size is now on the stack. - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ) }; + new CPUx86.Call { DestinationLabel = LabelName.Get( GCImplementationRefs.AllocNewObjectRef ) }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newobj.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newobj.cs index 5f19929f1..d88449015 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newobj.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Newobj.cs @@ -33,7 +33,7 @@ namespace Cosmos.IL2CPU.X86.IL var xCctor = (objectType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault(); if (xCctor != null) { - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) }; ILOp.EmitExceptionLogic(aAssembler, aMethod, xMethod, true, null, ".AfterCCTorExceptionCheck"); new Label(".AfterCCTorExceptionCheck"); } @@ -158,7 +158,7 @@ namespace Cosmos.IL2CPU.X86.IL } // todo: probably we want to check for exceptions after calling Alloc - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.AllocNewObjectRef) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(GCImplementationRefs.AllocNewObjectRef) }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; @@ -194,11 +194,11 @@ namespace Cosmos.IL2CPU.X86.IL } } - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(constructor) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(constructor) }; if (aMethod != null) { new CPUx86.Test { DestinationReg = CPUx86.Registers.ECX, SourceValue = 2 }; - string xNoErrorLabel = currentLabel + ".NoError" + MethodInfoLabelGenerator.LabelCount.ToString(); + string xNoErrorLabel = currentLabel + ".NoError" + LabelName.LabelCount.ToString(); new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = xNoErrorLabel }; //for( int i = 1; i < aCtorMethodInfo.Arguments.Length; i++ ) diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stfld.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stfld.cs index 49767567b..8186eb14e 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stfld.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stfld.cs @@ -73,8 +73,8 @@ namespace Cosmos.IL2CPU.X86.IL { if (aNeedsGC) { new CPUx86.Push { DestinationReg = CPUx86.Registers.ECX }; new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(GCImplementationRefs.DecRefCountRef) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(GCImplementationRefs.DecRefCountRef) }; } #endif new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stsfld.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stsfld.cs index 7e866b3fb..8fef8e5d0 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stsfld.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/IL/Stsfld.cs @@ -24,7 +24,7 @@ namespace Cosmos.IL2CPU.X86.IL var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault(); if (xCctor != null) { - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) }; + new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) }; ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck"); new Label(".AfterCCTorExceptionCheck"); } diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/NEW_PLUGS/InvokeImplAssembler.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/NEW_PLUGS/InvokeImplAssembler.cs index 5d06ccfba..6100280a5 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/NEW_PLUGS/InvokeImplAssembler.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/NEW_PLUGS/InvokeImplAssembler.cs @@ -41,7 +41,7 @@ namespace Cosmos.IL2CPU.X86.Plugs.NEW_PLUGS { var xGetInvocationListMethod = typeof(MulticastDelegate).GetMethod("GetInvocationList"); new CPU.Comment("push address of delgate to stack"); new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };//addrof this - new CPUx86.Call { DestinationLabel = CPU.MethodInfoLabelGenerator.GenerateLabelName(xGetInvocationListMethod) }; + new CPUx86.Call { DestinationLabel = CPU.LabelName.Get(xGetInvocationListMethod) }; new CPU.Comment("get address from return value -> eax"); new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; ;//list diff --git a/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/System/Assemblers/MulticastDelegate_Invoke.cs b/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/System/Assemblers/MulticastDelegate_Invoke.cs index 526d31013..1ef269722 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/System/Assemblers/MulticastDelegate_Invoke.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/x86/Plugs/System/Assemblers/MulticastDelegate_Invoke.cs @@ -43,7 +43,7 @@ namespace Cosmos.IL2CPU.X86.Plugs.CustomImplementations.System.Assemblers var xGetInvocationListMethod = typeof(MulticastDelegate).GetMethod("GetInvocationList"); new CPU.Comment("push address of delgate to stack"); new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };//addrof this - new CPUx86.Call { DestinationLabel = CPU.MethodInfoLabelGenerator.GenerateLabelName(xGetInvocationListMethod) }; + new CPUx86.Call { DestinationLabel = CPU.LabelName.Get(xGetInvocationListMethod) }; new CPU.Comment("get address from return value -> eax"); new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; ;//list new CPU.Comment("eax+=8 is where the offset where an array's count is"); diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/UpdateIDT.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/UpdateIDT.cs index 3dea93c88..752e63915 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/UpdateIDT.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/UpdateIDT.cs @@ -117,7 +117,7 @@ namespace Cosmos.Core.Plugs.Assemblers { if (xHandler == null) { xHandler = GetMethodDef(typeof(INTs).Assembly, typeof(INTs).FullName, "HandleInterrupt_Default", true); } - new CPUx86.Call { DestinationLabel = CPUAll.MethodInfoLabelGenerator.GenerateLabelName(xHandler) }; + new CPUx86.Call { DestinationLabel = CPUAll.LabelName.Get(xHandler) }; new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; new CPUx86.x87.FXStore { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true };