Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
add_compile_definitions(OUT_OF_PROCESS_SETTHREADCONTEXT)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)

add_compile_definitions(FEATURE_CODE_VERSIONING)
add_definitions(-DFEATURE_COLLECTIBLE_TYPES)

if(CLR_CMAKE_TARGET_WIN32)
Expand Down Expand Up @@ -176,6 +175,7 @@ endif(NOT CLR_CMAKE_HOST_ANDROID)
add_definitions(-DFEATURE_SYMDIFF)

if (FEATURE_TIERED_COMPILATION)
add_compile_definitions(FEATURE_CODE_VERSIONING)
add_compile_definitions(FEATURE_TIERED_COMPILATION)
endif(FEATURE_TIERED_COMPILATION)

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,9 @@ void SystemDomain::Attach()
CONTRACTL_END;

// Initialize stub managers
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
PrecodeStubManager::Init();
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
JumpStubStubManager::Init();
RangeSectionStubManager::Init();
ILStubManager::Init();
Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,9 @@ void Module::AllocateMaps()
m_TypeRefToMethodTableMap.dwCount = TYPEREF_MAP_INITIAL_SIZE;
m_MemberRefMap.dwCount = MEMBERREF_MAP_INITIAL_SIZE;
m_MethodDefToDescMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
#ifdef FEATURE_CODE_VERSIONING
m_ILCodeVersioningStateMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
#endif // FEATURE_CODE_VERSIONING
m_FieldDefToDescMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
m_GenericParamToDescMap.dwCount = GENERICPARAM_MAP_INITIAL_SIZE;
m_ManifestModuleReferencesMap.dwCount = ASSEMBLYREFERENCES_MAP_INITIAL_SIZE;
Expand All @@ -1340,8 +1342,10 @@ void Module::AllocateMaps()
// Get # MethodDefs
m_MethodDefToDescMap.dwCount = pImport->GetCountWithTokenKind(mdtMethodDef)+1;

#ifdef FEATURE_CODE_VERSIONING
// IL code versions are relatively rare so keep small.
m_ILCodeVersioningStateMap.dwCount = 1;
#endif // FEATURE_CODE_VERSIONING

// Get # FieldDefs
m_FieldDefToDescMap.dwCount = pImport->GetCountWithTokenKind(mdtFieldDef)+1;
Expand All @@ -1359,7 +1363,9 @@ void Module::AllocateMaps()
nTotal += m_TypeRefToMethodTableMap.dwCount;
nTotal += m_MemberRefMap.dwCount;
nTotal += m_MethodDefToDescMap.dwCount;
#ifdef FEATURE_CODE_VERSIONING
nTotal += m_ILCodeVersioningStateMap.dwCount;
#endif // FEATURE_CODE_VERSIONING
nTotal += m_FieldDefToDescMap.dwCount;
nTotal += m_GenericParamToDescMap.dwCount;
nTotal += m_ManifestModuleReferencesMap.dwCount;
Expand All @@ -1386,13 +1392,20 @@ void Module::AllocateMaps()
m_MethodDefToDescMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
m_MethodDefToDescMap.pTable = &m_MemberRefMap.pTable[m_MemberRefMap.dwCount];

#ifdef FEATURE_CODE_VERSIONING
m_ILCodeVersioningStateMap.pNext = NULL;
m_ILCodeVersioningStateMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
m_ILCodeVersioningStateMap.pTable = &m_MethodDefToDescMap.pTable[m_MethodDefToDescMap.dwCount];
#endif // FEATURE_CODE_VERSIONING

m_FieldDefToDescMap.pNext = NULL;
m_FieldDefToDescMap.supportedFlags = FIELD_DEF_MAP_ALL_FLAGS;

#ifdef FEATURE_CODE_VERSIONING
m_FieldDefToDescMap.pTable = &m_ILCodeVersioningStateMap.pTable[m_ILCodeVersioningStateMap.dwCount];
#else // !FEATURE_CODE_VERSIONING
m_FieldDefToDescMap.pTable = NULL;
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
#endif // FEATURE_CODE_VERSIONING

m_GenericParamToDescMap.pNext = NULL;
m_GenericParamToDescMap.supportedFlags = GENERIC_PARAM_MAP_ALL_FLAGS;
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,11 @@ class Module : public ModuleBase
// For generic methods, IsGenericTypeDefinition() is true i.e. instantiation at formals
LookupMap<PTR_MethodDesc> m_MethodDefToDescMap;

