diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2018-11-01 10:46:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-01 10:46:41 -0700 |
commit | 78a5ee8b39fc5664b47dea447ed2fb00d2c36afa (patch) | |
tree | 59d4598ba3a530bf1bc2c35ba4ce790c3244a255 /src/jit | |
parent | df0cd2cd2c026af3aff78206bed6b45429dc9e19 (diff) | |
download | coreclr-78a5ee8b39fc5664b47dea447ed2fb00d2c36afa.tar.gz coreclr-78a5ee8b39fc5664b47dea447ed2fb00d2c36afa.tar.bz2 coreclr-78a5ee8b39fc5664b47dea447ed2fb00d2c36afa.zip |
Fix JIT flags for ARM64 altjit (#20711)
The ARM64 altjit was interpreting some JIT flags from the (mismatched)
x64 runtime incorrectly: they actually specify x64 architecture
capabilities, not ARM64 capabilities. And some of these capabilities
are not fully implemented/tested, so were leading to crashes doing
altjit asm diffs.
Diffstat (limited to 'src/jit')
-rw-r--r-- | src/jit/compiler.cpp | 48 | ||||
-rw-r--r-- | src/jit/jitee.h | 28 |
2 files changed, 75 insertions, 1 deletions
diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp index b3e5605758..6d7079d271 100644 --- a/src/jit/compiler.cpp +++ b/src/jit/compiler.cpp @@ -5306,6 +5306,54 @@ int Compiler::compCompile(CORINFO_METHOD_HANDLE methodHnd, info.compMatchedVM = false; #endif + // If we are not compiling for a matched VM, then we are getting JIT flags that don't match our target + // architecture. The two main examples here are an ARM targeting altjit hosted on x86 and an ARM64 + // targeting altjit hosted on x64. (Though with cross-bitness work, the host doesn't necessarily need + // to be of the same bitness.) In these cases, we need to fix up the JIT flags to be appropriate for + // the target, as the VM's expected target may overlap bit flags with different meaning to our target. + // Note that it might be better to do this immediately when setting the JIT flags in CILJit::compileMethod() + // (when JitFlags::SetFromFlags() is called), but this is close enough. (To move this logic to + // CILJit::compileMethod() would require moving the info.compMatchedVM computation there as well.) + + if (!info.compMatchedVM) + { +#if defined(_TARGET_ARM_) + +// Currently nothing needs to be done. There are no ARM flags that conflict with other flags. + +#endif // defined(_TARGET_ARM_) + +#if defined(_TARGET_ARM64_) + + // The x86/x64 architecture capabilities flags overlap with the ARM64 ones. Set a reasonable architecture + // target default. Currently this is disabling all ARM64 architecture features except FP and SIMD, but this + // should be altered to possibly enable all of them, when they are known to all work. + + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_AES); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_ATOMICS); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_CRC32); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_DCPOP); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_DP); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_FCMA); + compileFlags->Set(JitFlags::JIT_FLAG_HAS_ARM64_FP); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_FP16); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_JSCVT); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_LRCPC); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_PMULL); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SHA1); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SHA256); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SHA512); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SHA3); + compileFlags->Set(JitFlags::JIT_FLAG_HAS_ARM64_SIMD); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SIMD_V81); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SIMD_FP16); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SM3); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SM4); + compileFlags->Clear(JitFlags::JIT_FLAG_HAS_ARM64_SVE); + +#endif // defined(_TARGET_ARM64_) + } + compMaxUncheckedOffsetForNullObject = eeGetEEInfo()->maxUncheckedOffsetForNullObject; // Set the context for token lookup. diff --git a/src/jit/jitee.h b/src/jit/jitee.h index 903b3cffd9..4ee0c74a2a 100644 --- a/src/jit/jitee.h +++ b/src/jit/jitee.h @@ -292,7 +292,32 @@ public: FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_NO_INLINING, JIT_FLAG_NO_INLINING); -#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) +#if defined(_TARGET_ARM64_) + + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_AES, JIT_FLAG_HAS_ARM64_AES); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_ATOMICS, JIT_FLAG_HAS_ARM64_ATOMICS); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_CRC32, JIT_FLAG_HAS_ARM64_CRC32); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_DCPOP, JIT_FLAG_HAS_ARM64_DCPOP); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_DP, JIT_FLAG_HAS_ARM64_DP); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FCMA, JIT_FLAG_HAS_ARM64_FCMA); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP, JIT_FLAG_HAS_ARM64_FP); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP16, JIT_FLAG_HAS_ARM64_FP16); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_JSCVT, JIT_FLAG_HAS_ARM64_JSCVT); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_LRCPC, JIT_FLAG_HAS_ARM64_LRCPC); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_PMULL, JIT_FLAG_HAS_ARM64_PMULL); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA1, JIT_FLAG_HAS_ARM64_SHA1); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA256, JIT_FLAG_HAS_ARM64_SHA256); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA512, JIT_FLAG_HAS_ARM64_SHA512); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA3, JIT_FLAG_HAS_ARM64_SHA3); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD, JIT_FLAG_HAS_ARM64_SIMD); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD_V81, JIT_FLAG_HAS_ARM64_SIMD_V81); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD_FP16, JIT_FLAG_HAS_ARM64_SIMD_FP16); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SM3, JIT_FLAG_HAS_ARM64_SM3); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SM4, JIT_FLAG_HAS_ARM64_SM4); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SVE, JIT_FLAG_HAS_ARM64_SVE); + +#elif defined(_TARGET_X86_) || defined(_TARGET_AMD64_) + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_SSE3, JIT_FLAG_USE_SSE3); FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_SSSE3, JIT_FLAG_USE_SSSE3); FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_SSE41, JIT_FLAG_USE_SSE41); @@ -304,6 +329,7 @@ public: FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_LZCNT, JIT_FLAG_USE_LZCNT); FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_PCLMULQDQ, JIT_FLAG_USE_PCLMULQDQ); FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_POPCNT, JIT_FLAG_USE_POPCNT); + #endif // _TARGET_X86_ || _TARGET_AMD64_ #undef FLAGS_EQUAL |