diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2016-10-26 15:52:06 -0700 |
---|---|---|
committer | Bruce Forstall <brucefo@microsoft.com> | 2016-10-27 12:08:20 -0700 |
commit | e72536c32676b412cfead025b577d4e8c18d1c2f (patch) | |
tree | 41c0b6f18262cdacc29070e5fa880c6ba82c1081 /src/vm | |
parent | 675622bb85f3c78de1967a78052d7280a2834611 (diff) | |
download | coreclr-e72536c32676b412cfead025b577d4e8c18d1c2f.tar.gz coreclr-e72536c32676b412cfead025b577d4e8c18d1c2f.tar.bz2 coreclr-e72536c32676b412cfead025b577d4e8c18d1c2f.zip |
Introduce new CORJIT_FLAGS type
The "JIT flags" currently passed between the EE and the JIT have traditionally
been bit flags in a 32-bit word. Recently, a second 32-bit word was added to
accommodate additional flags, but that set of flags is definitely "2nd class":
they are not universally passed, and require using a separate set of bit
definitions, and comparing those bits against the proper, 2nd word.
This change replaces all uses of bare DWORD or 'unsigned int' types
representing flags with CORJIT_FLAGS, which is now an opaque type. All
flag names were renamed from CORJIT_FLG_* to CORJIT_FLAG_* to ensure all
cases were changed to use the new names, which are also scoped within the
CORJIT_FLAGS type itself.
Another motivation to do this, besides cleaner code, is to allow enabling the
SSE/AVX flags for x86. For x86, we had fewer bits available in the "first
word", so would have to either put them in the "second word", which, as
stated, was very much 2nd class and not plumbed through many usages, or
we could move other bits to the "second word", with the same issues. Neither
was a good option.
RyuJIT compiles with both COR_JIT_EE_VERSION > 460 and <= 460. I introduced
a JitFlags adapter class in jitee.h to handle both JIT flag types. All JIT
code uses this JitFlags type, which operates identically to the new
CORJIT_FLAGS type.
In addition to introducing the new CORJIT_FLAGS type, the SSE/AVX flags are
enabled for x86.
The JIT-EE interface GUID is changed, as this is a breaking change.
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/ceeload.cpp | 4 | ||||
-rw-r--r-- | src/vm/cgensys.h | 10 | ||||
-rw-r--r-- | src/vm/codeman.cpp | 43 | ||||
-rw-r--r-- | src/vm/codeman.h | 6 | ||||
-rw-r--r-- | src/vm/commethodrental.cpp | 4 | ||||
-rw-r--r-- | src/vm/compile.cpp | 6 | ||||
-rw-r--r-- | src/vm/compile.h | 2 | ||||
-rw-r--r-- | src/vm/dllimport.cpp | 18 | ||||
-rw-r--r-- | src/vm/dllimportcallback.cpp | 4 | ||||
-rw-r--r-- | src/vm/i386/cgenx86.cpp | 25 | ||||
-rw-r--r-- | src/vm/ilstubcache.cpp | 2 | ||||
-rw-r--r-- | src/vm/ilstubresolver.cpp | 10 | ||||
-rw-r--r-- | src/vm/ilstubresolver.h | 6 | ||||
-rw-r--r-- | src/vm/interpreter.cpp | 6 | ||||
-rw-r--r-- | src/vm/jitinterface.cpp | 192 | ||||
-rw-r--r-- | src/vm/jitinterface.h | 6 | ||||
-rw-r--r-- | src/vm/method.cpp | 2 | ||||
-rw-r--r-- | src/vm/method.hpp | 2 | ||||
-rw-r--r-- | src/vm/methodtablebuilder.cpp | 4 | ||||
-rw-r--r-- | src/vm/multicorejitplayer.cpp | 2 | ||||
-rw-r--r-- | src/vm/prestub.cpp | 10 | ||||
-rw-r--r-- | src/vm/rejit.cpp | 11 | ||||
-rw-r--r-- | src/vm/stacksampler.cpp | 10 | ||||
-rw-r--r-- | src/vm/stacksampler.h | 4 | ||||
-rw-r--r-- | src/vm/stubgen.cpp | 39 | ||||
-rw-r--r-- | src/vm/stubgen.h | 2 | ||||
-rw-r--r-- | src/vm/util.cpp | 13 |
27 files changed, 219 insertions, 224 deletions
diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp index 80fc617d0e..feb9f85607 100644 --- a/src/vm/ceeload.cpp +++ b/src/vm/ceeload.cpp @@ -15911,9 +15911,9 @@ void Module::ExpandAll() pMD->GetMDImport(), &ignored)); #ifdef FEATURE_INTERPRETER - pMD->MakeJitWorker(pHeader, CORJIT_FLG_MAKEFINALCODE, 0); + pMD->MakeJitWorker(pHeader, CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE)); #else - pMD->MakeJitWorker(pHeader, 0, 0); + pMD->MakeJitWorker(pHeader, CORJIT_FLAGS()); #endif } } diff --git a/src/vm/cgensys.h b/src/vm/cgensys.h index 205d8a223e..fb5c087c5c 100644 --- a/src/vm/cgensys.h +++ b/src/vm/cgensys.h @@ -103,21 +103,21 @@ inline void GetSpecificCpuInfo(CORINFO_CPU * cpuInfo) #endif // !_TARGET_X86_ -#if defined(_TARGET_AMD64_) && !defined(CROSSGEN_COMPILE) +#if (defined(_TARGET_X86_) || defined(_TARGET_AMD64_)) && !defined(CROSSGEN_COMPILE) extern "C" DWORD __stdcall getcpuid(DWORD arg, unsigned char result[16]); -#endif // defined(_TARGET_AMD64_) +#endif inline bool TargetHasAVXSupport() { -#if defined(_TARGET_AMD64_) && !defined(CROSSGEN_COMPILE) +#if (defined(_TARGET_X86_) || defined(_TARGET_AMD64_)) && !defined(CROSSGEN_COMPILE) unsigned char buffer[16]; - // All AMD64 targets support cpuid. + // All x86/AMD64 targets support cpuid. (void) getcpuid(1, buffer); // getcpuid executes cpuid with eax set to its first argument, and ecx cleared. // It returns the resulting eax, ebx, ecx and edx (in that order) in buffer[]. // The AVX feature is ECX bit 28. return ((buffer[11] & 0x10) != 0); -#endif // defined(_TARGET_AMD64_) && !defined(CROSSGEN_COMPILE) +#endif // (defined(_TARGET_X86_) || defined(_TARGET_AMD64_)) && !defined(CROSSGEN_COMPILE) return false; } diff --git a/src/vm/codeman.cpp b/src/vm/codeman.cpp index 444dcf4fef..9d7d8d0e1b 100644 --- a/src/vm/codeman.cpp +++ b/src/vm/codeman.cpp @@ -1187,6 +1187,7 @@ EEJitManager::EEJitManager() // CRST_TAKEN_DURING_SHUTDOWN - We take this lock during shutdown if ETW is on (to do rundown) m_CodeHeapCritSec( CrstSingleUseLock, CrstFlags(CRST_UNSAFE_ANYMODE|CRST_DEBUGGER_THREAD|CRST_TAKEN_DURING_SHUTDOWN)), + m_CPUCompileFlags(), m_EHClauseCritSec( CrstSingleUseLock ) { CONTRACTL { @@ -1211,17 +1212,17 @@ EEJitManager::EEJitManager() m_AltJITRequired = false; #endif - m_dwCPUCompileFlags = 0; - m_cleanupList = NULL; } -#if defined(_TARGET_AMD64_) +#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) extern "C" DWORD __stdcall getcpuid(DWORD arg, unsigned char result[16]); extern "C" DWORD __stdcall xmmYmmStateSupport(); bool DoesOSSupportAVX() { + LIMITED_METHOD_CONTRACT; + #ifndef FEATURE_PAL // On Windows we have an api(GetEnabledXStateFeatures) to check if AVX is supported typedef DWORD64 (WINAPI *PGETENABLEDXSTATEFEATURES)(); @@ -1255,7 +1256,7 @@ bool DoesOSSupportAVX() return TRUE; } -#endif // defined(_TARGET_AMD64_) +#endif // defined(_TARGET_X86_) || defined(_TARGET_AMD64_) void EEJitManager::SetCpuInfo() { @@ -1265,7 +1266,7 @@ void EEJitManager::SetCpuInfo() // NOTE: This function needs to be kept in sync with Zapper::CompileAssembly() // - DWORD dwCPUCompileFlags = 0; + CORJIT_FLAGS CPUCompileFlags; #if defined(_TARGET_X86_) // NOTE: if you're adding any flags here, you probably should also be doing it @@ -1276,7 +1277,7 @@ void EEJitManager::SetCpuInfo() switch (CPU_X86_FAMILY(cpuInfo.dwCPUType)) { case CPU_X86_PENTIUM_4: - dwCPUCompileFlags |= CORJIT_FLG_TARGET_P4; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_TARGET_P4); break; default: break; @@ -1284,15 +1285,17 @@ void EEJitManager::SetCpuInfo() if (CPU_X86_USE_CMOV(cpuInfo.dwFeatures)) { - dwCPUCompileFlags |= CORJIT_FLG_USE_CMOV | - CORJIT_FLG_USE_FCOMI; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_CMOV); + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_FCOMI); } if (CPU_X86_USE_SSE2(cpuInfo.dwFeatures)) { - dwCPUCompileFlags |= CORJIT_FLG_USE_SSE2; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_SSE2); } -#elif defined(_TARGET_AMD64_) +#endif // _TARGET_X86_ + +#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) unsigned char buffer[16]; DWORD maxCpuId = getcpuid(0, buffer); if (maxCpuId >= 0) @@ -1301,17 +1304,17 @@ void EEJitManager::SetCpuInfo() // It returns the resulting eax in buffer[0-3], ebx in buffer[4-7], ecx in buffer[8-11], // and edx in buffer[12-15]. // We will set the following flags: - // CORJIT_FLG_USE_SSE3_4 if the following feature bits are set (input EAX of 1) + // CORJIT_FLAG_USE_SSE3_4 if the following feature bits are set (input EAX of 1) // SSE3 - ECX bit 0 (buffer[8] & 0x01) // SSSE3 - ECX bit 9 (buffer[9] & 0x02) // SSE4.1 - ECX bit 19 (buffer[10] & 0x08) // SSE4.2 - ECX bit 20 (buffer[10] & 0x10) - // CORJIT_FLG_USE_AVX if the following feature bits are set (input EAX of 1), and xmmYmmStateSupport returns 1: + // CORJIT_FLAG_USE_AVX if the following feature bits are set (input EAX of 1), and xmmYmmStateSupport returns 1: // OSXSAVE - ECX bit 27 (buffer[11] & 0x08) // AVX - ECX bit 28 (buffer[11] & 0x10) - // CORJIT_FLG_USE_AVX2 if the following feature bit is set (input EAX of 0x07 and input ECX of 0): + // CORJIT_FLAG_USE_AVX2 if the following feature bit is set (input EAX of 0x07 and input ECX of 0): // AVX2 - EBX bit 5 (buffer[4] & 0x20) - // CORJIT_FLG_USE_AVX_512 is not currently set, but defined so that it can be used in future without + // CORJIT_FLAG_USE_AVX_512 is not currently set, but defined so that it can be used in future without // synchronously updating VM and JIT. (void) getcpuid(1, buffer); // If SSE2 is not enabled, there is no point in checking the rest. @@ -1324,7 +1327,7 @@ void EEJitManager::SetCpuInfo() ((buffer[10] & 0x08) != 0) && // SSE4.1 ((buffer[10] & 0x10) != 0)) // SSE4.2 { - dwCPUCompileFlags |= CORJIT_FLG_USE_SSE3_4; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_SSE3_4); } if ((buffer[11] & 0x18) == 0x18) { @@ -1332,13 +1335,13 @@ void EEJitManager::SetCpuInfo() { if (xmmYmmStateSupport() == 1) { - dwCPUCompileFlags |= CORJIT_FLG_USE_AVX; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_AVX); if (maxCpuId >= 0x07) { (void) getcpuid(0x07, buffer); if ((buffer[4] & 0x20) != 0) { - dwCPUCompileFlags |= CORJIT_FLG_USE_AVX2; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_AVX2); } } } @@ -1347,13 +1350,13 @@ void EEJitManager::SetCpuInfo() static ConfigDWORD fFeatureSIMD; if (fFeatureSIMD.val(CLRConfig::EXTERNAL_FeatureSIMD) != 0) { - dwCPUCompileFlags |= CORJIT_FLG_FEATURE_SIMD; + CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_FEATURE_SIMD); } } } -#endif // defined(_TARGET_AMD64_) +#endif // defined(_TARGET_X86_) || defined(_TARGET_AMD64_) - m_dwCPUCompileFlags = dwCPUCompileFlags; + m_CPUCompileFlags = CPUCompileFlags; } // Define some data that we can use to get a better idea of what happened when we get a Watson dump that indicates the JIT failed to load. diff --git a/src/vm/codeman.h b/src/vm/codeman.h index f4e04b8c67..0fe261a92f 100644 --- a/src/vm/codeman.h +++ b/src/vm/codeman.h @@ -1146,17 +1146,17 @@ public: #endif // !DACCESS_COMPILE private: - DWORD m_dwCPUCompileFlags; + CORJIT_FLAGS m_CPUCompileFlags; #if !defined CROSSGEN_COMPILE && !defined DACCESS_COMPILE void SetCpuInfo(); #endif public: - inline DWORD GetCPUCompileFlags() + inline CORJIT_FLAGS GetCPUCompileFlags() { LIMITED_METHOD_CONTRACT; - return m_dwCPUCompileFlags; + return m_CPUCompileFlags; } private : diff --git a/src/vm/commethodrental.cpp b/src/vm/commethodrental.cpp index 0faf470a2a..0a5c011270 100644 --- a/src/vm/commethodrental.cpp +++ b/src/vm/commethodrental.cpp @@ -102,9 +102,9 @@ void QCALLTYPE COMMethodRental::SwapMethodBody(EnregisteredTypeHandle cls, INT32 COMPlusThrowHR(VLDTR_E_MD_BADHEADER); #ifdef FEATURE_INTERPRETER - pMethodDesc->MakeJitWorker(&header, CORJIT_FLG_MAKEFINALCODE, 0); + pMethodDesc->MakeJitWorker(&header, CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE)); #else // !FEATURE_INTERPRETER - pMethodDesc->MakeJitWorker(&header, 0, 0); + pMethodDesc->MakeJitWorker(&header, CORJIT_FLAGS()); #endif // !FEATURE_INTERPRETER } diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp index 50a2412904..bbd52f7932 100644 --- a/src/vm/compile.cpp +++ b/src/vm/compile.cpp @@ -1487,7 +1487,7 @@ void CEECompileInfo::CompressDebugInfo( HRESULT CEECompileInfo::GetBaseJitFlags( IN CORINFO_METHOD_HANDLE hMethod, - OUT DWORD *pFlags) + OUT CORJIT_FLAGS *pFlags) { STANDARD_VM_CONTRACT; @@ -6680,9 +6680,9 @@ MethodDesc * CEEPreloader::CompileMethodStubIfNeeded( { if (!pStubMD->AsDynamicMethodDesc()->GetILStubResolver()->IsCompiled()) { - DWORD dwJitFlags = pStubMD->AsDynamicMethodDesc()->GetILStubResolver()->GetJitFlags(); + CORJIT_FLAGS jitFlags = pStubMD->AsDynamicMethodDesc()->GetILStubResolver()->GetJitFlags(); - pfnCallback(pCallbackContext, (CORINFO_METHOD_HANDLE)pStubMD, dwJitFlags); + pfnCallback(pCallbackContext, (CORINFO_METHOD_HANDLE)pStubMD, jitFlags); } #ifndef FEATURE_FULL_NGEN // Deduplication diff --git a/src/vm/compile.h b/src/vm/compile.h index 19bbac3228..8ee66dbec8 100644 --- a/src/vm/compile.h +++ b/src/vm/compile.h @@ -377,7 +377,7 @@ class CEECompileInfo : public ICorCompileInfo HRESULT GetBaseJitFlags( IN CORINFO_METHOD_HANDLE hMethod, - OUT DWORD *pFlags); + OUT CORJIT_FLAGS *pFlags); #ifdef _WIN64 SIZE_T getPersonalityValue(); diff --git a/src/vm/dllimport.cpp b/src/vm/dllimport.cpp index 65e6871f73..5d63b1de87 100644 --- a/src/vm/dllimport.cpp +++ b/src/vm/dllimport.cpp @@ -1024,7 +1024,7 @@ public: pcsUnmarshal->EmitRET(); } - DWORD dwJitFlags = CORJIT_FLG_IL_STUB; + CORJIT_FLAGS jitFlags(CORJIT_FLAGS::CORJIT_FLAG_IL_STUB); if (m_slIL.HasInteropParamExceptionInfo()) { @@ -1049,7 +1049,7 @@ public: else { // All other IL stubs will need to use the secret parameter. - dwJitFlags |= CORJIT_FLG_PUBLISH_SECRET_PARAM; + jitFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_PUBLISH_SECRET_PARAM); } if (SF_IsReverseStub(m_dwStubFlags)) @@ -1114,7 +1114,7 @@ public: m_slIL.GenerateCode(pbBuffer, cbCode); m_slIL.GetLocalSig(pbLocalSig, cbSig); - pResolver->SetJitFlags(dwJitFlags); + pResolver->SetJitFlags(jitFlags); #ifdef LOGGING LOG((LF_STUBS, LL_INFO1000, "---------------------------------------------------------------------\n")); @@ -1153,7 +1153,7 @@ public: LogILStubFlags(LF_STUBS, LL_INFO1000, m_dwStubFlags); - m_slIL.LogILStub(dwJitFlags); + m_slIL.LogILStub(jitFlags); } LOG((LF_STUBS, LL_INFO1000, "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n")); #endif // LOGGING @@ -1170,7 +1170,7 @@ public: pStubMD, pbLocalSig, cbSig, - dwJitFlags, + jitFlags, &convertToHRTryCatch, &cleanupTryFinally, maxStack, @@ -1188,7 +1188,7 @@ public: MethodDesc * pStubMD, PCCOR_SIGNATURE pbLocalSig, DWORD cbSig, - DWORD dwJitFlags, + CORJIT_FLAGS jitFlags, ILStubEHClause * pConvertToHRTryCatchBounds, ILStubEHClause * pCleanupTryFinallyBounds, DWORD maxStack, @@ -1256,7 +1256,7 @@ public: strILStubCode.AppendPrintf(W(".maxstack %d \n"), maxStack); strILStubCode.AppendPrintf(W(".locals %s\n"), strLocalSig.GetUnicode()); - m_slIL.LogILStub(dwJitFlags, &strILStubCode); + m_slIL.LogILStub(jitFlags, &strILStubCode); if (pConvertToHRTryCatchBounds->cbTryLength != 0 && pConvertToHRTryCatchBounds->cbHandlerLength != 0) { @@ -5947,8 +5947,8 @@ PCODE JitILStub(MethodDesc* pStubMD) // A dynamically generated IL stub // - DWORD dwFlags = pStubMD->AsDynamicMethodDesc()->GetILStubResolver()->GetJitFlags(); - pCode = pStubMD->MakeJitWorker(NULL, dwFlags, 0); + CORJIT_FLAGS jitFlags = pStubMD->AsDynamicMethodDesc()->GetILStubResolver()->GetJitFlags(); + pCode = pStubMD->MakeJitWorker(NULL, jitFlags); _ASSERTE(pCode == pStubMD->GetNativeCode()); } diff --git a/src/vm/dllimportcallback.cpp b/src/vm/dllimportcallback.cpp index 198a00795f..8db5a4fd48 100644 --- a/src/vm/dllimportcallback.cpp +++ b/src/vm/dllimportcallback.cpp @@ -1320,7 +1320,7 @@ MethodDesc* UMThunkMarshInfo::GetILStubMethodDesc(MethodDesc* pInvokeMD, PInvoke dwStubFlags |= NDIRECTSTUB_FL_REVERSE_INTEROP; // could be either delegate interop or not--that info is passed in from the caller #if defined(DEBUGGING_SUPPORTED) - if (GetDebuggerCompileFlags(pSigInfo->GetModule(), 0) & CORJIT_FLG_DEBUG_CODE) + if (GetDebuggerCompileFlags(pSigInfo->GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL; } @@ -1394,7 +1394,7 @@ VOID UMThunkMarshInfo::RunTimeInit() DWORD dwStubFlags = NDIRECTSTUB_FL_NGENEDSTUB | NDIRECTSTUB_FL_REVERSE_INTEROP | NDIRECTSTUB_FL_DELEGATE; #if defined(DEBUGGING_SUPPORTED) - if (GetDebuggerCompileFlags(GetModule(), 0) & CORJIT_FLG_DEBUG_CODE) + if (GetDebuggerCompileFlags(GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL; } diff --git a/src/vm/i386/cgenx86.cpp b/src/vm/i386/cgenx86.cpp index ff2f2df5a3..e200c19f65 100644 --- a/src/vm/i386/cgenx86.cpp +++ b/src/vm/i386/cgenx86.cpp @@ -1682,7 +1682,7 @@ void ResumeAtJit(PCONTEXT pContext, LPVOID oldESP) #pragma warning(push) #pragma warning(disable: 4035) -DWORD getcpuid(DWORD arg, unsigned char result[16]) +extern "C" DWORD __stdcall getcpuid(DWORD arg, unsigned char result[16]) { LIMITED_METHOD_CONTRACT @@ -1709,7 +1709,7 @@ DWORD getcpuid(DWORD arg, unsigned char result[16]) // Arg3 is a pointer to the return buffer // No need to check whether or not CPUID is supported because we have already called CPUID with success to come here. -DWORD getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16]) +extern "C" DWORD __stdcall getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16]) { LIMITED_METHOD_CONTRACT @@ -1730,6 +1730,27 @@ DWORD getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16]) } } +extern "C" DWORD __stdcall xmmYmmStateSupport() +{ + // No CONTRACT + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_GC_NOTRIGGER; + + __asm + { + mov ecx, 0 ; Specify xcr0 + xgetbv ; result in EDX:EAX + and eax, 06H + cmp eax, 06H ; check OS has enabled both XMM and YMM state support + jne not_supported + mov eax, 1 + jmp done + not_supported: + mov eax, 0 + done: + } +} + #pragma warning(pop) diff --git a/src/vm/ilstubcache.cpp b/src/vm/ilstubcache.cpp index 4343ba819f..9cd904aec7 100644 --- a/src/vm/ilstubcache.cpp +++ b/src/vm/ilstubcache.cpp @@ -128,7 +128,7 @@ MethodDesc* ILStubCache::CreateAndLinkNewILStubMethodDesc(LoaderAllocator* pAllo pStubLinker->GenerateCode(pbBuffer, cbCode); pStubLinker->GetLocalSig(pbLocalSig, cbSig); - pResolver->SetJitFlags(CORJIT_FLG_IL_STUB); + pResolver->SetJitFlags(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_IL_STUB)); } pResolver->SetTokenLookupMap(pStubLinker->GetTokenLookupMap()); diff --git a/src/vm/ilstubresolver.cpp b/src/vm/ilstubresolver.cpp index 64ff99f67e..5ba6c8a3b0 100644 --- a/src/vm/ilstubresolver.cpp +++ b/src/vm/ilstubresolver.cpp @@ -299,7 +299,7 @@ ILStubResolver::ILStubResolver() : m_pStubMD(dac_cast<PTR_MethodDesc>(nullptr)), m_pStubTargetMD(dac_cast<PTR_MethodDesc>(nullptr)), m_type(Unassigned), - m_dwJitFlags(0) + m_jitFlags() { LIMITED_METHOD_CONTRACT; @@ -488,16 +488,16 @@ bool ILStubResolver::IsILGenerated() return (dac_cast<TADDR>(m_pCompileTimeState) != ILNotYetGenerated); } -void ILStubResolver::SetJitFlags(DWORD dwFlags) +void ILStubResolver::SetJitFlags(CORJIT_FLAGS jitFlags) { LIMITED_METHOD_CONTRACT; - m_dwJitFlags = dwFlags; + m_jitFlags = jitFlags; } -DWORD ILStubResolver::GetJitFlags() +CORJIT_FLAGS ILStubResolver::GetJitFlags() { LIMITED_METHOD_CONTRACT; - return m_dwJitFlags; + return m_jitFlags; } // static diff --git a/src/vm/ilstubresolver.h b/src/vm/ilstubresolver.h index b100931107..47181c8a94 100644 --- a/src/vm/ilstubresolver.h +++ b/src/vm/ilstubresolver.h @@ -64,8 +64,8 @@ public: void SetTokenLookupMap(TokenLookupMap* pMap); - void SetJitFlags(DWORD dwJitFlags); - DWORD GetJitFlags(); + void SetJitFlags(CORJIT_FLAGS jitFlags); + CORJIT_FLAGS GetJitFlags(); static void StubGenFailed(ILStubResolver* pResolver); @@ -116,7 +116,7 @@ protected: PTR_MethodDesc m_pStubMD; PTR_MethodDesc m_pStubTargetMD; ILStubType m_type; - DWORD m_dwJitFlags; + CORJIT_FLAGS m_jitFlags; }; typedef Holder<ILStubResolver*, DoNothing<ILStubResolver*>, ILStubResolver::StubGenFailed, NULL> ILStubGenHolder; diff --git a/src/vm/interpreter.cpp b/src/vm/interpreter.cpp index ed289cb3cc..d92bf16ace 100644 --- a/src/vm/interpreter.cpp +++ b/src/vm/interpreter.cpp @@ -1736,13 +1736,13 @@ void Interpreter::JitMethodIfAppropriate(InterpreterMethodInfo* interpMethInfo, fprintf(GetLogFile(), "JITting method %s:%s.\n", md->m_pszDebugClassName, md->m_pszDebugMethodName); } #endif // _DEBUG - DWORD dwFlags = CORJIT_FLG_MAKEFINALCODE; + CORJIT_FLAGS jitFlags(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE); NewHolder<COR_ILMETHOD_DECODER> pDecoder(NULL); // Dynamic methods (e.g., IL stubs) do not have an IL decoder but may // require additional flags. Ordinary methods require the opposite. if (md->IsDynamicMethod()) { - dwFlags |= md->AsDynamicMethodDesc()->GetILStubResolver()->GetJitFlags(); + jitFlags.Add(md->AsDynamicMethodDesc()->GetILStubResolver()->GetJitFlags()); } else { @@ -1751,7 +1751,7 @@ void Interpreter::JitMethodIfAppropriate(InterpreterMethodInfo* interpMethInfo, md->GetMDImport(), &status); } - PCODE res = md->MakeJitWorker(pDecoder, dwFlags, 0); + PCODE res = md->MakeJitWorker(pDecoder, jitFlags); interpMethInfo->m_jittedCode = res; } } diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index a2485a4417..0ac9bd9373 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -7394,7 +7394,7 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller, // If the callee wants debuggable code, don't allow it to be inlined - if (GetDebuggerCompileFlags(pCallee->GetModule(), 0) & CORJIT_FLG_DEBUG_CODE) + if (GetDebuggerCompileFlags(pCallee->GetModule(), CORJIT_FLAGS()).IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { result = INLINE_NEVER; szFailReason = "Inlinee is debuggable"; @@ -9112,7 +9112,7 @@ CorInfoTypeWithMod CEEInfo::getArgType ( CorElementType normType = typeHnd.GetInternalCorElementType(); // if we are looking up a value class, don't morph it to a refernece type - // (This can only happen in illegal IL + // (This can only happen in illegal IL) if (!CorTypeInfo::IsObjRef(normType) || type != ELEMENT_TYPE_VALUETYPE) { type = normType; @@ -11686,8 +11686,7 @@ static CorJitResult CompileMethodWithEtwWrapper(EEJitManager *jitMgr, CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, CEEInfo *comp, struct CORINFO_METHOD_INFO *info, - unsigned flags, - unsigned flags2, + CORJIT_FLAGS jitFlags, BYTE **nativeEntry, ULONG *nativeSizeOfCode) { @@ -11698,13 +11697,9 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, CorJitResult ret = CORJIT_SKIPPED; // Note that CORJIT_SKIPPED is an error exit status code - CORJIT_FLAGS jitFlags = { 0 }; - jitFlags.corJitFlags = flags; - jitFlags.corJitFlags2 = flags2; - #if !defined(FEATURE_CORECLR) // Ask the JIT to generate desktop-quirk-compatible code. - jitFlags.corJitFlags2 |= CORJIT_FLG2_DESKTOP_QUIRKS; + jitFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_DESKTOP_QUIRKS); #endif comp->setJitFlags(jitFlags); @@ -11720,7 +11715,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, #if defined(CROSSGEN_COMPILE) && !defined(FEATURE_CORECLR) ret = getJit()->compileMethod( comp, info, - CORJIT_FLG_CALL_GETJITFLAGS, + CORJIT_FLAGS::CORJIT_FLAG_CALL_GETJITFLAGS, nativeEntry, nativeSizeOfCode); @@ -11729,18 +11724,18 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, #if defined(ALLOW_SXS_JIT) && !defined(CROSSGEN_COMPILE) if (FAILED(ret) && jitMgr->m_alternateJit #ifdef FEATURE_STACK_SAMPLING - && (!samplingEnabled || (jitFlags.corJitFlags2 & CORJIT_FLG2_SAMPLING_JIT_BACKGROUND)) + && (!samplingEnabled || (jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND))) #endif ) { ret = jitMgr->m_alternateJit->compileMethod( comp, info, - CORJIT_FLG_CALL_GETJITFLAGS, + CORJIT_FLAGS::CORJIT_FLAG_CALL_GETJITFLAGS, nativeEntry, nativeSizeOfCode ); #ifdef FEATURE_STACK_SAMPLING - if (jitFlags.corJitFlags2 & CORJIT_FLG2_SAMPLING_JIT_BACKGROUND) + if (jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND)) { // Don't bother with failures if we couldn't collect a trace. ret = CORJIT_OK; @@ -11767,7 +11762,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, { // If we're doing an "import_only" compilation, it's for verification, so don't interpret. // (We assume that importation is completely architecture-independent, or at least nearly so.) - if (FAILED(ret) && (jitFlags.corJitFlags & (CORJIT_FLG_IMPORT_ONLY | CORJIT_FLG_MAKEFINALCODE)) == 0) + if (FAILED(ret) && !jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) && !jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE)) { ret = Interpreter::GenerateInterpreterStub(comp, info, nativeEntry, nativeSizeOfCode); } @@ -11778,7 +11773,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, ret = CompileMethodWithEtwWrapper(jitMgr, comp, info, - CORJIT_FLG_CALL_GETJITFLAGS, + CORJIT_FLAGS::CORJIT_FLAG_CALL_GETJITFLAGS, nativeEntry, nativeSizeOfCode); } @@ -11787,7 +11782,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, { // If we're doing an "import_only" compilation, it's for verification, so don't interpret. // (We assume that importation is completely architecture-independent, or at least nearly so.) - if (FAILED(ret) && (jitFlags.corJitFlags & (CORJIT_FLG_IMPORT_ONLY | CORJIT_FLG_MAKEFINALCODE)) == 0) + if (FAILED(ret) && !jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) && !jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE)) { ret = Interpreter::GenerateInterpreterStub(comp, info, nativeEntry, nativeSizeOfCode); } @@ -11797,7 +11792,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, { ret = jitMgr->m_jit->compileMethod( comp, info, - CORJIT_FLG_CALL_GETJITFLAGS, + CORJIT_FLAGS::CORJIT_FLAG_CALL_GETJITFLAGS, nativeEntry, nativeSizeOfCode); } @@ -11809,7 +11804,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, // If the JIT fails we keep the IL around and will // try reJIT the same IL. VSW 525059 // - if (SUCCEEDED(ret) && !(jitFlags.corJitFlags & CORJIT_FLG_IMPORT_ONLY) && !((CEEJitInfo*)comp)->JitAgain()) + if (SUCCEEDED(ret) && !jitFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) && !((CEEJitInfo*)comp)->JitAgain()) { ((CEEJitInfo*)comp)->CompressDebugInfo(); @@ -11842,8 +11837,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr, CorJitResult invokeCompileMethod(EEJitManager *jitMgr, CEEInfo *comp, struct CORINFO_METHOD_INFO *info, - unsigned flags, - unsigned flags2, + CORJIT_FLAGS jitFlags, BYTE **nativeEntry, ULONG *nativeSizeOfCode) { @@ -11858,7 +11852,7 @@ CorJitResult invokeCompileMethod(EEJitManager *jitMgr, GCX_PREEMP(); - CorJitResult ret = invokeCompileMethodHelper(jitMgr, comp, info, flags, flags2, nativeEntry, nativeSizeOfCode); + CorJitResult ret = invokeCompileMethodHelper(jitMgr, comp, info, jitFlags, nativeEntry, nativeSizeOfCode); // // Verify that we are still in preemptive mode when we return @@ -11870,9 +11864,9 @@ CorJitResult invokeCompileMethod(EEJitManager *jitMgr, return ret; } -CorJitFlag GetCompileFlagsIfGenericInstantiation( +CORJIT_FLAGS GetCompileFlagsIfGenericInstantiation( CORINFO_METHOD_HANDLE method, - CorJitFlag compileFlags, + CORJIT_FLAGS compileFlags, ICorJitInfo * pCorJitInfo, BOOL * raiseVerificationException, BOOL * unverifiableGenericCode); @@ -11880,8 +11874,7 @@ CorJitFlag GetCompileFlagsIfGenericInstantiation( CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, CEEInfo *comp, struct CORINFO_METHOD_INFO *info, - unsigned flags, - unsigned flags2, + CORJIT_FLAGS flags, BYTE **nativeEntry, ULONG *nativeSizeOfCode, MethodDesc *ftn) @@ -11897,8 +11890,7 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, EEJitManager *jitMgr; CEEInfo *comp; struct CORINFO_METHOD_INFO *info; - unsigned flags; - unsigned flags2; + CORJIT_FLAGS flags; BYTE **nativeEntry; ULONG *nativeSizeOfCode; MethodDesc *ftn; @@ -11908,7 +11900,6 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, param.comp = comp; param.info = info; param.flags = flags; - param.flags2 = flags2; param.nativeEntry = nativeEntry; param.nativeSizeOfCode = nativeSizeOfCode; param.ftn = ftn; @@ -11924,16 +11915,16 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, pParam->comp, pParam->info, pParam->flags, - pParam->flags2, pParam->nativeEntry, pParam->nativeSizeOfCode); } PAL_FINALLY { #if defined(DEBUGGING_SUPPORTED) && !defined(CROSSGEN_COMPILE) - if (!(flags & (CORJIT_FLG_IMPORT_ONLY | CORJIT_FLG_MCJIT_BACKGROUND)) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) && + !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND) #ifdef FEATURE_STACK_SAMPLING - && !(flags2 & CORJIT_FLG2_SAMPLING_JIT_BACKGROUND) + && !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND) #endif // FEATURE_STACK_SAMPLING ) { @@ -11971,7 +11962,7 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, /*********************************************************************/ // Figures out the compile flags that are used by both JIT and NGen -/* static */ DWORD CEEInfo::GetBaseCompileFlags(MethodDesc * ftn) +/* static */ CORJIT_FLAGS CEEInfo::GetBaseCompileFlags(MethodDesc * ftn) { CONTRACTL { THROWS; @@ -11982,16 +11973,16 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, // Figure out the code quality flags // - DWORD flags = 0; + CORJIT_FLAGS flags; if (g_pConfig->JitFramed()) - flags |= CORJIT_FLG_FRAMED; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_FRAMED); if (g_pConfig->JitAlignLoops()) - flags |= CORJIT_FLG_ALIGN_LOOPS; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_ALIGN_LOOPS); if (ReJitManager::IsReJITEnabled() || g_pConfig->AddRejitNops()) - flags |= CORJIT_FLG_PROF_REJIT_NOPS; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_PROF_REJIT_NOPS); #ifdef _TARGET_X86_ if (g_pConfig->PInvokeRestoreEsp(ftn->GetModule()->IsPreV4Assembly())) - flags |= CORJIT_FLG_PINVOKE_RESTORE_ESP; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_PINVOKE_RESTORE_ESP); #endif // _TARGET_X86_ //See if we should instruct the JIT to emit calls to JIT_PollGC for thread suspension. If we have a @@ -11999,9 +11990,9 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, #ifdef FEATURE_ENABLE_GCPOLL EEConfig::GCPollType pollType = g_pConfig->GetGCPollType(); if (EEConfig::GCPOLL_TYPE_POLL == pollType) - flags |= CORJIT_FLG_GCPOLL_CALLS; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_GCPOLL_CALLS); else if (EEConfig::GCPOLL_TYPE_INLINE == pollType) - flags |= CORJIT_FLG_GCPOLL_INLINE; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_GCPOLL_INLINE); #endif //FEATURE_ENABLE_GCPOLL // Set flags based on method's ImplFlags. @@ -12012,13 +12003,13 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, if (IsMiNoOptimization(dwImplFlags)) { - flags |= CORJIT_FLG_MIN_OPT; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MIN_OPT); } // Always emit frames for methods marked no-inline (see #define ETW_EBP_FRAMED in the JIT) if (IsMiNoInlining(dwImplFlags)) { - flags |= CORJIT_FLG_FRAMED; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_FRAMED); } } @@ -12029,7 +12020,7 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr, // Figures out (some of) the flags to use to compile the method // Returns the new set to use -DWORD GetDebuggerCompileFlags(Module* pModule, DWORD flags) +CORJIT_FLAGS GetDebuggerCompileFlags(Module* pModule, CORJIT_FLAGS flags) { STANDARD_VM_CONTRACT; @@ -12044,36 +12035,37 @@ DWORD GetDebuggerCompileFlags(Module* pModule, DWORD flags) #ifdef _DEBUG if (g_pConfig->GenDebuggableCode()) - flags |= CORJIT_FLG_DEBUG_CODE; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE); #endif // _DEBUG #ifdef EnC_SUPPORTED if (pModule->IsEditAndContinueEnabled()) { - flags |= CORJIT_FLG_DEBUG_EnC; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_EnC); } #endif // EnC_SUPPORTED // Debug info is always tracked - flags |= CORJIT_FLG_DEBUG_INFO; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_INFO); #endif // DEBUGGING_SUPPORTED if (CORDisableJITOptimizations(pModule->GetDebuggerInfoBits())) { - flags |= CORJIT_FLG_DEBUG_CODE; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE); } - if (flags & CORJIT_FLG_IMPORT_ONLY) + if (flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)) { // If we are only verifying the method, dont need any debug info and this // prevents getVars()/getBoundaries() from being called unnecessarily. - flags &= ~(CORJIT_FLG_DEBUG_INFO|CORJIT_FLG_DEBUG_CODE); + flags.Clear(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_INFO); + flags.Clear(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE); } return flags; } -CorJitFlag GetCompileFlags(MethodDesc * ftn, DWORD flags, CORINFO_METHOD_INFO * methodInfo) +CORJIT_FLAGS GetCompileFlags(MethodDesc * ftn, CORJIT_FLAGS flags, CORINFO_METHOD_INFO * methodInfo) { STANDARD_VM_CONTRACT; @@ -12082,14 +12074,14 @@ CorJitFlag GetCompileFlags(MethodDesc * ftn, DWORD flags, CORINFO_METHOD_INFO * // // Get the compile flags that are shared between JIT and NGen // - flags |= CEEInfo::GetBaseCompileFlags(ftn); + flags.Add(CEEInfo::GetBaseCompileFlags(ftn)); // // Get CPU specific flags // - if ((flags & CORJIT_FLG_IMPORT_ONLY) == 0) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)) { - flags |= ExecutionManager::GetEEJitManager()->GetCPUCompileFlags(); + flags.Add(ExecutionManager::GetEEJitManager()->GetCPUCompileFlags()); } // @@ -12097,21 +12089,19 @@ CorJitFlag GetCompileFlags(MethodDesc * ftn, DWORD flags, CORINFO_METHOD_INFO * // #ifdef DEBUGGING_SUPPORTED - flags |= GetDebuggerCompileFlags(ftn->GetModule(), flags); + flags.Add(GetDebuggerCompileFlags(ftn->GetModule(), flags)); #endif #ifdef PROFILING_SUPPORTED - if (CORProfilerTrackEnterLeave() - && !ftn->IsNoMetadata() - ) - flags |= CORJIT_FLG_PROF_ENTERLEAVE; + if (CORProfilerTrackEnterLeave() && !ftn->IsNoMetadata()) + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_PROF_ENTERLEAVE); if (CORProfilerTrackTransitions()) - flags |= CORJIT_FLG_PROF_NO_PINVOKE_INLINE; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_PROF_NO_PINVOKE_INLINE); #endif // PROFILING_SUPPORTED // Set optimization flags - if (0 == (flags & CORJIT_FLG_MIN_OPT)) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MIN_OPT)) { unsigned optType = g_pConfig->GenOptimizeType(); _ASSERTE(optType <= OPT_RANDOM); @@ -12120,18 +12110,16 @@ CorJitFlag GetCompileFlags(MethodDesc * ftn, DWORD flags, CORINFO_METHOD_INFO * optType = methodInfo->ILCodeSize % OPT_RANDOM; if (g_pConfig->JitMinOpts()) - flags |= CORJIT_FLG_MIN_OPT; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MIN_OPT); - const static unsigned optTypeFlags[] = + if (optType == OPT_SIZE) { - 0, // OPT_BLENDED - CORJIT_FLG_SIZE_OPT, // OPT_CODE_SIZE - CORJIT_FLG_SPEED_OPT // OPT_CODE_SPEED - }; - - _ASSERTE(optType < OPT_RANDOM); - _ASSERTE((sizeof(optTypeFlags)/sizeof(optTypeFlags[0])) == OPT_RANDOM); - flags |= optTypeFlags[optType]; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_SIZE_OPT); + } + else if (optType == OPT_SPEED) + { + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_SPEED_OPT); + } } // @@ -12140,22 +12128,21 @@ CorJitFlag GetCompileFlags(MethodDesc * ftn, DWORD flags, CORINFO_METHOD_INFO * #ifdef _DEBUG if (g_pConfig->IsJitVerificationDisabled()) - flags |= CORJIT_FLG_SKIP_VERIFICATION; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION); #endif // _DEBUG - if ((flags & CORJIT_FLG_IMPORT_ONLY) == 0 && - Security::CanSkipVerification(ftn)) - flags |= CORJIT_FLG_SKIP_VERIFICATION; + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) && Security::CanSkipVerification(ftn)) + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION); if (ftn->IsILStub()) { - flags |= CORJIT_FLG_SKIP_VERIFICATION; + flags.Set(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION); // no debug info available for IL stubs - flags &= ~CORJIT_FLG_DEBUG_INFO; + flags.Clear(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_INFO); } - return (CorJitFlag)flags; + return flags; } #if defined(_WIN64) @@ -12165,12 +12152,12 @@ CorJitFlag GetCompileFlags(MethodDesc * ftn, DWORD flags, CORINFO_METHOD_INFO * // //This only works for real methods. If the method isn't IsIL, then IsVerifiable will AV. That would be a //bad thing (TM). -BOOL IsTransparentMethodSafeToSkipVerification(CorJitFlag flags, MethodDesc * ftn) +BOOL IsTransparentMethodSafeToSkipVerification(CORJIT_FLAGS flags, MethodDesc * ftn) { STANDARD_VM_CONTRACT; BOOL ret = FALSE; - if (!(flags & CORJIT_FLG_IMPORT_ONLY) && !(flags & CORJIT_FLG_SKIP_VERIFICATION) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) && !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION) && Security::IsMethodTransparent(ftn) && ((ftn->IsIL() && !ftn->IsUnboxingStub()) || (ftn->IsDynamicMethod() && !ftn->IsILStub()))) @@ -12200,9 +12187,9 @@ BOOL IsTransparentMethodSafeToSkipVerification(CorJitFlag flags, MethodDesc * ft // failed, then we need to throw an exception whenever we try // to compile a real instantiation -CorJitFlag GetCompileFlagsIfGenericInstantiation( +CORJIT_FLAGS GetCompileFlagsIfGenericInstantiation( CORINFO_METHOD_HANDLE method, - CorJitFlag compileFlags, + CORJIT_FLAGS compileFlags, ICorJitInfo * pCorJitInfo, BOOL * raiseVerificationException, BOOL * unverifiableGenericCode) @@ -12213,7 +12200,7 @@ CorJitFlag GetCompileFlagsIfGenericInstantiation( *unverifiableGenericCode = FALSE; // If we have already decided to skip verification, keep on going. - if (compileFlags & CORJIT_FLG_SKIP_VERIFICATION) + if (compileFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION)) return compileFlags; CorInfoInstantiationVerification ver = pCorJitInfo->isInstantiationOfVerifiedGeneric(method); @@ -12223,13 +12210,14 @@ CorJitFlag GetCompileFlagsIfGenericInstantiation( case INSTVER_NOT_INSTANTIATION: // Non-generic, or open instantiation of a generic type/method if (IsTransparentMethodSafeToSkipVerification(compileFlags, (MethodDesc*)method)) - compileFlags = (CorJitFlag)(compileFlags | CORJIT_FLG_SKIP_VERIFICATION); + compileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION); return compileFlags; case INSTVER_GENERIC_PASSED_VERIFICATION: // If the typical instantiation is verifiable, there is no need // to verify the concrete instantiations - return (CorJitFlag)(compileFlags | CORJIT_FLG_SKIP_VERIFICATION); + compileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION); + return compileFlags; case INSTVER_GENERIC_FAILED_VERIFICATION: @@ -12255,9 +12243,9 @@ CorJitFlag GetCompileFlagsIfGenericInstantiation( // hits unverifiable code. Since we've already hit unverifiable code, // there's no point in starting the JIT, just to have it give up, so we // give up here. - _ASSERTE(compileFlags & CORJIT_FLG_PREJIT); + _ASSERTE(compileFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_PREJIT)); *raiseVerificationException = TRUE; - return (CorJitFlag)-1; // This value will not be used + return CORJIT_FLAGS(); // This value will not be used } #else // FEATURE_PREJIT // Need to have this case here to keep the MAC build happy @@ -12276,17 +12264,18 @@ CorJitFlag GetCompileFlagsIfGenericInstantiation( // branches while compiling the concrete instantiation. Instead, // just throw a VerificationException right away. *raiseVerificationException = TRUE; - return (CorJitFlag)-1; // This value will not be used + return CORJIT_FLAGS(); // This value will not be used } case CORINFO_VERIFICATION_CAN_SKIP: { - return (CorJitFlag)(compileFlags | CORJIT_FLG_SKIP_VERIFICATION); + compileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION); + return compileFlags; } case CORINFO_VERIFICATION_RUNTIME_CHECK: { - // Compile the method without CORJIT_FLG_SKIP_VERIFICATION. + // Compile the method without CORJIT_FLAG_SKIP_VERIFICATION. // The compiler will know to add a call to // CORINFO_HELP_VERIFICATION_RUNTIME_CHECK, and then to skip verification. return compileFlags; @@ -12361,8 +12350,8 @@ BOOL g_fAllowRel32 = TRUE; // Calls to this method that occur to check if inlining can occur on x86, // are OK since they discard the return value of this method. -PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, - DWORD flags, DWORD flags2, ULONG * pSizeOfCode) +PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS flags, + ULONG * pSizeOfCode) { STANDARD_VM_CONTRACT; @@ -12376,9 +12365,9 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, ftn->GetModule()->GetDomainFile()->IsZapRequired() && PartialNGenStressPercentage() == 0 && #ifdef FEATURE_STACK_SAMPLING - !(flags2 & CORJIT_FLG2_SAMPLING_JIT_BACKGROUND) && + !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND) && #endif - !(flags & CORJIT_FLG_IMPORT_ONLY)) + !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)) { StackSString ss(SString::Ascii, "ZapRequire: JIT compiler invoked for "); TypeString::AppendMethodInternal(ss, ftn); @@ -12468,10 +12457,10 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, getMethodInfoHelper(ftn, ftnHnd, ILHeader, &methodInfo); // If it's generic then we can only enter through an instantiated md (unless we're just verifying it) - _ASSERTE((flags & CORJIT_FLG_IMPORT_ONLY) != 0 || !ftn->IsGenericMethodDefinition()); + _ASSERTE(flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) || !ftn->IsGenericMethodDefinition()); // If it's an instance method then it must not be entered from a generic class - _ASSERTE((flags & CORJIT_FLG_IMPORT_ONLY) != 0 || ftn->IsStatic() || + _ASSERTE(flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) || ftn->IsStatic() || ftn->GetNumGenericClassArgs() == 0 || ftn->HasClassInstantiation()); // method attributes and signature are consistant @@ -12480,7 +12469,7 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, flags = GetCompileFlags(ftn, flags, &methodInfo); #ifdef _DEBUG - if (!(flags & CORJIT_FLG_SKIP_VERIFICATION)) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION)) { SString methodString; if (LoggingOn(LF_VERIFIER, LL_INFO100)) @@ -12512,10 +12501,10 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, for (;;) { #ifndef CROSSGEN_COMPILE - CEEJitInfo jitInfo(ftn, ILHeader, jitMgr, (flags & CORJIT_FLG_IMPORT_ONLY) != 0); + CEEJitInfo jitInfo(ftn, ILHeader, jitMgr, flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)); #else // This path should be only ever used for verification in crossgen and so we should not need EEJitManager - _ASSERTE((flags & CORJIT_FLG_IMPORT_ONLY) != 0); + _ASSERTE(flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)); CEEInfo jitInfo(ftn, true); EEJitManager *jitMgr = NULL; #endif @@ -12574,7 +12563,7 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, flags = GetCompileFlagsIfGenericInstantiation( ftnHnd, - (CorJitFlag)flags, + flags, &jitInfo, &raiseVerificationException, &unverifiableGenericCode); @@ -12595,7 +12584,7 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, #ifdef PERF_TRACK_METHOD_JITTIMES //Because we're not calling QPC enough. I'm not going to track times if we're just importing. LARGE_INTEGER methodJitTimeStart = {0}; - if (!(flags & CORJIT_FLG_IMPORT_ONLY)) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)) QueryPerformanceCounter (&methodJitTimeStart); #endif @@ -12615,7 +12604,6 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, &jitInfo, &methodInfo, flags, - flags2, &nativeEntry, &sizeOfCode, (MethodDesc*)ftn); @@ -12646,7 +12634,7 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, #ifdef PERF_TRACK_METHOD_JITTIMES //store the time in the string buffer. Module name and token are unique enough. Also, do not //capture importing time, just actual compilation time. - if (!(flags & CORJIT_FLG_IMPORT_ONLY)) + if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)) { LARGE_INTEGER methodJitTimeStop; QueryPerformanceCounter(&methodJitTimeStop); @@ -12677,7 +12665,7 @@ PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* ILHeader, ThrowExceptionForJit(res); } - if (flags & CORJIT_FLG_IMPORT_ONLY) + if (flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)) { // The method must been processed by the verifier. Note that it may // either have been marked as verifiable or unverifiable. diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h index 41d0f6221d..1a7f643381 100644 --- a/src/vm/jitinterface.h +++ b/src/vm/jitinterface.h @@ -54,7 +54,7 @@ void InitJITHelpers1(); void InitJITHelpers2(); PCODE UnsafeJitFunction(MethodDesc* ftn, COR_ILMETHOD_DECODER* header, - DWORD flags, DWORD flags2, ULONG* sizeOfCode = NULL); + CORJIT_FLAGS flags, ULONG* sizeOfCode = NULL); void getMethodInfoHelper(MethodDesc * ftn, CORINFO_METHOD_HANDLE ftnHnd, @@ -647,7 +647,7 @@ public: ); // Returns that compilation flags that are shared between JIT and NGen - static DWORD GetBaseCompileFlags(MethodDesc * ftn); + static CORJIT_FLAGS GetBaseCompileFlags(MethodDesc * ftn); // Resolve metadata token into runtime method handles. void resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken); @@ -1691,7 +1691,7 @@ public: static FCDECL3(void, UnsafeSetArrayElement, PtrArray* pPtrArray, INT32 index, Object* object); }; -DWORD GetDebuggerCompileFlags(Module* pModule, DWORD flags); +CORJIT_FLAGS GetDebuggerCompileFlags(Module* pModule, CORJIT_FLAGS flags); bool TrackAllocationsEnabled(); diff --git a/src/vm/method.cpp b/src/vm/method.cpp index 70714b710d..14651239a7 100644 --- a/src/vm/method.cpp +++ b/src/vm/method.cpp @@ -1078,7 +1078,7 @@ BOOL MethodDesc::IsVerifiable() #endif // _VER_EE_VERIFICATION_ENABLED } - UnsafeJitFunction(this, pHeader, CORJIT_FLG_IMPORT_ONLY, 0); + UnsafeJitFunction(this, pHeader, CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY)); _ASSERTE(IsVerified()); return (IsVerified() && (m_wFlags & mdcVerifiable)); diff --git a/src/vm/method.hpp b/src/vm/method.hpp index d96cddc315..499112d149 100644 --- a/src/vm/method.hpp +++ b/src/vm/method.hpp @@ -1649,7 +1649,7 @@ public: PCODE DoPrestub(MethodTable *pDispatchingMT); - PCODE MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, DWORD flags, DWORD flags2); + PCODE MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS flags); VOID GetMethodInfo(SString &namespaceOrClassName, SString &methodName, SString &methodSignature); VOID GetMethodInfoWithNewSig(SString &namespaceOrClassName, SString &methodName, SString &methodSignature); diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp index 70c0e3b8cb..bb8717780d 100644 --- a/src/vm/methodtablebuilder.cpp +++ b/src/vm/methodtablebuilder.cpp @@ -1245,8 +1245,8 @@ BOOL MethodTableBuilder::CheckIfSIMDAndUpdateSize() EEJitManager *jitMgr = ExecutionManager::GetEEJitManager(); if (jitMgr->LoadJIT()) { - DWORD cpuCompileFlags = jitMgr->GetCPUCompileFlags(); - if ((cpuCompileFlags & CORJIT_FLG_FEATURE_SIMD) != 0) + CORJIT_FLAGS cpuCompileFlags = jitMgr->GetCPUCompileFlags(); + if (cpuCompileFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_FEATURE_SIMD)) { unsigned intrinsicSIMDVectorLength = jitMgr->m_jit->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags); if (intrinsicSIMDVectorLength != 0) diff --git a/src/vm/multicorejitplayer.cpp b/src/vm/multicorejitplayer.cpp index 0c69fdcf94..7d13bbc462 100644 --- a/src/vm/multicorejitplayer.cpp +++ b/src/vm/multicorejitplayer.cpp @@ -556,7 +556,7 @@ bool MulticoreJitProfilePlayer::CompileMethodDesc(Module * pModule, MethodDesc * #endif // MakeJitWorker calls back to MulticoreJitCodeStorage::StoreMethodCode under MethodDesc lock - pMD->MakeJitWorker(& header, CORJIT_FLG_MCJIT_BACKGROUND, 0); + pMD->MakeJitWorker(& header, CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND)); return true; } diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp index 572065ce4c..f75ef1411c 100644 --- a/src/vm/prestub.cpp +++ b/src/vm/prestub.cpp @@ -256,7 +256,7 @@ void DACNotifyCompilationFinished(MethodDesc *methodDesc) // which prevents us from trying to JIT the same method more that once. -PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, DWORD flags, DWORD flags2) +PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS flags) { STANDARD_VM_CONTRACT; @@ -280,7 +280,7 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, DWORD flags, DWO #ifdef FEATURE_MULTICOREJIT MulticoreJitManager & mcJitManager = GetAppDomain()->GetMulticoreJitManager(); - bool fBackgroundThread = (flags & CORJIT_FLG_MCJIT_BACKGROUND) != 0; + bool fBackgroundThread = flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND); #endif { @@ -461,13 +461,13 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, DWORD flags, DWO if (!fBackgroundThread) #endif // FEATURE_MULTICOREJIT { - StackSampler::RecordJittingInfo(this, flags, flags2); + StackSampler::RecordJittingInfo(this, flags); } #endif // FEATURE_STACK_SAMPLING EX_TRY { - pCode = UnsafeJitFunction(this, ILHeader, flags, flags2, &sizeOfCode); + pCode = UnsafeJitFunction(this, ILHeader, flags, &sizeOfCode); } EX_CATCH { @@ -1463,7 +1463,7 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT) // Mark the code as hot in case the method ends up in the native image g_IBCLogger.LogMethodCodeAccess(this); - pCode = MakeJitWorker(pHeader, 0, 0); + pCode = MakeJitWorker(pHeader, CORJIT_FLAGS()); #ifdef FEATURE_INTERPRETER if ((pCode != NULL) && !HasStableEntryPoint()) diff --git a/src/vm/rejit.cpp b/src/vm/rejit.cpp index 6b3caa9091..0b6e922831 100644 --- a/src/vm/rejit.cpp +++ b/src/vm/rejit.cpp @@ -178,22 +178,22 @@ CrstStatic ReJitManager::s_csGlobalRequest; //--------------------------------------------------------------------------------------- // Helpers -inline DWORD JitFlagsFromProfCodegenFlags(DWORD dwCodegenFlags) +inline CORJIT_FLAGS JitFlagsFromProfCodegenFlags(DWORD dwCodegenFlags) { LIMITED_METHOD_DAC_CONTRACT; - DWORD jitFlags = 0; + CORJIT_FLAGS jitFlags; // Note: COR_PRF_CODEGEN_DISABLE_INLINING is checked in // code:CEEInfo::canInline#rejit (it has no equivalent CORJIT flag). if ((dwCodegenFlags & COR_PRF_CODEGEN_DISABLE_ALL_OPTIMIZATIONS) != 0) { - jitFlags |= CORJIT_FLG_DEBUG_CODE; + jitFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE); } // In the future more flags may be added that need to be converted here (e.g., - // COR_PRF_CODEGEN_ENTERLEAVE / CORJIT_FLG_PROF_ENTERLEAVE) + // COR_PRF_CODEGEN_ENTERLEAVE / CORJIT_FLAG_PROF_ENTERLEAVE) return jitFlags; } @@ -2170,8 +2170,7 @@ PCODE ReJitManager::DoReJit(ReJitInfo * pInfo) pCodeOfRejittedCode = UnsafeJitFunction( pInfo->GetMethodDesc(), &ILHeader, - JitFlagsFromProfCodegenFlags(pInfo->m_pShared->m_dwCodegenFlags), - 0); + JitFlagsFromProfCodegenFlags(pInfo->m_pShared->m_dwCodegenFlags)); _ASSERTE(pCodeOfRejittedCode != NULL); diff --git a/src/vm/stacksampler.cpp b/src/vm/stacksampler.cpp index 270d278b66..d95adb1f63 100644 --- a/src/vm/stacksampler.cpp +++ b/src/vm/stacksampler.cpp @@ -154,7 +154,7 @@ bool IsGoodMethodDesc(MethodDesc* pMD) // // An opportunity to record the parameters passed to the JIT at the time of JITting this method. /* static */ -void StackSampler::RecordJittingInfo(MethodDesc* pMD, DWORD dwFlags, DWORD dwFlags2) +void StackSampler::RecordJittingInfo(MethodDesc* pMD, CORJIT_FLAGS flags) { WRAPPER_NO_CONTRACT; if (g_pStackSampler == nullptr) @@ -167,10 +167,10 @@ void StackSampler::RecordJittingInfo(MethodDesc* pMD, DWORD dwFlags, DWORD dwFla return; } // Record in the hash map. - g_pStackSampler->RecordJittingInfoInternal(pMD, dwFlags); + g_pStackSampler->RecordJittingInfoInternal(pMD, flags); } -void StackSampler::RecordJittingInfoInternal(MethodDesc* pMD, DWORD dwFlags) +void StackSampler::RecordJittingInfoInternal(MethodDesc* pMD, CORJIT_FLAGS flags) { ADID dwDomainId = GetThread()->GetDomain()->GetId(); JitInfoHashEntry entry(pMD, dwDomainId); @@ -426,7 +426,7 @@ void StackSampler::JitAndCollectTrace(MethodDesc* pMD, const ADID& adId) // Indicate to the JIT or the JIT interface that we are JITting // in the background for stack sampling. - DWORD dwFlags2 = CORJIT_FLG2_SAMPLING_JIT_BACKGROUND; + CORJIT_FLAGS flags(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND); _ASSERTE(pMD->IsIL()); @@ -447,7 +447,7 @@ void StackSampler::JitAndCollectTrace(MethodDesc* pMD, const ADID& adId) LOG((LF_JIT, LL_INFO100000, "%s:%s\n", pMD->GetMethodTable()->GetClass()->GetDebugClassName(), pMD->GetName())); #endif - PCODE pCode = UnsafeJitFunction(pMD, pDecoder, 0, dwFlags2); + PCODE pCode = UnsafeJitFunction(pMD, pDecoder, flags); } END_DOMAIN_TRANSITION; diff --git a/src/vm/stacksampler.h b/src/vm/stacksampler.h index 33fc6b93ce..0b9add1713 100644 --- a/src/vm/stacksampler.h +++ b/src/vm/stacksampler.h @@ -21,7 +21,7 @@ class StackSampler public: // Interface static void Init(); - static void RecordJittingInfo(MethodDesc* pMD, DWORD dwFlags, DWORD dwFlags2); + static void RecordJittingInfo(MethodDesc* pMD, CORJIT_FLAGS flags); private: @@ -41,7 +41,7 @@ private: void JitAndCollectTrace(MethodDesc* pMD, const ADID& adId); - void RecordJittingInfoInternal(MethodDesc* pMD, DWORD flags); + void RecordJittingInfoInternal(MethodDesc* pMD, CORJIT_FLAGS flags); ADID GetDomainId(MethodDesc* pMD, const ADID& defaultId); diff --git a/src/vm/stubgen.cpp b/src/vm/stubgen.cpp index fffa52a366..18a6c19480 100644 --- a/src/vm/stubgen.cpp +++ b/src/vm/stubgen.cpp @@ -631,15 +631,7 @@ ILStubLinker::LogILStubWorker( } } -static inline void LogOneFlag(DWORD flags, DWORD flag, LPCSTR str, DWORD facility, DWORD level) -{ - if (flags & flag) - { - LOG((facility, level, str)); - } -} - -static void LogJitFlags(DWORD facility, DWORD level, DWORD dwJitFlags) +static void LogJitFlags(DWORD facility, DWORD level, CORJIT_FLAGS jitFlags) { CONTRACTL { @@ -647,29 +639,28 @@ static void LogJitFlags(DWORD facility, DWORD level, DWORD dwJitFlags) } CONTRACTL_END; - LOG((facility, level, "dwJitFlags: 0x%08x\n", dwJitFlags)); + LOG((facility, level, "jitFlags:\n")); -#define LOG_FLAG(name) LogOneFlag(dwJitFlags, name, " " #name "\n", facility, level); +#define LOG_FLAG(name) \ + if (jitFlags.IsSet(name)) \ + { \ + LOG((facility, level, " " #name "\n")); \ + jitFlags.Clear(name); \ + } // these are all we care about at the moment - LOG_FLAG(CORJIT_FLG_IL_STUB); - LOG_FLAG(CORJIT_FLG_PUBLISH_SECRET_PARAM); + LOG_FLAG(CORJIT_FLAGS::CORJIT_FLAG_IL_STUB); + LOG_FLAG(CORJIT_FLAGS::CORJIT_FLAG_PUBLISH_SECRET_PARAM); #undef LOG_FLAGS - DWORD dwKnownMask = - CORJIT_FLG_IL_STUB | - CORJIT_FLG_PUBLISH_SECRET_PARAM | - NULL; - - DWORD dwUnknownFlags = dwJitFlags & ~dwKnownMask; - if (0 != dwUnknownFlags) + if (!jitFlags.IsEmpty()) { - LOG((facility, level, "UNKNOWN FLAGS: 0x%08x\n", dwUnknownFlags)); + LOG((facility, level, "UNKNOWN FLAGS also set\n")); } } -void ILStubLinker::LogILStub(DWORD dwJitFlags, SString *pDumpILStubCode) +void ILStubLinker::LogILStub(CORJIT_FLAGS jitFlags, SString *pDumpILStubCode) { CONTRACTL { @@ -683,7 +674,7 @@ void ILStubLinker::LogILStub(DWORD dwJitFlags, SString *pDumpILStubCode) INT iCurStack = 0; if (pDumpILStubCode == NULL) - LogJitFlags(LF_STUBS, LL_INFO1000, dwJitFlags); + LogJitFlags(LF_STUBS, LL_INFO1000, jitFlags); while (pCurrentStream) { @@ -841,7 +832,7 @@ size_t ILStubLinker::Link(UINT* puMaxStack) #ifdef _DEBUG if (fStackUnderflow) { - LogILStub(NULL); + LogILStub(CORJIT_FLAGS()); CONSISTENCY_CHECK_MSG(false, "IL stack underflow! -- see logging output"); } #endif // _DEBUG diff --git a/src/vm/stubgen.h b/src/vm/stubgen.h index e6d3f9ec4d..7bebfa7610 100644 --- a/src/vm/stubgen.h +++ b/src/vm/stubgen.h @@ -431,7 +431,7 @@ public: void ClearCodeStreams(); - void LogILStub(DWORD dwJitFlags, SString *pDumpILStubCode = NULL); + void LogILStub(CORJIT_FLAGS jitFlags, SString *pDumpILStubCode = NULL); protected: void LogILStubWorker(ILInstruction* pInstrBuffer, UINT numInstr, size_t* pcbCode, INT* piCurStack, SString *pDumpILStubCode = NULL); void LogILInstruction(size_t curOffset, bool isLabeled, INT iCurStack, ILInstruction* pInstruction, SString *pDumpILStubCode = NULL); diff --git a/src/vm/util.cpp b/src/vm/util.cpp index 2cb3460122..a7c264fb67 100644 --- a/src/vm/util.cpp +++ b/src/vm/util.cpp @@ -2069,16 +2069,9 @@ lDone: #define CACHE_PARTITION_BITS 0x003FF000 // number of cache Physical Partitions is returned in EBX[21:12] (10 bits) using cpuid function 4 #define CACHE_LINESIZE_BITS 0x00000FFF // Linesize returned in EBX[11:0] (12 bits) using cpuid function 4 -#if defined(_TARGET_X86_) - // these are defined in cgenx86.cpp - extern DWORD getcpuid(DWORD arg1, unsigned char result[16]); - extern DWORD getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16]); -#elif defined(_TARGET_AMD64_) - // these are defined in src\VM\AMD64\asmhelpers.asm - extern "C" DWORD __stdcall getcpuid(DWORD arg1, unsigned char result[16]); - extern "C" DWORD __stdcall getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16]); -#endif - +// these are defined in src\VM\AMD64\asmhelpers.asm / cgenx86.cpp +extern "C" DWORD __stdcall getcpuid(DWORD arg1, unsigned char result[16]); +extern "C" DWORD __stdcall getextcpuid(DWORD arg1, DWORD arg2, unsigned char result[16]); // The following function uses a deterministic mechanism for enumerating/calculating the details of the cache hierarychy at runtime // by using deterministic cache parameter leafs on Prescott and higher processors. |