Skip to content

Commit 7f5cd02

Browse files
Remove usage of Precode::GetPrecodeFromEntryPoint in WASM. (#120583)
* Remove usage of Precode::GetPrecodeFromEntryPoint in WASM. * Remove unused declarations in precode_portable.hpp * Move ReversePInvokeBadTransition * Forcibly set entry point on PortableEntryPoint scenarios. * Rename MethodDesc::IsPointingToPrestub to ShouldCallPrestub. Update ShouldCallPrestub for NULL to return TRUE. --------- Co-authored-by: Radek Doulik <[email protected]>
1 parent d9e5294 commit 7f5cd02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+400
-347
lines changed

src/coreclr/clrdefinitions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
6060
add_compile_definitions(OUT_OF_PROCESS_SETTHREADCONTEXT)
6161
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
6262

63-
add_compile_definitions(FEATURE_CODE_VERSIONING)
6463
add_definitions(-DFEATURE_COLLECTIBLE_TYPES)
6564

6665
if(CLR_CMAKE_TARGET_WIN32)
@@ -176,6 +175,7 @@ endif(NOT CLR_CMAKE_HOST_ANDROID)
176175
add_definitions(-DFEATURE_SYMDIFF)
177176

178177
if (FEATURE_TIERED_COMPILATION)
178+
add_compile_definitions(FEATURE_CODE_VERSIONING)
179179
add_compile_definitions(FEATURE_TIERED_COMPILATION)
180180
endif(FEATURE_TIERED_COMPILATION)
181181

src/coreclr/vm/appdomain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,9 @@ void SystemDomain::Attach()
719719
CONTRACTL_END;
720720

721721
// Initialize stub managers
722+
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
722723
PrecodeStubManager::Init();
724+
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
723725
JumpStubStubManager::Init();
724726
RangeSectionStubManager::Init();
725727
ILStubManager::Init();

src/coreclr/vm/assembly.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,9 +2113,11 @@ BOOL Assembly::DoIncrementalLoad(FileLoadLevel level)
21132113
DeliverSyncEvents();
21142114
break;
21152115

2116+
#ifdef FEATURE_IJW
21162117
case FILE_LOAD_VTABLE_FIXUPS:
21172118
VtableFixups();
21182119
break;
2120+
#endif // FEATURE_IJW
21192121

21202122
case FILE_LOADED:
21212123
FinishLoad();
@@ -2192,12 +2194,14 @@ void Assembly::EagerFixups()
21922194
#endif // FEATURE_READYTORUN
21932195
}
21942196

2197+
#ifdef FEATURE_IJW
21952198
void Assembly::VtableFixups()
21962199
{
21972200
WRAPPER_NO_CONTRACT;
21982201

21992202
GetModule()->FixupVTables();
22002203
}
2204+
#endif // FEATURE_IJW
22012205

22022206
void Assembly::FinishLoad()
22032207
{

src/coreclr/vm/assembly.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ class Assembly
126126
void Begin();
127127
void BeforeTypeLoad();
128128
void EagerFixups();
129+
#ifdef FEATURE_IJW
129130
void VtableFixups();
131+
#endif // FEATURE_IJW
130132
void DeliverSyncEvents();
131133
void DeliverAsyncEvents();
132134
void FinishLoad();

src/coreclr/vm/assemblyspec.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ enum FileLoadLevel
3333
FILE_LOAD_BEFORE_TYPE_LOAD,
3434
FILE_LOAD_EAGER_FIXUPS,
3535
FILE_LOAD_DELIVER_EVENTS,
36+
#ifdef FEATURE_IJW
3637
FILE_LOAD_VTABLE_FIXUPS,
38+
#endif // FEATURE_IJW
3739
FILE_LOADED, // Loaded by not yet active
3840
FILE_ACTIVE // Fully active (constructors run & security checked)
3941
};

