diff options
author | Fei Peng <fei.peng@intel.com> | 2017-09-24 10:54:56 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-09-29 14:23:43 -0700 |
commit | 03c5c252281325e5a7b94cec6a198946f903b359 (patch) | |
tree | 44e3e04572c86ba2e6714e70dca3613a854ce6d4 /src | |
parent | 4252e77681840228d95318e920d649bb5b27ea82 (diff) | |
download | coreclr-03c5c252281325e5a7b94cec6a198946f903b359.tar.gz coreclr-03c5c252281325e5a7b94cec6a198946f903b359.tar.bz2 coreclr-03c5c252281325e5a7b94cec6a198946f903b359.zip |
Enable hardware intrinsic in debug and reflection
Diffstat (limited to 'src')
-rw-r--r-- | src/dlls/mscorrc/mscorrc.rc | 1 | ||||
-rw-r--r-- | src/dlls/mscorrc/resource.h | 1 | ||||
-rw-r--r-- | src/jit/compiler.cpp | 2 | ||||
-rw-r--r-- | src/jit/compiler.h | 46 | ||||
-rw-r--r-- | src/jit/hwintrinsicxarch.cpp | 93 | ||||
-rw-r--r-- | src/jit/importer.cpp | 10 | ||||
-rw-r--r-- | src/jit/instr.h | 13 | ||||
-rw-r--r-- | src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs | 1 | ||||
-rw-r--r-- | src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs | 1 | ||||
-rw-r--r-- | src/vm/methodtablebuilder.cpp | 36 | ||||
-rw-r--r-- | src/vm/methodtablebuilder.h | 2 | ||||
-rw-r--r-- | src/zap/zapimage.cpp | 6 |
12 files changed, 119 insertions, 93 deletions
diff --git a/src/dlls/mscorrc/mscorrc.rc b/src/dlls/mscorrc/mscorrc.rc index 8dd29ae75f..8bc7ff00b9 100644 --- a/src/dlls/mscorrc/mscorrc.rc +++ b/src/dlls/mscorrc/mscorrc.rc @@ -853,6 +853,7 @@ BEGIN IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED "SIMD intrinsics may not be used by partial trust applications." IDS_IBC_MISSING_EXTERNAL_TYPE "The generic type specified by the IBC data is not available to this assembly" IDS_IBC_MISSING_EXTERNAL_METHOD "The generic method specified by the IBC data is not available to this assembly" + IDS_EE_HWINTRINSIC_NGEN_DISALLOWED "Hardware intrinsics may not be used with ngen." IDS_INET_E_CANNOT_CONNECT "Cannot connect to URL for '%1'." IDS_INET_E_RESOURCE_NOT_FOUND "The server or proxy was not found for '%1'." diff --git a/src/dlls/mscorrc/resource.h b/src/dlls/mscorrc/resource.h index 205445acbe..eb1cb293f4 100644 --- a/src/dlls/mscorrc/resource.h +++ b/src/dlls/mscorrc/resource.h @@ -613,6 +613,7 @@ #define IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED 0x1ac4 #define IDS_IBC_MISSING_EXTERNAL_TYPE 0x1ac5 #define IDS_IBC_MISSING_EXTERNAL_METHOD 0x1ac6 +#define IDS_EE_HWINTRINSIC_NGEN_DISALLOWED 0x1ac7 #define BFA_INVALID_FILE_TOKEN 0x2000 #define BFA_INVALID_TOKEN_TYPE 0x2001 diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp index 86179ec48b..6e1323ff2e 100644 --- a/src/jit/compiler.cpp +++ b/src/jit/compiler.cpp @@ -2561,7 +2561,7 @@ void Compiler::compSetProcessor() #endif // _TARGET_X86_ -// Instruction set flags fo// Instruction set flags for Intel hardware intrinsics +// Instruction set flags for Intel hardware intrinsics #ifdef _TARGET_XARCH_ opts.compSupportsISA = 0; diff --git a/src/jit/compiler.h b/src/jit/compiler.h index dfc50ee605..4bdb7ac07e 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -3021,22 +3021,22 @@ protected: InstructionSet lookupHWIntrinsicISA(const char* className); NamedIntrinsic lookupHWIntrinsic(const char* methodName, InstructionSet isa); InstructionSet isaOfHWIntrinsic(NamedIntrinsic intrinsic); - GenTree* impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); - GenTree* impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method); + GenTree* impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); + GenTree* impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); #endif GenTreePtr impArrayAccessIntrinsic(CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, @@ -7824,6 +7824,15 @@ private: #endif } + bool compSupports(InstructionSet isa) + { +#ifdef _TARGET_XARCH_ + return (opts.compSupportsISA & (1 << isa)) != 0; +#else + return false; +#endif + } + /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX @@ -7938,16 +7947,11 @@ public: #endif // _TARGET_XARCH_ #ifdef _TARGET_XARCH_ - // only for Intel hardware intrinsics uint64_t compSupportsISA; void setSupportedISA(InstructionSet isa) { compSupportsISA |= 1 << isa; } - bool compSupports(InstructionSet isa) - { - return (compSupportsISA & (1 << isa)) != 0; - } #endif // optimize maximally and/or favor speed over size? diff --git a/src/jit/hwintrinsicxarch.cpp b/src/jit/hwintrinsicxarch.cpp index 4a1ca85c10..45ee468174 100644 --- a/src/jit/hwintrinsicxarch.cpp +++ b/src/jit/hwintrinsicxarch.cpp @@ -154,225 +154,226 @@ InstructionSet Compiler::isaOfHWIntrinsic(NamedIntrinsic intrinsic) // Arguments: // intrinsic -- id of the intrinsic function. // method -- method handle of the intrinsic function. +// sig -- signature of the intrinsic call // // Return Value: // the expanded intrinsic. // -GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { InstructionSet isa = isaOfHWIntrinsic(intrinsic); switch (isa) { case InstructionSet_SSE: - return impSSEIntrinsic(intrinsic, method); + return impSSEIntrinsic(intrinsic, method, sig); case InstructionSet_SSE2: - return impSSE2Intrinsic(intrinsic, method); + return impSSE2Intrinsic(intrinsic, method, sig); case InstructionSet_SSE3: - return impSSE3Intrinsic(intrinsic, method); + return impSSE3Intrinsic(intrinsic, method, sig); case InstructionSet_SSSE3: - return impSSSE3Intrinsic(intrinsic, method); + return impSSSE3Intrinsic(intrinsic, method, sig); case InstructionSet_SSE41: - return impSSE41Intrinsic(intrinsic, method); + return impSSE41Intrinsic(intrinsic, method, sig); case InstructionSet_SSE42: - return impSSE42Intrinsic(intrinsic, method); + return impSSE42Intrinsic(intrinsic, method, sig); case InstructionSet_AVX: - return impAVXIntrinsic(intrinsic, method); + return impAVXIntrinsic(intrinsic, method, sig); case InstructionSet_AVX2: - return impAVX2Intrinsic(intrinsic, method); + return impAVX2Intrinsic(intrinsic, method, sig); case InstructionSet_AES: - return impAESIntrinsic(intrinsic, method); + return impAESIntrinsic(intrinsic, method, sig); case InstructionSet_BMI1: - return impBMI1Intrinsic(intrinsic, method); + return impBMI1Intrinsic(intrinsic, method, sig); case InstructionSet_BMI2: - return impBMI2Intrinsic(intrinsic, method); + return impBMI2Intrinsic(intrinsic, method, sig); case InstructionSet_FMA: - return impFMAIntrinsic(intrinsic, method); + return impFMAIntrinsic(intrinsic, method, sig); case InstructionSet_LZCNT: - return impLZCNTIntrinsic(intrinsic, method); + return impLZCNTIntrinsic(intrinsic, method, sig); case InstructionSet_PCLMULQDQ: - return impPCLMULQDQIntrinsic(intrinsic, method); + return impPCLMULQDQIntrinsic(intrinsic, method, sig); case InstructionSet_POPCNT: - return impPOPCNTIntrinsic(intrinsic, method); + return impPOPCNTIntrinsic(intrinsic, method, sig); default: return nullptr; } } -GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_SSE_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_SSE)); + return gtNewIconNode(compSupports(InstructionSet_SSE)); default: return nullptr; } } -GenTree* Compiler::impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_SSE2_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_SSE2)); + return gtNewIconNode(compSupports(InstructionSet_SSE2)); default: return nullptr; } } -GenTree* Compiler::impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_SSE3_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_SSE3)); + return gtNewIconNode(compSupports(InstructionSet_SSE3)); default: return nullptr; } } -GenTree* Compiler::impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_SSSE3_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_SSSE3)); + return gtNewIconNode(compSupports(InstructionSet_SSSE3)); default: return nullptr; } } -GenTree* Compiler::impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_SSE41_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_SSE41)); + return gtNewIconNode(compSupports(InstructionSet_SSE41)); default: return nullptr; } } -GenTree* Compiler::impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_SSE42_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_SSE42)); + return gtNewIconNode(compSupports(InstructionSet_SSE42)); default: return nullptr; } } -GenTree* Compiler::impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_AVX_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_AVX)); + return gtNewIconNode(compSupports(InstructionSet_AVX)); default: return nullptr; } } -GenTree* Compiler::impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_AVX2_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_AVX2)); + return gtNewIconNode(compSupports(InstructionSet_AVX2)); default: return nullptr; } } -GenTree* Compiler::impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_AES_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_AES)); + return gtNewIconNode(compSupports(InstructionSet_AES)); default: return nullptr; } } -GenTree* Compiler::impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_BMI1_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_BMI1)); + return gtNewIconNode(compSupports(InstructionSet_BMI1)); default: return nullptr; } } -GenTree* Compiler::impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_BMI2_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_BMI2)); + return gtNewIconNode(compSupports(InstructionSet_BMI2)); default: return nullptr; } } -GenTree* Compiler::impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_FMA_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_FMA)); + return gtNewIconNode(compSupports(InstructionSet_FMA)); default: return nullptr; } } -GenTree* Compiler::impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_LZCNT_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_LZCNT)); + return gtNewIconNode(compSupports(InstructionSet_LZCNT)); default: return nullptr; } } -GenTree* Compiler::impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_PCLMULQDQ_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_PCLMULQDQ)); + return gtNewIconNode(compSupports(InstructionSet_PCLMULQDQ)); default: return nullptr; } } -GenTree* Compiler::impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method) +GenTree* Compiler::impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig) { switch (intrinsic) { case NI_POPCNT_IsSupported: - return gtNewIconNode(opts.compSupports(InstructionSet_POPCNT)); + return gtNewIconNode(compSupports(InstructionSet_POPCNT)); default: return nullptr; diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index d16dfe3975..714e6fe21f 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -3322,9 +3322,11 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis, GenTreePtr retNode = nullptr; // - // We disable the inlining of instrinsics for MinOpts. - // - if (!mustExpand && (opts.compDbgCode || opts.MinOpts())) + // We disable the inlining of intrinsic for MinOpts, + // but we should always expand hardware intrinsics whose managed method body + // is a directly recursive call site. This design makes hardware intrinsic + // be able to work with debugger and reflection. + if (!mustExpand && (opts.compDbgCode || opts.MinOpts()) && !gtIsRecursiveCall(method)) { *pIntrinsicID = CORINFO_INTRINSIC_Illegal; return retNode; @@ -3738,7 +3740,7 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis, #ifdef _TARGET_XARCH_ if (ni > NI_HW_INTRINSIC_START && ni < NI_HW_INTRINSIC_END) { - retNode = impX86HWIntrinsic(ni, method); + retNode = impX86HWIntrinsic(ni, method, sig); } #endif switch (ni) diff --git a/src/jit/instr.h b/src/jit/instr.h index e364fbc330..eac425634c 100644 --- a/src/jit/instr.h +++ b/src/jit/instr.h @@ -274,9 +274,6 @@ enum emitAttr : unsigned #define EmitSize(x) (EA_ATTR(genTypeSize(TypeGet(x)))) -// Enum specifying the instruction set for generating floating point or SIMD code. -// These enums are ordered such that each one is inclusive of previous instruction sets -// and the VM ensures this as well when setting the CONFIG flags. enum InstructionSet { #ifdef _TARGET_XARCH_ @@ -292,10 +289,12 @@ enum InstructionSet InstructionSet_AVX = 8, InstructionSet_AVX2 = 9, // Linear order end - // Instruction sets have the linear order only in above area. - // Values of InstructionSet not in this area cannot be compared - // (i.e. compiler->getSIMDInstructionSet() >= InstructionSet_SSE3_4). - + // TODO - Instruction sets have the linear order only in above area. + // We should no long compare the return value of getSIMDInstructionSet() + // or getFloatingPointInstructionSet() to the InstructionSet values. + // Should refactor SIMD code only to be aware of SIMD feature levels + // (SSE2, SSE3_4, AVX, and AVX2, etc.) rather than concrete ISA. + InstructionSet_AES = 32, InstructionSet_BMI1 = 33, InstructionSet_BMI2 = 34, diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs index 17d7716fc0..6bdc8cc3a0 100644 --- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs +++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.Intrinsics; namespace System.Runtime.Intrinsics.X86 { diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs index c9e71b3a47..21cae3170c 100644 --- a/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs +++ b/src/mscorlib/src/System/Runtime/Intrinsics/X86/Popcnt.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.Intrinsics; namespace System.Runtime.Intrinsics.X86 { diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp index 8a96e6825f..adcf7bbc79 100644 --- a/src/vm/methodtablebuilder.cpp +++ b/src/vm/methodtablebuilder.cpp @@ -1484,6 +1484,26 @@ MethodTableBuilder::BuildMethodTableThrowing( } } +#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) + // All the funtions in System.Runtime.Intrinsics.X86 are hardware intrinsics. + // We specially treat them here to reduce the disk footprint of mscorlib. + if (GetModule()->IsSystem() && !bmtGenerics->HasInstantiation()) + { + LPCUTF8 x86className; + LPCUTF8 x86nameSpace; + HRESULT hr = GetMDImport()->GetNameOfTypeDef(bmtInternal->pType->GetTypeDefToken(), &x86className, &x86nameSpace); + + if (hr == S_OK && strcmp(x86nameSpace, "System.Runtime.Intrinsics.X86") == 0) + { + if (IsCompilationProcess()) + { + // Disable AOT compiling for managed implementation of hardware intrinsics in mscorlib. + COMPlusThrow(kTypeLoadException, IDS_EE_HWINTRINSIC_NGEN_DISALLOWED); + } + bmtProp->fIsHardwareIntrinsic = true; + } + } +#endif #ifdef FEATURE_COMINTEROP @@ -5090,19 +5110,7 @@ MethodTableBuilder::InitNewMethodDesc( NULL, NULL); - if (hr == S_OK) - { - pNewMD->SetIsJitIntrinsic(); - } - - // All the funtions in System.Runtime.Intrinsics.X86 are hardware intrinsics. - // We specially treat them here to reduce the disk footprint of mscorlib. - LPCUTF8 className; - LPCUTF8 nameSpace; - - HRESULT hrns = GetMDImport()->GetNameOfTypeDef(bmtInternal->pType->GetTypeDefToken(), &className, &nameSpace); - - if (hrns == S_OK && strcmp(nameSpace, "System.Runtime.Intrinsics.X86") == 0) + if (hr == S_OK || bmtProp->fIsHardwareIntrinsic) { pNewMD->SetIsJitIntrinsic(); } @@ -9402,7 +9410,7 @@ void MethodTableBuilder::CheckForSystemTypes() { BuildMethodTableThrowException(IDS_CLASSLOAD_BADFORMAT); } - + if (IsValueClass()) { // diff --git a/src/vm/methodtablebuilder.h b/src/vm/methodtablebuilder.h index a7d7bdd158..c5ce09f397 100644 --- a/src/vm/methodtablebuilder.h +++ b/src/vm/methodtablebuilder.h @@ -1333,6 +1333,8 @@ private: bool fDynamicStatics; // Set to true if the statics will be allocated in the dynamic bool fGenericsStatics; // Set to true if the there are per-instantiation statics + bool fIsHardwareIntrinsic; // Set to true if the class is a hardware intrinsic + DWORD dwNonGCRegularStaticFieldBytes; DWORD dwNonGCThreadStaticFieldBytes; diff --git a/src/zap/zapimage.cpp b/src/zap/zapimage.cpp index 96fa81fba1..98b9e9224d 100644 --- a/src/zap/zapimage.cpp +++ b/src/zap/zapimage.cpp @@ -3560,6 +3560,12 @@ void ZapImage::Error(mdToken token, HRESULT hr, UINT resID, LPCWSTR message) level = CORZAP_LOGLEVEL_INFO; } + if (resID == IDS_EE_HWINTRINSIC_NGEN_DISALLOWED) + { + // Supress printing of "Hardware intrinsics may not be used with ngen." + level = CORZAP_LOGLEVEL_INFO; + } + #ifdef CROSSGEN_COMPILE if ((resID == IDS_IBC_MISSING_EXTERNAL_TYPE) || (resID == IDS_IBC_MISSING_EXTERNAL_METHOD)) |