diff --git a/clr.defines.targets b/clr.defines.targets
index c3e7b954d1ca..b59dc754596b 100644
--- a/clr.defines.targets
+++ b/clr.defines.targets
@@ -17,6 +17,7 @@
$(DefineConstants);FEATURE_HOSTING
$(DefineConstants);FEATURE_IMPLICIT_LONGPATH
$(DefineConstants);FEATURE_ISOLATED_STORAGE_QUOTA_ENFORCEMENT
+ $(DefineConstants);FEATURE_JUMPSTAMP
$(DefineConstants);FEATURE_MACL
$(DefineConstants);FEATURE_MANAGED_ETW
$(DefineConstants);FEATURE_MANAGED_ETW_CHANNELS
diff --git a/clrdefinitions.cmake b/clrdefinitions.cmake
index 9be4ff08b25b..b1814753b36d 100644
--- a/clrdefinitions.cmake
+++ b/clrdefinitions.cmake
@@ -119,7 +119,6 @@ endif(CLR_CMAKE_PLATFORM_LINUX)
if(CLR_CMAKE_PLATFORM_UNIX)
add_definitions(-DFEATURE_EVENTSOURCE_XPLAT=1)
endif(CLR_CMAKE_PLATFORM_UNIX)
-add_definitions(-DFEATURE_TIERED_COMPILATION)
# NetBSD doesn't implement this feature
if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
add_definitions(-DFEATURE_HIJACK)
@@ -136,6 +135,9 @@ if(FEATURE_INTERPRETER)
add_definitions(-DFEATURE_INTERPRETER)
endif(FEATURE_INTERPRETER)
add_definitions(-DFEATURE_ISYM_READER)
+if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+ add_definitions(-DFEATURE_JUMPSTAMP)
+ endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
add_definitions(-DFEATURE_LOADER_OPTIMIZATION)
if (CLR_CMAKE_PLATFORM_LINUX OR WIN32)
add_definitions(-DFEATURE_MANAGED_ETW)
@@ -175,6 +177,7 @@ if (CLR_CMAKE_PLATFORM_UNIX OR CLR_CMAKE_TARGET_ARCH_ARM64)
endif ()
add_definitions(-DFEATURE_SVR_GC)
add_definitions(-DFEATURE_SYMDIFF)
+add_definitions(-DFEATURE_TIERED_COMPILATION)
if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
# Enable the AMD64 Unix struct passing JIT-EE interface for all AMD64 platforms, to enable altjit.
add_definitions(-DFEATURE_UNIX_AMD64_STRUCT_PASSING_ITF)
diff --git a/src/vm/codeversion.cpp b/src/vm/codeversion.cpp
index d3e08eacbe70..349643711b6a 100644
--- a/src/vm/codeversion.cpp
+++ b/src/vm/codeversion.cpp
@@ -983,7 +983,9 @@ MethodDescVersioningState::MethodDescVersioningState(PTR_MethodDesc pMethodDesc)
m_pFirstVersionNode(dac_cast(nullptr))
{
LIMITED_METHOD_DAC_CONTRACT;
+#ifdef FEATURE_JUMPSTAMP
ZeroMemory(m_rgSavedCode, JumpStubSize);
+#endif
}
PTR_MethodDesc MethodDescVersioningState::GetMethodDesc() const
@@ -1006,6 +1008,7 @@ PTR_NativeCodeVersionNode MethodDescVersioningState::GetFirstVersionNode() const
return m_pFirstVersionNode;
}
+#ifdef FEATURE_JUMPSTAMP
MethodDescVersioningState::JumpStampFlags MethodDescVersioningState::GetJumpStampState()
{
LIMITED_METHOD_DAC_CONTRACT;
@@ -1018,7 +1021,7 @@ void MethodDescVersioningState::SetJumpStampState(JumpStampFlags newState)
LIMITED_METHOD_CONTRACT;
m_flags = (m_flags & ~JumpStampMask) | (BYTE)newState;
}
-#endif
+#endif // DACCESS_COMPILE
#ifndef DACCESS_COMPILE
HRESULT MethodDescVersioningState::SyncJumpStamp(NativeCodeVersion nativeCodeVersion, BOOL fEESuspended)
@@ -1058,7 +1061,7 @@ HRESULT MethodDescVersioningState::SyncJumpStamp(NativeCodeVersion nativeCodeVer
}
}
}
-#endif
+#endif // DACCESS_COMPILE
//---------------------------------------------------------------------------------------
//
@@ -1106,6 +1109,7 @@ LPBYTE FirstCodeByteAddr(LPBYTE pbCode, DebuggerControllerPatch * dbgpatch)
#ifdef _DEBUG
+#ifndef DACCESS_COMPILE
BOOL MethodDescVersioningState::CodeIsSaved()
{
LIMITED_METHOD_CONTRACT;
@@ -1117,6 +1121,7 @@ BOOL MethodDescVersioningState::CodeIsSaved()
}
return FALSE;
}
+#endif //DACCESS_COMPILE
#endif //_DEBUG
//---------------------------------------------------------------------------------------
@@ -1554,6 +1559,7 @@ HRESULT MethodDescVersioningState::UpdateJumpStampHelper(BYTE* pbCode, INT64 i64
#endif // _X86_ || _AMD64_
}
#endif
+#endif // FEATURE_JUMPSTAMP
BOOL MethodDescVersioningState::IsDefaultVersionActiveChild() const
{
@@ -1835,7 +1841,7 @@ ILCodeVersion CodeVersionManager::GetILCodeVersion(PTR_MethodDesc pMethod, ReJIT
return ILCodeVersion();
#else // FEATURE_REJIT
_ASSERTE(rejitId == 0);
- return ILCodeVersion(pModule, methodDef);
+ return ILCodeVersion(dac_cast(pMethod->GetModule()), pMethod->GetMemberDef());
#endif // FEATURE_REJIT
}
@@ -2181,6 +2187,11 @@ HRESULT CodeVersionManager::PublishNativeCodeVersion(MethodDesc* pMethod, Native
}
else
{
+#ifndef FEATURE_JUMPSTAMP
+ _ASSERTE(!"This platform doesn't support JumpStamp but this method doesn't version with Precode,"
+ " this method can't be updated");
+ return E_FAIL;
+#else
MethodDescVersioningState* pVersioningState;
if (FAILED(hr = GetOrCreateMethodDescVersioningState(pMethod, &pVersioningState)))
{
@@ -2188,6 +2199,7 @@ HRESULT CodeVersionManager::PublishNativeCodeVersion(MethodDesc* pMethod, Native
return hr;
}
return pVersioningState->SyncJumpStamp(nativeCodeVersion, fEESuspended);
+#endif
}
}
@@ -2456,6 +2468,10 @@ HRESULT CodeVersionManager::DoJumpStampIfNecessary(MethodDesc* pMD, PCODE pCode)
return GetNonVersionableError(pMD);
}
+#ifndef FEATURE_JUMPSTAMP
+ _ASSERTE(!"How did we get here? IsVersionableWithJumpStamp() should have been FALSE above");
+ return S_OK;
+#else
MethodDescVersioningState* pVersioningState;
if (FAILED(hr = GetOrCreateMethodDescVersioningState(pMD, &pVersioningState)))
{
@@ -2468,6 +2484,8 @@ HRESULT CodeVersionManager::DoJumpStampIfNecessary(MethodDesc* pMD, PCODE pCode)
return S_OK;
}
return pVersioningState->JumpStampNativeCode(pCode);
+#endif // FEATURE_JUMPSTAMP
+
}
#endif // DACCESS_COMPILE
diff --git a/src/vm/codeversion.h b/src/vm/codeversion.h
index 73e792f3d300..9e5648aeb239 100644
--- a/src/vm/codeversion.h
+++ b/src/vm/codeversion.h
@@ -399,13 +399,14 @@ class MethodDescVersioningState
{
public:
// The size of the code used to jump stamp the prolog
+#ifdef FEATURE_JUMPSTAMP
static const size_t JumpStubSize =
#if defined(_X86_) || defined(_AMD64_)
5;
#else
-#error "Need to define size of rejit jump-stamp for this platform"
- 1;
+#error "Need to define size of jump-stamp for this platform"
#endif
+#endif // FEATURE_JUMPSTAMP
MethodDescVersioningState(PTR_MethodDesc pMethodDesc);
PTR_MethodDesc GetMethodDesc() const;
@@ -413,13 +414,16 @@ class MethodDescVersioningState
PTR_NativeCodeVersionNode GetFirstVersionNode() const;
#ifndef DACCESS_COMPILE
+#ifdef FEATURE_JUMPSTAMP
HRESULT SyncJumpStamp(NativeCodeVersion nativeCodeVersion, BOOL fEESuspended);
HRESULT UpdateJumpTarget(BOOL fEESuspended, PCODE pRejittedCode);
HRESULT UndoJumpStampNativeCode(BOOL fEESuspended);
HRESULT JumpStampNativeCode(PCODE pCode = NULL);
+#endif // FEATURE_JUMPSTAMP
void LinkNativeCodeVersionNode(NativeCodeVersionNode* pNativeCodeVersionNode);
-#endif
+#endif // DACCESS_COMPILE
+#ifdef FEATURE_JUMPSTAMP
enum JumpStampFlags
{
// There is no jump stamp in place on this method (Either because
@@ -437,6 +441,7 @@ class MethodDescVersioningState
JumpStampFlags GetJumpStampState();
void SetJumpStampState(JumpStampFlags newState);
+#endif // FEATURE_JUMPSTAMP
//read-write data for the default native code version
BOOL IsDefaultVersionActiveChild() const;
@@ -445,8 +450,8 @@ class MethodDescVersioningState
#endif
private:
+#if !defined(DACCESS_COMPILE) && defined(FEATURE_JUMPSTAMP)
INDEBUG(BOOL CodeIsSaved();)
-#ifndef DACCESS_COMPILE
HRESULT UpdateJumpStampHelper(BYTE* pbCode, INT64 i64OldValue, INT64 i64NewValue, BOOL fContentionPossible);
#endif
PTR_MethodDesc m_pMethodDesc;
@@ -460,8 +465,11 @@ class MethodDescVersioningState
NativeCodeVersionId m_nextId;
PTR_NativeCodeVersionNode m_pFirstVersionNode;
+
// The originally JITted code that was overwritten with the jmp stamp.
+#ifdef FEATURE_JUMPSTAMP
BYTE m_rgSavedCode[JumpStubSize];
+#endif
};
class MethodDescVersioningStateHashTraits : public NoRemoveSHashTraits>
diff --git a/src/vm/method.hpp b/src/vm/method.hpp
index c390b2fe2e3b..b3dde7bfecfa 100644
--- a/src/vm/method.hpp
+++ b/src/vm/method.hpp
@@ -1286,7 +1286,7 @@ class MethodDesc
public:
// TRUE iff it is possible to change the code this method will run using
- // the MethodCodeVersioningManager.
+ // the CodeVersionManager.
// Note: EnC currently returns FALSE here because it uses its own seperate
// scheme to manage versionability. We will likely want to converge them
// at some point.
@@ -1302,8 +1302,14 @@ class MethodDesc
if (IsUnboxingStub() || IsInstantiatingStub())
return FALSE;
- return TRUE;
+#ifndef FEATURE_JUMPSTAMP
+ // if we don't support jumpstamps then only the methods that support precodes are versionable
+ if (!IsVersionableWithPrecode())
+ return FALSE;
#endif
+
+ return TRUE;
+#endif // FEATURE_CODE_VERSIONING
}
// Of the methods where IsVersionable() == TRUE, these methods switch between
@@ -1333,7 +1339,7 @@ class MethodDesc
// If IsVersionable() == FALSE, undefined
BOOL IsVersionableWithJumpStamp()
{
-#ifdef FEATURE_CODE_VERSIONING
+#if defined(FEATURE_CODE_VERSIONING) && defined(FEATURE_JUMPSTAMP)
return !IsVersionableWithPrecode();
#else
return FALSE;
diff --git a/src/vm/rejit.cpp b/src/vm/rejit.cpp
index b7c60a998134..f392dcf5f245 100644
--- a/src/vm/rejit.cpp
+++ b/src/vm/rejit.cpp
@@ -1060,10 +1060,6 @@ HRESULT ReJitManager::RequestRevert(
return E_NOTIMPL;
}
-void ReJitManager::PreInit(BOOL fSharedDomain)
-{
-}
-
ReJITID ReJitManager::GetReJitId(PTR_MethodDesc pMD, PCODE pCodeStart)
{
return 0;