src/coreclr/vm/ceeload.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,10 +1325,12 @@ void Module::AllocateMaps()
13251325
m_TypeRefToMethodTableMap.dwCount = TYPEREF_MAP_INITIAL_SIZE;
13261326
m_MemberRefMap.dwCount = MEMBERREF_MAP_INITIAL_SIZE;
13271327
m_MethodDefToDescMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
1328-
m_ILCodeVersioningStateMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
13291328
m_FieldDefToDescMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
13301329
m_GenericParamToDescMap.dwCount = GENERICPARAM_MAP_INITIAL_SIZE;
13311330
m_ManifestModuleReferencesMap.dwCount = ASSEMBLYREFERENCES_MAP_INITIAL_SIZE;
1331+
#ifdef FEATURE_CODE_VERSIONING
1332+
m_ILCodeVersioningStateMap.dwCount = MEMBERDEF_MAP_INITIAL_SIZE;
1333+
#endif // FEATURE_CODE_VERSIONING
13321334
}
13331335
else
13341336
{
@@ -1346,9 +1348,6 @@ void Module::AllocateMaps()
13461348
// Get # MethodDefs
13471349
m_MethodDefToDescMap.dwCount = pImport->GetCountWithTokenKind(mdtMethodDef)+1;
13481350

1349-
// IL code versions are relatively rare so keep small.
1350-
m_ILCodeVersioningStateMap.dwCount = 1;
1351-
13521351
// Get # FieldDefs
13531352
m_FieldDefToDescMap.dwCount = pImport->GetCountWithTokenKind(mdtFieldDef)+1;
13541353

@@ -1357,6 +1356,11 @@ void Module::AllocateMaps()
13571356

13581357
// Get the number of AssemblyReferences in the map
13591358
m_ManifestModuleReferencesMap.dwCount = pImport->GetCountWithTokenKind(mdtAssemblyRef)+1;
1359+
1360+
#ifdef FEATURE_CODE_VERSIONING
1361+
// IL code versions are relatively rare so keep small.
1362+
m_ILCodeVersioningStateMap.dwCount = 1;
1363+
#endif // FEATURE_CODE_VERSIONING
13601364
}
13611365

13621366
S_SIZE_T nTotal;
@@ -1365,10 +1369,12 @@ void Module::AllocateMaps()
13651369
nTotal += m_TypeRefToMethodTableMap.dwCount;
13661370
nTotal += m_MemberRefMap.dwCount;
13671371
nTotal += m_MethodDefToDescMap.dwCount;
1368-
nTotal += m_ILCodeVersioningStateMap.dwCount;
13691372
nTotal += m_FieldDefToDescMap.dwCount;
13701373
nTotal += m_GenericParamToDescMap.dwCount;
13711374
nTotal += m_ManifestModuleReferencesMap.dwCount;
1375+
#ifdef FEATURE_CODE_VERSIONING
1376+
nTotal += m_ILCodeVersioningStateMap.dwCount;
1377+
#endif // FEATURE_CODE_VERSIONING
13721378

13731379
_ASSERTE (m_pAssembly && m_pAssembly->GetLowFrequencyHeap());
13741380
pTable = (PTR_TADDR)(void*)m_pAssembly->GetLowFrequencyHeap()->AllocMem(nTotal * S_SIZE_T(sizeof(TADDR)));
@@ -1382,7 +1388,7 @@ void Module::AllocateMaps()
13821388

13831389
m_TypeRefToMethodTableMap.pNext = NULL;
13841390
m_TypeRefToMethodTableMap.supportedFlags = TYPE_REF_MAP_ALL_FLAGS;
1385-
m_TypeRefToMethodTableMap.pTable = &pTable[m_TypeDefToMethodTableMap.dwCount];
1391+
m_TypeRefToMethodTableMap.pTable = &m_TypeDefToMethodTableMap.pTable[m_TypeDefToMethodTableMap.dwCount];
13861392

13871393
m_MemberRefMap.pNext = NULL;
13881394
m_MemberRefMap.supportedFlags = MEMBER_REF_MAP_ALL_FLAGS;
@@ -1392,13 +1398,9 @@ void Module::AllocateMaps()
13921398
m_MethodDefToDescMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
13931399
m_MethodDefToDescMap.pTable = &m_MemberRefMap.pTable[m_MemberRefMap.dwCount];
13941400

1395-
m_ILCodeVersioningStateMap.pNext = NULL;
1396-
m_ILCodeVersioningStateMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
1397-
m_ILCodeVersioningStateMap.pTable = &m_MethodDefToDescMap.pTable[m_MethodDefToDescMap.dwCount];
1398-
13991401
m_FieldDefToDescMap.pNext = NULL;
14001402
m_FieldDefToDescMap.supportedFlags = FIELD_DEF_MAP_ALL_FLAGS;
1401-
m_FieldDefToDescMap.pTable = &m_ILCodeVersioningStateMap.pTable[m_ILCodeVersioningStateMap.dwCount];
1403+
m_FieldDefToDescMap.pTable = &m_MethodDefToDescMap.pTable[m_MethodDefToDescMap.dwCount];
14021404