#ifdef FEATURE_CODE_VERSIONING
// Linear mapping from MethodDef token to ILCodeVersioningState *
// This is used for Code Versioning logic
LookupMap<PTR_ILCodeVersioningState> m_ILCodeVersioningStateMap;
#endif // FEATURE_CODE_VERSIONING

// Linear mapping from FieldDef token to FieldDesc*
LookupMap<PTR_FieldDesc> m_FieldDefToDescMap;
Expand Down Expand Up @@ -1252,6 +1254,7 @@ class Module : public ModuleBase
}
#endif // !DACCESS_COMPILE

#ifdef FEATURE_CODE_VERSIONING
PTR_ILCodeVersioningState LookupILCodeVersioningState(mdMethodDef token);

#ifndef DACCESS_COMPILE
Expand All @@ -1270,6 +1273,7 @@ class Module : public ModuleBase
m_ILCodeVersioningStateMap.SetElement(RidFromToken(token), value);
}
#endif // !DACCESS_COMPILE
#endif // FEATURE_CODE_VERSIONING

#ifndef DACCESS_COMPILE
FieldDesc *LookupFieldDef(mdFieldDef token)
Expand Down Expand Up @@ -1714,7 +1718,9 @@ struct cdac_data<Module>
static constexpr size_t MethodDefToDescMap = offsetof(Module, m_MethodDefToDescMap);
static constexpr size_t TypeDefToMethodTableMap = offsetof(Module, m_TypeDefToMethodTableMap);
static constexpr size_t TypeRefToMethodTableMap = offsetof(Module, m_TypeRefToMethodTableMap);
#ifdef FEATURE_CODE_VERSIONING
static constexpr size_t MethodDefToILCodeVersioningStateMap = offsetof(Module, m_ILCodeVersioningStateMap);
#endif // FEATURE_CODE_VERSIONING
static constexpr size_t DynamicILBlobTable = offsetof(Module, m_debuggerSpecificData.m_pDynamicILBlobTable);
};

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/ceeload.inl
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ inline PTR_MethodDesc Module::LookupMethodDef(mdMethodDef token)
return m_MethodDefToDescMap.GetElement(RidFromToken(token));
}

#ifdef FEATURE_CODE_VERSIONING
inline PTR_ILCodeVersioningState Module::LookupILCodeVersioningState(mdMethodDef token)
{
CONTRACTL
Expand All @@ -288,6 +289,7 @@ inline PTR_ILCodeVersioningState Module::LookupILCodeVersioningState(mdMethodDef
_ASSERTE(TypeFromToken(token) == mdtMethodDef);
return m_ILCodeVersioningStateMap.GetElement(RidFromToken(token));
}
#endif // FEATURE_CODE_VERSIONING

inline MethodDesc *Module::LookupMemberRefAsMethod(mdMemberRef token)
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,16 @@ void EEStartupHelper()

JITInlineTrackingMap::StaticInitialize();
MethodDescBackpatchInfoTracker::StaticInitialize();

#ifdef FEATURE_CODE_VERSIONING
CodeVersionManager::StaticInitialize();
#endif // FEATURE_CODE_VERSIONING

#ifdef FEATURE_TIERED_COMPILATION
TieredCompilationManager::StaticInitialize();
CallCountingManager::StaticInitialize();
#endif // FEATURE_TIERED_COMPILATION

OnStackReplacementManager::StaticInitialize();
MethodTable::InitMethodDataCache();

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/codeversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef DPTR(class ILCodeVersioningState) PTR_ILCodeVersioningState;
class CodeVersionManager;
typedef DPTR(class CodeVersionManager) PTR_CodeVersionManager;

#endif
#endif // FEATURE_CODE_VERSIONING

#ifdef HAVE_GCCOVER
class GCCoverageInfo;
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/comdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ OBJECTREF COMDelegate::ConvertToDelegate(LPVOID pCallback, MethodTable* pMT)

UMEntryThunk* pUMEntryThunk = NULL;

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
auto stubKind = RangeSectionStubManager::GetStubKind((PCODE)pCallback);
if (stubKind == STUB_CODE_BLOCK_STUBPRECODE)
{
Expand All @@ -1442,7 +1443,7 @@ OBJECTREF COMDelegate::ConvertToDelegate(LPVOID pCallback, MethodTable* pMT)
pUMEntryThunk = pPrecode->AsUMEntryThunk();
}
}

