Skip to content

Commit 5e7d681

Browse files
Delete vestiges of universal shared code support (#113640)
1 parent a1a3fb7 commit 5e7d681

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+122
-1021
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/CompatibilitySuppressions.xml

-4
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,6 @@
697697
<DiagnosticId>CP0001</DiagnosticId>
698698
<Target>T:Internal.Runtime.Augments.TypeLoaderCallbacks</Target>
699699
</Suppression>
700-
<Suppression>
701-
<DiagnosticId>CP0001</DiagnosticId>
702-
<Target>T:Internal.Runtime.CanonTypeKind</Target>
703-
</Suppression>
704700
<Suppression>
705701
<DiagnosticId>CP0001</DiagnosticId>
706702
<Target>T:Internal.Runtime.CompilerServices.FunctionPointerOps</Target>

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public static IntPtr NewInterfaceDispatchCell(RuntimeTypeHandle interfaceTypeHan
483483
}
484484

485485
[Intrinsic]
486-
public static RuntimeTypeHandle GetCanonType(CanonTypeKind kind)
486+
public static RuntimeTypeHandle GetCanonType()
487487
{
488488
// Compiler needs to expand this. This is not expressible in IL.
489489
throw new NotSupportedException();

src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,6 @@
353353
<Compile Include="$(CompilerCommonPath)\Internal\LowLevelLinq\LowLevelEnumerable.ToArray.cs">
354354
<Link>Internal\LowLevelLinq\LowLevelEnumerable.ToArray.cs</Link>
355355
</Compile>
356-
<Compile Include="$(CompilerCommonPath)\Internal\Runtime\CanonTypeKind.cs">
357-
<Link>Internal\Runtime\CanonTypeKind.cs</Link>
358-
</Compile>
359356
<Compile Include="$(AotCommonPath)\System\Runtime\RhFailFastReason.cs">
360357
<Link>System\Runtime\RhFailFastReason.cs</Link>
361358
</Compile>

src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs

+4-30
Original file line numberDiff line numberDiff line change
@@ -227,28 +227,8 @@ public sealed override MethodBaseInvoker TryGetMethodInvokerNoConstraintCheck(Ru
227227
{
228228
MethodBase methodInfo = ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles);
229229

230-
MethodInvokeInfo methodInvokeInfo;
231-
#if GENERICS_FORCE_USG
232-
// Stress mode to force the usage of universal canonical method targets for reflection invokes.
233-
// It is recommended to use "/SharedGenericsMode GenerateAllUniversalGenerics" NUTC command line argument when
234-
// compiling the application in order to effectively use the GENERICS_FORCE_USG mode.
235-
236-
// If we are just trying to invoke a non-generic method on a non-generic type, we won't force the universal lookup
237-
if (!RuntimeAugments.IsGenericType(declaringTypeHandle) && (genericMethodTypeArgumentHandles == null || genericMethodTypeArgumentHandles.Length == 0))
238-
methodInvokeInfo = TryGetMethodInvokeInfo(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles,
239-
methodInfo, ref methodSignatureComparer, CanonicalFormKind.Specific);
240-
else
241-
methodInvokeInfo = TryGetMethodInvokeInfo(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles,
242-
methodInfo, ref methodSignatureComparer, CanonicalFormKind.Universal);
243-
#else
244-
methodInvokeInfo = TryGetMethodInvokeInfo(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles,
245-
methodInfo, CanonicalFormKind.Specific);
246-
247-
// If we failed to get a MethodInvokeInfo for an exact method, or a canonically equivalent method, check if there is a universal canonically
248-
// equivalent entry that could be used (it will be much slower, and require a calling convention converter)
249-
methodInvokeInfo ??= TryGetMethodInvokeInfo(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles,
250-
methodInfo, CanonicalFormKind.Universal);
251-
#endif
230+
MethodInvokeInfo methodInvokeInfo = TryGetMethodInvokeInfo(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles,
231+
methodInfo);
252232

253233
if (methodInvokeInfo == null)
254234
return null;
@@ -307,22 +287,19 @@ private static IntPtr TryGetVirtualResolveData(RuntimeTypeHandle methodHandleDec
307287
/// <param name="methodHandle">Handle of method to look up</param>
308288
/// <param name="genericMethodTypeArgumentHandles">Runtime handles of generic method arguments</param>
309289
/// <param name="methodInfo">MethodInfo of method to look up</param>
310-
/// <param name="canonFormKind">Requested canon form</param>
311290
/// <returns>Constructed method invoke info, null on failure</returns>
312291
private static unsafe MethodInvokeInfo TryGetMethodInvokeInfo(
313292
RuntimeTypeHandle declaringTypeHandle,
314293
QMethodDefinition methodHandle,
315294
RuntimeTypeHandle[] genericMethodTypeArgumentHandles,
316-
MethodBase methodInfo,
317-
CanonicalFormKind canonFormKind)
295+
MethodBase methodInfo)
318296
{
319297
MethodInvokeMetadata methodInvokeMetadata;
320298

321299
if (!TypeLoaderEnvironment.TryGetMethodInvokeMetadata(
322300
declaringTypeHandle,
323301
methodHandle,
324302
genericMethodTypeArgumentHandles,
325-
canonFormKind,
326303
out methodInvokeMetadata))
327304
{
328305
// Method invoke info not found
@@ -740,8 +717,7 @@ public sealed override FieldAccessor TryGetFieldAccessor(
740717
{
741718
FieldAccessMetadata fieldAccessMetadata;
742719

743-
if (!TypeLoaderEnvironment.TryGetFieldAccessMetadata(
744-
metadataReader,
720+
if (!TypeLoaderEnvironment.TryGetFieldAccessMetadataFromFieldAccessMap(
745721
declaringTypeHandle,
746722
fieldHandle,
747723
out fieldAccessMetadata))
@@ -788,8 +764,6 @@ public sealed override FieldAccessor TryGetFieldAccessor(
788764
}
789765
else
790766
{
791-
Debug.Assert((fieldAccessMetadata.Flags & FieldTableFlags.IsUniversalCanonicalEntry) == 0);
792-
793767
if (fieldBase != FieldTableFlags.NonGCStatic)
794768
{
795769
fieldOffset = fieldAccessMetadata.Offset;

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CanonicallyEquivalentEntryLocator.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ public struct CanonicallyEquivalentEntryLocator
1717
private RuntimeTypeHandle _genericDefinition;
1818
private RuntimeTypeHandle[] _genericArgs;
1919
private DefType _defType;
20-
private CanonicalFormKind _canonKind;
2120

22-
public CanonicallyEquivalentEntryLocator(RuntimeTypeHandle typeToFind, CanonicalFormKind kind)
21+
public CanonicallyEquivalentEntryLocator(RuntimeTypeHandle typeToFind)
2322
{
2423
if (RuntimeAugments.IsGenericType(typeToFind))
2524
{
@@ -32,16 +31,14 @@ public CanonicallyEquivalentEntryLocator(RuntimeTypeHandle typeToFind, Canonical
3231
}
3332

3433
_typeToFind = typeToFind;
35-
_canonKind = kind;
3634
_defType = null;
3735
}
3836

39-
internal CanonicallyEquivalentEntryLocator(DefType typeToFind, CanonicalFormKind kind)
37+
internal CanonicallyEquivalentEntryLocator(DefType typeToFind)
4038
{
4139
_genericArgs = null;
4240
_genericDefinition = default(RuntimeTypeHandle);
4341
_typeToFind = default(RuntimeTypeHandle);
44-
_canonKind = kind;
4542
_defType = typeToFind;
4643
}
4744

@@ -50,10 +47,10 @@ public int LookupHashCode
5047
get
5148
{
5249
if (_defType != null)
53-
return _defType.ConvertToCanonForm(_canonKind).GetHashCode();
50+
return _defType.ConvertToCanonForm(CanonicalFormKind.Specific).GetHashCode();
5451

5552
if (!_genericDefinition.IsNull())
56-
return TypeLoaderEnvironment.Instance.GetCanonicalHashCode(_typeToFind, _canonKind);
53+
return TypeLoaderEnvironment.Instance.GetCanonicalHashCode(_typeToFind, CanonicalFormKind.Specific);
5754
else
5855
return _typeToFind.GetHashCode();
5956
}
@@ -63,9 +60,9 @@ public bool IsCanonicallyEquivalent(RuntimeTypeHandle other)
6360
{
6461
if (_defType != null)
6562
{
66-
TypeDesc typeToFindAsCanon = _defType.ConvertToCanonForm(_canonKind);
63+
TypeDesc typeToFindAsCanon = _defType.ConvertToCanonForm(CanonicalFormKind.Specific);
6764
TypeDesc otherTypeAsTypeDesc = _defType.Context.ResolveRuntimeTypeHandle(other);
68-
TypeDesc otherTypeAsCanon = otherTypeAsTypeDesc.ConvertToCanonForm(_canonKind);
65+
TypeDesc otherTypeAsCanon = otherTypeAsTypeDesc.ConvertToCanonForm(CanonicalFormKind.Specific);
6966
return typeToFindAsCanon == otherTypeAsCanon;
7067
}
7168

@@ -77,7 +74,7 @@ public bool IsCanonicallyEquivalent(RuntimeTypeHandle other)
7774
RuntimeTypeHandle[] otherGenericArgs;
7875
otherGenericDefinition = RuntimeAugments.GetGenericInstantiation(other, out otherGenericArgs);
7976

80-
return _genericDefinition.Equals(otherGenericDefinition) && TypeLoaderEnvironment.Instance.CanInstantiationsShareCode(_genericArgs, otherGenericArgs, _canonKind);
77+
return _genericDefinition.Equals(otherGenericDefinition) && TypeLoaderEnvironment.Instance.CanInstantiationsShareCode(_genericArgs, otherGenericArgs, CanonicalFormKind.Specific);
8178
}
8279
else
8380
return false;

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/EETypeCreator.cs

-2
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ private static void CreateEETypeWorker(MethodTable* pTemplateEEType, uint hashCo
216216
if (state.ThreadDataSize != 0)
217217
dynamicTypeFlags |= DynamicTypeFlags.HasThreadStatics;
218218

219-
// Note: The number of vtable slots on the MethodTable to create is not necessary equal to the number of
220-
// vtable slots on the template type for universal generics (see ComputeVTableLayout)
221219
ushort numVtableSlots = state.NumVTableSlots;
222220

223221
// Compute the MethodTable size and allocate it

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/GenericDictionaryCell.cs

-3
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ internal override unsafe void Prepare(TypeBuilder builder)
242242

243243
internal override IntPtr Create(TypeBuilder builder)
244244
{
245-
// TODO (USG): What if this method's instantiation is a non-shareable one (from a normal canonical
246-
// perspective) and there's an exact method pointer for the method in question, do we still
247-
// construct a method dictionary to be used with the universal canonical method implementation?
248245
Debug.Assert(GenericMethod.RuntimeMethodDictionary != IntPtr.Zero);
249246
return GenericMethod.RuntimeMethodDictionary;
250247
}

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TemplateLocator.cs

-8
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ private static TypeDesc TryGetTypeTemplate_Internal(TypeDesc concreteType, Canon
5656
continue;
5757
}
5858

59-
Debug.Assert(
60-
(kind != CanonicalFormKind.Universal) ||
61-
(kind == CanonicalFormKind.Universal && candidateTemplate == candidateTemplate.ConvertToCanonForm(kind)));
62-
6359
nativeLayoutInfoModule = moduleInfo;
6460
return candidateTemplate;
6561
}
@@ -126,10 +122,6 @@ private static InstantiatedMethod TryGetGenericMethodTemplate_Internal(Instantia
126122
continue;
127123
}
128124

129-
Debug.Assert(
130-
(kind != CanonicalFormKind.Universal) ||
131-
(kind == CanonicalFormKind.Universal && candidateTemplate == candidateTemplate.GetCanonMethodTarget(kind)));
132-
133125
return candidateTemplate;
134126
}
135127
}

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeBuilder.cs

-17
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,6 @@ internal void ParseNativeLayoutInfo(InstantiatedMethod method)
322322
}
323323
}
324324

325-
// Ensure that if this method is non-shareable from a normal canonical perspective, then
326-
// its template MUST be a universal canonical template method
327-
Debug.Assert(!method.IsNonSharableMethod || (method.IsNonSharableMethod && templateMethod.IsCanonicalMethod(CanonicalFormKind.Universal)));
328-
329325
NativeReader nativeLayoutInfoReader = TypeLoaderEnvironment.GetNativeLayoutInfoReader(nativeLayoutModule.Handle);
330326

331327
var methodInfoParser = new NativeParser(nativeLayoutInfoReader, nativeLayoutInfoToken);
@@ -361,12 +357,6 @@ internal void ParseNativeLayoutInfo(TypeBuilderState state, TypeDesc type)
361357
{
362358
TypeLoaderLogger.WriteLine("Parsing NativeLayoutInfo for type " + type.ToString() + " ...");
363359

364-
bool isTemplateUniversalCanon = false;
365-
if (state.TemplateType != null)
366-
{
367-
isTemplateUniversalCanon = state.TemplateType.IsCanonicalSubtype(CanonicalFormKind.Universal);
368-
}
369-
370360
if (state.TemplateType == null)
371361
{
372362
throw new MissingTemplateException();
@@ -427,15 +417,8 @@ internal void ParseNativeLayoutInfo(TypeBuilderState state, TypeDesc type)
427417
state.ThreadStaticDesc = context.GetGCStaticInfo(typeInfoParser.GetUnsigned());
428418
break;
429419

430-
case BagElementKind.FieldLayout:
431-
TypeLoaderLogger.WriteLine("Found BagElementKind.FieldLayout");
432-
typeInfoParser.SkipInteger(); // Handled in type layout algorithm
433-
break;
434-
435420
case BagElementKind.DictionaryLayout:
436421
TypeLoaderLogger.WriteLine("Found BagElementKind.DictionaryLayout");
437-
Debug.Assert(!isTemplateUniversalCanon, "Universal template nativelayout do not have DictionaryLayout");
438-
439422
Debug.Assert(state.Dictionary == null);
440423
if (!state.TemplateType.RetrieveRuntimeTypeHandleIfPossible())
441424
{

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeBuilderState.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public TypeDesc TemplateType
8585

8686
_templateTypeLoaderNativeLayout = true;
8787
_templateComputed = true;
88-
if ((_templateType != null) && !_templateType.IsCanonicalSubtype(CanonicalFormKind.Universal))
88+
if (_templateType != null)
8989
_nativeLayoutTokenComputed = true;
9090
}
9191

@@ -267,7 +267,6 @@ private ushort ComputeNumVTableSlots()
267267
}
268268
else
269269
{
270-
// This should only happen for non-universal templates
271270
Debug.Assert(TypeBeingBuilt.IsTemplateCanonical());
272271

273272
TypeDesc templateType = TypeBeingBuilt.ComputeTemplate(false);

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericMethodsLookup.cs

-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ public bool TryGetGenericVirtualMethodPointer(InstantiatedMethod method, out Int
247247
{
248248
if (!method.CanShareNormalGenericCode())
249249
{
250-
// First see if we can find an exact method implementation for the GVM (avoid using USG implementations if we can,
251-
// because USG code is much slower).
252250
if (TryLookupExactMethodPointer(method, out methodPointer))
253251
{
254252
Debug.Assert(methodPointer != IntPtr.Zero);

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.FieldAccess.cs

+5-46
Original file line numberDiff line numberDiff line change
@@ -41,58 +41,21 @@ public struct FieldAccessMetadata
4141

4242
public sealed partial class TypeLoaderEnvironment
4343
{
44-
/// <summary>
45-
/// Try to look up field access info for given canon in metadata blobs for all available modules.
46-
/// </summary>
47-
/// <param name="metadataReader">Metadata reader for the declaring type</param>
48-
/// <param name="runtimeTypeHandle">Declaring type for the method</param>
49-
/// <param name="fieldHandle">Field handle</param>
50-
/// <param name="fieldAccessMetadata">Output - metadata information for field accessor construction</param>
51-
/// <returns>true when found, false otherwise</returns>
52-
public static bool TryGetFieldAccessMetadata(
53-
MetadataReader metadataReader,
54-
RuntimeTypeHandle runtimeTypeHandle,
55-
FieldHandle fieldHandle,
56-
out FieldAccessMetadata fieldAccessMetadata)
57-
{
58-
fieldAccessMetadata = default(FieldAccessMetadata);
59-
60-
if (TryGetFieldAccessMetadataFromFieldAccessMap(
61-
runtimeTypeHandle,
62-
fieldHandle,
63-
CanonicalFormKind.Specific,
64-
ref fieldAccessMetadata))
65-
{
66-
return true;
67-
}
68-
69-
if (TryGetFieldAccessMetadataFromFieldAccessMap(
70-
runtimeTypeHandle,
71-
fieldHandle,
72-
CanonicalFormKind.Universal,
73-
ref fieldAccessMetadata))
74-
{
75-
return true;
76-
}
77-
78-
return false;
79-
}
80-
8144
/// <summary>
8245
/// Try to look up field access info for given canon in metadata blobs for all available modules.
8346
/// </summary>
8447
/// <param name="declaringTypeHandle">Declaring type for the method</param>
8548
/// <param name="fieldHandle">Field handle</param>
86-
/// <param name="canonFormKind">Canonical form to use</param>
8749
/// <param name="fieldAccessMetadata">Output - metadata information for field accessor construction</param>
8850
/// <returns>true when found, false otherwise</returns>
89-
private static unsafe bool TryGetFieldAccessMetadataFromFieldAccessMap(
51+
public static unsafe bool TryGetFieldAccessMetadataFromFieldAccessMap(
9052
RuntimeTypeHandle declaringTypeHandle,
9153
FieldHandle fieldHandle,
92-
CanonicalFormKind canonFormKind,
93-
ref FieldAccessMetadata fieldAccessMetadata)
54+
out FieldAccessMetadata fieldAccessMetadata)
9455
{
95-
CanonicallyEquivalentEntryLocator canonWrapper = new CanonicallyEquivalentEntryLocator(declaringTypeHandle, canonFormKind);
56+
fieldAccessMetadata = default;
57+
58+
CanonicallyEquivalentEntryLocator canonWrapper = new CanonicallyEquivalentEntryLocator(declaringTypeHandle);
9659

9760
foreach (NativeFormatModuleInfo mappingTableModule in ModuleList.EnumerateModules(RuntimeAugments.GetModuleFromTypeHandle(declaringTypeHandle)))
9861
{
@@ -119,9 +82,6 @@ private static unsafe bool TryGetFieldAccessMetadataFromFieldAccessMap(
11982

12083
FieldTableFlags entryFlags = (FieldTableFlags)entryParser.GetUnsigned();
12184

122-
if ((canonFormKind == CanonicalFormKind.Universal) != ((entryFlags & FieldTableFlags.IsUniversalCanonicalEntry) != 0))
123-
continue;
124-
12585
RuntimeTypeHandle entryDeclaringTypeHandle = externalReferences.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
12686
if (!entryDeclaringTypeHandle.Equals(declaringTypeHandle)
12787
&& !canonWrapper.IsCanonicallyEquivalent(entryDeclaringTypeHandle))
@@ -134,7 +94,6 @@ private static unsafe bool TryGetFieldAccessMetadataFromFieldAccessMap(
13494
int fieldOffset;
13595
IntPtr fieldAddressCookie = IntPtr.Zero;
13696

137-
Debug.Assert(canonFormKind != CanonicalFormKind.Universal);
13897
if ((entryFlags & FieldTableFlags.FieldOffsetEncodedDirectly) != 0)
13998
{
14099
fieldOffset = (int)entryParser.GetUnsigned();

0 commit comments

Comments
 (0)