14031405
m_GenericParamToDescMap.pNext = NULL;
14041406
m_GenericParamToDescMap.supportedFlags = GENERIC_PARAM_MAP_ALL_FLAGS;
@@ -1407,6 +1409,12 @@ void Module::AllocateMaps()
14071409
m_ManifestModuleReferencesMap.pNext = NULL;
14081410
m_ManifestModuleReferencesMap.supportedFlags = MANIFEST_MODULE_MAP_ALL_FLAGS;
14091411
m_ManifestModuleReferencesMap.pTable = &m_GenericParamToDescMap.pTable[m_GenericParamToDescMap.dwCount];
1412+
1413+
#ifdef FEATURE_CODE_VERSIONING
1414+
m_ILCodeVersioningStateMap.pNext = NULL;
1415+
m_ILCodeVersioningStateMap.supportedFlags = METHOD_DEF_MAP_ALL_FLAGS;
1416+
m_ILCodeVersioningStateMap.pTable = &m_ManifestModuleReferencesMap.pTable[m_ManifestModuleReferencesMap.dwCount];
1417+
#endif // FEATURE_CODE_VERSIONING
14101418
}
14111419

14121420

@@ -3143,16 +3151,18 @@ BYTE * GetTargetForVTableEntry(HINSTANCE hInst, BYTE **ppVTEntry)
31433151
return *ppVTEntry;
31443152
}
31453153

3154+
#ifdef FEATURE_IJW
31463155
//======================================================================================
31473156
// Fixup vtables stored in the header to contain pointers to method desc
31483157
// prestubs rather than metadata method tokens.
31493158
void Module::FixupVTables()
31503159
{
3151-
CONTRACTL{
3160+
CONTRACTL
3161+
{
31523162
INSTANCE_CHECK;
31533163
STANDARD_VM_CHECK;
3154-
} CONTRACTL_END;
3155-
3164+
}
3165+
CONTRACTL_END;
31563166

31573167
// If we've already fixed up, or this is not an IJW module, just return.
31583168
// NOTE: This relies on ILOnly files not having fixups. If this changes,
@@ -3412,6 +3422,7 @@ void Module::FixupVTables()
34123422
SetIsIJWFixedUp(); // On the module
34133423
} // End of Stage 3
34143424
}
3425+
#endif // FEATURE_IJW
34153426

34163427
ModuleBase *Module::GetModuleFromIndex(DWORD ix)
34173428
{

src/coreclr/vm/ceeload.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,16 +742,18 @@ class Module : public ModuleBase
742742
// For generic methods, IsGenericTypeDefinition() is true i.e. instantiation at formals
743743
LookupMap<PTR_MethodDesc> m_MethodDefToDescMap;
744744

745-
// Linear mapping from MethodDef token to ILCodeVersioningState *
746-
// This is used for Code Versioning logic
747-
LookupMap<PTR_ILCodeVersioningState> m_ILCodeVersioningStateMap;
748-
749745
// Linear mapping from FieldDef token to FieldDesc*
750746
LookupMap<PTR_FieldDesc> m_FieldDefToDescMap;
751747

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

751+
#ifdef FEATURE_CODE_VERSIONING
752+
// Linear mapping from MethodDef token to ILCodeVersioningState *
753+
// This is used for Code Versioning logic
754+
LookupMap<PTR_ILCodeVersioningState> m_ILCodeVersioningStateMap;
755+
#endif // FEATURE_CODE_VERSIONING
756+
755757
// IL stub cache with fabricated MethodTable parented by this module.
756758
ILStubCache *m_pILStubCache;
757759

@@ -873,7 +875,9 @@ class Module : public ModuleBase
873875

874876
void ApplyMetaData();
875877

878+
#ifdef FEATURE_IJW
876879
void FixupVTables();
880+
#endif // FEATURE_IJW
877881

878882
void FreeClassTables();
879883

@@ -1254,6 +1258,7 @@ class Module : public ModuleBase
12541258
}
12551259
#endif // !DACCESS_COMPILE
12561260

1261+
#ifdef FEATURE_CODE_VERSIONING
12571262
PTR_ILCodeVersioningState LookupILCodeVersioningState(mdMethodDef token);
12581263