#endif // !FEATURE_PORTABLE_ENTRYPOINTS

// Lookup the callsite in the hash, if found, we can map this call back to its managed function.
// Otherwise, we'll treat this as an unmanaged callsite.
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/vm/datadescriptor/datadescriptor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ CDAC_TYPE_FIELD(Module, /*pointer*/, MemberRefToDescMap, cdac_data<Module>::Memb
CDAC_TYPE_FIELD(Module, /*pointer*/, MethodDefToDescMap, cdac_data<Module>::MethodDefToDescMap)
CDAC_TYPE_FIELD(Module, /*pointer*/, TypeDefToMethodTableMap, cdac_data<Module>::TypeDefToMethodTableMap)
CDAC_TYPE_FIELD(Module, /*pointer*/, TypeRefToMethodTableMap, cdac_data<Module>::TypeRefToMethodTableMap)
#ifdef FEATURE_CODE_VERSIONING
CDAC_TYPE_FIELD(Module, /*pointer*/, MethodDefToILCodeVersioningStateMap, cdac_data<Module>::MethodDefToILCodeVersioningStateMap)
#endif // FEATURE_CODE_VERSIONING
CDAC_TYPE_FIELD(Module, /*pointer*/, DynamicILBlobTable, cdac_data<Module>::DynamicILBlobTable)
CDAC_TYPE_END(Module)

Expand Down Expand Up @@ -499,14 +501,18 @@ CDAC_TYPE_END(CodePointer)
CDAC_TYPE_BEGIN(MethodDescCodeData)
CDAC_TYPE_INDETERMINATE(MethodDescCodeData)
CDAC_TYPE_FIELD(MethodDescCodeData, /*CodePointer*/, TemporaryEntryPoint, offsetof(MethodDescCodeData,TemporaryEntryPoint))
#ifdef FEATURE_CODE_VERSIONING
CDAC_TYPE_FIELD(MethodDescCodeData, /*pointer*/, VersioningState, offsetof(MethodDescCodeData,VersioningState))
#endif // FEATURE_CODE_VERSIONING
CDAC_TYPE_END(MethodDescCodeData)

#ifdef FEATURE_CODE_VERSIONING
CDAC_TYPE_BEGIN(MethodDescVersioningState)
CDAC_TYPE_INDETERMINATE(MethodDescVersioningState)
CDAC_TYPE_FIELD(MethodDescVersioningState, /*pointer*/, NativeCodeVersionNode, cdac_data<MethodDescVersioningState>::NativeCodeVersionNode)
CDAC_TYPE_FIELD(MethodDescVersioningState, /*uint8*/, Flags, cdac_data<MethodDescVersioningState>::Flags)
CDAC_TYPE_END(MethodDescVersioningState)
#endif // FEATURE_CODE_VERSIONING

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
CDAC_TYPE_BEGIN(PrecodeMachineDescriptor)
Expand Down Expand Up @@ -677,6 +683,7 @@ CDAC_TYPE_FIELD(CodeHeapListNode, /*pointer*/, MapBase, offsetof(HeapList, mapBa
CDAC_TYPE_FIELD(CodeHeapListNode, /*pointer*/, HeaderMap, offsetof(HeapList, pHdrMap))
CDAC_TYPE_END(CodeHeapListNode)

#ifdef FEATURE_CODE_VERSIONING
CDAC_TYPE_BEGIN(ILCodeVersioningState)
CDAC_TYPE_INDETERMINATE(ILCodeVersioningState)
CDAC_TYPE_FIELD(ILCodeVersioningState, /*pointer*/, FirstVersionNode, cdac_data<ILCodeVersioningState>::FirstVersionNode)
Expand Down Expand Up @@ -705,6 +712,7 @@ CDAC_TYPE_FIELD(ILCodeVersionNode, /*pointer*/, Next, cdac_data<ILCodeVersionNod
CDAC_TYPE_FIELD(ILCodeVersionNode, /*uint32*/, RejitState, cdac_data<ILCodeVersionNode>::RejitState)
CDAC_TYPE_FIELD(ILCodeVersionNode, /*pointer*/, ILAddress, cdac_data<ILCodeVersionNode>::ILAddress)
CDAC_TYPE_END(ILCodeVersionNode)
#endif // FEATURE_CODE_VERSIONING

CDAC_TYPE_BEGIN(ProfControlBlock)
CDAC_TYPE_FIELD(ProfControlBlock, /*uint64*/, GlobalEventMask, offsetof(ProfControlBlock, globalEventMask))
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/dllimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5650,13 +5650,17 @@ PCODE PInvoke::GetStubForILStub(PInvokeMethodDesc* pNMD, MethodDesc** ppStubMD,
{
CONSISTENCY_CHECK(pNMD->IsVarArgs());

#ifdef FEATURE_PORTABLE_ENTRYPOINTS
_ASSERTE(false && "Vararg P/Invoke is not supported with portable entrypoints");
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
#else // !FEATURE_PORTABLE_ENTRYPOINTS
//
// varargs goes through vararg PInvoke stub
//
pStub = TheVarargPInvokeStub(pNMD->HasRetBuffArg());

// Only vararg P/Invoke use shared stubs, they need a precode to push the hidden argument.
(void)pNMD->GetOrCreatePrecode();
#endif // FEATURE_PORTABLE_ENTRYPOINTS
}

if (pNMD->IsEarlyBound())
Expand Down
11 changes: 8 additions & 3 deletions src/coreclr/vm/dllimportcallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ class UMEntryThunkData

PCODE entryPoint = m_pUMThunkMarshInfo->GetExecStubEntryPoint();

#ifdef FEATURE_INTERPRETER
bool nullEntryPoint;
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
// For interpreted stubs we need to ensure that TheUMEntryPrestubWorker runs for every
// unmanaged-to-managed invocation in order to populate the TLS variable every time.
auto stubKind = RangeSectionStubManager::GetStubKind(entryPoint);
Expand All @@ -260,9 +261,13 @@ class UMEntryThunkData
entryPoint = (PCODE)0;
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
}
}
nullEntryPoint = entryPoint == (PCODE)0;
#else // !FEATURE_INTERPRETER || FEATURE_PORTABLE_ENTRYPOINTS
nullEntryPoint = false;
_ASSERTE(entryPoint != (PCODE)0);
#endif // FEATURE_INTERPRETER && !FEATURE_PORTABLE_ENTRYPOINTS

if (entryPoint != (PCODE)0)
#endif // FEATURE_INTERPRETER
if (!nullEntryPoint)
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
{
m_pUMEntryThunk->SetTargetUnconditional(entryPoint);
}
Expand Down
17 changes: 11 additions & 6 deletions src/coreclr/vm/interpexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,15 @@ static void CallPreStub(MethodDesc *pMD)
STATIC_STANDARD_VM_CONTRACT;
_ASSERTE(pMD != NULL);

if (!pMD->IsPointingToPrestub() &&
pMD->GetTemporaryEntryPoint() && // The prestub may not yet be ready to be used, so force temporary entry point creation, and check again.
!pMD->IsPointingToPrestub())
return;
// The prestub may not yet be ready to be used, so force temporary entry point creation, and check again.
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
if (!pMD->IsPointingToPrestub())
{
PCODE entryPoint = pMD->GetTemporaryEntryPoint();
if (entryPoint != NULL && !pMD->IsPointingToPrestub())
{
return;
}
}

struct Param
{
Expand Down Expand Up @@ -2541,10 +2546,10 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
break;
}
}

OBJECTREF targetMethodObj = (*delegateObj)->GetTarget();
LOCAL_VAR(callArgsOffset, OBJECTREF) = targetMethodObj;

if ((targetMethod = NonVirtualEntry2MethodDesc(targetAddress)) != NULL)
{
// In this case targetMethod holds a pointer to the MethodDesc that will be called by using targetMethodObj as
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9124,17 +9124,22 @@ void CEEInfo::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftnHnd,
{
// FCalls can be called directly
ret = (void*)ECall::GetFCallImpl(ftn, false /* throwForInvalidFCall */);
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
if (ret == NULL)
{
ret = ((FixupPrecode*)ftn->GetOrCreatePrecode())->GetTargetSlot();
accessType = IAT_PVALUE;
}
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
_ASSERTE(ret != NULL);
}
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
else if (ftn->IsVersionableWithPrecode() && (ftn->GetPrecodeType() == PRECODE_FIXUP) && !ftn->IsPointingToStableNativeCode())
{
ret = ((FixupPrecode*)ftn->GetOrCreatePrecode())->GetTargetSlot();
accessType = IAT_PVALUE;
}
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
else
{
ret = (void *)ftn->TryGetMultiCallableAddrOfCode(accessFlags);
Expand Down
Loading
Loading