Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2127,9 +2127,11 @@ BOOL Assembly::DoIncrementalLoad(FileLoadLevel level)
DeliverSyncEvents();
break;

#ifdef FEATURE_IJW
case FILE_LOAD_VTABLE_FIXUPS:
VtableFixups();
break;
#endif // FEATURE_IJW

case FILE_LOADED:
FinishLoad();
Expand Down Expand Up @@ -2206,12 +2208,14 @@ void Assembly::EagerFixups()
#endif // FEATURE_READYTORUN
}

#ifdef FEATURE_IJW
void Assembly::VtableFixups()
{
WRAPPER_NO_CONTRACT;

GetModule()->FixupVTables();
}
#endif // FEATURE_IJW

void Assembly::FinishLoad()
{
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class Assembly
void Begin();
void BeforeTypeLoad();
void EagerFixups();
#ifdef FEATURE_IJW
void VtableFixups();
#endif // FEATURE_IJW
void DeliverSyncEvents();
void DeliverAsyncEvents();
void FinishLoad();
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/assemblyspec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ enum FileLoadLevel
FILE_LOAD_BEFORE_TYPE_LOAD,
FILE_LOAD_EAGER_FIXUPS,
FILE_LOAD_DELIVER_EVENTS,
#ifdef FEATURE_IJW
FILE_LOAD_VTABLE_FIXUPS,
#endif // FEATURE_IJW
FILE_LOADED, // Loaded by not yet active
FILE_ACTIVE // Fully active (constructors run & security checked)
};
Expand Down
39 changes: 25 additions & 14 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,12 @@ void Module::AllocateMaps()
m_TypeRefToMethodTableMap.dwCount = TYPEREF_MAP_INITIAL_SIZE;
m_MemberRefMap.dwCount = MEMBERREF_MAP_INITIAL_SIZE;
m_MethodDefToDescMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
m_ILCodeVersioningStateMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
m_FieldDefToDescMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
m_GenericParamToDescMap.dwCount = GENERICPARAM_MAP_INITIAL_SIZE;
m_ManifestModuleReferencesMap.dwCount = ASSEMBLYREFERENCES_MAP_INITIAL_SIZE;
#ifdef FEATURE_CODE_VERSIONING
m_ILCodeVersioningStateMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
#endif // FEATURE_CODE_VERSIONING
}
else
{
Expand All @@ -1340,9 +1342,6 @@ void Module::AllocateMaps()
// Get # MethodDefs
m_MethodDefToDescMap.dwCount = pImport->GetCountWithTokenKind(mdtMethodDef)+1;

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

// Get # FieldDefs
m_FieldDefToDescMap.dwCount = pImport->GetCountWithTokenKind(mdtFieldDef)+1;

Expand All @@ -1351,6 +1350,11 @@ void Module::AllocateMaps()

// Get the number of AssemblyReferences in the map
m_ManifestModuleReferencesMap.dwCount = pImport->GetCountWithTokenKind(mdtAssemblyRef)+1;

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

S_SIZE_T nTotal;
Expand All @@ -1359,10 +1363,12 @@ void Module::AllocateMaps()
nTotal += m_TypeRefToMethodTableMap.dwCount;
nTotal += m_MemberRefMap.dwCount;
nTotal += m_MethodDefToDescMap.dwCount;
nTotal += m_ILCodeVersioningStateMap.dwCount;
nTotal += m_FieldDefToDescMap.dwCount;
nTotal += m_GenericParamToDescMap.dwCount;
nTotal += m_ManifestModuleReferencesMap.dwCount;
#ifdef FEATURE_CODE_VERSIONING
nTotal += m_ILCodeVersioningStateMap.dwCount;
#endif // FEATURE_CODE_VERSIONING

_ASSERTE (m_pAssembly && m_pAssembly->GetLowFrequencyHeap());
pTable = (PTR_TADDR)(void*)m_pAssembly->GetLowFrequencyHeap()->AllocMem(nTotal * S_SIZE_T(sizeof(TADDR)));
Expand All @@ -1376,7 +1382,7 @@ void Module::AllocateMaps()

m_TypeRefToMethodTableMap.pNext = NULL;
m_TypeRefToMethodTableMap.supportedFlags = TYPE_REF_MAP_ALL_FLAGS;
m_TypeRefToMethodTableMap.pTable = &pTable[m_TypeDefToMethodTableMap.dwCount];
m_TypeRefToMethodTableMap.pTable = &m_TypeDefToMethodTableMap.pTable[m_TypeDefToMethodTableMap.dwCount];

m_MemberRefMap.pNext = NULL;
m_MemberRefMap.supportedFlags = MEMBER_REF_MAP_ALL_FLAGS;
Expand All @@ -1386,13 +1392,9 @@ void Module::AllocateMaps()
m_MethodDefToDescMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
m_MethodDefToDescMap.pTable = &m_MemberRefMap.pTable[m_MemberRefMap.dwCount];

m_ILCodeVersioningStateMap.pNext = NULL;
m_ILCodeVersioningStateMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
m_ILCodeVersioningStateMap.pTable = &m_MethodDefToDescMap.pTable[m_MethodDefToDescMap.dwCount];

m_FieldDefToDescMap.pNext = NULL;
m_FieldDefToDescMap.supportedFlags = FIELD_DEF_MAP_ALL_FLAGS;
m_FieldDefToDescMap.pTable = &m_ILCodeVersioningStateMap.pTable[m_ILCodeVersioningStateMap.dwCount];
m_FieldDefToDescMap.pTable = &m_MethodDefToDescMap.pTable[m_MethodDefToDescMap.dwCount];

m_GenericParamToDescMap.pNext = NULL;
m_GenericParamToDescMap.supportedFlags = GENERIC_PARAM_MAP_ALL_FLAGS;
Expand All @@ -1401,6 +1403,12 @@ void Module::AllocateMaps()
m_ManifestModuleReferencesMap.pNext = NULL;
m_ManifestModuleReferencesMap.supportedFlags = MANIFEST_MODULE_MAP_ALL_FLAGS;
m_ManifestModuleReferencesMap.pTable = &m_GenericParamToDescMap.pTable[m_GenericParamToDescMap.dwCount];

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


Expand Down Expand Up @@ -3137,16 +3145,18 @@ BYTE * GetTargetForVTableEntry(HINSTANCE hInst, BYTE **ppVTEntry)
return *ppVTEntry;
}

