diff options
author | noahfalk <noahfalk@microsoft.com> | 2017-07-24 17:38:30 -0700 |
---|---|---|
committer | noahfalk <noahfalk@microsoft.com> | 2017-07-24 17:38:30 -0700 |
commit | fd1998903d5eef356f27c54e5a9d490711cbc9e7 (patch) | |
tree | b1d3d7ff1978483060a0f7c879b22006edd417b4 /src/vm/multicorejitplayer.cpp | |
parent | 39cd3cfcb078154f9b595ae476f2c5fb7b445e18 (diff) | |
download | coreclr-fd1998903d5eef356f27c54e5a9d490711cbc9e7.tar.gz coreclr-fd1998903d5eef356f27c54e5a9d490711cbc9e7.tar.bz2 coreclr-fd1998903d5eef356f27c54e5a9d490711cbc9e7.zip |
Add the runtime code versioning feature
This makes tiered compilation work properly with profiler ReJIT, and positions the runtime to integrate other versioning related features together in the future. See the newly added code-versioning design-doc in this commit for more information.
Breaking changes for profilers: See code-versioning-profiler-breaking-changes.md for more details.
Diffstat (limited to 'src/vm/multicorejitplayer.cpp')
-rw-r--r-- | src/vm/multicorejitplayer.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/vm/multicorejitplayer.cpp b/src/vm/multicorejitplayer.cpp index d7c2cec8a1..8a9c8f8397 100644 --- a/src/vm/multicorejitplayer.cpp +++ b/src/vm/multicorejitplayer.cpp @@ -17,7 +17,6 @@ #include "dllimport.h" #include "comdelegate.h" #include "dbginterface.h" -#include "listlock.inl" #include "stubgen.h" #include "eventtrace.h" #include "array.h" @@ -103,7 +102,7 @@ void MulticoreJitCodeStorage::StoreMethodCode(MethodDesc * pMD, PCODE pCode) // Query from MakeJitWorker: Lookup stored JITted methods -PCODE MulticoreJitCodeStorage::QueryMethodCode(MethodDesc * pMethod) +PCODE MulticoreJitCodeStorage::QueryMethodCode(MethodDesc * pMethod, BOOL shouldRemoveCode) { STANDARD_VM_CONTRACT; @@ -113,7 +112,7 @@ PCODE MulticoreJitCodeStorage::QueryMethodCode(MethodDesc * pMethod) { CrstHolder holder(& m_crstCodeMap); - if (m_nativeCodeMap.Lookup(pMethod, & code)) + if (m_nativeCodeMap.Lookup(pMethod, & code) && shouldRemoveCode) { m_nReturned ++; @@ -507,6 +506,23 @@ HRESULT MulticoreJitProfilePlayer::HandleModuleRecord(const ModuleRecord * pMod) } +#ifndef DACCESS_COMPILE +class MulticoreJitPrepareCodeConfig : public PrepareCodeConfig +{ +public: + MulticoreJitPrepareCodeConfig(MethodDesc* pMethod) : + PrepareCodeConfig(NativeCodeVersion(pMethod), FALSE, FALSE) + {} + + virtual BOOL SetNativeCode(PCODE pCode, PCODE * ppAlternateCodeToUse) + { + MulticoreJitManager & mcJitManager = GetAppDomain()->GetMulticoreJitManager(); + mcJitManager.GetMulticoreJitCodeStorage().StoreMethodCode(GetMethodDesc(), pCode); + return TRUE; + } +}; +#endif + // Call JIT to compile a method bool MulticoreJitProfilePlayer::CompileMethodDesc(Module * pModule, MethodDesc * pMD) @@ -529,8 +545,9 @@ bool MulticoreJitProfilePlayer::CompileMethodDesc(Module * pModule, MethodDesc * // Reset the flag to allow managed code to be called in multicore JIT background thread from this routine ThreadStateNCStackHolder holder(-1, Thread::TSNC_CallingManagedCodeDisabled); - // MakeJitWorker calls back to MulticoreJitCodeStorage::StoreMethodCode under MethodDesc lock - pMD->MakeJitWorker(& header, CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND)); + // PrepareCode calls back to MulticoreJitCodeStorage::StoreMethodCode under MethodDesc lock + MulticoreJitPrepareCodeConfig config(pMD); + pMD->PrepareCode(&config); return true; } |