diff --git a/src/coreclr/vm/codeversion.cpp b/src/coreclr/vm/codeversion.cpp index d880cd3e5290f4..d8ce701e499898 100644 --- a/src/coreclr/vm/codeversion.cpp +++ b/src/coreclr/vm/codeversion.cpp @@ -1980,7 +1980,11 @@ HRESULT CodeVersionManager::PublishNativeCodeVersion(MethodDesc* pMethod, Native pMethod, nativeCodeVersion.GetVersionId())); - #ifdef FEATURE_TIERED_COMPILATION +#ifdef FEATURE_INTERPRETER + // When we hit the Precode that should fixup any issues with an unset interpreter code pointer. This is notably most important in ReJIT scenarios + pMethod->ClearInterpreterCodePointer(); +#endif +#ifdef FEATURE_TIERED_COMPILATION bool wasSet = CallCountingManager::SetCodeEntryPoint(nativeCodeVersion, pCode, false, nullptr); _ASSERTE(wasSet); #else diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index 0fe5e1a7a5817a..98b4cb9caaa8e1 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -3233,6 +3233,10 @@ void MethodDesc::ResetCodeEntryPoint() WRAPPER_NO_CONTRACT; _ASSERTE(IsVersionable()); +#ifdef FEATURE_INTERPRETER + ClearInterpreterCodePointer(); +#endif + if (MayHaveEntryPointSlotsToBackpatch()) { BackpatchToResetEntryPointSlots(); @@ -3265,6 +3269,10 @@ void MethodDesc::ResetCodeEntryPointForEnC() return; } +#ifdef FEATURE_INTERPRETER + ClearInterpreterCodePointer(); +#endif + LOG((LF_ENC, LL_INFO100000, "MD::RCEPFENC: this:%p - %s::%s\n", this, m_pszDebugClassName, m_pszDebugMethodName)); #ifndef FEATURE_PORTABLE_ENTRYPOINTS LOG((LF_ENC, LL_INFO100000, "MD::RCEPFENC: HasPrecode():%s, HasNativeCodeSlot():%s\n",