From ac5218af157e541c6d4004cef7c79b217f0ad775 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Jan 2024 13:58:34 +0100 Subject: [PATCH 01/21] Make Type.IsGenericType a JIT intrinsic --- src/coreclr/jit/fgbasic.cpp | 1 + src/coreclr/jit/importercalls.cpp | 20 +++++++++++++++++++ src/coreclr/jit/namedintrinsiclist.h | 1 + .../System.Private.CoreLib/src/System/Type.cs | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp index 653ff015c3272..da31f325424e4 100644 --- a/src/coreclr/jit/fgbasic.cpp +++ b/src/coreclr/jit/fgbasic.cpp @@ -1382,6 +1382,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed case NI_System_Type_get_IsValueType: case NI_System_Type_get_IsPrimitive: case NI_System_Type_get_IsByRefLike: + case NI_System_Type_get_IsGenericType: case NI_System_Type_GetTypeFromHandle: case NI_System_String_get_Length: case NI_System_Buffers_Binary_BinaryPrimitives_ReverseEndianness: diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index c920ac70cfef5..bdb8e4f2c4eb9 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -3165,6 +3165,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, case NI_System_Type_get_IsByRefLike: case NI_System_Type_IsAssignableFrom: case NI_System_Type_IsAssignableTo: + case NI_System_Type_get_IsGenericType: // Lightweight intrinsics case NI_System_String_get_Chars: @@ -3785,6 +3786,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, case NI_System_Type_get_IsValueType: case NI_System_Type_get_IsPrimitive: case NI_System_Type_get_IsByRefLike: + case NI_System_Type_get_IsGenericType: { // Optimize // @@ -3831,6 +3833,20 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, retNode = gtNewFalse(); } break; + case NI_System_Type_get_IsGenericType: + // a type is a generic type if there is at least one type argument that is + // some valid type, so we can always just check the one at index 0 for this. + // This will work on open generic types as well, and the returned type handle + // will be some handle that represents the (non constructed) type parameter. + if (info.compCompHnd->getTypeInstantiationArgument(hClass, 0) != NO_CLASS_HANDLE) + { + retNode = gtNewTrue(); + } + else + { + retNode = gtNewFalse(); + } + break; default: NO_WAY("Intrinsic not supported in this path."); @@ -10015,6 +10031,10 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method) { result = NI_System_Type_get_IsPrimitive; } + else if (strcmp(methodName, "get_IsGenericType") == 0) + { + result = NI_System_Type_get_IsGenericType; + } else if (strcmp(methodName, "get_IsByRefLike") == 0) { result = NI_System_Type_get_IsByRefLike; diff --git a/src/coreclr/jit/namedintrinsiclist.h b/src/coreclr/jit/namedintrinsiclist.h index d778414428272..0ec8fd2496ba3 100644 --- a/src/coreclr/jit/namedintrinsiclist.h +++ b/src/coreclr/jit/namedintrinsiclist.h @@ -81,6 +81,7 @@ enum NamedIntrinsic : unsigned short NI_System_Type_get_IsPrimitive, NI_System_Type_get_IsByRefLike, NI_System_Type_get_TypeHandle, + NI_System_Type_get_IsGenericType, NI_System_Type_IsAssignableFrom, NI_System_Type_IsAssignableTo, NI_System_Type_op_Equality, diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.cs b/src/libraries/System.Private.CoreLib/src/System/Type.cs index c93a158339a03..6c9185193dabf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.cs @@ -57,7 +57,7 @@ public bool IsInterface public virtual bool IsGenericParameter => false; public virtual bool IsGenericTypeParameter => IsGenericParameter && DeclaringMethod is null; public virtual bool IsGenericMethodParameter => IsGenericParameter && DeclaringMethod != null; - public virtual bool IsGenericType => false; + public virtual bool IsGenericType { [Intrinsic] get => false; } public virtual bool IsGenericTypeDefinition => false; public virtual bool IsSZArray => throw NotImplemented.ByDesign; From c9d6555ab335c17493a499293dbb36921974e59d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Jan 2024 14:09:16 +0100 Subject: [PATCH 02/21] Add Type.IsGenericType intrinsic tests --- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 218f17e3d1793..98181c6eb0b46 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -133,6 +133,7 @@ public static int TestEntryPoint() GetEnumUnderlyingType.TestGetEnumUnderlyingType(); IsPrimitiveTests(); + IsGenericTypeTests(); return 100 + _errors; } @@ -186,6 +187,71 @@ private static void IsPrimitiveTests() IsFalse(typeof(Dictionary<,>).IsPrimitive); } + private static void IsGenericTypeTests() + { + IsFalse(typeof(bool).IsGenericType); + IsFalse(typeof(char).IsGenericType); + IsFalse(typeof(sbyte).IsGenericType); + IsFalse(typeof(byte).IsGenericType); + IsFalse(typeof(short).IsGenericType); + IsFalse(typeof(ushort).IsGenericType); + IsFalse(typeof(int).IsGenericType); + IsFalse(typeof(uint).IsGenericType); + IsFalse(typeof(long).IsGenericType); + IsFalse(typeof(ulong).IsGenericType); + IsFalse(typeof(float).IsGenericType); + IsFalse(typeof(double).IsGenericType); + IsFalse(typeof(nint).IsGenericType); + IsFalse(typeof(nuint).IsGenericType); + IsFalse(typeof(IntPtr).IsGenericType); + IsFalse(typeof(UIntPtr).IsGenericType); + IsFalse(typeof(Enum).IsGenericType); + IsFalse(typeof(ValueType).IsGenericType); + IsFalse(typeof(SimpleEnum).IsGenericType); + IsFalse(typeof(IntPtrEnum).IsGenericType); + IsFalse(typeof(FloatEnum).IsGenericType); + IsFalse(typeof(decimal).IsGenericType); + IsFalse(typeof(TimeSpan).IsGenericType); + IsFalse(typeof(DateTime).IsGenericType); + IsFalse(typeof(DateTimeOffset).IsGenericType); + IsFalse(typeof(Guid).IsGenericType); + IsFalse(typeof(Half).IsGenericType); + IsFalse(typeof(DateOnly).IsGenericType); + IsFalse(typeof(TimeOnly).IsGenericType); + IsFalse(typeof(Int128).IsGenericType); + IsFalse(typeof(UInt128).IsGenericType); + IsFalse(typeof(string).IsGenericType); + IsFalse(typeof(object).IsGenericType); + IsFalse(typeof(RuntimeArgumentHandle).IsGenericType); + IsFalse(typeof(DerivedGenericSimpleClass).IsGenericType); + IsFalse(typeof(int[]).IsGenericType); + IsFalse(typeof(int[,]).IsGenericType); + IsFalse(typeof(int*).IsGenericType); + IsFalse(typeof(void*).IsGenericType); + IsFalse(typeof(delegate*).IsGenericType); + + IsTrue(typeof(GenericSimpleClass).IsGenericType); + IsTrue(typeof(GenericSimpleClass<>).IsGenericType); + IsTrue(typeof(GenericEnumClass).IsGenericType); + IsTrue(typeof(GenericEnumClass<>).IsGenericType); + IsTrue(typeof(IGenericInterface).IsGenericType); + IsTrue(typeof(IGenericInterface<>).IsGenericType); + IsTrue(typeof(GenericStruct).IsGenericType); + IsTrue(typeof(GenericStruct<>).IsGenericType); + IsTrue(typeof(SimpleEnum?).IsGenericType); + IsTrue(typeof(int?).IsGenericType); + IsTrue(typeof(IntPtr?).IsGenericType); + IsTrue(typeof(Nullable<>).IsGenericType); + IsTrue(typeof(Dictionary).IsGenericType); + IsTrue(typeof(Dictionary<,>).IsGenericType); + IsTrue(typeof(List).IsGenericType); + IsTrue(typeof(List<>).IsGenericType); + IsTrue(typeof(Action<>).IsGenericType); + IsTrue(typeof(Action).IsGenericType); + IsTrue(typeof(Func).IsGenericType); + IsTrue(typeof(Func<,>).IsGenericType); + } + private static int _varInt = 42; private static int? _varNullableInt = 42; private static decimal _varDecimal = 42M; @@ -258,6 +324,14 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil } } +public class GenericSimpleClass +{ +} + +public class DerivedGenericSimpleClass : GenericSimpleClass +{ +} + public class GenericEnumClass where T : Enum { public T field; From c74d7ab88ed47893f1bf189cfeb142dc521a3b65 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Jan 2024 14:16:53 +0100 Subject: [PATCH 03/21] Add intrinsic tests for nested types too --- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 98181c6eb0b46..93faad7571661 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -232,6 +232,8 @@ private static void IsGenericTypeTests() IsTrue(typeof(GenericSimpleClass).IsGenericType); IsTrue(typeof(GenericSimpleClass<>).IsGenericType); + IsTrue(typeof(GenericSimpleClass.Nested).IsGenericType); + IsTrue(typeof(GenericSimpleClass<>.Nested).IsGenericType); IsTrue(typeof(GenericEnumClass).IsGenericType); IsTrue(typeof(GenericEnumClass<>).IsGenericType); IsTrue(typeof(IGenericInterface).IsGenericType); @@ -325,7 +327,10 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil } public class GenericSimpleClass -{ +{ + public class Nested + { + } } public class DerivedGenericSimpleClass : GenericSimpleClass From 7e9f1bb43635e745a74a1933cad0cf3b32ea2581 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Jan 2024 19:12:40 +0100 Subject: [PATCH 04/21] Skip expanding the intrinsic for __Canon --- src/coreclr/jit/importercalls.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index bdb8e4f2c4eb9..6e230991b6a93 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -3842,6 +3842,13 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, { retNode = gtNewTrue(); } + else if ((info.compCompHnd->getClassAttribs(hClass) & CORINFO_FLG_SHAREDINST) != 0) + { + // if we have no type arguments, check that the type itself is not __Canon, and + // simply skip expanding the intrinsic in that case, rather than incorrectly + // hardcoding 'false' as the resulting expression. + retNode = nullptr; + } else { retNode = gtNewFalse(); From 87438eac670690578839d9c0510949215dbd1aae Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 11 Mar 2024 11:51:34 -0700 Subject: [PATCH 05/21] Add 'isGenericType' generated thunk Fix vtable in CorInfoImpl_generated.cs --- src/coreclr/inc/icorjitinfoimpl_generated.h | 3 +++ src/coreclr/jit/ICorJitInfo_names_generated.h | 1 + src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp | 11 ++++++++++- .../Common/JitInterface/ThunkGenerator/ThunkInput.txt | 1 + .../tools/aot/jitinterface/jitinterface_generated.h | 10 ++++++++++ .../superpmi-shim-counter/icorjitinfo_generated.cpp | 7 +++++++ .../superpmi-shim-simple/icorjitinfo_generated.cpp | 6 ++++++ 7 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index 9567498e59768..a19704e69e71a 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -345,6 +345,9 @@ bool isMoreSpecificType( bool isExactType( CORINFO_CLASS_HANDLE cls) override; +bool isGenericType( + CORINFO_CLASS_HANDLE cls) override; + TypeCompareState isNullableType( CORINFO_CLASS_HANDLE cls) override; diff --git a/src/coreclr/jit/ICorJitInfo_names_generated.h b/src/coreclr/jit/ICorJitInfo_names_generated.h index c1c21429e05a2..a2bfe1de9c80c 100644 --- a/src/coreclr/jit/ICorJitInfo_names_generated.h +++ b/src/coreclr/jit/ICorJitInfo_names_generated.h @@ -86,6 +86,7 @@ DEF_CLR_API(compareTypesForCast) DEF_CLR_API(compareTypesForEquality) DEF_CLR_API(isMoreSpecificType) DEF_CLR_API(isExactType) +DEF_CLR_API(isGenericType) DEF_CLR_API(isNullableType) DEF_CLR_API(isEnum) DEF_CLR_API(getParentType) diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index ec77bd3eed0a3..71936e08e1d8b 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -811,13 +811,22 @@ bool WrapICorJitInfo::isExactType( return temp; } +bool WrapICorJitInfo::isGenericType( + CORINFO_CLASS_HANDLE cls) +{ + API_ENTER(isGenericType); + bool temp = wrapHnd->isGenericType(cls); + API_LEAVE(isGenericType); + return temp; +} + TypeCompareState WrapICorJitInfo::isNullableType( CORINFO_CLASS_HANDLE cls) { API_ENTER(isNullableType); TypeCompareState temp = wrapHnd->isNullableType(cls); API_LEAVE(isNullableType); - return temp; + return temp } TypeCompareState WrapICorJitInfo::isEnum( diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 5cb584a948b5b..5128d38222f47 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -245,6 +245,7 @@ FUNCTIONS TypeCompareState compareTypesForEquality(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) bool isMoreSpecificType(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) bool isExactType(CORINFO_CLASS_HANDLE cls) + bool isGenericType(CORINFO_CLASS_HANDLE cls) TypeCompareState isNullableType(CORINFO_CLASS_HANDLE cls) TypeCompareState isEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType) CORINFO_CLASS_HANDLE getParentType(CORINFO_CLASS_HANDLE cls) diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index 0e266984cd88c..6e6aa4bb0c5b5 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -93,6 +93,7 @@ struct JitInterfaceCallbacks TypeCompareState (* compareTypesForEquality)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2); bool (* isMoreSpecificType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2); bool (* isExactType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); + bool (* isGenericType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); TypeCompareState (* isNullableType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); TypeCompareState (* isEnum)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType); CORINFO_CLASS_HANDLE (* getParentType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); @@ -1000,6 +1001,15 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } + virtual bool isGenericType( + CORINFO_CLASS_HANDLE cls) +{ + CorInfoExceptionClass* pException = nullptr; + bool temp = _callbacks->isGenericType(_thisHandle, &pException, cls); + if (pException != nullptr) throw pException; + return temp; +} + virtual TypeCompareState isNullableType( CORINFO_CLASS_HANDLE cls) { diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp index aa5ab8a37b7ba..12913cfbde5f3 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -664,6 +664,13 @@ bool interceptor_ICJI::isExactType( return original_ICorJitInfo->isExactType(cls); } +bool interceptor_ICJI::isGenericType( + CORINFO_CLASS_HANDLE cls) +{ + mcs->AddCall("isGenericType"); + return original_ICorJitInfo->isGenericType(cls); +} + TypeCompareState interceptor_ICJI::isNullableType( CORINFO_CLASS_HANDLE cls) { diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp index 7cfceafebcb55..62514c7e8e1bf 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -582,6 +582,12 @@ bool interceptor_ICJI::isExactType( return original_ICorJitInfo->isExactType(cls); } +bool interceptor_ICJI::isGenericType( + CORINFO_CLASS_HANDLE cls) +{ + return original_ICorJitInfo->isGenericType(cls); +} + TypeCompareState interceptor_ICJI::isNullableType( CORINFO_CLASS_HANDLE cls) { From 1f42a915c6e9a43f8230f41e1a9421a3bc7d0ea0 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 11 Mar 2024 11:51:47 -0700 Subject: [PATCH 06/21] Implement 'isGenericType' JIT/EE method --- src/coreclr/inc/corinfo.h | 5 +++++ .../tools/Common/JitInterface/CorInfoImpl.cs | 7 +++++++ src/coreclr/vm/jitinterface.cpp | 21 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 271eb8492aef7..8cfb042e75c69 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2718,6 +2718,11 @@ class ICorStaticInfo CORINFO_CLASS_HANDLE cls ) = 0; + // Returns true if a class handle represents a generic type. + virtual bool isGenericType( + CORINFO_CLASS_HANDLE cls + ) = 0; + // Returns whether a class handle represents a Nullable type, if that can be statically determined. virtual TypeCompareState isNullableType( CORINFO_CLASS_HANDLE cls diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index f39bafc4f3837..65208b34273a9 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2938,6 +2938,13 @@ private bool isExactType(CORINFO_CLASS_STRUCT_* cls) return _compilation.IsEffectivelySealed(type); } + private bool isGenericType(CORINFO_CLASS_STRUCT_* cls) + { + TypeDesc type = HandleToObject(cls); + + return type.HasInstantiation; + } + private TypeCompareState isNullableType(CORINFO_CLASS_STRUCT_* cls) { TypeDesc type = HandleToObject(cls); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 2631fb927d5d8..b4def3274082f 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4547,6 +4547,27 @@ bool CEEInfo::isExactType(CORINFO_CLASS_HANDLE cls) return result; } +// Returns true if a class handle represents a generic type. +bool CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) +{ + CONTRACTL { + THROWS; + GC_TRIGGERS; + MODE_PREEMPTIVE; + } CONTRACTL_END; + + TypeCompareState result = TypeCompareState::May; + + bool result = false; + + JIT_TO_EE_TRANSITION(); + + result = TypeHandle(cls).HasInstantiation(); + + EE_TO_JIT_TRANSITION(); + return result; +} + // Returns whether a class handle represents a Nullable type, if that can be statically determined. TypeCompareState CEEInfo::isNullableType(CORINFO_CLASS_HANDLE cls) { From 33c4b6f3bbd0b394c6640e4aa21c63881c917f1f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 11 Mar 2024 11:57:13 -0700 Subject: [PATCH 07/21] Plug 'isGenericType' in importer --- src/coreclr/jit/importercalls.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 6e230991b6a93..2f34324879ff8 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -3834,25 +3834,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, } break; case NI_System_Type_get_IsGenericType: - // a type is a generic type if there is at least one type argument that is - // some valid type, so we can always just check the one at index 0 for this. - // This will work on open generic types as well, and the returned type handle - // will be some handle that represents the (non constructed) type parameter. - if (info.compCompHnd->getTypeInstantiationArgument(hClass, 0) != NO_CLASS_HANDLE) - { - retNode = gtNewTrue(); - } - else if ((info.compCompHnd->getClassAttribs(hClass) & CORINFO_FLG_SHAREDINST) != 0) - { - // if we have no type arguments, check that the type itself is not __Canon, and - // simply skip expanding the intrinsic in that case, rather than incorrectly - // hardcoding 'false' as the resulting expression. - retNode = nullptr; - } - else - { - retNode = gtNewFalse(); - } + retNode = info.compCompHnd->isGenericType(hClass) ? gtNewTrue() : gtNewFalse(); break; default: From de41e530e96b977c04d660fdf2774be5b28ef62a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 11 Mar 2024 14:26:25 -0700 Subject: [PATCH 08/21] Fix superPMI build --- .../tools/superpmi/superpmi-shared/lwmlist.h | 1 + .../superpmi-shared/methodcontext.cpp | 22 +++++++++++++++++++ .../superpmi/superpmi-shared/methodcontext.h | 5 +++++ .../superpmi-shim-collector/icorjitinfo.cpp | 10 ++++++++- .../tools/superpmi/superpmi/icorjitinfo.cpp | 7 ++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index 0dcf59296462f..fd85fdd97e892 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -159,6 +159,7 @@ LWM(PrintMethodName, DWORDLONG, Agnostic_PrintResult) LWM(IsValueClass, DWORDLONG, DWORD) LWM(IsMoreSpecificType, DLDL, DWORD) LWM(IsExactType, DWORDLONG, DWORD) +LWM(IsGenericType, DWORDLONG, DWORD) LWM(IsNullableType, DWORDLONG, DWORD) LWM(IsEnum, DWORDLONG, DLD) LWM(PInvokeMarshalingRequired, MethodOrSigInfoValue, DWORD) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 98b76813d5ba4..2f7be340c3d96 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -5926,6 +5926,28 @@ bool MethodContext::repIsExactType(CORINFO_CLASS_HANDLE cls) return value != 0; } +void MethodContext::recIsGenericType(CORINFO_CLASS_HANDLE cls, bool result) +{ + if (IsGenericType == nullptr) + IsGenericType = new LightWeightMap(); + + DWORDLONG key = CastHandle(cls); + DWORD value = result ? 1 : 0; + IsGenericType->Add(key, value); + DEBUG_REC(dmpIsGenericType(key, value)); +} +void MethodContext::dmpIsGenericType(DWORDLONG key, DWORD value) +{ + printf("IsGenericType key cls-%016" PRIX64 ", value res-%u", key, value); +} +bool MethodContext::repIsGenericType(CORINFO_CLASS_HANDLE cls) +{ + DWORDLONG key = CastHandle(cls); + DWORD value = LookupByKeyOrMiss(IsGenericType, key, ": key %016" PRIX64 "", key); + DEBUG_REP(dmpIsGenericType(key, value)); + return value != 0; +} + void MethodContext::recIsNullableType(CORINFO_CLASS_HANDLE cls, TypeCompareState result) { if (IsNullableType == nullptr) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 807b2311a49e6..ddb2a3fef24aa 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -727,6 +727,10 @@ class MethodContext void dmpIsExactType(DWORDLONG key, DWORD value); bool repIsExactType(CORINFO_CLASS_HANDLE cls); + void recIsGenericType(CORINFO_CLASS_HANDLE cls, bool result); + void dmpIsGenericType(DWORDLONG key, DWORD value); + bool repIsGenericType(CORINFO_CLASS_HANDLE cls); + void recIsNullableType(CORINFO_CLASS_HANDLE cls, TypeCompareState result); void dmpIsNullableType(DWORDLONG key, DWORD value); TypeCompareState repIsNullableType(CORINFO_CLASS_HANDLE cls); @@ -1176,6 +1180,7 @@ enum mcPackets Packet_IsNullableType = 217, Packet_GetClassStaticDynamicInfo = 218, Packet_GetClassThreadStaticDynamicInfo = 219, + Packet_IsGenericType = 220, }; void SetDebugDumpVariables(); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index ee43051dd1ce1..a0261967bbb0f 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -905,13 +905,21 @@ bool interceptor_ICJI::isExactType(CORINFO_CLASS_HANDLE cls) return temp; } +// Returns true if a class handle represents a generic type. +bool interceptor_ICJI::isGenericType(CORINFO_CLASS_HANDLE cls) +{ + mc->cr->AddCall("isGenericType"); + bool temp = original_ICorJitInfo->isGenericType(cls); + mc->recIsGenericType(cls, temp); + return temp; +} + // Returns whether a class handle represents a Nullable type, if that can be statically determined. TypeCompareState interceptor_ICJI::isNullableType(CORINFO_CLASS_HANDLE cls) { mc->cr->AddCall("isNullableType"); TypeCompareState temp = original_ICorJitInfo->isNullableType(cls); mc->recIsNullableType(cls, temp); - return temp; } // Returns TypeCompareState::Must if cls is known to be an enum. diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 0736fc8deee8a..17305575332cb 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -768,6 +768,13 @@ bool MyICJI::isExactType(CORINFO_CLASS_HANDLE cls) return jitInstance->mc->repIsExactType(cls); } +// Returns true if a class handle represents a generic type. +bool MyICJI::isGenericType(CORINFO_CLASS_HANDLE cls) +{ + jitInstance->mc->cr->AddCall("isGenericType"); + return jitInstance->mc->repIsGenericType(cls); +} + // Returns true if a class handle represents a Nullable type. TypeCompareState MyICJI::isNullableType(CORINFO_CLASS_HANDLE cls) { From 3b3d31de279ad78f8579abaa3509cd9b2e187113 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 12 Mar 2024 13:38:14 -0700 Subject: [PATCH 09/21] Use 'TypeCompareState' for 'isGenericType' --- src/coreclr/inc/corinfo.h | 4 ++-- src/coreclr/inc/icorjitinfoimpl_generated.h | 2 +- .../jit/ICorJitInfo_wrapper_generated.hpp | 4 ++-- src/coreclr/jit/importercalls.cpp | 11 +++++++++-- .../tools/Common/JitInterface/CorInfoImpl.cs | 9 +++++++-- .../JitInterface/ThunkGenerator/ThunkInput.txt | 2 +- .../aot/jitinterface/jitinterface_generated.h | 6 +++--- .../superpmi/superpmi-shared/methodcontext.cpp | 10 +++++----- .../superpmi/superpmi-shared/methodcontext.h | 4 ++-- .../superpmi-shim-collector/icorjitinfo.cpp | 6 +++--- .../icorjitinfo_generated.cpp | 2 +- .../icorjitinfo_generated.cpp | 2 +- .../tools/superpmi/superpmi/icorjitinfo.cpp | 2 +- src/coreclr/vm/jitinterface.cpp | 15 +++++++++------ src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 16 ++++++++++++++++ 15 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 8cfb042e75c69..89c61ebeac690 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2718,8 +2718,8 @@ class ICorStaticInfo CORINFO_CLASS_HANDLE cls ) = 0; - // Returns true if a class handle represents a generic type. - virtual bool isGenericType( + // Returns whether a class handle represents a generic type, if that can be statically determined. + virtual TypeCompareState isGenericType( CORINFO_CLASS_HANDLE cls ) = 0; diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index a19704e69e71a..38f9dac0e2e4d 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -345,7 +345,7 @@ bool isMoreSpecificType( bool isExactType( CORINFO_CLASS_HANDLE cls) override; -bool isGenericType( +TypeCompareState isGenericType( CORINFO_CLASS_HANDLE cls) override; TypeCompareState isNullableType( diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index 71936e08e1d8b..df19cc5ac986e 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -811,11 +811,11 @@ bool WrapICorJitInfo::isExactType( return temp; } -bool WrapICorJitInfo::isGenericType( +TypeCompareState WrapICorJitInfo::isGenericType( CORINFO_CLASS_HANDLE cls) { API_ENTER(isGenericType); - bool temp = wrapHnd->isGenericType(cls); + TypeCompareState temp = wrapHnd->isGenericType(cls); API_LEAVE(isGenericType); return temp; } diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 2f34324879ff8..d8041a548412c 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -3834,9 +3834,16 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, } break; case NI_System_Type_get_IsGenericType: - retNode = info.compCompHnd->isGenericType(hClass) ? gtNewTrue() : gtNewFalse(); + { + TypeCompareState state = info.compCompHnd->isGenericType(hClass); + if (state == TypeCompareState::May) + { + retNode = nullptr; + break; + } + retNode = state == TypeCompareState::Must ? gtNewTrue() : gtNewFalse(); break; - + } default: NO_WAY("Intrinsic not supported in this path."); } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 65208b34273a9..5d83989e15ecb 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2938,11 +2938,16 @@ private bool isExactType(CORINFO_CLASS_STRUCT_* cls) return _compilation.IsEffectivelySealed(type); } - private bool isGenericType(CORINFO_CLASS_STRUCT_* cls) + private TypeCompareState isGenericType(CORINFO_CLASS_STRUCT_* cls) { TypeDesc type = HandleToObject(cls); - return type.HasInstantiation; + if (type.IsCanonicalSubtype(CanonicalFormKind.Any)) + { + return TypeCompareState.May; + } + + return type.HasInstantiation ? TypeCompareState.Must : TypeCompareState.MustNot; } private TypeCompareState isNullableType(CORINFO_CLASS_STRUCT_* cls) diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 5128d38222f47..ff00c41ce2653 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -245,8 +245,8 @@ FUNCTIONS TypeCompareState compareTypesForEquality(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) bool isMoreSpecificType(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) bool isExactType(CORINFO_CLASS_HANDLE cls) - bool isGenericType(CORINFO_CLASS_HANDLE cls) TypeCompareState isNullableType(CORINFO_CLASS_HANDLE cls) + TypeCompareState isGenericType(CORINFO_CLASS_HANDLE cls) TypeCompareState isEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType) CORINFO_CLASS_HANDLE getParentType(CORINFO_CLASS_HANDLE cls) CorInfoType getChildType(CORINFO_CLASS_HANDLE clsHnd, CORINFO_CLASS_HANDLE* clsRet) diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index 6e6aa4bb0c5b5..75722274d9e9b 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -93,7 +93,7 @@ struct JitInterfaceCallbacks TypeCompareState (* compareTypesForEquality)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2); bool (* isMoreSpecificType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2); bool (* isExactType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); - bool (* isGenericType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); + TypeCompareState (* isGenericType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); TypeCompareState (* isNullableType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); TypeCompareState (* isEnum)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType); CORINFO_CLASS_HANDLE (* getParentType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); @@ -1001,11 +1001,11 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } - virtual bool isGenericType( + virtual TypeCompareState isGenericType( CORINFO_CLASS_HANDLE cls) { CorInfoExceptionClass* pException = nullptr; - bool temp = _callbacks->isGenericType(_thisHandle, &pException, cls); + TypeCompareState temp = _callbacks->isGenericType(_thisHandle, &pException, cls); if (pException != nullptr) throw pException; return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 2f7be340c3d96..0e0fa438e727a 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -5926,26 +5926,26 @@ bool MethodContext::repIsExactType(CORINFO_CLASS_HANDLE cls) return value != 0; } -void MethodContext::recIsGenericType(CORINFO_CLASS_HANDLE cls, bool result) +void MethodContext::recIsGenericType(CORINFO_CLASS_HANDLE cls, TypeCompareState result) { if (IsGenericType == nullptr) IsGenericType = new LightWeightMap(); DWORDLONG key = CastHandle(cls); - DWORD value = result ? 1 : 0; + DWORD value = (DWORD)result; IsGenericType->Add(key, value); DEBUG_REC(dmpIsGenericType(key, value)); } void MethodContext::dmpIsGenericType(DWORDLONG key, DWORD value) { - printf("IsGenericType key cls-%016" PRIX64 ", value res-%u", key, value); + printf("IsGenericType key cls-%016" PRIX64 ", value res-%d", key, value); } -bool MethodContext::repIsGenericType(CORINFO_CLASS_HANDLE cls) +TypeCompareState MethodContext::repIsGenericType(CORINFO_CLASS_HANDLE cls) { DWORDLONG key = CastHandle(cls); DWORD value = LookupByKeyOrMiss(IsGenericType, key, ": key %016" PRIX64 "", key); DEBUG_REP(dmpIsGenericType(key, value)); - return value != 0; + return (TypeCompareState)value; } void MethodContext::recIsNullableType(CORINFO_CLASS_HANDLE cls, TypeCompareState result) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index ddb2a3fef24aa..c970dd9a7b226 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -727,9 +727,9 @@ class MethodContext void dmpIsExactType(DWORDLONG key, DWORD value); bool repIsExactType(CORINFO_CLASS_HANDLE cls); - void recIsGenericType(CORINFO_CLASS_HANDLE cls, bool result); + void recIsGenericType(CORINFO_CLASS_HANDLE cls, TypeCompareState result); void dmpIsGenericType(DWORDLONG key, DWORD value); - bool repIsGenericType(CORINFO_CLASS_HANDLE cls); + TypeCompareState repIsGenericType(CORINFO_CLASS_HANDLE cls); void recIsNullableType(CORINFO_CLASS_HANDLE cls, TypeCompareState result); void dmpIsNullableType(DWORDLONG key, DWORD value); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index a0261967bbb0f..304ea616b55dd 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -905,11 +905,11 @@ bool interceptor_ICJI::isExactType(CORINFO_CLASS_HANDLE cls) return temp; } -// Returns true if a class handle represents a generic type. -bool interceptor_ICJI::isGenericType(CORINFO_CLASS_HANDLE cls) +// Returns whether a class handle represents a generic type, if that can be statically determined. +TypeCompareState interceptor_ICJI::isGenericType(CORINFO_CLASS_HANDLE cls) { mc->cr->AddCall("isGenericType"); - bool temp = original_ICorJitInfo->isGenericType(cls); + TypeCompareState temp = original_ICorJitInfo->isGenericType(cls); mc->recIsGenericType(cls, temp); return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp index 12913cfbde5f3..2d6faf2c65728 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -664,7 +664,7 @@ bool interceptor_ICJI::isExactType( return original_ICorJitInfo->isExactType(cls); } -bool interceptor_ICJI::isGenericType( +TypeCompareState interceptor_ICJI::isGenericType( CORINFO_CLASS_HANDLE cls) { mcs->AddCall("isGenericType"); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp index 62514c7e8e1bf..210485e727c9b 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -582,7 +582,7 @@ bool interceptor_ICJI::isExactType( return original_ICorJitInfo->isExactType(cls); } -bool interceptor_ICJI::isGenericType( +TypeCompareState interceptor_ICJI::isGenericType( CORINFO_CLASS_HANDLE cls) { return original_ICorJitInfo->isGenericType(cls); diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 17305575332cb..9e29f43e03ec3 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -769,7 +769,7 @@ bool MyICJI::isExactType(CORINFO_CLASS_HANDLE cls) } // Returns true if a class handle represents a generic type. -bool MyICJI::isGenericType(CORINFO_CLASS_HANDLE cls) +TypeCompareState MyICJI::isGenericType(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("isGenericType"); return jitInstance->mc->repIsGenericType(cls); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index b4def3274082f..5c8f1fc1a2dde 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4547,8 +4547,8 @@ bool CEEInfo::isExactType(CORINFO_CLASS_HANDLE cls) return result; } -// Returns true if a class handle represents a generic type. -bool CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) +// Returns whether a class handle represents a generic type, if that can be statically determined. +TypeCompareState CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) { CONTRACTL { THROWS; @@ -4556,13 +4556,16 @@ bool CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) MODE_PREEMPTIVE; } CONTRACTL_END; + TypeHandle typeHandle = TypeHandle(); + TypeCompareState result = TypeCompareState::May; - bool result = false; + JIT_TO_EE_TRANSITION(); - JIT_TO_EE_TRANSITION(); - - result = TypeHandle(cls).HasInstantiation(); + if (!typeHandle.IsCanonicalSubtype()) + { + result = typeHandle.HasInstantiation() ? TypeCompareState::Must : TypeCompareState::MustNot; + } EE_TO_JIT_TRANSITION(); return result; diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 93faad7571661..7f05c07a58eed 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -229,6 +229,12 @@ private static void IsGenericTypeTests() IsFalse(typeof(int*).IsGenericType); IsFalse(typeof(void*).IsGenericType); IsFalse(typeof(delegate*).IsGenericType); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); IsTrue(typeof(GenericSimpleClass).IsGenericType); IsTrue(typeof(GenericSimpleClass<>).IsGenericType); @@ -252,6 +258,11 @@ private static void IsGenericTypeTests() IsTrue(typeof(Action).IsGenericType); IsTrue(typeof(Func).IsGenericType); IsTrue(typeof(Func<,>).IsGenericType); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); } private static int _varInt = 42; @@ -326,6 +337,11 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil } } +public class ClassUsingIsGenericTypeOnT +{ + public bool IsGenericType() => typeof(T).IsGenericType; +} + public class GenericSimpleClass { public class Nested From fd9a4504ce9f523735cb2d3913bcf9ef4a428816 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 12 Mar 2024 13:42:23 -0700 Subject: [PATCH 10/21] Add more test cases for shared generics --- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 7f05c07a58eed..0c9f985283d59 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -229,12 +229,15 @@ private static void IsGenericTypeTests() IsFalse(typeof(int*).IsGenericType); IsFalse(typeof(void*).IsGenericType); IsFalse(typeof(delegate*).IsGenericType); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); IsTrue(typeof(GenericSimpleClass).IsGenericType); IsTrue(typeof(GenericSimpleClass<>).IsGenericType); @@ -258,11 +261,19 @@ private static void IsGenericTypeTests() IsTrue(typeof(Action).IsGenericType); IsTrue(typeof(Func).IsGenericType); IsTrue(typeof(Func<,>).IsGenericType); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); } private static int _varInt = 42; @@ -340,6 +351,10 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil public class ClassUsingIsGenericTypeOnT { public bool IsGenericType() => typeof(T).IsGenericType; + + public bool IsGenericTypeFromArray() => typeof(T[]).IsGenericType; + + public bool IsGenericTypeFromOtherGenericType() => typeof(GenericSimpleClass).IsGenericType; } public class GenericSimpleClass From b5cc4eb3c578a977bac4dd05d8a7fbdbd204e44a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 12 Mar 2024 15:11:15 -0700 Subject: [PATCH 11/21] Remove ref struct type from 'IsGenericType' tests --- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 0c9f985283d59..7422d7b50b865 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -233,7 +233,7 @@ private static void IsGenericTypeTests() IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); From 33c2fbf3ddac5c729c1779a996bf2a7e22a5b41d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 13 Mar 2024 09:42:58 -0700 Subject: [PATCH 12/21] Make __Canon type check less conservative Co-authored-by: Jan Kotas --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 5c8f1fc1a2dde..4c70d7b887707 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4562,7 +4562,7 @@ TypeCompareState CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) JIT_TO_EE_TRANSITION(); - if (!typeHandle.IsCanonicalSubtype()) + if (typeHandle != TypeHandle(g_pCanonMethodTableClass)) { result = typeHandle.HasInstantiation() ? TypeCompareState::Must : TypeCompareState::MustNot; } From affbcd15e0326682b089bc87f3f82817a2f4b0c7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 13 Mar 2024 09:43:26 -0700 Subject: [PATCH 13/21] Update __Canon check in managed impl too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michal Strehovský --- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 5d83989e15ecb..a695d07be6fcf 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2942,7 +2942,7 @@ private TypeCompareState isGenericType(CORINFO_CLASS_STRUCT_* cls) { TypeDesc type = HandleToObject(cls); - if (type.IsCanonicalSubtype(CanonicalFormKind.Any)) + if (type.IsCanonicalDefinitionType(CanonicalFormKind.Any)) { return TypeCompareState.May; } From 869233163bfc4612f03f0859aea74cbd695d0a1a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 13 Mar 2024 09:45:42 -0700 Subject: [PATCH 14/21] Update tests, make them no inline --- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 7422d7b50b865..0ac16fd70db5e 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -238,6 +238,10 @@ private static void IsGenericTypeTests() IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); IsTrue(typeof(GenericSimpleClass).IsGenericType); IsTrue(typeof(GenericSimpleClass<>).IsGenericType); @@ -266,10 +270,6 @@ private static void IsGenericTypeTests() IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericType()); IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); - IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); - IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); - IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); - IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); @@ -350,10 +350,13 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil public class ClassUsingIsGenericTypeOnT { + [MethodImpl(MethodImplOptions.NoInlining)] public bool IsGenericType() => typeof(T).IsGenericType; + [MethodImpl(MethodImplOptions.NoInlining)] public bool IsGenericTypeFromArray() => typeof(T[]).IsGenericType; + [MethodImpl(MethodImplOptions.NoInlining)] public bool IsGenericTypeFromOtherGenericType() => typeof(GenericSimpleClass).IsGenericType; } From 42a59db34e65ff11b55f16b03003a366cb85463a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 14 Mar 2024 11:19:59 -0700 Subject: [PATCH 15/21] Update generated code --- src/coreclr/inc/jiteeversionguid.h | 10 +- .../JitInterface/CorInfoImpl_generated.cs | 214 ++++++++++-------- 2 files changed, 120 insertions(+), 104 deletions(-) diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 6bcb13b5a9265..70854c634ccee 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* de0cd36d-3094-4110-af7d-31eb36234e46 */ - 0xde0cd36d, - 0x3094, - 0x4110, - {0xaf, 0x7d, 0x31, 0xeb, 0x36, 0x23, 0x4e, 0x46} +constexpr GUID JITEEVersionIdentifier = { /* f29567ab-8d23-4418-a672-a7495b291d91 */ + 0xf29567ab, + 0x8d23, + 0x4418, + {0xa6, 0x72, 0xa7, 0x49, 0x5b, 0x29, 0x1d, 0x91} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index 0eaaf5a78dc7d..3c51066237fe9 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -1225,6 +1225,21 @@ private static byte _isExactType(IntPtr thisHandle, IntPtr* ppException, CORINFO } } + [UnmanagedCallersOnly] + private static TypeCompareState _isGenericType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) + { + var _this = GetThis(thisHandle); + try + { + return _this.isGenericType(cls); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default; + } + } + [UnmanagedCallersOnly] private static TypeCompareState _isNullableType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { @@ -2642,105 +2657,106 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[43] = (delegate* unmanaged)&_getAssemblyName; callbacks[44] = (delegate* unmanaged)&_LongLifetimeMalloc; callbacks[45] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[46] = (delegate* unmanaged)&_getIsClassInitedFlagAddress; - callbacks[47] = (delegate* unmanaged)&_getClassThreadStaticDynamicInfo; - callbacks[48] = (delegate* unmanaged)&_getClassStaticDynamicInfo; - callbacks[49] = (delegate* unmanaged)&_getStaticBaseAddress; - callbacks[50] = (delegate* unmanaged)&_getClassSize; - callbacks[51] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[52] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[53] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[54] = (delegate* unmanaged)&_getClassGClayout; - callbacks[55] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[56] = (delegate* unmanaged)&_getFieldInClass; - callbacks[57] = (delegate* unmanaged)&_getTypeLayout; - callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[59] = (delegate* unmanaged)&_getNewHelper; - callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[61] = (delegate* unmanaged)&_getCastingHelper; - callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[63] = (delegate* unmanaged)&_getTypeForBox; - callbacks[64] = (delegate* unmanaged)&_getBoxHelper; - callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; - callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[67] = (delegate* unmanaged)&_isObjectImmutable; - callbacks[68] = (delegate* unmanaged)&_getStringChar; - callbacks[69] = (delegate* unmanaged)&_getObjectType; - callbacks[70] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[71] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[72] = (delegate* unmanaged)&_initClass; - callbacks[73] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[74] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[77] = (delegate* unmanaged)&_canCast; - callbacks[78] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[79] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[81] = (delegate* unmanaged)&_isExactType; - callbacks[82] = (delegate* unmanaged)&_isNullableType; - callbacks[83] = (delegate* unmanaged)&_isEnum; - callbacks[84] = (delegate* unmanaged)&_getParentType; - callbacks[85] = (delegate* unmanaged)&_getChildType; - callbacks[86] = (delegate* unmanaged)&_isSDArray; - callbacks[87] = (delegate* unmanaged)&_getArrayRank; - callbacks[88] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[89] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[90] = (delegate* unmanaged)&_canAccessClass; - callbacks[91] = (delegate* unmanaged)&_printFieldName; - callbacks[92] = (delegate* unmanaged)&_getFieldClass; - callbacks[93] = (delegate* unmanaged)&_getFieldType; - callbacks[94] = (delegate* unmanaged)&_getFieldOffset; - callbacks[95] = (delegate* unmanaged)&_getFieldInfo; - callbacks[96] = (delegate* unmanaged)&_getThreadLocalFieldInfo; - callbacks[97] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo; - callbacks[98] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT; - callbacks[99] = (delegate* unmanaged)&_isFieldStatic; - callbacks[100] = (delegate* unmanaged)&_getArrayOrStringLength; - callbacks[101] = (delegate* unmanaged)&_getBoundaries; - callbacks[102] = (delegate* unmanaged)&_setBoundaries; - callbacks[103] = (delegate* unmanaged)&_getVars; - callbacks[104] = (delegate* unmanaged)&_setVars; - callbacks[105] = (delegate* unmanaged)&_reportRichMappings; - callbacks[106] = (delegate* unmanaged)&_reportMetadata; - callbacks[107] = (delegate* unmanaged)&_allocateArray; - callbacks[108] = (delegate* unmanaged)&_freeArray; - callbacks[109] = (delegate* unmanaged)&_getArgNext; - callbacks[110] = (delegate* unmanaged)&_getArgType; - callbacks[111] = (delegate* unmanaged)&_getExactClasses; - callbacks[112] = (delegate* unmanaged)&_getArgClass; - callbacks[113] = (delegate* unmanaged)&_getHFAType; - callbacks[114] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[115] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[116] = (delegate* unmanaged)&_getEEInfo; - callbacks[117] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[118] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[119] = (delegate* unmanaged)&_printMethodName; - callbacks[120] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[121] = (delegate* unmanaged)&_getMethodHash; - callbacks[122] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[123] = (delegate* unmanaged)&_getSwiftLowering; - callbacks[124] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[125] = (delegate* unmanaged)&_getRISCV64PassStructInRegisterFlags; - callbacks[126] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[127] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[128] = (delegate* unmanaged)&_getHelperFtn; - callbacks[129] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[130] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[131] = (delegate* unmanaged)&_getMethodSync; - callbacks[132] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[133] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[134] = (delegate* unmanaged)&_embedClassHandle; - callbacks[135] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[136] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[137] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[138] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[139] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[140] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[141] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[142] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[143] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[144] = (delegate* unmanaged)&_getCallInfo; + callbacks[46] = (delegate* unmanaged)&_getClassModuleIdForStatics; + callbacks[47] = (delegate* unmanaged)&_getIsClassInitedFlagAddress; + callbacks[48] = (delegate* unmanaged)&_getStaticBaseAddress; + callbacks[49] = (delegate* unmanaged)&_getClassSize; + callbacks[50] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[51] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[52] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[53] = (delegate* unmanaged)&_getClassGClayout; + callbacks[54] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[55] = (delegate* unmanaged)&_getFieldInClass; + callbacks[56] = (delegate* unmanaged)&_getTypeLayout; + callbacks[57] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[58] = (delegate* unmanaged)&_getNewHelper; + callbacks[59] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[60] = (delegate* unmanaged)&_getCastingHelper; + callbacks[61] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[62] = (delegate* unmanaged)&_getTypeForBox; + callbacks[63] = (delegate* unmanaged)&_getBoxHelper; + callbacks[64] = (delegate* unmanaged)&_getUnBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[66] = (delegate* unmanaged)&_isObjectImmutable; + callbacks[67] = (delegate* unmanaged)&_getStringChar; + callbacks[68] = (delegate* unmanaged)&_getObjectType; + callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[71] = (delegate* unmanaged)&_initClass; + callbacks[72] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[73] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[76] = (delegate* unmanaged)&_canCast; + callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[79] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[80] = (delegate* unmanaged)&_isExactType; + callbacks[81] = (delegate* unmanaged)&_isGenericType; + callbacks[81] = (delegate* unmanaged)&_isNullableType; + callbacks[82] = (delegate* unmanaged)&_isEnum; + callbacks[83] = (delegate* unmanaged)&_getParentType; + callbacks[84] = (delegate* unmanaged)&_getChildType; + callbacks[85] = (delegate* unmanaged)&_isSDArray; + callbacks[86] = (delegate* unmanaged)&_getArrayRank; + callbacks[87] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[88] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[89] = (delegate* unmanaged)&_canAccessClass; + callbacks[90] = (delegate* unmanaged)&_printFieldName; + callbacks[91] = (delegate* unmanaged)&_getFieldClass; + callbacks[92] = (delegate* unmanaged)&_getFieldType; + callbacks[93] = (delegate* unmanaged)&_getFieldOffset; + callbacks[94] = (delegate* unmanaged)&_getFieldInfo; + callbacks[95] = (delegate* unmanaged)&_getThreadLocalFieldInfo; + callbacks[96] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo; + callbacks[97] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT; + callbacks[98] = (delegate* unmanaged)&_isFieldStatic; + callbacks[99] = (delegate* unmanaged)&_getArrayOrStringLength; + callbacks[100] = (delegate* unmanaged)&_getBoundaries; + callbacks[101] = (delegate* unmanaged)&_setBoundaries; + callbacks[102] = (delegate* unmanaged)&_getVars; + callbacks[103] = (delegate* unmanaged)&_setVars; + callbacks[104] = (delegate* unmanaged)&_reportRichMappings; + callbacks[105] = (delegate* unmanaged)&_reportMetadata; + callbacks[106] = (delegate* unmanaged)&_allocateArray; + callbacks[107] = (delegate* unmanaged)&_freeArray; + callbacks[108] = (delegate* unmanaged)&_getArgNext; + callbacks[109] = (delegate* unmanaged)&_getArgType; + callbacks[110] = (delegate* unmanaged)&_getExactClasses; + callbacks[111] = (delegate* unmanaged)&_getArgClass; + callbacks[112] = (delegate* unmanaged)&_getHFAType; + callbacks[113] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[114] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[115] = (delegate* unmanaged)&_getEEInfo; + callbacks[116] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[117] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[118] = (delegate* unmanaged)&_printMethodName; + callbacks[119] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[120] = (delegate* unmanaged)&_getMethodHash; + callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[122] = (delegate* unmanaged)&_getSwiftLowering; + callbacks[123] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[124] = (delegate* unmanaged)&_getRISCV64PassStructInRegisterFlags; + callbacks[125] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[126] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[127] = (delegate* unmanaged)&_getHelperFtn; + callbacks[128] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[129] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[130] = (delegate* unmanaged)&_getMethodSync; + callbacks[131] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[132] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[133] = (delegate* unmanaged)&_embedClassHandle; + callbacks[134] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[135] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[136] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[137] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[138] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[139] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[140] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[141] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[142] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[143] = (delegate* unmanaged)&_getCallInfo; + callbacks[144] = (delegate* unmanaged)&_getClassDomainID; callbacks[145] = (delegate* unmanaged)&_getStaticFieldContent; callbacks[146] = (delegate* unmanaged)&_getObjectContent; callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; From 140e261a8cc001697731caf64fc69d81d292d0c0 Mon Sep 17 00:00:00 2001 From: Miha Zupan Date: Tue, 16 Apr 2024 00:05:47 +0200 Subject: [PATCH 16/21] Fix rebase errors --- .../jit/ICorJitInfo_wrapper_generated.hpp | 2 +- .../JitInterface/CorInfoImpl_generated.cs | 190 +++++++++--------- .../ThunkGenerator/ThunkInput.txt | 2 +- .../superpmi-shim-collector/icorjitinfo.cpp | 1 + src/coreclr/vm/jitinterface.cpp | 2 +- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 6 +- 6 files changed, 102 insertions(+), 101 deletions(-) diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index df19cc5ac986e..ff54b778f2a2c 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -826,7 +826,7 @@ TypeCompareState WrapICorJitInfo::isNullableType( API_ENTER(isNullableType); TypeCompareState temp = wrapHnd->isNullableType(cls); API_LEAVE(isNullableType); - return temp + return temp; } TypeCompareState WrapICorJitInfo::isEnum( diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index 3c51066237fe9..a551e9c05aa5d 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -2609,7 +2609,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 175); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 176); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_notifyMethodInfoUsage; @@ -2693,100 +2693,100 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[79] = (delegate* unmanaged)&_isMoreSpecificType; callbacks[80] = (delegate* unmanaged)&_isExactType; callbacks[81] = (delegate* unmanaged)&_isGenericType; - callbacks[81] = (delegate* unmanaged)&_isNullableType; - callbacks[82] = (delegate* unmanaged)&_isEnum; - callbacks[83] = (delegate* unmanaged)&_getParentType; - callbacks[84] = (delegate* unmanaged)&_getChildType; - callbacks[85] = (delegate* unmanaged)&_isSDArray; - callbacks[86] = (delegate* unmanaged)&_getArrayRank; - callbacks[87] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[88] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[89] = (delegate* unmanaged)&_canAccessClass; - callbacks[90] = (delegate* unmanaged)&_printFieldName; - callbacks[91] = (delegate* unmanaged)&_getFieldClass; - callbacks[92] = (delegate* unmanaged)&_getFieldType; - callbacks[93] = (delegate* unmanaged)&_getFieldOffset; - callbacks[94] = (delegate* unmanaged)&_getFieldInfo; - callbacks[95] = (delegate* unmanaged)&_getThreadLocalFieldInfo; - callbacks[96] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo; - callbacks[97] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT; - callbacks[98] = (delegate* unmanaged)&_isFieldStatic; - callbacks[99] = (delegate* unmanaged)&_getArrayOrStringLength; - callbacks[100] = (delegate* unmanaged)&_getBoundaries; - callbacks[101] = (delegate* unmanaged)&_setBoundaries; - callbacks[102] = (delegate* unmanaged)&_getVars; - callbacks[103] = (delegate* unmanaged)&_setVars; - callbacks[104] = (delegate* unmanaged)&_reportRichMappings; - callbacks[105] = (delegate* unmanaged)&_reportMetadata; - callbacks[106] = (delegate* unmanaged)&_allocateArray; - callbacks[107] = (delegate* unmanaged)&_freeArray; - callbacks[108] = (delegate* unmanaged)&_getArgNext; - callbacks[109] = (delegate* unmanaged)&_getArgType; - callbacks[110] = (delegate* unmanaged)&_getExactClasses; - callbacks[111] = (delegate* unmanaged)&_getArgClass; - callbacks[112] = (delegate* unmanaged)&_getHFAType; - callbacks[113] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[114] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[115] = (delegate* unmanaged)&_getEEInfo; - callbacks[116] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[117] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[118] = (delegate* unmanaged)&_printMethodName; - callbacks[119] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[120] = (delegate* unmanaged)&_getMethodHash; - callbacks[121] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[122] = (delegate* unmanaged)&_getSwiftLowering; - callbacks[123] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[124] = (delegate* unmanaged)&_getRISCV64PassStructInRegisterFlags; - callbacks[125] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[126] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[127] = (delegate* unmanaged)&_getHelperFtn; - callbacks[128] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[129] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[130] = (delegate* unmanaged)&_getMethodSync; - callbacks[131] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[132] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[133] = (delegate* unmanaged)&_embedClassHandle; - callbacks[134] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[135] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[136] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[137] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[138] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[139] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[140] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[141] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[142] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[143] = (delegate* unmanaged)&_getCallInfo; - callbacks[144] = (delegate* unmanaged)&_getClassDomainID; - callbacks[145] = (delegate* unmanaged)&_getStaticFieldContent; - callbacks[146] = (delegate* unmanaged)&_getObjectContent; - callbacks[147] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[148] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[149] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[150] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[151] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[152] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[153] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[154] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[155] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[156] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[157] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[158] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[159] = (delegate* unmanaged)&_allocMem; - callbacks[160] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[161] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[162] = (delegate* unmanaged)&_allocGCInfo; - callbacks[163] = (delegate* unmanaged)&_setEHcount; - callbacks[164] = (delegate* unmanaged)&_setEHinfo; - callbacks[165] = (delegate* unmanaged)&_logMsg; - callbacks[166] = (delegate* unmanaged)&_doAssert; - callbacks[167] = (delegate* unmanaged)&_reportFatalError; - callbacks[168] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[169] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[170] = (delegate* unmanaged)&_recordCallSite; - callbacks[171] = (delegate* unmanaged)&_recordRelocation; - callbacks[172] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[173] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[174] = (delegate* unmanaged)&_getJitFlags; + callbacks[82] = (delegate* unmanaged)&_isNullableType; + callbacks[83] = (delegate* unmanaged)&_isEnum; + callbacks[84] = (delegate* unmanaged)&_getParentType; + callbacks[85] = (delegate* unmanaged)&_getChildType; + callbacks[86] = (delegate* unmanaged)&_isSDArray; + callbacks[87] = (delegate* unmanaged)&_getArrayRank; + callbacks[88] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[89] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[90] = (delegate* unmanaged)&_canAccessClass; + callbacks[91] = (delegate* unmanaged)&_printFieldName; + callbacks[92] = (delegate* unmanaged)&_getFieldClass; + callbacks[93] = (delegate* unmanaged)&_getFieldType; + callbacks[94] = (delegate* unmanaged)&_getFieldOffset; + callbacks[95] = (delegate* unmanaged)&_getFieldInfo; + callbacks[96] = (delegate* unmanaged)&_getThreadLocalFieldInfo; + callbacks[97] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo; + callbacks[98] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT; + callbacks[99] = (delegate* unmanaged)&_isFieldStatic; + callbacks[100] = (delegate* unmanaged)&_getArrayOrStringLength; + callbacks[101] = (delegate* unmanaged)&_getBoundaries; + callbacks[102] = (delegate* unmanaged)&_setBoundaries; + callbacks[103] = (delegate* unmanaged)&_getVars; + callbacks[104] = (delegate* unmanaged)&_setVars; + callbacks[105] = (delegate* unmanaged)&_reportRichMappings; + callbacks[106] = (delegate* unmanaged)&_reportMetadata; + callbacks[107] = (delegate* unmanaged)&_allocateArray; + callbacks[108] = (delegate* unmanaged)&_freeArray; + callbacks[109] = (delegate* unmanaged)&_getArgNext; + callbacks[110] = (delegate* unmanaged)&_getArgType; + callbacks[111] = (delegate* unmanaged)&_getExactClasses; + callbacks[112] = (delegate* unmanaged)&_getArgClass; + callbacks[113] = (delegate* unmanaged)&_getHFAType; + callbacks[114] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[115] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[116] = (delegate* unmanaged)&_getEEInfo; + callbacks[117] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[118] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[119] = (delegate* unmanaged)&_printMethodName; + callbacks[120] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[121] = (delegate* unmanaged)&_getMethodHash; + callbacks[122] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[123] = (delegate* unmanaged)&_getSwiftLowering; + callbacks[124] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[125] = (delegate* unmanaged)&_getRISCV64PassStructInRegisterFlags; + callbacks[126] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[127] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[128] = (delegate* unmanaged)&_getHelperFtn; + callbacks[129] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[130] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[131] = (delegate* unmanaged)&_getMethodSync; + callbacks[132] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[133] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[134] = (delegate* unmanaged)&_embedClassHandle; + callbacks[135] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[136] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[137] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[138] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[139] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[140] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[141] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[142] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[143] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[144] = (delegate* unmanaged)&_getCallInfo; + callbacks[145] = (delegate* unmanaged)&_getClassDomainID; + callbacks[146] = (delegate* unmanaged)&_getStaticFieldContent; + callbacks[147] = (delegate* unmanaged)&_getObjectContent; + callbacks[148] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[149] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[150] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[151] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[152] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[153] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[160] = (delegate* unmanaged)&_allocMem; + callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[163] = (delegate* unmanaged)&_allocGCInfo; + callbacks[164] = (delegate* unmanaged)&_setEHcount; + callbacks[165] = (delegate* unmanaged)&_setEHinfo; + callbacks[166] = (delegate* unmanaged)&_logMsg; + callbacks[167] = (delegate* unmanaged)&_doAssert; + callbacks[168] = (delegate* unmanaged)&_reportFatalError; + callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[171] = (delegate* unmanaged)&_recordCallSite; + callbacks[172] = (delegate* unmanaged)&_recordRelocation; + callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[175] = (delegate* unmanaged)&_getJitFlags; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index ff00c41ce2653..9fc314fe56a37 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -245,8 +245,8 @@ FUNCTIONS TypeCompareState compareTypesForEquality(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) bool isMoreSpecificType(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) bool isExactType(CORINFO_CLASS_HANDLE cls) - TypeCompareState isNullableType(CORINFO_CLASS_HANDLE cls) TypeCompareState isGenericType(CORINFO_CLASS_HANDLE cls) + TypeCompareState isNullableType(CORINFO_CLASS_HANDLE cls) TypeCompareState isEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType) CORINFO_CLASS_HANDLE getParentType(CORINFO_CLASS_HANDLE cls) CorInfoType getChildType(CORINFO_CLASS_HANDLE clsHnd, CORINFO_CLASS_HANDLE* clsRet) diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 304ea616b55dd..84ad616c28eb9 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -920,6 +920,7 @@ TypeCompareState interceptor_ICJI::isNullableType(CORINFO_CLASS_HANDLE cls) mc->cr->AddCall("isNullableType"); TypeCompareState temp = original_ICorJitInfo->isNullableType(cls); mc->recIsNullableType(cls, temp); + return temp; } // Returns TypeCompareState::Must if cls is known to be an enum. diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 4c70d7b887707..9457680e096b4 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4560,7 +4560,7 @@ TypeCompareState CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) TypeCompareState result = TypeCompareState::May; - JIT_TO_EE_TRANSITION(); + JIT_TO_EE_TRANSITION(); if (typeHandle != TypeHandle(g_pCanonMethodTableClass)) { diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 0ac16fd70db5e..3821f74bf1876 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -363,12 +363,12 @@ public class ClassUsingIsGenericTypeOnT public class GenericSimpleClass { public class Nested - { - } + { + } } public class DerivedGenericSimpleClass : GenericSimpleClass -{ +{ } public class GenericEnumClass where T : Enum From b0c8c756d95b3b90be8b17c952dbefe443cd15f7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 15 Jun 2024 11:21:53 -0700 Subject: [PATCH 17/21] Fix more rebase errors --- src/coreclr/inc/jiteeversionguid.h | 10 +- .../JitInterface/CorInfoImpl_generated.cs | 202 +++++++++--------- 2 files changed, 106 insertions(+), 106 deletions(-) diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 70854c634ccee..76a1bbc466d79 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* f29567ab-8d23-4418-a672-a7495b291d91 */ - 0xf29567ab, - 0x8d23, - 0x4418, - {0xa6, 0x72, 0xa7, 0x49, 0x5b, 0x29, 0x1d, 0x91} +constexpr GUID JITEEVersionIdentifier = { /* e428e66d-5e0e-4320-ad8a-fa5a50f6da07 */ + 0xe428e66d, + 0x5e0e, + 0x4320, + {0xad, 0x8a, 0xfa, 0x5a, 0x50, 0xf6, 0xda, 0x07} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index a551e9c05aa5d..950ce7f4a1223 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -2657,106 +2657,106 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[43] = (delegate* unmanaged)&_getAssemblyName; callbacks[44] = (delegate* unmanaged)&_LongLifetimeMalloc; callbacks[45] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[46] = (delegate* unmanaged)&_getClassModuleIdForStatics; - callbacks[47] = (delegate* unmanaged)&_getIsClassInitedFlagAddress; - callbacks[48] = (delegate* unmanaged)&_getStaticBaseAddress; - callbacks[49] = (delegate* unmanaged)&_getClassSize; - callbacks[50] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[51] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[52] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[53] = (delegate* unmanaged)&_getClassGClayout; - callbacks[54] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[55] = (delegate* unmanaged)&_getFieldInClass; - callbacks[56] = (delegate* unmanaged)&_getTypeLayout; - callbacks[57] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[58] = (delegate* unmanaged)&_getNewHelper; - callbacks[59] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[60] = (delegate* unmanaged)&_getCastingHelper; - callbacks[61] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[62] = (delegate* unmanaged)&_getTypeForBox; - callbacks[63] = (delegate* unmanaged)&_getBoxHelper; - callbacks[64] = (delegate* unmanaged)&_getUnBoxHelper; - callbacks[65] = (delegate* unmanaged)&_getRuntimeTypePointer; - callbacks[66] = (delegate* unmanaged)&_isObjectImmutable; - callbacks[67] = (delegate* unmanaged)&_getStringChar; - callbacks[68] = (delegate* unmanaged)&_getObjectType; - callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[71] = (delegate* unmanaged)&_initClass; - callbacks[72] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[73] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[76] = (delegate* unmanaged)&_canCast; - callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[79] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[80] = (delegate* unmanaged)&_isExactType; - callbacks[81] = (delegate* unmanaged)&_isGenericType; - callbacks[82] = (delegate* unmanaged)&_isNullableType; - callbacks[83] = (delegate* unmanaged)&_isEnum; - callbacks[84] = (delegate* unmanaged)&_getParentType; - callbacks[85] = (delegate* unmanaged)&_getChildType; - callbacks[86] = (delegate* unmanaged)&_isSDArray; - callbacks[87] = (delegate* unmanaged)&_getArrayRank; - callbacks[88] = (delegate* unmanaged)&_getArrayIntrinsicID; - callbacks[89] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[90] = (delegate* unmanaged)&_canAccessClass; - callbacks[91] = (delegate* unmanaged)&_printFieldName; - callbacks[92] = (delegate* unmanaged)&_getFieldClass; - callbacks[93] = (delegate* unmanaged)&_getFieldType; - callbacks[94] = (delegate* unmanaged)&_getFieldOffset; - callbacks[95] = (delegate* unmanaged)&_getFieldInfo; - callbacks[96] = (delegate* unmanaged)&_getThreadLocalFieldInfo; - callbacks[97] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo; - callbacks[98] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT; - callbacks[99] = (delegate* unmanaged)&_isFieldStatic; - callbacks[100] = (delegate* unmanaged)&_getArrayOrStringLength; - callbacks[101] = (delegate* unmanaged)&_getBoundaries; - callbacks[102] = (delegate* unmanaged)&_setBoundaries; - callbacks[103] = (delegate* unmanaged)&_getVars; - callbacks[104] = (delegate* unmanaged)&_setVars; - callbacks[105] = (delegate* unmanaged)&_reportRichMappings; - callbacks[106] = (delegate* unmanaged)&_reportMetadata; - callbacks[107] = (delegate* unmanaged)&_allocateArray; - callbacks[108] = (delegate* unmanaged)&_freeArray; - callbacks[109] = (delegate* unmanaged)&_getArgNext; - callbacks[110] = (delegate* unmanaged)&_getArgType; - callbacks[111] = (delegate* unmanaged)&_getExactClasses; - callbacks[112] = (delegate* unmanaged)&_getArgClass; - callbacks[113] = (delegate* unmanaged)&_getHFAType; - callbacks[114] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[115] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[116] = (delegate* unmanaged)&_getEEInfo; - callbacks[117] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[118] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[119] = (delegate* unmanaged)&_printMethodName; - callbacks[120] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[121] = (delegate* unmanaged)&_getMethodHash; - callbacks[122] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[123] = (delegate* unmanaged)&_getSwiftLowering; - callbacks[124] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; - callbacks[125] = (delegate* unmanaged)&_getRISCV64PassStructInRegisterFlags; - callbacks[126] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[127] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[128] = (delegate* unmanaged)&_getHelperFtn; - callbacks[129] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[130] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[131] = (delegate* unmanaged)&_getMethodSync; - callbacks[132] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[133] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[134] = (delegate* unmanaged)&_embedClassHandle; - callbacks[135] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[136] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[137] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[138] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[139] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[140] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[141] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[142] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[143] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[144] = (delegate* unmanaged)&_getCallInfo; - callbacks[145] = (delegate* unmanaged)&_getClassDomainID; + callbacks[46] = (delegate* unmanaged)&_getIsClassInitedFlagAddress; + callbacks[47] = (delegate* unmanaged)&_getClassThreadStaticDynamicInfo; + callbacks[48] = (delegate* unmanaged)&_getClassStaticDynamicInfo; + callbacks[49] = (delegate* unmanaged)&_getStaticBaseAddress; + callbacks[50] = (delegate* unmanaged)&_getClassSize; + callbacks[51] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[52] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[53] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[54] = (delegate* unmanaged)&_getClassGClayout; + callbacks[55] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[56] = (delegate* unmanaged)&_getFieldInClass; + callbacks[57] = (delegate* unmanaged)&_getTypeLayout; + callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[59] = (delegate* unmanaged)&_getNewHelper; + callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[61] = (delegate* unmanaged)&_getCastingHelper; + callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[63] = (delegate* unmanaged)&_getTypeForBox; + callbacks[64] = (delegate* unmanaged)&_getBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; + callbacks[66] = (delegate* unmanaged)&_getRuntimeTypePointer; + callbacks[67] = (delegate* unmanaged)&_isObjectImmutable; + callbacks[68] = (delegate* unmanaged)&_getStringChar; + callbacks[69] = (delegate* unmanaged)&_getObjectType; + callbacks[70] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[71] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[72] = (delegate* unmanaged)&_initClass; + callbacks[73] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[74] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[77] = (delegate* unmanaged)&_canCast; + callbacks[78] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[79] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[81] = (delegate* unmanaged)&_isExactType; + callbacks[82] = (delegate* unmanaged)&_isGenericType; + callbacks[83] = (delegate* unmanaged)&_isNullableType; + callbacks[84] = (delegate* unmanaged)&_isEnum; + callbacks[85] = (delegate* unmanaged)&_getParentType; + callbacks[86] = (delegate* unmanaged)&_getChildType; + callbacks[87] = (delegate* unmanaged)&_isSDArray; + callbacks[88] = (delegate* unmanaged)&_getArrayRank; + callbacks[89] = (delegate* unmanaged)&_getArrayIntrinsicID; + callbacks[90] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[91] = (delegate* unmanaged)&_canAccessClass; + callbacks[92] = (delegate* unmanaged)&_printFieldName; + callbacks[93] = (delegate* unmanaged)&_getFieldClass; + callbacks[94] = (delegate* unmanaged)&_getFieldType; + callbacks[95] = (delegate* unmanaged)&_getFieldOffset; + callbacks[96] = (delegate* unmanaged)&_getFieldInfo; + callbacks[97] = (delegate* unmanaged)&_getThreadLocalFieldInfo; + callbacks[98] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo; + callbacks[99] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT; + callbacks[100] = (delegate* unmanaged)&_isFieldStatic; + callbacks[101] = (delegate* unmanaged)&_getArrayOrStringLength; + callbacks[102] = (delegate* unmanaged)&_getBoundaries; + callbacks[103] = (delegate* unmanaged)&_setBoundaries; + callbacks[104] = (delegate* unmanaged)&_getVars; + callbacks[105] = (delegate* unmanaged)&_setVars; + callbacks[106] = (delegate* unmanaged)&_reportRichMappings; + callbacks[107] = (delegate* unmanaged)&_reportMetadata; + callbacks[108] = (delegate* unmanaged)&_allocateArray; + callbacks[109] = (delegate* unmanaged)&_freeArray; + callbacks[110] = (delegate* unmanaged)&_getArgNext; + callbacks[111] = (delegate* unmanaged)&_getArgType; + callbacks[112] = (delegate* unmanaged)&_getExactClasses; + callbacks[113] = (delegate* unmanaged)&_getArgClass; + callbacks[114] = (delegate* unmanaged)&_getHFAType; + callbacks[115] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[116] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[117] = (delegate* unmanaged)&_getEEInfo; + callbacks[118] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[119] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[120] = (delegate* unmanaged)&_printMethodName; + callbacks[121] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[122] = (delegate* unmanaged)&_getMethodHash; + callbacks[123] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[124] = (delegate* unmanaged)&_getSwiftLowering; + callbacks[125] = (delegate* unmanaged)&_getLoongArch64PassStructInRegisterFlags; + callbacks[126] = (delegate* unmanaged)&_getRISCV64PassStructInRegisterFlags; + callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[128] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[129] = (delegate* unmanaged)&_getHelperFtn; + callbacks[130] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[131] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[132] = (delegate* unmanaged)&_getMethodSync; + callbacks[133] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[134] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[135] = (delegate* unmanaged)&_embedClassHandle; + callbacks[136] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[137] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[138] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[139] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[140] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[141] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[142] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[143] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[144] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[145] = (delegate* unmanaged)&_getCallInfo; callbacks[146] = (delegate* unmanaged)&_getStaticFieldContent; callbacks[147] = (delegate* unmanaged)&_getObjectContent; callbacks[148] = (delegate* unmanaged)&_getStaticFieldCurrentClass; @@ -2780,7 +2780,7 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[166] = (delegate* unmanaged)&_logMsg; callbacks[167] = (delegate* unmanaged)&_doAssert; callbacks[168] = (delegate* unmanaged)&_reportFatalError; - callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults; callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; callbacks[171] = (delegate* unmanaged)&_recordCallSite; callbacks[172] = (delegate* unmanaged)&_recordRelocation; From 791e29e41fe15744bd6cf3ec1cf231a2709a54cc Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sun, 16 Jun 2024 14:54:30 +0200 Subject: [PATCH 18/21] Update jitinterface.cpp --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 9457680e096b4..c39fc2d0d2251 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4556,7 +4556,7 @@ TypeCompareState CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) MODE_PREEMPTIVE; } CONTRACTL_END; - TypeHandle typeHandle = TypeHandle(); + TypeHandle typeHandle(cls); TypeCompareState result = TypeCompareState::May; From 09e55a22f14053e8cd24fb141cd1030dd6c3d748 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 16 Jun 2024 09:10:03 -0700 Subject: [PATCH 19/21] Make `isGenericType` use _LEAF transition Co-authored-by: Jan Kotas --- src/coreclr/vm/jitinterface.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index c39fc2d0d2251..4752520f5bc1d 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4551,23 +4551,23 @@ bool CEEInfo::isExactType(CORINFO_CLASS_HANDLE cls) TypeCompareState CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) { CONTRACTL { - THROWS; - GC_TRIGGERS; + NOTHROW; + GC_NOTRIGGER; MODE_PREEMPTIVE; } CONTRACTL_END; - TypeHandle typeHandle(cls); - TypeCompareState result = TypeCompareState::May; - JIT_TO_EE_TRANSITION(); + JIT_TO_EE_TRANSITION_LEAF(); + + TypeHandle typeHandle(cls); if (typeHandle != TypeHandle(g_pCanonMethodTableClass)) { result = typeHandle.HasInstantiation() ? TypeCompareState::Must : TypeCompareState::MustNot; } - EE_TO_JIT_TRANSITION(); + EE_TO_JIT_TRANSITION_LEAF(); return result; } From 1a7b1c1c8a365f25900f62fb4e591605d3267b73 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 16 Jun 2024 09:12:46 -0700 Subject: [PATCH 20/21] Make `isNullableType` use _LEAF transition --- src/coreclr/vm/jitinterface.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 4752520f5bc1d..6e3df639aae43 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4575,16 +4575,16 @@ TypeCompareState CEEInfo::isGenericType(CORINFO_CLASS_HANDLE cls) TypeCompareState CEEInfo::isNullableType(CORINFO_CLASS_HANDLE cls) { CONTRACTL { - THROWS; - GC_TRIGGERS; + NOTHROW; + GC_NOTRIGGER; MODE_PREEMPTIVE; } CONTRACTL_END; - TypeHandle typeHandle = TypeHandle(); - TypeCompareState result = TypeCompareState::May; - JIT_TO_EE_TRANSITION(); + JIT_TO_EE_TRANSITION_LEAF(); + + TypeHandle typeHandle = TypeHandle(); if (typeHandle != TypeHandle(g_pCanonMethodTableClass)) { @@ -4592,7 +4592,7 @@ TypeCompareState CEEInfo::isNullableType(CORINFO_CLASS_HANDLE cls) result = Nullable::IsNullableType(VMClsHnd) ? TypeCompareState::Must : TypeCompareState::MustNot; } - EE_TO_JIT_TRANSITION(); + EE_TO_JIT_TRANSITION_LEAF(); return result; } From 75967c25fb87c871bb42ca22c94bb0cd9c9bfef8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 16 Jun 2024 09:16:21 -0700 Subject: [PATCH 21/21] Remove unnecessary shared generic check --- src/coreclr/vm/jitinterface.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 6e3df639aae43..54ce75255eeaf 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -4580,17 +4580,13 @@ TypeCompareState CEEInfo::isNullableType(CORINFO_CLASS_HANDLE cls) MODE_PREEMPTIVE; } CONTRACTL_END; - TypeCompareState result = TypeCompareState::May; + TypeCompareState result; JIT_TO_EE_TRANSITION_LEAF(); - TypeHandle typeHandle = TypeHandle(); + TypeHandle typeHandle(cls); - if (typeHandle != TypeHandle(g_pCanonMethodTableClass)) - { - TypeHandle VMClsHnd(cls); - result = Nullable::IsNullableType(VMClsHnd) ? TypeCompareState::Must : TypeCompareState::MustNot; - } + result = Nullable::IsNullableType(typeHandle) ? TypeCompareState::Must : TypeCompareState::MustNot; EE_TO_JIT_TRANSITION_LEAF(); return result;