diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs index 1c48c00b406078..89be9fa3a7d881 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.Sorting.cs @@ -8,9 +8,9 @@ namespace Internal.IL.Stubs // Functionality related to deterministic ordering of methods partial class CalliMarshallingMethodThunk { - protected internal override int ClassCode => 1594107963; + protected override int ClassCode => 1594107963; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (CalliMarshallingMethodThunk)other; return comparer.Compare(_targetSignature, otherMethod._targetSignature); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs index c0a4887211c179..b38cd1fda8e540 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Sorting.cs @@ -8,9 +8,9 @@ namespace Internal.IL.Stubs // Functionality related to deterministic ordering of methods partial class DelegateMarshallingMethodThunk { - protected internal override int ClassCode => 1018037605; + protected override int ClassCode => 1018037605; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (DelegateMarshallingMethodThunk)other; int result = (int)Kind - (int)otherMethod.Kind; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs index a5aece70b22371..1126e01d4020ba 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.Sorting.cs @@ -8,7 +8,7 @@ namespace Internal.IL.Stubs // Functionality related to deterministic ordering of types partial class DelegateThunk { - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (DelegateThunk)other; return comparer.Compare(_delegateInfo.Type, otherMethod._delegateInfo.Type); @@ -17,39 +17,39 @@ protected internal override int CompareToImpl(MethodDesc other, TypeSystemCompar partial class DelegateInvokeOpenStaticThunk { - protected internal override int ClassCode => 386356101; + protected override int ClassCode => 386356101; } public sealed partial class DelegateInvokeOpenInstanceThunk { - protected internal override int ClassCode => -1787190244; + protected override int ClassCode => -1787190244; } partial class DelegateInvokeClosedStaticThunk { - protected internal override int ClassCode => 28195375; + protected override int ClassCode => 28195375; } partial class DelegateInvokeMulticastThunk { - protected internal override int ClassCode => 639863471; + protected override int ClassCode => 639863471; } partial class DelegateInvokeInstanceClosedOverGenericMethodThunk { - protected internal override int ClassCode => -354480633; + protected override int ClassCode => -354480633; } partial class DelegateInvokeObjectArrayThunk { - protected internal override int ClassCode => 1993292344; + protected override int ClassCode => 1993292344; } partial class DelegateGetThunkMethodOverride { - protected internal override int ClassCode => -321263379; + protected override int ClassCode => -321263379; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (DelegateGetThunkMethodOverride)other; return comparer.Compare(_delegateInfo.Type, otherMethod._delegateInfo.Type); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index 2d76523052ecd0..5e9ed17fbc478b 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -726,7 +726,8 @@ public override MethodIL EmitIL() Debug.Assert(_delegateInfo.Thunks[i] == null); var sig = new DynamicInvokeMethodSignature(_delegateInfo.Signature); - MethodDesc thunk = Context.GetDynamicInvokeThunk(sig); + // TODO: layering violation. Should move delegate thunk stuff to ILCompiler.Compiler. + MethodDesc thunk = ((ILCompiler.CompilerTypeSystemContext)Context).GetDynamicInvokeThunk(sig); if (thunk.HasInstantiation) { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs index 43da587d086346..29976d1a659c4e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.Sorting.cs @@ -11,9 +11,9 @@ namespace Internal.IL.Stubs // Functionality related to determinstic ordering of types partial class DynamicInvokeMethodThunk { - protected internal override int ClassCode => -1980933220; + protected override int ClassCode => -1980933220; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { return CompareTo((DynamicInvokeMethodThunk)other); } @@ -51,9 +51,9 @@ private int CompareTo(DynamicInvokeMethodThunk otherMethod) partial class DynamicInvokeThunkGenericParameter { - protected internal override int ClassCode => -234393261; + protected override int ClassCode => -234393261; - protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { var otherType = (DynamicInvokeThunkGenericParameter)other; int result = Index - otherType.Index; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs index d6ae00c139863f..33b07a8e86f109 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs @@ -8,9 +8,9 @@ namespace Internal.IL.Stubs // Functionality related to deterministic ordering of types partial class EnumGetHashCodeThunk { - protected internal override int ClassCode => 261739662; + protected override int ClassCode => 261739662; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (EnumGetHashCodeThunk)other; return comparer.Compare(_owningType, otherMethod._owningType); @@ -19,9 +19,9 @@ protected internal override int CompareToImpl(MethodDesc other, TypeSystemCompar partial class EnumEqualsThunk { - protected internal override int ClassCode => -1774524780; + protected override int ClassCode => -1774524780; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (EnumEqualsThunk)other; return comparer.Compare(_owningType, otherMethod._owningType); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs index 7bdbbadd0d00fc..66d5142caa2878 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.Sorting.cs @@ -8,9 +8,9 @@ namespace Internal.IL.Stubs // Functionality related to deterministic ordering of types partial class ForwardDelegateCreationThunk { - protected internal override int ClassCode => 1026039617; + protected override int ClassCode => 1026039617; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (ForwardDelegateCreationThunk)other; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs index edfccf89890e67..d3156fbefb2cf4 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.Sorting.cs @@ -7,9 +7,9 @@ namespace Internal.IL.Stubs { partial class PInvokeLazyFixupField { - protected internal override int ClassCode => -1784477702; + protected override int ClassCode => -1784477702; - protected internal override int CompareToImpl(FieldDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(FieldDesc other, TypeSystemComparer comparer) { return comparer.Compare(_targetMethod, ((PInvokeLazyFixupField)other)._targetMethod); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs index f2eee55f961086..0cbb4f7e7c6c38 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Sorting.cs @@ -8,9 +8,9 @@ namespace Internal.IL.Stubs // Functionality related to deterministic ordering of types partial class StructMarshallingThunk { - protected internal override int ClassCode => 340834018; + protected override int ClassCode => 340834018; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (StructMarshallingThunk)other; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs index 882a4419e2e242..e12b3bc41567f9 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.Sorting.cs @@ -7,9 +7,9 @@ namespace Internal.IL.Stubs { partial class ValueTypeGetFieldHelperMethodOverride { - protected internal override int ClassCode => 2036839816; + protected override int ClassCode => 2036839816; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (ValueTypeGetFieldHelperMethodOverride)other; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs index 2bcee373962bea..c8655241711389 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.Sorting.cs @@ -6,9 +6,9 @@ namespace Internal.TypeSystem.Interop // Functionality related to determinstic ordering of types partial class InlineArrayType { - protected internal override int ClassCode => 226817075; + protected override int ClassCode => 226817075; - protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { var otherType = (InlineArrayType)other; int result = (int)Length - (int)otherType.Length; @@ -20,9 +20,9 @@ protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer partial class InlineArrayMethod { - protected internal override int ClassCode => -1303220581; + protected override int ClassCode => -1303220581; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var otherMethod = (InlineArrayMethod)other; @@ -30,19 +30,19 @@ protected internal override int CompareToImpl(MethodDesc other, TypeSystemCompar if (result != 0) return result; - return comparer.CompareWithinClass(OwningType, otherMethod.OwningType); + return comparer.Compare(OwningType, otherMethod.OwningType); } } partial class InlineArrayField { - protected internal override int ClassCode => 1542668652; + protected override int ClassCode => 1542668652; - protected internal override int CompareToImpl(FieldDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(FieldDesc other, TypeSystemComparer comparer) { var otherField = (InlineArrayField)other; - return comparer.CompareWithinClass(OwningType, otherField.OwningType); + return comparer.Compare(OwningType, otherField.OwningType); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs index 0da2d42007d56b..bcd97084e56718 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.Sorting.cs @@ -6,18 +6,18 @@ namespace Internal.TypeSystem.Interop // Functionality related to determinstic ordering of types partial class NativeStructType { - protected internal override int ClassCode => -377751537; + protected override int ClassCode => -377751537; - protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { return comparer.Compare(ManagedStructType, ((NativeStructType)other).ManagedStructType); } partial class NativeStructField { - protected internal override int ClassCode => 1580219745; + protected override int ClassCode => 1580219745; - protected internal override int CompareToImpl(FieldDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(FieldDesc other, TypeSystemComparer comparer) { return comparer.Compare(_managedField, ((NativeStructField)other)._managedField); } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs index 6b4f6b9ca06206..72948268466607 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Sorting.cs @@ -6,9 +6,9 @@ namespace Internal.TypeSystem.Interop // Functionality related to determinstic ordering of types partial class PInvokeDelegateWrapper { - protected internal override int ClassCode => -262930217; + protected override int ClassCode => -262930217; - protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { return comparer.Compare(DelegateType, ((PInvokeDelegateWrapper)other).DelegateType); } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs index 2509b265ea71e8..5fe9290213b2f6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.Sorting.cs @@ -6,9 +6,9 @@ namespace Internal.TypeSystem.Interop // Functionality related to deterministic ordering of methods partial class PInvokeDelegateWrapperConstructor { - protected internal override int ClassCode => 1000342011; + protected override int ClassCode => 1000342011; - protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { var owningType = (PInvokeDelegateWrapper)OwningType; var otherOwningType = (PInvokeDelegateWrapper)other.OwningType; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs index 33305d2011c876..91446e51641879 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs @@ -19,7 +19,6 @@ public SharedGenericsConfiguration GenericsConfig get; } - private readonly DelegateFeature _delegateFeatures; private readonly MetadataFieldLayoutAlgorithm _metadataFieldLayoutAlgorithm = new CompilerMetadataFieldLayoutAlgorithm(); private readonly RuntimeDeterminedFieldLayoutAlgorithm _runtimeDeterminedFieldLayoutAlgorithm = new RuntimeDeterminedFieldLayoutAlgorithm(); private readonly VectorOfTFieldLayoutAlgorithm _vectorOfTFieldLayoutAlgorithm; @@ -37,7 +36,7 @@ public CompilerTypeSystemContext(TargetDetails details, SharedGenericsMode gener _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_metadataFieldLayoutAlgorithm); _vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_metadataFieldLayoutAlgorithm); - _delegateFeatures = delegateFeatures; + _delegateInfoHashtable = new DelegateInfoHashtable(delegateFeatures); GenericsConfig = new SharedGenericsConfiguration(); } @@ -165,11 +164,6 @@ protected virtual IEnumerable GetAllMethodsForDelegate(TypeDesc type yield return m; } - protected override DelegateInfo CreateDelegateInfo(TypeDesc delegateType) - { - return new DelegateInfo(delegateType, _delegateFeatures); - } - internal DefType GetClosestDefType(TypeDesc type) { if (type.IsArray) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs similarity index 67% rename from src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs index b9a3a3e1fdbbb2..a021e39691d226 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DelegateInfo.cs @@ -4,13 +4,19 @@ using System; using Internal.IL; +using Internal.TypeSystem; -namespace Internal.TypeSystem +namespace ILCompiler { - public abstract partial class TypeSystemContext + partial class CompilerTypeSystemContext { private class DelegateInfoHashtable : LockFreeReaderHashtable { + private readonly DelegateFeature _delegateFeatures; + + public DelegateInfoHashtable(DelegateFeature features) + => _delegateFeatures = features; + protected override int GetKeyHashCode(TypeDesc key) { return key.GetHashCode(); @@ -29,24 +35,15 @@ protected override bool CompareValueToValue(DelegateInfo value1, DelegateInfo va } protected override DelegateInfo CreateValueFromKey(TypeDesc key) { - return key.Context.CreateDelegateInfo(key); + return new DelegateInfo(key, _delegateFeatures); } } - private DelegateInfoHashtable _delegateInfoHashtable = new DelegateInfoHashtable(); + private readonly DelegateInfoHashtable _delegateInfoHashtable; public DelegateInfo GetDelegateInfo(TypeDesc delegateType) { return _delegateInfoHashtable.GetOrCreateValue(delegateType); } - - /// - /// Creates a for a given delegate type. - /// - protected virtual DelegateInfo CreateDelegateInfo(TypeDesc key) - { - // Type system contexts that support creating delegate infos need to override. - throw new NotSupportedException(); - } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.DynamicInvoke.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs similarity index 85% rename from src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.DynamicInvoke.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs index 290f11dd90a508..0ed3d107b3a396 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.DynamicInvoke.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.DynamicInvoke.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using Internal.IL.Stubs; +using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; -namespace Internal.TypeSystem +namespace ILCompiler { - partial class TypeSystemContext + partial class CompilerTypeSystemContext { private class DynamicInvokeThunkHashtable : LockFreeReaderHashtable { @@ -17,7 +18,7 @@ private class DynamicInvokeThunkHashtable : LockFreeReaderHashtable value.TargetSignature.GetHashCode(); protected override DynamicInvokeMethodThunk CreateValueFromKey(DynamicInvokeMethodSignature key) { - return new DynamicInvokeMethodThunk(key.Context.GeneratedAssembly.GetGlobalModuleType(), key); + return new DynamicInvokeMethodThunk(((CompilerTypeSystemContext)key.Context).GeneratedAssembly.GetGlobalModuleType(), key); } } DynamicInvokeThunkHashtable _dynamicInvokeThunks = new DynamicInvokeThunkHashtable(); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.EnumMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs similarity index 97% rename from src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.EnumMethods.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs index 0be009f53c7bb3..b777e28a2d144e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.EnumMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs @@ -3,13 +3,14 @@ using System.Collections.Generic; +using Internal.TypeSystem; using Internal.IL.Stubs; using Debug = System.Diagnostics.Debug; -namespace Internal.TypeSystem +namespace ILCompiler { - public abstract partial class TypeSystemContext + partial class CompilerTypeSystemContext { private class EnumInfo { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.GeneratedAssembly.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs similarity index 64% rename from src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.GeneratedAssembly.Sorting.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs index a2490a4cb196e7..41254150763cf9 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.GeneratedAssembly.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.Sorting.cs @@ -3,16 +3,18 @@ using System; -namespace Internal.TypeSystem +using Internal.TypeSystem; + +namespace ILCompiler { - partial class TypeSystemContext + partial class CompilerTypeSystemContext { // Functionality related to determinstic ordering of types and members partial class CompilerGeneratedType : MetadataType { - protected internal override int ClassCode => -1036681447; + protected override int ClassCode => -1036681447; - protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) + protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { // Should be a singleton throw new NotSupportedException(); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs similarity index 98% rename from src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.GeneratedAssembly.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index 1a289f651f107e..280f2d85684a3b 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -4,14 +4,16 @@ using System; using System.Collections.Generic; +using Internal.TypeSystem; + using TypeHashingAlgorithms = Internal.NativeFormat.TypeHashingAlgorithms; using Interlocked = System.Threading.Interlocked; using AssemblyName = System.Reflection.AssemblyName; using Debug = System.Diagnostics.Debug; -namespace Internal.TypeSystem +namespace ILCompiler { - partial class TypeSystemContext + partial class CompilerTypeSystemContext { private ModuleDesc _generatedAssembly; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.IntefaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.IntefaceThunks.cs index 06c13c51e6d8d1..adc509298c0bbc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.IntefaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.IntefaceThunks.cs @@ -149,7 +149,7 @@ protected override bool CompareValueToValue(DefaultInterfaceMethodImplementation } protected override DefaultInterfaceMethodImplementationInstantiationThunk CreateValueFromKey(DefaultInterfaceMethodImplementationInstantiationThunkHashtableKey key) { - TypeDesc owningTypeOfThunks = key.TargetMethod.Context.GeneratedAssembly.GetGlobalModuleType(); + TypeDesc owningTypeOfThunks = ((CompilerTypeSystemContext)key.TargetMethod.Context).GeneratedAssembly.GetGlobalModuleType(); return new DefaultInterfaceMethodImplementationInstantiationThunk(owningTypeOfThunks, key.TargetMethod, key.InterfaceIndex); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.ValueTypeMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs similarity index 97% rename from src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.ValueTypeMethods.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs index f44bf4b11cf8e2..738b43554182c8 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/TypeSystemContext.ValueTypeMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs @@ -3,13 +3,14 @@ using System.Collections.Generic; +using Internal.TypeSystem; using Internal.IL.Stubs; using Debug = System.Diagnostics.Debug; -namespace Internal.TypeSystem +namespace ILCompiler { - public abstract partial class TypeSystemContext + partial class CompilerTypeSystemContext { private MethodDesc _objectEqualsMethod; @@ -154,7 +155,7 @@ private bool ComputeCanCompareValueTypeBits(MetadataType type) // Would be a suprise if this wasn't a valuetype. We checked ContainsGCPointers above. Debug.Assert(fieldType.IsValueType); - MethodDesc objectEqualsMethod = fieldType.Context._objectEqualsMethod; + MethodDesc objectEqualsMethod = ((CompilerTypeSystemContext)fieldType.Context)._objectEqualsMethod; // If the field overrides Equals, we can't use the fast helper because we need to call the method. if (fieldType.FindVirtualFunctionTargetMethodOnObjectType(objectEqualsMethod).OwningType == fieldType) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs index 0195f82d6c3692..dc6cd81fcccf5d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs @@ -161,7 +161,7 @@ private DelegateCreationInfo(IMethodNode constructor, MethodDesc targetMethod, T /// public static DelegateCreationInfo Create(TypeDesc delegateType, MethodDesc targetMethod, NodeFactory factory, bool followVirtualDispatch) { - TypeSystemContext context = delegateType.Context; + CompilerTypeSystemContext context = factory.TypeSystemContext; DefType systemDelegate = context.GetWellKnownType(WellKnownType.MulticastDelegate).BaseType; int paramCountTargetMethod = targetMethod.Signature.Length; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs index 9f93ae3ea87a13..a7c4b27afd274f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MultiFileCompilationModuleGroup.cs @@ -15,7 +15,7 @@ public abstract class MultiFileCompilationModuleGroup : CompilationModuleGroup { private HashSet _compilationModuleSet; - public MultiFileCompilationModuleGroup(TypeSystemContext context, IEnumerable compilationModuleSet) + public MultiFileCompilationModuleGroup(CompilerTypeSystemContext context, IEnumerable compilationModuleSet) { _compilationModuleSet = new HashSet(compilationModuleSet); @@ -94,7 +94,7 @@ public override bool CanHaveReferenceThroughImportTable /// public class MultiFileSharedCompilationModuleGroup : MultiFileCompilationModuleGroup { - public MultiFileSharedCompilationModuleGroup(TypeSystemContext context, IEnumerable compilationModuleSet) + public MultiFileSharedCompilationModuleGroup(CompilerTypeSystemContext context, IEnumerable compilationModuleSet) : base(context, compilationModuleSet) { } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 3273d2cc58f567..33cefd92b42620 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -23,6 +23,144 @@ + + IL\DelegateInfo.cs + + + IL\Stubs\DelegateThunks.Sorting.cs + + + IL\Stubs\DynamicInvokeMethodThunk.cs + + + IL\Stubs\DynamicInvokeMethodThunk.Sorting.cs + + + IL\Stubs\EnumThunks.cs + + + IL\Stubs\EnumThunks.Sorting.cs + + + IL\Stubs\PInvokeLazyFixupField.cs + + + IL\Stubs\PInvokeLazyFixupField.Sorting.cs + + + IL\Stubs\StructMarshallingThunk.Sorting.cs + + + IL\Stubs\ValueTypeGetFieldHelperMethodOverride.cs + + + IL\Stubs\ValueTypeGetFieldHelperMethodOverride.Sorting.cs + + + TypeSystem\Interop\IL\InlineArrayType.Sorting.cs + + + Interop\IL\MarshalHelpers.cs + + + Interop\IL\MarshalHelpers.Aot.cs + + + Interop\IL\MarshalUtils.cs + + + Interop\IL\Marshaller.cs + + + Interop\IL\Marshaller.Aot.cs + + + TypeSystem\Interop\IL\NativeStructType.Sorting.cs + + + Interop\IL\PInvokeILEmitterConfiguration.cs + + + IL\Stubs\PInvokeILEmitter.cs + + + IL\Stubs\PInvokeILCodeStreams.cs + + + IL\Stubs\DebuggerSteppingHelpers.cs + + + IL\Stubs\CalliMarshallingMethodThunk.cs + + + IL\Stubs\CalliMarshallingMethodThunk.Mangling.cs + + + IL\Stubs\CalliMarshallingMethodThunk.Sorting.cs + + + IL\Stubs\DelegateMarshallingMethodThunk.cs + + + IL\Stubs\DelegateMarshallingMethodThunk.Mangling.cs + + + IL\Stubs\DelegateMarshallingMethodThunk.Sorting.cs + + + IL\Stubs\ForwardDelegateCreationThunk.cs + + + IL\Stubs\ForwardDelegateCreationThunk.Mangling.cs + + + IL\Stubs\ForwardDelegateCreationThunk.Sorting.cs + + + IL\Stubs\DelegateThunks.cs + + + IL\Stubs\StructMarshallingThunk.cs + + + IL\Stubs\StructMarshallingThunk.Mangling.cs + + + TypeSystem\Interop\IL\NativeStructType.cs + + + TypeSystem\Interop\IL\NativeStructType.Mangling.cs + + + TypeSystem\Interop\IL\PInvokeDelegateWrapper.cs + + + TypeSystem\Interop\IL\PInvokeDelegateWrapper.Mangling.cs + + + TypeSystem\Interop\IL\PInvokeDelegateWrapper.Sorting.cs + + + TypeSystem\Interop\IL\PInvokeDelegateWrapperConstructor.cs + + + TypeSystem\Interop\IL\PInvokeDelegateWrapperConstructor.Sorting.cs + + + TypeSystem\Interop\IL\InlineArrayType.cs + + + TypeSystem\Interop\InteropTypes.cs + + + TypeSystem\Interop\InteropStateManager.cs + + + TypeSystem\CodeGen\INonEmittableType.cs + + + TypeSystem\CodeGen\NativeStructType.CodeGen.cs + Compiler\Logging\CompilerGeneratedState.cs @@ -179,6 +317,12 @@ + + + + + + diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj b/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj index a638f7310d0523..e2703506aae36b 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj @@ -457,60 +457,12 @@ Ecma\CachingMetadataStringDecoder.cs - - IL\DelegateInfo.cs - - - IL\Stubs\DelegateThunks.Sorting.cs - - - IL\Stubs\DynamicInvokeMethodThunk.cs - - - IL\Stubs\DynamicInvokeMethodThunk.Sorting.cs - - - IL\Stubs\EnumThunks.cs - - - IL\Stubs\EnumThunks.Sorting.cs - - - IL\Stubs\PInvokeLazyFixupField.cs - - - IL\Stubs\PInvokeLazyFixupField.Sorting.cs - - - IL\Stubs\StructMarshallingThunk.Sorting.cs - - - IL\Stubs\ValueTypeGetFieldHelperMethodOverride.cs - - - IL\Stubs\ValueTypeGetFieldHelperMethodOverride.Sorting.cs - - - IL\TypeSystemContext.DelegateInfo.cs - - - IL\TypeSystemContext.DynamicInvoke.cs - - - IL\TypeSystemContext.GeneratedAssembly.cs - - - IL\TypeSystemContext.GeneratedAssembly.Sorting.cs - IL\EcmaMethodIL.cs IL\EcmaMethodIL.Symbols.cs - - IL\HelperExtensions.cs - IL\MethodIL.cs @@ -535,42 +487,6 @@ IL\ILOpcodeHelper.cs - - IL\TypeSystemContext.EnumMethods.cs - - - IL\TypeSystemContext.ValueTypeMethods.cs - - - TypeSystem\Interop\IL\InlineArrayType.Sorting.cs - - - Interop\IL\MarshalHelpers.cs - - - Interop\IL\MarshalHelpers.Aot.cs - - - Interop\IL\MarshalUtils.cs - - - Interop\IL\Marshaller.cs - - - Interop\IL\Marshaller.Aot.cs - - - TypeSystem\Interop\IL\NativeStructType.Sorting.cs - - - Interop\IL\PInvokeILEmitterConfiguration.cs - - - IL\Stubs\PInvokeILEmitter.cs - - - IL\Stubs\PInvokeILCodeStreams.cs - IL\Stubs\ILEmitter.cs @@ -586,48 +502,6 @@ IL\Stubs\PInvokeTargetNativeMethod.Sorting.cs - - IL\Stubs\DebuggerSteppingHelpers.cs - - - IL\Stubs\CalliMarshallingMethodThunk.cs - - - IL\Stubs\CalliMarshallingMethodThunk.Mangling.cs - - - IL\Stubs\CalliMarshallingMethodThunk.Sorting.cs - - - IL\Stubs\DelegateMarshallingMethodThunk.cs - - - IL\Stubs\DelegateMarshallingMethodThunk.Mangling.cs - - - IL\Stubs\DelegateMarshallingMethodThunk.Sorting.cs - - - IL\Stubs\ForwardDelegateCreationThunk.cs - - - IL\Stubs\ForwardDelegateCreationThunk.Mangling.cs - - - IL\Stubs\ForwardDelegateCreationThunk.Sorting.cs - - - IL\Stubs\DelegateThunks.cs - - - IL\Stubs\StructMarshallingThunk.cs - - - IL\Stubs\StructMarshallingThunk.Mangling.cs - - - TypeSystem\Interop\IL\NativeStructType.cs - TypeSystem\CodeGen\FieldDesc.Serialization.cs @@ -649,33 +523,6 @@ TypeSystem\Sorting\MethodForInstantiatedType.Sorting.cs - - TypeSystem\Interop\IL\NativeStructType.Mangling.cs - - - TypeSystem\Interop\IL\PInvokeDelegateWrapper.cs - - - TypeSystem\Interop\IL\PInvokeDelegateWrapper.Mangling.cs - - - TypeSystem\Interop\IL\PInvokeDelegateWrapper.Sorting.cs - - - TypeSystem\Interop\IL\PInvokeDelegateWrapperConstructor.cs - - - TypeSystem\Interop\IL\PInvokeDelegateWrapperConstructor.Sorting.cs - - - TypeSystem\Interop\IL\InlineArrayType.cs - - - TypeSystem\Interop\InteropTypes.cs - - - TypeSystem\Interop\InteropStateManager.cs - TypeSystem\Interop\FieldDesc.Interop.cs @@ -709,12 +556,6 @@ TypeSystem\Common\LocalVariableDefinition.cs - - TypeSystem\CodeGen\INonEmittableType.cs - - - TypeSystem\CodeGen\NativeStructType.CodeGen.cs - TypeSystem\RuntimeDetermined\ArrayType.RuntimeDetermined.cs diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index 007c3787df15f5..d9b7d79b012d3b 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -270,7 +270,7 @@ private ArgumentSyntax ParseCommandLine(string[] args) return argSyntax; } - private IReadOnlyCollection CreateInitializerList(TypeSystemContext context) + private IReadOnlyCollection CreateInitializerList(CompilerTypeSystemContext context) { List assembliesWithInitalizers = new List(); @@ -278,7 +278,7 @@ private IReadOnlyCollection CreateInitializerList(TypeSystemContext // any user code runs. foreach (string initAssemblyName in _initAssemblies) { - ModuleDesc assembly = context.ResolveAssembly(new AssemblyName(initAssemblyName)); + ModuleDesc assembly = context.ResolveAssembly(new AssemblyName(initAssemblyName), throwIfNotFound: true); assembliesWithInitalizers.Add(assembly); }