#ifdef FEATURE_IJW
//======================================================================================
// Fixup vtables stored in the header to contain pointers to method desc
// prestubs rather than metadata method tokens.
void Module::FixupVTables()
{
CONTRACTL{
CONTRACTL
{
INSTANCE_CHECK;
STANDARD_VM_CHECK;
} CONTRACTL_END;

}
CONTRACTL_END;

// If we've already fixed up, or this is not an IJW module, just return.
// NOTE: This relies on ILOnly files not having fixups. If this changes,
Expand Down Expand Up @@ -3406,6 +3416,7 @@ void Module::FixupVTables()
SetIsIJWFixedUp(); // On the module
} // End of Stage 3
}
#endif // FEATURE_IJW

ModuleBase *Module::GetModuleFromIndex(DWORD ix)
{
Expand Down
16 changes: 12 additions & 4 deletions src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,16 +740,18 @@ class Module : public ModuleBase
// For generic methods, IsGenericTypeDefinition() is true i.e. instantiation at formals
LookupMap<PTR_MethodDesc> m_MethodDefToDescMap;

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

// Linear mapping from FieldDef token to FieldDesc*
LookupMap<PTR_FieldDesc> m_FieldDefToDescMap;

// Linear mapping from GenericParam token to TypeVarTypeDesc*
LookupMap<PTR_TypeVarTypeDesc> m_GenericParamToDescMap;

#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

// IL stub cache with fabricated MethodTable parented by this module.
ILStubCache *m_pILStubCache;

Expand Down Expand Up @@ -871,7 +873,9 @@ class Module : public ModuleBase

void ApplyMetaData();

#ifdef FEATURE_IJW
void FixupVTables();
#endif // FEATURE_IJW

void FreeClassTables();

Expand Down Expand Up @@ -1252,6 +1256,7 @@ class Module : public ModuleBase
}
#endif // !DACCESS_COMPILE