12591264
#ifndef DACCESS_COMPILE
@@ -1272,6 +1277,7 @@ class Module : public ModuleBase
12721277
m_ILCodeVersioningStateMap.SetElement(RidFromToken(token), value);
12731278
}
12741279
#endif // !DACCESS_COMPILE
1280+
#endif // FEATURE_CODE_VERSIONING
12751281

12761282
#ifndef DACCESS_COMPILE
12771283
FieldDesc *LookupFieldDef(mdFieldDef token)
@@ -1722,7 +1728,9 @@ struct cdac_data<Module>
17221728
static constexpr size_t MethodDefToDescMap = offsetof(Module, m_MethodDefToDescMap);
17231729
static constexpr size_t TypeDefToMethodTableMap = offsetof(Module, m_TypeDefToMethodTableMap);
17241730
static constexpr size_t TypeRefToMethodTableMap = offsetof(Module, m_TypeRefToMethodTableMap);
1731+
#ifdef FEATURE_CODE_VERSIONING
17251732
static constexpr size_t MethodDefToILCodeVersioningStateMap = offsetof(Module, m_ILCodeVersioningStateMap);
1733+
#endif // FEATURE_CODE_VERSIONING
17261734
static constexpr size_t DynamicILBlobTable = offsetof(Module, m_debuggerSpecificData.m_pDynamicILBlobTable);
17271735
};
17281736

src/coreclr/vm/ceeload.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ inline PTR_MethodDesc Module::LookupMethodDef(mdMethodDef token)
274274
return m_MethodDefToDescMap.GetElement(RidFromToken(token));
275275
}
276276

277+
#ifdef FEATURE_CODE_VERSIONING
277278
inline PTR_ILCodeVersioningState Module::LookupILCodeVersioningState(mdMethodDef token)
278279
{
279280
CONTRACTL
@@ -288,6 +289,7 @@ inline PTR_ILCodeVersioningState Module::LookupILCodeVersioningState(mdMethodDef
288289
_ASSERTE(TypeFromToken(token) == mdtMethodDef);
289290
return m_ILCodeVersioningStateMap.GetElement(RidFromToken(token));
290291
}
292+
#endif // FEATURE_CODE_VERSIONING
291293

292294
inline MethodDesc *Module::LookupMemberRefAsMethod(mdMemberRef token)
293295
{

src/coreclr/vm/ceemain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,16 @@ void EEStartupHelper()
665665

666666
JITInlineTrackingMap::StaticInitialize();
667667
MethodDescBackpatchInfoTracker::StaticInitialize();
668+
669+
#ifdef FEATURE_CODE_VERSIONING
668670
CodeVersionManager::StaticInitialize();
671+
#endif // FEATURE_CODE_VERSIONING
672+
669673
#ifdef FEATURE_TIERED_COMPILATION
670674
TieredCompilationManager::StaticInitialize();
671675
CallCountingManager::StaticInitialize();
672676
#endif // FEATURE_TIERED_COMPILATION
677+
673678
OnStackReplacementManager::StaticInitialize();
674679
MethodTable::InitMethodDataCache();
675680

src/coreclr/vm/codeman.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,7 @@ TypeHandle InterpreterJitManager::ResolveEHClause(EE_ILEXCEPTION_CLAUSE* pEHClau
34073407
_ASSERTE(!declaringType.IsNull());
34083408

34093409
SigTypeContext typeContext(pMD, declaringType);
3410-
3410+
34113411
Module* pModule = pMD->GetModule();
34123412

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

51295129
ExecutionManager::ScanFlag scanFlag = ExecutionManager::GetScanFlags();
5130-
#ifdef FEATURE_INTERPRETER
5130+
#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
51315131
RangeSection * pRS = ExecutionManager::FindCodeRange(currentPC, scanFlag);
51325132
if (pRS == NULL)
51335133
return NULL;
@@ -5143,7 +5143,7 @@ MethodDesc * ExecutionManager::GetCodeMethodDesc(PCODE currentPC)
51435143
}
51445144
}
51455145
}
5146-
#endif // FEATURE_INTERPRETER
5146+
#endif // FEATURE_INTERPRETER && !FEATURE_PORTABLE_ENTRYPOINTS
51475147

51485148
EECodeInfo codeInfo(currentPC, scanFlag);
51495149
if (!codeInfo.IsValid())

0 commit comments

Comments
 (0)