From eb17cdc82f9ace479bf8713976125c9e70866d77 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 26 Oct 2019 23:48:05 -0700 Subject: [PATCH] Removing IsSIMDVectorAssembly and obsoleting isInSIMDModule (dotnet/coreclr#27467) * Removing IsSIMDVectorAssembly from the VM layer * Removing SimdHelper from crossgen2 * Obsoleting isInSIMDModule in the VM layer * Renaming isInSIMDModule to isIntrinsicType * Implementing isIntrinsicType for the JIT/EE interface * Update JITEEVersionIdentifier * Update crossgen2 JITEEVersionIdentifier Commit migrated from https://github.com/dotnet/coreclr/commit/ca6c03eed7d38819b8b093b7ee6098a4c69cd6c8 --- .../superpmi/superpmi-shared/icorjitinfoimpl.h | 5 +- .../src/ToolBox/superpmi/superpmi-shared/lwmlist.h | 2 +- .../superpmi/superpmi-shared/methodcontext.cpp | 24 ++++---- .../superpmi/superpmi-shared/methodcontext.h | 8 +-- .../superpmi-shim-collector/icorjitinfo.cpp | 10 ++-- .../superpmi/superpmi-shim-counter/icorjitinfo.cpp | 8 +-- .../superpmi/superpmi-shim-simple/icorjitinfo.cpp | 6 +- .../src/ToolBox/superpmi/superpmi/icorjitinfo.cpp | 8 +-- src/coreclr/src/inc/corinfo.h | 14 ++--- src/coreclr/src/jit/ICorJitInfo_API_names.h | 2 +- src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp | 8 +-- src/coreclr/src/jit/compiler.h | 10 +++- .../Common/Compiler/CompilerTypeSystemContext.cs | 2 - .../tools/crossgen2/Common/Compiler/SimdHelper.cs | 70 ---------------------- .../crossgen2/Common/JitInterface/CorInfoBase.cs | 8 +-- .../crossgen2/Common/JitInterface/CorInfoImpl.cs | 23 +------ .../JitInterface/ThunkGenerator/ThunkInput.txt | 2 +- .../Compiler/ReadyToRunCompilerContext.cs | 2 +- .../ILCompiler.ReadyToRun.csproj | 1 - .../tools/crossgen2/jitinterface/jitinterface.h | 6 +- .../tools/crossgen2/jitinterface/jitwrapper.cpp | 10 ++-- src/coreclr/src/vm/assembly.cpp | 16 ----- src/coreclr/src/vm/assembly.hpp | 4 -- src/coreclr/src/vm/interpreter.cpp | 6 +- src/coreclr/src/vm/jitinterface.cpp | 26 +------- src/coreclr/src/vm/jitinterface.h | 2 +- src/coreclr/src/vm/methodtablebuilder.cpp | 6 +- src/coreclr/src/zap/zapinfo.cpp | 4 +- src/coreclr/src/zap/zapinfo.h | 2 +- 29 files changed, 84 insertions(+), 211 deletions(-) delete mode 100644 src/coreclr/src/tools/crossgen2/Common/Compiler/SimdHelper.cs diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h index 61d70a2..6d5602f 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h @@ -144,9 +144,8 @@ void expandRawHandleIntrinsic( // *pMustExpand tells whether or not JIT must expand the intrinsic. CorInfoIntrinsics getIntrinsicID(CORINFO_METHOD_HANDLE method, bool* pMustExpand = NULL /* OUT */); -// Is the given module the System.Numerics.Vectors module? -// This defaults to false. -bool isInSIMDModule(CORINFO_CLASS_HANDLE classHnd); /* { return false; } */ +// Is the given type in System.Private.Corelib and marked with IntrinsicAttribute? +bool isIntrinsicType(CORINFO_CLASS_HANDLE classHnd); // return the unmanaged calling convention for a PInvoke CorInfoUnmanagedCallConv getUnmanagedCallConv(CORINFO_METHOD_HANDLE method); diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h index 36b8469..45449d1 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h @@ -142,7 +142,7 @@ LWM(InitConstraintsForVerification, DWORDLONG, DD) LWM(IsCompatibleDelegate, Agnostic_IsCompatibleDelegate, DD) LWM(IsDelegateCreationAllowed, DLDL, DWORD) LWM(IsFieldStatic, DWORDLONG, DWORD) -LWM(IsInSIMDModule, DWORDLONG, DWORD) +LWM(IsIntrinsicType, DWORDLONG, DWORD) LWM(IsInstantiationOfVerifiedGeneric, DWORDLONG, DWORD) LWM(IsSDArray, DWORDLONG, DWORD) LWM(IsStructRequiringStackAllocRetBuf, DWORDLONG, DWORD) diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index 53c882e..12041dd 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -1577,25 +1577,25 @@ CorInfoIntrinsics MethodContext::repGetIntrinsicID(CORINFO_METHOD_HANDLE method, return result; } -void MethodContext::recIsInSIMDModule(CORINFO_CLASS_HANDLE cls, BOOL result) +void MethodContext::recIsIntrinsicType(CORINFO_CLASS_HANDLE cls, BOOL result) { - if (IsInSIMDModule == nullptr) - IsInSIMDModule = new LightWeightMap(); + if (IsIntrinsicType == nullptr) + IsIntrinsicType = new LightWeightMap(); - IsInSIMDModule->Add((DWORDLONG)cls, (DWORD)result); - DEBUG_REC(dmpIsInSIMDModule((DWORDLONG)cls, (DWORD)result)); + IsIntrinsicType->Add((DWORDLONG)cls, (DWORD)result); + DEBUG_REC(dmpIsIntrinsicType((DWORDLONG)cls, (DWORD)result)); } -void MethodContext::dmpIsInSIMDModule(DWORDLONG key, DWORD value) +void MethodContext::dmpIsIntrinsicType(DWORDLONG key, DWORD value) { - printf("IsInSIMDModule key mth-%016llX, value intr-%u", key, value); + printf("IsIntrinsicType key mth-%016llX, value intr-%u", key, value); } -BOOL MethodContext::repIsInSIMDModule(CORINFO_CLASS_HANDLE cls) +BOOL MethodContext::repIsIntrinsicType(CORINFO_CLASS_HANDLE cls) { - AssertCodeMsg(IsInSIMDModule != nullptr, EXCEPTIONCODE_MC, "Didn't find anything for %016llX", (DWORDLONG)cls); - AssertCodeMsg(IsInSIMDModule->GetIndex((DWORDLONG)cls) != -1, EXCEPTIONCODE_MC, "Didn't find %016llX", + AssertCodeMsg(IsIntrinsicType != nullptr, EXCEPTIONCODE_MC, "Didn't find anything for %016llX", (DWORDLONG)cls); + AssertCodeMsg(IsIntrinsicType->GetIndex((DWORDLONG)cls) != -1, EXCEPTIONCODE_MC, "Didn't find %016llX", (DWORDLONG)cls); - BOOL result = (BOOL)IsInSIMDModule->Get((DWORDLONG)cls); - DEBUG_REP(dmpIsInSIMDModule((DWORDLONG)cls, (DWORD)result)); + BOOL result = (BOOL)IsIntrinsicType->Get((DWORDLONG)cls); + DEBUG_REP(dmpIsIntrinsicType((DWORDLONG)cls, (DWORD)result)); return result; } diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index a312fdd..1b63611 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -769,9 +769,9 @@ public: void dmpIsSDArray(DWORDLONG key, DWORD value); BOOL repIsSDArray(CORINFO_CLASS_HANDLE cls); - void recIsInSIMDModule(CORINFO_CLASS_HANDLE cls, BOOL result); - void dmpIsInSIMDModule(DWORDLONG key, DWORD value); - BOOL repIsInSIMDModule(CORINFO_CLASS_HANDLE cls); + void recIsIntrinsicType(CORINFO_CLASS_HANDLE cls, BOOL result); + void dmpIsIntrinsicType(DWORDLONG key, DWORD value); + BOOL repIsIntrinsicType(CORINFO_CLASS_HANDLE cls); void recGetFieldClass(CORINFO_FIELD_HANDLE field, CORINFO_CLASS_HANDLE result); void dmpGetFieldClass(DWORDLONG key, DWORDLONG value); @@ -1488,7 +1488,7 @@ enum mcPackets Packet_IsCompatibleDelegate = 99, Packet_IsDelegateCreationAllowed = 155, Packet_IsFieldStatic = 137, // Added 4/9/2013 - needed for 4.5.1 - Packet_IsInSIMDModule = 148, // Added 6/18/2014 - SIMD support + Packet_IsIntrinsicType = 148, // Added 10/26/2019 - SIMD support Packet_IsInstantiationOfVerifiedGeneric = 100, Packet_IsSDArray = 101, Packet_IsStructRequiringStackAllocRetBuf = 102, diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 0d41b10..b2ead48 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -284,12 +284,12 @@ CorInfoIntrinsics interceptor_ICJI::getIntrinsicID(CORINFO_METHOD_HANDLE method, return temp; } -// Is the given module the System.Numerics.Vectors module? -bool interceptor_ICJI::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +// Is the given type in System.Private.Corelib and marked with IntrinsicAttribute? +bool interceptor_ICJI::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { - mc->cr->AddCall("isInSIMDModule"); - bool temp = original_ICorJitInfo->isInSIMDModule(classHnd); - mc->recIsInSIMDModule(classHnd, temp); + mc->cr->AddCall("isIntrinsicType"); + bool temp = original_ICorJitInfo->isIntrinsicType(classHnd); + mc->recIsIntrinsicType(classHnd, temp); return temp; } diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 587aeec..7ffa1eb 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -194,11 +194,11 @@ CorInfoIntrinsics interceptor_ICJI::getIntrinsicID(CORINFO_METHOD_HANDLE method, return original_ICorJitInfo->getIntrinsicID(method, pMustExpand); } -// Is the given module the System.Numerics.Vectors module? -bool interceptor_ICJI::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +// Is the given type in System.Private.Corelib and marked with IntrinsicAttribute? +bool interceptor_ICJI::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { - mcs->AddCall("isInSIMDModule"); - return original_ICorJitInfo->isInSIMDModule(classHnd); + mcs->AddCall("isIntrinsicType"); + return original_ICorJitInfo->isIntrinsicType(classHnd); } // return the unmanaged calling convention for a PInvoke diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index e33d9e6..f390fcb 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -177,10 +177,10 @@ CorInfoIntrinsics interceptor_ICJI::getIntrinsicID(CORINFO_METHOD_HANDLE method, return original_ICorJitInfo->getIntrinsicID(method, pMustExpand); } -// Is the given module the System.Numerics.Vectors module? -bool interceptor_ICJI::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +// Is the given type in System.Private.Corelib and marked with IntrinsicAttribute? +bool interceptor_ICJI::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { - return original_ICorJitInfo->isInSIMDModule(classHnd); + return original_ICorJitInfo->isIntrinsicType(classHnd); } // return the unmanaged calling convention for a PInvoke diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index 2ced2d8..bf143b8 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -218,11 +218,11 @@ CorInfoIntrinsics MyICJI::getIntrinsicID(CORINFO_METHOD_HANDLE method, bool* pMu return jitInstance->mc->repGetIntrinsicID(method, pMustExpand); } -// Is the given module the System.Numerics.Vectors module? -bool MyICJI::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +// Is the given type in System.Private.Corelib and marked with IntrinsicAttribute? +bool MyICJI::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { - jitInstance->mc->cr->AddCall("isInSIMDModule"); - return jitInstance->mc->repIsInSIMDModule(classHnd) ? true : false; + jitInstance->mc->cr->AddCall("isIntrinsicType"); + return jitInstance->mc->repIsIntrinsicType(classHnd) ? true : false; } // return the unmanaged calling convention for a PInvoke diff --git a/src/coreclr/src/inc/corinfo.h b/src/coreclr/src/inc/corinfo.h index 91a8136..63d05aa 100644 --- a/src/coreclr/src/inc/corinfo.h +++ b/src/coreclr/src/inc/corinfo.h @@ -217,11 +217,11 @@ TODO: Talk about initializing strutures before use #endif #endif -SELECTANY const GUID JITEEVersionIdentifier = { /* 1ce51eeb-dfd0-4450-ba2c-ea0d2d863df5 */ - 0x1ce51eeb, - 0xdfd0, - 0x4450, - {0xba, 0x2c, 0xea, 0x0d, 0x2d, 0x86, 0x3d, 0xf5} +SELECTANY const GUID JITEEVersionIdentifier = { /* aec2498a-ca70-408e-903e-1e6d84e90bd2 */ + 0xaec2498a, + 0xca70, + 0x408e, + {0x90, 0x3e, 0x1e, 0x6d, 0x84, 0xe9, 0x0b, 0xd2} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2171,9 +2171,9 @@ public: bool* pMustExpand = NULL /* OUT */ ) = 0; - // Is the given module the System.Numerics.Vectors module? + // Is the given type in System.Private.Corelib and marked with IntrinsicAttribute? // This defaults to false. - virtual bool isInSIMDModule( + virtual bool isIntrinsicType( CORINFO_CLASS_HANDLE classHnd ) { return false; } diff --git a/src/coreclr/src/jit/ICorJitInfo_API_names.h b/src/coreclr/src/jit/ICorJitInfo_API_names.h index 3a287f8..7a587f8 100644 --- a/src/coreclr/src/jit/ICorJitInfo_API_names.h +++ b/src/coreclr/src/jit/ICorJitInfo_API_names.h @@ -15,7 +15,7 @@ DEF_CLR_API(getMethodClass) DEF_CLR_API(getMethodModule) DEF_CLR_API(getMethodVTableOffset) DEF_CLR_API(getIntrinsicID) -DEF_CLR_API(isInSIMDModule) +DEF_CLR_API(isIntrinsicType) DEF_CLR_API(getUnmanagedCallConv) DEF_CLR_API(pInvokeMarshalingRequired) DEF_CLR_API(satisfiesMethodConstraints) diff --git a/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp index 758c189..6fe2200 100644 --- a/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp @@ -140,11 +140,11 @@ CorInfoIntrinsics WrapICorJitInfo::getIntrinsicID( return temp; } -bool WrapICorJitInfo::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +bool WrapICorJitInfo::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { - API_ENTER(isInSIMDModule); - bool temp = wrapHnd->isInSIMDModule(classHnd); - API_LEAVE(isInSIMDModule); + API_ENTER(isIntrinsicType); + bool temp = wrapHnd->isIntrinsicType(classHnd); + API_LEAVE(isIntrinsicType); return temp; } diff --git a/src/coreclr/src/jit/compiler.h b/src/coreclr/src/jit/compiler.h index d989863..2579864 100644 --- a/src/coreclr/src/jit/compiler.h +++ b/src/coreclr/src/jit/compiler.h @@ -7770,12 +7770,18 @@ private: bool isSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { - return info.compCompHnd->isInSIMDModule(clsHnd); + if (isIntrinsicType(clsHnd)) + { + const char* namespaceName = nullptr; + (void)getClassNameFromMetadata(clsHnd, &namespaceName); + return strcmp(namespaceName, "System.Numerics") == 0; + } + return false; } bool isIntrinsicType(CORINFO_CLASS_HANDLE clsHnd) { - return (info.compCompHnd->getClassAttribs(clsHnd) & CORINFO_FLG_INTRINSIC_TYPE) != 0; + return info.compCompHnd->isIntrinsicType(clsHnd); } const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) diff --git a/src/coreclr/src/tools/crossgen2/Common/Compiler/CompilerTypeSystemContext.cs b/src/coreclr/src/tools/crossgen2/Common/Compiler/CompilerTypeSystemContext.cs index 0203ce7..7463ec7 100644 --- a/src/coreclr/src/tools/crossgen2/Common/Compiler/CompilerTypeSystemContext.cs +++ b/src/coreclr/src/tools/crossgen2/Common/Compiler/CompilerTypeSystemContext.cs @@ -20,8 +20,6 @@ namespace ILCompiler private readonly MetadataRuntimeInterfacesAlgorithm _metadataRuntimeInterfacesAlgorithm = new MetadataRuntimeInterfacesAlgorithm(); private readonly MetadataVirtualMethodAlgorithm _virtualMethodAlgorithm = new MetadataVirtualMethodAlgorithm(); - protected SimdHelper _simdHelper; - private MetadataStringDecoder _metadataStringDecoder; private class ModuleData diff --git a/src/coreclr/src/tools/crossgen2/Common/Compiler/SimdHelper.cs b/src/coreclr/src/tools/crossgen2/Common/Compiler/SimdHelper.cs deleted file mode 100644 index a8550b7..0000000 --- a/src/coreclr/src/tools/crossgen2/Common/Compiler/SimdHelper.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; - -using Internal.TypeSystem; - -using AssemblyName = System.Reflection.AssemblyName; - -namespace ILCompiler -{ - /// - /// Helper type that deals with System.Numerics.Vectors intrinsics. - /// - public struct SimdHelper - { - private ModuleDesc[] _simdModulesCached; - - public bool IsSimdType(TypeDesc type) - { - if (type is MetadataType metadataType) - { - if (_simdModulesCached == null) - { - InitializeSimdModules(type); - } - - ModuleDesc typeModule = metadataType.Module; - foreach (ModuleDesc simdModule in _simdModulesCached) - if (typeModule == simdModule) - return true; - - if (metadataType.IsIntrinsic) - { - string name = metadataType.Name; - if (((name == "Vector") || (name == "Vector`1") || (name == "Vector2") || (name == "Vector3") || (name == "Vector4")) && - (metadataType.Namespace == "System.Numerics")) - return true; - } - } - - return false; - } - - private void InitializeSimdModules(TypeDesc type) - { - TypeSystemContext context = type.Context; - - ArrayBuilder simdModules = new ArrayBuilder(); - - ModuleDesc module = context.ResolveAssembly(new AssemblyName("System.Numerics"), false); - if (module != null) - simdModules.Add(module); - - module = context.ResolveAssembly(new AssemblyName("System.Numerics.Vectors"), false); - if (module != null) - simdModules.Add(module); - - _simdModulesCached = simdModules.ToArray(); - } - - public bool IsVectorOfT(TypeDesc type) - { - return IsSimdType(type) - && ((MetadataType)type).Name == "Vector`1" - && ((MetadataType)type).Namespace == "System.Numerics"; - } - } -} diff --git a/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoBase.cs b/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoBase.cs index c092c45..1aa42f3 100644 --- a/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoBase.cs @@ -46,7 +46,7 @@ namespace Internal.JitInterface [UnmanagedFunctionPointerAttribute(default(CallingConvention))] delegate CorInfoIntrinsics __getIntrinsicID(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, byte* pMustExpand); [UnmanagedFunctionPointerAttribute(default(CallingConvention))] - [return: MarshalAs(UnmanagedType.I1)]delegate bool __isInSIMDModule(IntPtr _this, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd); + [return: MarshalAs(UnmanagedType.I1)]delegate bool __isIntrinsicType(IntPtr _this, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd); [UnmanagedFunctionPointerAttribute(default(CallingConvention))] delegate CorInfoUnmanagedCallConv __getUnmanagedCallConv(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method); [UnmanagedFunctionPointerAttribute(default(CallingConvention))] @@ -601,12 +601,12 @@ namespace Internal.JitInterface } } - [return: MarshalAs(UnmanagedType.I1)]static bool _isInSIMDModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd) + [return: MarshalAs(UnmanagedType.I1)]static bool _isIntrinsicType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* classHnd) { var _this = GetThis(thisHandle); try { - return _this.isInSIMDModule(classHnd); + return _this.isIntrinsicType(classHnd); } catch (Exception ex) { @@ -2887,7 +2887,7 @@ namespace Internal.JitInterface var d16 = new __getIntrinsicID(_getIntrinsicID); callbacks[16] = Marshal.GetFunctionPointerForDelegate(d16); delegates[16] = d16; - var d17 = new __isInSIMDModule(_isInSIMDModule); + var d17 = new __isIntrinsicType(_isIntrinsicType); callbacks[17] = Marshal.GetFunctionPointerForDelegate(d17); delegates[17] = d17; var d18 = new __getUnmanagedCallConv(_getUnmanagedCallConv); diff --git a/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs index b895a8a..d09b12b 100644 --- a/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs @@ -885,29 +885,10 @@ namespace Internal.JitInterface return comparer != null ? ObjectToHandle(comparer) : null; } - private SimdHelper _simdHelper; - private bool isInSIMDModule(CORINFO_CLASS_STRUCT_* classHnd) + private bool isIntrinsicType(CORINFO_CLASS_STRUCT_* classHnd) { TypeDesc type = HandleToObject(classHnd); - - if (_simdHelper.IsSimdType(type)) - { -#if DEBUG - // If this is Vector, make sure the codegen and the type system agree on what instructions/registers - // we're generating code for. - - CORJIT_FLAGS flags = default(CORJIT_FLAGS); - getJitFlags(ref flags, (uint)sizeof(CORJIT_FLAGS)); - - Debug.Assert(!_simdHelper.IsVectorOfT(type) - || ((DefType)type).InstanceFieldSize.IsIndeterminate /* This would happen in the ReadyToRun case */ - || ((DefType)type).InstanceFieldSize.AsInt == GetMaxIntrinsicSIMDVectorLength(_jit, &flags)); -#endif - - return true; - } - - return false; + return type.IsIntrinsic; } private CorInfoUnmanagedCallConv getUnmanagedCallConv(CORINFO_METHOD_STRUCT_* method) diff --git a/src/coreclr/src/tools/crossgen2/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/src/tools/crossgen2/Common/JitInterface/ThunkGenerator/ThunkInput.txt index f4fd347..fffc0de 100644 --- a/src/coreclr/src/tools/crossgen2/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/src/tools/crossgen2/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -180,7 +180,7 @@ FUNCTIONS CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE elemType); void expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult); CorInfoIntrinsics getIntrinsicID( CORINFO_METHOD_HANDLE method , BoolStar pMustExpand); - bool isInSIMDModule( CORINFO_CLASS_HANDLE classHnd ); + bool isIntrinsicType( CORINFO_CLASS_HANDLE classHnd ); CorInfoUnmanagedCallConv getUnmanagedCallConv( CORINFO_METHOD_HANDLE method ); BOOL pInvokeMarshalingRequired( CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig ); BOOL satisfiesMethodConstraints( CORINFO_CLASS_HANDLE parent, CORINFO_METHOD_HANDLE method ); diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs index 61dc419..5ffa4e5 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs @@ -45,7 +45,7 @@ namespace ILCompiler throw new NotImplementedException(); else if (type.IsRuntimeDeterminedType) throw new NotImplementedException(); - else if (_simdHelper.IsVectorOfT(type)) + else if (type.IsIntrinsic && (type.Name == "Vector`1") && (type.Namespace == "System.Numerics")) { return _vectorFieldLayoutAlgorithm; } diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index 7f46c38..e36cc91 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -89,7 +89,6 @@ - diff --git a/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h b/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h index 3b59c54..96ea074 100644 --- a/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h +++ b/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h @@ -27,7 +27,7 @@ struct JitInterfaceCallbacks void* (* getDefaultEqualityComparerClass)(void * thisHandle, CorInfoException** ppException, void* elemType); void (* expandRawHandleIntrinsic)(void * thisHandle, CorInfoException** ppException, void* pResolvedToken, void* pResult); int (* getIntrinsicID)(void * thisHandle, CorInfoException** ppException, void* method, bool* pMustExpand); - bool (* isInSIMDModule)(void * thisHandle, CorInfoException** ppException, void* classHnd); + bool (* isIntrinsicType)(void * thisHandle, CorInfoException** ppException, void* classHnd); int (* getUnmanagedCallConv)(void * thisHandle, CorInfoException** ppException, void* method); int (* pInvokeMarshalingRequired)(void * thisHandle, CorInfoException** ppException, void* method, void* callSiteSig); int (* satisfiesMethodConstraints)(void * thisHandle, CorInfoException** ppException, void* parent, void* method); @@ -349,10 +349,10 @@ public: return _ret; } - virtual bool isInSIMDModule(void* classHnd) + virtual bool isIntrinsicType(void* classHnd) { CorInfoException* pException = nullptr; - bool _ret = _callbacks->isInSIMDModule(_thisHandle, &pException, classHnd); + bool _ret = _callbacks->isIntrinsicType(_thisHandle, &pException, classHnd); if (pException != nullptr) throw pException; return _ret; diff --git a/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp b/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp index 6e67409..ada2b05 100644 --- a/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp +++ b/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp @@ -27,11 +27,11 @@ private: uint64_t corJitFlags; }; -static const GUID JITEEVersionIdentifier = { /* 1ce51eeb-dfd0-4450-ba2c-ea0d2d863df5 */ - 0x1ce51eeb, - 0xdfd0, - 0x4450, - {0xba, 0x2c, 0xea, 0x0d, 0x2d, 0x86, 0x3d, 0xf5} +static const GUID JITEEVersionIdentifier = { /* aec2498a-ca70-408e-903e-1e6d84e90bd2 */ + 0xaec2498a, + 0xca70, + 0x408e, + {0x90, 0x3e, 0x1e, 0x6d, 0x84, 0xe9, 0x0b, 0xd2} }; class Jit diff --git a/src/coreclr/src/vm/assembly.cpp b/src/coreclr/src/vm/assembly.cpp index ede9372..aa199a0 100644 --- a/src/coreclr/src/vm/assembly.cpp +++ b/src/coreclr/src/vm/assembly.cpp @@ -190,22 +190,6 @@ void Assembly::Init(AllocMemTracker *pamTracker, LoaderAllocator *pLoaderAllocat if (!m_pManifest->IsReadyToRun()) CacheManifestExportedTypes(pamTracker); - - // Check for the assemblies that contain SIMD Vector types. - // If we encounter a non-trusted assembly with these names, we will simply not recognize any of its - // methods as intrinsics. - LPCUTF8 assemblyName = GetSimpleName(); - const int length = sizeof("System.Numerics") - 1; - if ((strncmp(assemblyName, "System.Numerics", length) == 0) && - ((assemblyName[length] == '\0') || (strcmp(assemblyName+length, ".Vectors") == 0))) - { - m_fIsSIMDVectorAssembly = true; - } - else - { - m_fIsSIMDVectorAssembly = false; - } - // We'll load the friend assembly information lazily. For the ngen case we should avoid // loading it entirely. //CacheFriendAssemblyInfo(); diff --git a/src/coreclr/src/vm/assembly.hpp b/src/coreclr/src/vm/assembly.hpp index e4b0795..09a005c 100644 --- a/src/coreclr/src/vm/assembly.hpp +++ b/src/coreclr/src/vm/assembly.hpp @@ -439,8 +439,6 @@ public: OBJECTHANDLE GetLoaderAllocatorObjectHandle() { WRAPPER_NO_CONTRACT; return GetLoaderAllocator()->GetLoaderAllocatorObjectHandle(); } #endif // FEATURE_COLLECTIBLE_TYPES - BOOL IsSIMDVectorAssembly() { LIMITED_METHOD_DAC_CONTRACT; return m_fIsSIMDVectorAssembly; } - #if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN) BOOL IsInstrumented(); BOOL IsInstrumentedHelper(); @@ -617,8 +615,6 @@ private: BOOL m_fTerminated; - BOOL m_fIsSIMDVectorAssembly; - #if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN) enum IsInstrumentedStatus { IS_INSTRUMENTED_UNSET = 0, diff --git a/src/coreclr/src/vm/interpreter.cpp b/src/coreclr/src/vm/interpreter.cpp index 8dcdacf..2612734 100644 --- a/src/coreclr/src/vm/interpreter.cpp +++ b/src/coreclr/src/vm/interpreter.cpp @@ -9050,15 +9050,15 @@ void Interpreter::DoCallWork(bool virtualCall, void* thisArg, CORINFO_RESOLVED_T // Check for the simd class... assert(exactClass != NULL); GCX_PREEMP(); - bool isSIMD = m_interpCeeInfo.isInSIMDModule(exactClass); + bool isIntrinsicType = m_interpCeeInfo.isIntrinsicType(exactClass); - if (isSIMD) + if (isIntrinsicType) { // SIMD intrinsics are recognized by name. const char* namespaceName = NULL; const char* className = NULL; const char* methodName = m_interpCeeInfo.getMethodNameFromMetadata((CORINFO_METHOD_HANDLE)methToCall, &className, &namespaceName, NULL); - if (strcmp(methodName, "get_IsHardwareAccelerated") == 0) + if ((strcmp(methodName, "get_IsHardwareAccelerated") == 0) && (strcmp(className, "Vector") == 0) && (strcmp(namespaceName, "System.Numerics") == 0)) { GCX_COOP(); DoSIMDHwAccelerated(); diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index c7588fb..a718972 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -8947,10 +8947,9 @@ CorInfoIntrinsics CEEInfo::getIntrinsicID(CORINFO_METHOD_HANDLE methodHnd, } /*********************************************************************/ -// TODO: This method should probably be renamed to something like "isSIMDType" -bool CEEInfo::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +bool CEEInfo::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { -CONTRACTL { + CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_PREEMPTIVE; @@ -8961,28 +8960,9 @@ CONTRACTL { TypeHandle VMClsHnd(classHnd); PTR_MethodTable methodTable = VMClsHnd.GetMethodTable(); - if (methodTable->GetAssembly()->IsSIMDVectorAssembly()) - { - result = true; - } - else if (methodTable->IsIntrinsicType()) - { - LPCUTF8 namespaceName; - LPCUTF8 className = methodTable->GetFullyQualifiedNameInfo(&namespaceName); - - if (strncmp(className, "Vector", 6) == 0) - { - className += 6; + result = methodTable->IsIntrinsicType(); - if ((className[0] == '\0') || (strcmp(className, "`1") == 0) || (strcmp(className, "2") == 0) || (strcmp(className, "3") == 0) || (strcmp(className, "4") == 0)) - { - assert(strcmp(namespaceName, "System.Numerics") == 0); - result = true; - } - } - } EE_TO_JIT_TRANSITION_LEAF(); - return result; } diff --git a/src/coreclr/src/vm/jitinterface.h b/src/coreclr/src/vm/jitinterface.h index c56f82d..f5a694f 100644 --- a/src/coreclr/src/vm/jitinterface.h +++ b/src/coreclr/src/vm/jitinterface.h @@ -822,7 +822,7 @@ public: CorInfoIntrinsics getIntrinsicID(CORINFO_METHOD_HANDLE method, bool * pMustExpand = NULL); - bool isInSIMDModule(CORINFO_CLASS_HANDLE classHnd); + bool isIntrinsicType(CORINFO_CLASS_HANDLE classHnd); CorInfoUnmanagedCallConv getUnmanagedCallConv(CORINFO_METHOD_HANDLE method); BOOL pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig); diff --git a/src/coreclr/src/vm/methodtablebuilder.cpp b/src/coreclr/src/vm/methodtablebuilder.cpp index b332530..b8b0956 100644 --- a/src/coreclr/src/vm/methodtablebuilder.cpp +++ b/src/coreclr/src/vm/methodtablebuilder.cpp @@ -1163,7 +1163,7 @@ BOOL MethodTableBuilder::CheckIfSIMDAndUpdateSize() STANDARD_VM_CONTRACT; #if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) - if (!(GetAssembly()->IsSIMDVectorAssembly() || bmtProp->fIsIntrinsicType)) + if (!bmtProp->fIsIntrinsicType) return false; if (bmtFP->NumInstanceFieldBytes != 16) @@ -1485,7 +1485,7 @@ MethodTableBuilder::BuildMethodTableThrowing( // SIMD types have [Intrinsic] attribute, for example // // We check this here fairly early to ensure other downstream checks on these types can be slightly more efficient. - if (GetModule()->IsSystem() || GetAssembly()->IsSIMDVectorAssembly()) + if (GetModule()->IsSystem()) { HRESULT hr = GetCustomAttribute(bmtInternal->pType->GetTypeDefToken(), WellKnownAttribute::Intrinsic, @@ -5134,7 +5134,7 @@ MethodTableBuilder::InitNewMethodDesc( } // Check for methods marked as [Intrinsic] - if (GetModule()->IsSystem() || GetAssembly()->IsSIMDVectorAssembly()) + if (GetModule()->IsSystem()) { if (bmtProp->fIsHardwareIntrinsic || (S_OK == GetCustomAttribute(pMethod->GetMethodSignature().GetToken(), WellKnownAttribute::Intrinsic, diff --git a/src/coreclr/src/zap/zapinfo.cpp b/src/coreclr/src/zap/zapinfo.cpp index 756e266..8718db2 100644 --- a/src/coreclr/src/zap/zapinfo.cpp +++ b/src/coreclr/src/zap/zapinfo.cpp @@ -4017,9 +4017,9 @@ CorInfoIntrinsics ZapInfo::getIntrinsicID(CORINFO_METHOD_HANDLE method, return intrinsicID; } -bool ZapInfo::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) +bool ZapInfo::isIntrinsicType(CORINFO_CLASS_HANDLE classHnd) { - return m_pEEJitInfo->isInSIMDModule(classHnd); + return m_pEEJitInfo->isIntrinsicType(classHnd); } CorInfoUnmanagedCallConv ZapInfo::getUnmanagedCallConv(CORINFO_METHOD_HANDLE method) diff --git a/src/coreclr/src/zap/zapinfo.h b/src/coreclr/src/zap/zapinfo.h index c05cd6f..fbfe573 100644 --- a/src/coreclr/src/zap/zapinfo.h +++ b/src/coreclr/src/zap/zapinfo.h @@ -707,7 +707,7 @@ public: CorInfoIntrinsics getIntrinsicID(CORINFO_METHOD_HANDLE method, bool * pMustExpand = NULL); - bool isInSIMDModule(CORINFO_CLASS_HANDLE classHnd); + bool isIntrinsicType(CORINFO_CLASS_HANDLE classHnd); CorInfoUnmanagedCallConv getUnmanagedCallConv(CORINFO_METHOD_HANDLE method); BOOL pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); LPVOID GetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig, -- 2.7.4