#ifdef FEATURE_CODE_VERSIONING
PTR_ILCodeVersioningState LookupILCodeVersioningState(mdMethodDef token);

#ifndef DACCESS_COMPILE
Expand All @@ -1270,6 +1275,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 +1720,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
6 changes: 3 additions & 3 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,7 @@ TypeHandle InterpreterJitManager::ResolveEHClause(EE_ILEXCEPTION_CLAUSE* pEHClau
_ASSERTE(!declaringType.IsNull());

SigTypeContext typeContext(pMD, declaringType);

Module* pModule = pMD->GetModule();

thResolved = ClassLoader::LoadTypeDefOrRefOrSpecThrowing(pModule, pEHClause->ClassToken, &typeContext,
Expand Down Expand Up @@ -5127,7 +5127,7 @@ MethodDesc * ExecutionManager::GetCodeMethodDesc(PCODE currentPC)
CONTRACTL_END

ExecutionManager::ScanFlag scanFlag = ExecutionManager::GetScanFlags();
#ifdef FEATURE_INTERPRETER
#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
RangeSection * pRS = ExecutionManager::FindCodeRange(currentPC, scanFlag);
if (pRS == NULL)
return NULL;
Expand All @@ -5143,7 +5143,7 @@ MethodDesc * ExecutionManager::GetCodeMethodDesc(PCODE currentPC)
}
}
}
#endif // FEATURE_INTERPRETER
#endif // FEATURE_INTERPRETER && !FEATURE_PORTABLE_ENTRYPOINTS

EECodeInfo codeInfo(currentPC, scanFlag);
if (!codeInfo.IsValid())
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/codeversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ MethodDescVersioningState* NativeCodeVersion::GetMethodDescVersioningState()
CodeVersionManager* pCodeVersionManager = pMethodDesc->GetCodeVersionManager();
return pCodeVersionManager->GetMethodDescVersioningState(pMethodDesc);
}
#endif
#endif // !DACCESS_COMPILE

bool NativeCodeVersion::IsFinalTier() const
{
Expand Down Expand Up @@ -1737,7 +1737,7 @@ PCODE CodeVersionManager::PublishVersionableCodeIfNecessary(
break;
}

if (!pMethodDesc->IsPointingToPrestub())
if (!pMethodDesc->ShouldCallPrestub())
{
*doFullBackpatchRef = true;
return (PCODE)NULL;
Expand Down
8 changes: 4 additions & 4 deletions 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 All @@ -46,14 +46,14 @@ class NativeCodeVersion
#ifdef FEATURE_CODE_VERSIONING
friend class MethodDescVersioningState;
friend class ILCodeVersion;
#endif
#endif // FEATURE_CODE_VERSIONING

public:
NativeCodeVersion();
NativeCodeVersion(const NativeCodeVersion & rhs);
#ifdef FEATURE_CODE_VERSIONING
NativeCodeVersion(PTR_NativeCodeVersionNode pVersionNode);
#endif
#endif // FEATURE_CODE_VERSIONING
explicit NativeCodeVersion(PTR_MethodDesc pMethod);

BOOL IsNull() const;
Expand All @@ -65,7 +65,7 @@ class NativeCodeVersion
#ifdef FEATURE_CODE_VERSIONING
ILCodeVersion GetILCodeVersion() const;
ReJITID GetILCodeVersionId() const;
#endif
#endif // FEATURE_CODE_VERSIONING

#ifndef DACCESS_COMPILE
BOOL SetNativeCodeInterlocked(PCODE pCode, PCODE pExpected = 0);
Expand Down
Loading