Skip to content

Commit 9c0555e

Browse files
Make ETW rundown operate more effectively with JIT (#116354)
* Make the EECodeGenManager API surface narrower. Rename some locals removing critical section notion and replace with lock. Rework the CodeHeapIterator. Rename members to more accurately reflect their purpose. Generally move to more canonical C++. EECodeGenManager now has a iterator counter. This is used to track the number of outstanding iterators and can be used to defer deletes. Adds are still valid since the iterator will only operate on the state at the time the iterator was created. * Move DynamicMethodDesc destruction to finalizer queue if not possible due to MethodDesc iteration. Rework how DynamicMethodDesc and LCGMethodResolver destruction works. This was needed due to Crst lock inversion. * Remove CrstIbcProfile * Move finalizer related work functions to finalizerthread.cpp. * Unconditionally publish UnwindInfo. * Remove CEECodeGenInfo::BackoutJitData() Rework allocation order for recording of code pointer. --------- Co-authored-by: Jan Kotas <[email protected]>
1 parent e53094d commit 9c0555e

36 files changed

+1076
-1061
lines changed

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,9 +3423,9 @@ void DacDbiInterfaceImpl::EnumerateMemRangesForJitCodeHeaps(CQuickArrayList<COR_
34233423
{
34243424
// We should always have a valid EEJitManager with at least one code heap.
34253425
EEJitManager *pEM = ExecutionManager::GetEEJitManager();
3426-
_ASSERTE(pEM != NULL && pEM->m_pCodeHeap.IsValid());
3426+
_ASSERTE(pEM != NULL && pEM->m_pAllCodeHeaps.IsValid());
34273427

3428-
PTR_HeapList pHeapList = pEM->m_pCodeHeap;
3428+
PTR_HeapList pHeapList = pEM->m_pAllCodeHeaps;
34293429
while (pHeapList != NULL)
34303430
{
34313431
CodeHeap *pHeap = pHeapList->pHeap;

src/coreclr/debug/daccess/fntableaccess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern "C" NTSTATUS OutOfProcessFunctionTableCallbackEx(IN ReadMemoryFunction
169169
*ppFunctions = 0;
170170
*pnEntries = 0;
171171

172-
DWORD_PTR pHp = JitMan + (DWORD_PTR)offsetof(FakeEEJitManager, m_pCodeHeap);
172+
DWORD_PTR pHp = JitMan + (DWORD_PTR)offsetof(FakeEEJitManager, m_pAllCodeHeaps);
173173

174174
move(pHp, pHp);
175175

src/coreclr/debug/daccess/fntableaccess.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ struct FakeEEJitManager
1515
{
1616
LPVOID __VFN_table;
1717
LPVOID m_runtimeSupport;
18-
LPVOID m_pCodeHeap;
19-
// Nothing after this point matters: we only need the correct offset of m_pCodeHeap.
18+
LPVOID m_pAllCodeHeaps;
19+
// Nothing after this point matters: we only need the correct offset of m_pAllCodeHeaps.
2020
};
2121

2222
struct FakeHeapList
@@ -76,7 +76,7 @@ class CheckDuplicatedStructLayouts
7676
{
7777
#define CHECK_OFFSET(cls, fld) CPP_ASSERT(cls##fld, offsetof(Fake##cls, fld) == offsetof(cls, fld))
7878

79-
CHECK_OFFSET(EEJitManager, m_pCodeHeap);
79+
CHECK_OFFSET(EEJitManager, m_pAllCodeHeaps);
8080

8181
CHECK_OFFSET(HeapList, hpNext);
8282
CHECK_OFFSET(HeapList, startAddress);

src/coreclr/debug/daccess/request.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ ClrDataAccess::GetJitManagerList(unsigned int count, struct DacpJitManagerInfo m
362362
currentPtr->codeType = managerPtr->GetCodeType();
363363

364364
EEJitManager *eeJitManager = PTR_EEJitManager(PTR_HOST_TO_TADDR(managerPtr));
365-
currentPtr->ptrHeapList = HOST_CDADDR(eeJitManager->m_pCodeHeap);
365+
currentPtr->ptrHeapList = HOST_CDADDR(eeJitManager->m_pAllCodeHeaps);
366366
}
367367
}
368368
else if (pNeeded)
@@ -528,7 +528,7 @@ ClrDataAccess::GetCodeHeapList(CLRDATA_ADDRESS jitManager, unsigned int count, s
528528
SOSDacEnter();
529529

530530
EEJitManager *pJitManager = PTR_EEJitManager(TO_TADDR(jitManager));
531-
HeapList *heapList = pJitManager->m_pCodeHeap;
531+
HeapList *heapList = pJitManager->m_pAllCodeHeaps;
532532

533533
if (codeHeaps)
534534
{

src/coreclr/debug/ee/debugger.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,10 +2286,10 @@ void DebuggerLazyInit::Init()
22862286
DebuggerLazyInit::~DebuggerLazyInit()
22872287
{
22882288
{
2289-
USHORT cBlobs = m_pMemBlobs.Count();
2289+
INT32 cBlobs = m_pMemBlobs.Count();
22902290
void **rgpBlobs = m_pMemBlobs.Table();
22912291

2292-
for (int i = 0; i < cBlobs; i++)
2292+
for (INT32 i = 0; i < cBlobs; i++)
22932293
{
22942294
g_pDebugger->ReleaseRemoteBuffer(rgpBlobs[i], false);
22952295
}
@@ -12154,10 +12154,10 @@ HRESULT Debugger::ReleaseRemoteBuffer(void *pBuffer, bool removeFromBlobList)
1215412154
// Remove the buffer from the blob list if necessary.
1215512155
if (removeFromBlobList)
1215612156
{
12157-
USHORT cBlobs = GetMemBlobs()->Count();
12157+
INT32 cBlobs = GetMemBlobs()->Count();
1215812158
void **rgpBlobs = GetMemBlobs()->Table();
1215912159

12160-
USHORT i;
12160+
INT32 i;
1216112161
for (i = 0; i < cBlobs; i++)
1216212162
{
1216312163
if (rgpBlobs[i] == pBuffer)

src/coreclr/inc/CrstTypes.def

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Crst AppDomainCache
7878
End
7979

8080
Crst PinnedHeapHandleTable
81-
AcquiredBefore AvailableParamTypes HandleTable IbcProfile SyncBlockCache SystemDomainDelayedUnloadList
81+
AcquiredBefore AvailableParamTypes HandleTable SyncBlockCache SystemDomainDelayedUnloadList
8282
SystemDomain
8383
End
8484

@@ -91,7 +91,7 @@ Crst AvailableClass
9191
End
9292

9393
Crst AvailableParamTypes
94-
AcquiredBefore ModuleLookupTable IbcProfile LoaderHeap
94+
AcquiredBefore ModuleLookupTable LoaderHeap
9595
End
9696

9797
Crst CCompRC
@@ -103,7 +103,7 @@ Crst ClassFactInfoHash
103103
End
104104

105105
Crst ClassInit
106-
AcquiredBefore DeadlockDetection IbcProfile
106+
AcquiredBefore DeadlockDetection
107107
SameLevelAs Jit
108108
End
109109

@@ -176,14 +176,14 @@ Crst DbgTransport
176176
End
177177

178178
Crst GenericDictionaryExpansion
179-
AcquiredBefore PinnedHeapHandleTable IbcProfile LoaderHeap SystemDomainDelayedUnloadList UniqueStack
179+
AcquiredBefore PinnedHeapHandleTable LoaderHeap SystemDomainDelayedUnloadList UniqueStack
180180
End
181181

182182
Crst DynamicIL
183183
End
184184

185185
Crst DynamicMT
186-
AcquiredBefore IbcProfile CodeVersioning
186+
AcquiredBefore CodeVersioning
187187
End
188188

189189
Crst EventStore
@@ -209,7 +209,7 @@ Crst MethodTableExposedObject
209209
End
210210

211211
Crst FuncPtrStubs
212-
AcquiredBefore IbcProfile LoaderHeap UniqueStack CodeFragmentHeap JumpStubCache
212+
AcquiredBefore LoaderHeap UniqueStack CodeFragmentHeap JumpStubCache
213213
End
214214

215215
Crst FusionAppCtx
@@ -221,16 +221,13 @@ Crst GCCover
221221
End
222222

223223
Crst GlobalStrLiteralMap
224-
AcquiredBefore PinnedHeapHandleTable HandleTable IbcProfile SyncBlockCache SystemDomainDelayedUnloadList ThreadStore UniqueStack
224+
AcquiredBefore PinnedHeapHandleTable HandleTable SyncBlockCache SystemDomainDelayedUnloadList ThreadStore UniqueStack
225225
End
226226

227227
Crst HandleTable
228228
SameLevelAs HandleTable
229229
End
230230

231-
Crst IbcProfile
232-
End
233-
234231
Crst IJWFixupData
235232
AcquiredBefore FuncPtrStubs IJWHash LoaderHeap
236233
End
@@ -329,7 +326,7 @@ Crst PendingTypeLoadEntry
329326
AcquiredBefore AppDomainCache PinnedHeapHandleTable AssemblyLoader AvailableClass AvailableParamTypes
330327
ClassInit DeadlockDetection DebuggerController DebuggerJitInfo DebuggerMutex
331328
GenericDictionaryExpansion Exception FuncPtrStubs
332-
FusionAppCtx GlobalStrLiteralMap HandleTable IbcProfile
329+
FusionAppCtx GlobalStrLiteralMap HandleTable
333330
IJWFixupData IJWHash ISymUnmanagedReader Jit JumpStubCache LoaderHeap
334331
Module ModuleLookupTable PEImage
335332
SigConvert SingleUseLock StubDispatchCache
@@ -352,7 +349,7 @@ Crst ProfilingAPIStatus
352349
End
353350

354351
Crst RCWCache
355-
AcquiredBefore IbcProfile LoaderHeap RCWCleanupList
352+
AcquiredBefore LoaderHeap RCWCleanupList
356353
End
357354

358355
Crst RCWCleanupList
@@ -415,7 +412,7 @@ Crst SyncHashLock
415412
End
416413

417414
Crst SystemDomain
418-
AcquiredBefore DebuggerMutex HandleTable IbcProfile
415+
AcquiredBefore DebuggerMutex HandleTable
419416
ThreadIdDispenser ThreadStore
420417
End
421418

@@ -431,7 +428,7 @@ End
431428

432429
Crst ThreadStore
433430
AcquiredBefore AvailableParamTypes DeadlockDetection DebuggerController
434-
DebuggerHeapLock DebuggerJitInfo DynamicIL HandleTable IbcProfile
431+
DebuggerHeapLock DebuggerJitInfo DynamicIL HandleTable
435432
JumpStubCache LoaderHeap ModuleLookupTable ProfilerGCRefDataFreeList
436433
SingleUseLock SyncBlockCache SystemDomainDelayedUnloadList ThreadIdDispenser DebuggerMutex
437434
JitInlineTrackingMap
@@ -453,11 +450,11 @@ Crst UniqueStack
453450
End
454451

455452
Crst UnresolvedClassLock
456-
AcquiredBefore AvailableParamTypes IbcProfile JumpStubCache
453+
AcquiredBefore AvailableParamTypes JumpStubCache
457454
End
458455

459456
Crst WrapperTemplate
460-
AcquiredBefore IbcProfile
457+
AcquiredBefore ExecutableAllocatorLock
461458
End
462459

463460
Crst UMEntryThunkCache
@@ -479,7 +476,6 @@ Crst MulticoreJitManager
479476
End
480477

481478
Crst InlineTrackingMap
482-
AcquiredBefore IbcProfile
483479
End
484480

485481
Crst JitInlineTrackingMap

src/coreclr/inc/contract.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ void CONTRACT_ASSERT(const char *szElaboration,
585585
}
586586
else
587587
{
588-
strcat_s(Buf,ARRAY_SIZE(Buf), "We can't find the violated contract. Look for an old-style non-holder-based contract.\n");
588+
strcat_s(Buf,ARRAY_SIZE(Buf), "Missing tracking information. Look for data structures that manipulate contract state (i.e., CrstHolder).\n");
589589
}
590590
}
591591

src/coreclr/inc/crsttypes_generated.h

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -54,72 +54,71 @@ enum CrstType
5454
CrstGenericDictionaryExpansion = 36,
5555
CrstGlobalStrLiteralMap = 37,
5656
CrstHandleTable = 38,
57-
CrstIbcProfile = 39,
58-
CrstIJWFixupData = 40,
59-
CrstIJWHash = 41,
60-
CrstILStubGen = 42,
61-
CrstInlineTrackingMap = 43,
62-
CrstInstMethodHashTable = 44,
63-
CrstInterfaceDispatchGlobalLists = 45,
64-
CrstInterop = 46,
65-
CrstInteropData = 47,
66-
CrstIsJMCMethod = 48,
67-
CrstISymUnmanagedReader = 49,
68-
CrstJit = 50,
69-
CrstJitInlineTrackingMap = 51,
70-
CrstJitPatchpoint = 52,
71-
CrstJumpStubCache = 53,
72-
CrstLeafLock = 54,
73-
CrstListLock = 55,
74-
CrstLoaderAllocator = 56,
75-
CrstLoaderAllocatorReferences = 57,
76-
CrstLoaderHeap = 58,
77-
CrstManagedObjectWrapperMap = 59,
78-
CrstMethodDescBackpatchInfoTracker = 60,
79-
CrstMethodTableExposedObject = 61,
80-
CrstModule = 62,
81-
CrstModuleLookupTable = 63,
82-
CrstMulticoreJitHash = 64,
83-
CrstMulticoreJitManager = 65,
84-
CrstNativeImageEagerFixups = 66,
85-
CrstNativeImageLoad = 67,
86-
CrstNotifyGdb = 68,
87-
CrstPEImage = 69,
88-
CrstPendingTypeLoadEntry = 70,
89-
CrstPerfMap = 71,
90-
CrstPgoData = 72,
91-
CrstPinnedByrefValidation = 73,
92-
CrstPinnedHeapHandleTable = 74,
93-
CrstProfilerGCRefDataFreeList = 75,
94-
CrstProfilingAPIStatus = 76,
95-
CrstRCWCache = 77,
96-
CrstRCWCleanupList = 78,
97-
CrstReadyToRunEntryPointToMethodDescMap = 79,
98-
CrstReflection = 80,
99-
CrstReJITGlobalRequest = 81,
100-
CrstSigConvert = 82,
101-
CrstSingleUseLock = 83,
102-
CrstStressLog = 84,
103-
CrstStubCache = 85,
104-
CrstStubDispatchCache = 86,
105-
CrstSyncBlockCache = 87,
106-
CrstSyncHashLock = 88,
107-
CrstSystemDomain = 89,
108-
CrstSystemDomainDelayedUnloadList = 90,
109-
CrstThreadIdDispenser = 91,
110-
CrstThreadLocalStorageLock = 92,
111-
CrstThreadStore = 93,
112-
CrstTieredCompilation = 94,
113-
CrstTypeEquivalenceMap = 95,
114-
CrstTypeIDMap = 96,
115-
CrstUMEntryThunkCache = 97,
116-
CrstUMEntryThunkFreeListLock = 98,
117-
CrstUniqueStack = 99,
118-
CrstUnresolvedClassLock = 100,
119-
CrstUnwindInfoTableLock = 101,
120-
CrstVSDIndirectionCellLock = 102,
121-
CrstWrapperTemplate = 103,
122-
kNumberOfCrstTypes = 104
57+
CrstIJWFixupData = 39,
58+
CrstIJWHash = 40,
59+
CrstILStubGen = 41,
60+
CrstInlineTrackingMap = 42,
61+
CrstInstMethodHashTable = 43,
62+
CrstInterfaceDispatchGlobalLists = 44,
63+
CrstInterop = 45,
64+
CrstInteropData = 46,
65+
CrstIsJMCMethod = 47,
66+
CrstISymUnmanagedReader = 48,
67+
CrstJit = 49,
68+
CrstJitInlineTrackingMap = 50,
69+
CrstJitPatchpoint = 51,
70+
CrstJumpStubCache = 52,
71+
CrstLeafLock = 53,
72+
CrstListLock = 54,
73+
CrstLoaderAllocator = 55,
74+
CrstLoaderAllocatorReferences = 56,
75+
CrstLoaderHeap = 57,
76+
CrstManagedObjectWrapperMap = 58,
77+
CrstMethodDescBackpatchInfoTracker = 59,
78+
CrstMethodTableExposedObject = 60,
79+
CrstModule = 61,
80+
CrstModuleLookupTable = 62,
81+
CrstMulticoreJitHash = 63,
82+
CrstMulticoreJitManager = 64,
83+
CrstNativeImageEagerFixups = 65,
84+
CrstNativeImageLoad = 66,
85+
CrstNotifyGdb = 67,
86+
CrstPEImage = 68,
87+
CrstPendingTypeLoadEntry = 69,
88+
CrstPerfMap = 70,
89+
CrstPgoData = 71,
90+
CrstPinnedByrefValidation = 72,
91+
CrstPinnedHeapHandleTable = 73,
92+
CrstProfilerGCRefDataFreeList = 74,
93+
CrstProfilingAPIStatus = 75,
94+
CrstRCWCache = 76,
95+
CrstRCWCleanupList = 77,
96+
CrstReadyToRunEntryPointToMethodDescMap = 78,
97+
CrstReflection = 79,
98+
CrstReJITGlobalRequest = 80,
99+
CrstSigConvert = 81,
100+
CrstSingleUseLock = 82,
101+
CrstStressLog = 83,
102+
CrstStubCache = 84,
103+
CrstStubDispatchCache = 85,
104+
CrstSyncBlockCache = 86,
105+
CrstSyncHashLock = 87,
106+
CrstSystemDomain = 88,
107+
CrstSystemDomainDelayedUnloadList = 89,
108+
CrstThreadIdDispenser = 90,
109+
CrstThreadLocalStorageLock = 91,
110+
CrstThreadStore = 92,
111+
CrstTieredCompilation = 93,
112+
CrstTypeEquivalenceMap = 94,
113+
CrstTypeIDMap = 95,
114+
CrstUMEntryThunkCache = 96,
115+
CrstUMEntryThunkFreeListLock = 97,
116+
CrstUniqueStack = 98,
117+
CrstUnresolvedClassLock = 99,
118+
CrstUnwindInfoTableLock = 100,
119+
CrstVSDIndirectionCellLock = 101,
120+
CrstWrapperTemplate = 102,
121+
kNumberOfCrstTypes = 103
123122
};
124123

125124
#endif // __CRST_TYPES_INCLUDED
@@ -169,11 +168,10 @@ int g_rgCrstLevelMap[] =
169168
17, // CrstGenericDictionaryExpansion
170169
16, // CrstGlobalStrLiteralMap
171170
1, // CrstHandleTable
172-
0, // CrstIbcProfile
173171
7, // CrstIJWFixupData
174172
0, // CrstIJWHash
175173
6, // CrstILStubGen
176-
2, // CrstInlineTrackingMap
174+
0, // CrstInlineTrackingMap
177175
18, // CrstInstMethodHashTable
178176
0, // CrstInterfaceDispatchGlobalLists
179177
21, // CrstInterop
@@ -278,7 +276,6 @@ LPCSTR g_rgCrstNameMap[] =
278276
"CrstGenericDictionaryExpansion",
279277
"CrstGlobalStrLiteralMap",
280278
"CrstHandleTable",
281-
"CrstIbcProfile",
282279
"CrstIJWFixupData",
283280
"CrstIJWHash",
284281
"CrstILStubGen",

0 commit comments

Comments
 (0)