Skip to content

Commit 10526fe

Browse files
committed
Delete stackwalk cache
It costs about as much as it saves on x64. It may be helping a little bit on x86, but it is not worth it to keep it around for that.
1 parent 8806af9 commit 10526fe

23 files changed

+89
-720
lines changed

src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/AsmOffsets.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ class AsmOffsets
4848

4949
#if TARGET_64BIT
5050
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x8;
51-
public const int SIZEOF__StackFrameIterator = 0x370;
52-
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x352;
53-
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x368;
51+
public const int SIZEOF__StackFrameIterator = 0x358;
52+
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x33A;
53+
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x350;
5454
#else // TARGET_64BIT
5555
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x4;
56-
public const int SIZEOF__StackFrameIterator = 0x2d8;
57-
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2c2;
58-
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2d0;
56+
public const int SIZEOF__StackFrameIterator = 0x2c8;
57+
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2b6;
58+
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2c4;
5959
#endif // TARGET_64BIT
6060

6161
#else // DEBUG
@@ -94,14 +94,14 @@ class AsmOffsets
9494

9595
#if TARGET_64BIT
9696
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x8;
97-
public const int SIZEOF__StackFrameIterator = 0x370;
98-
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x34a;
99-
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x360;
97+
public const int SIZEOF__StackFrameIterator = 0x350;
98+
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x332;
99+
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x348;
100100
#else // TARGET_64BIT
101101
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x4;
102-
public const int SIZEOF__StackFrameIterator = 0x2d0;
103-
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2ba;
104-
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2c8;
102+
public const int SIZEOF__StackFrameIterator = 0x2c0;
103+
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2ae;
104+
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2bc;
105105
#endif // TARGET_64BIT
106106

107107
#endif // DEBUG
@@ -155,7 +155,7 @@ class AsmOffsets
155155
public const int OFFSETOF__ExInfo__m_kind = 0xd0;
156156
public const int OFFSETOF__ExInfo__m_passNumber = 0xd1;
157157
public const int OFFSETOF__ExInfo__m_idxCurClause = 0xd4;
158-
public const int OFFSETOF__ExInfo__m_frameIter = 0xe0;
158+
public const int OFFSETOF__ExInfo__m_frameIter = 0xd8;
159159
public const int OFFSETOF__ExInfo__m_notifyDebuggerSP = OFFSETOF__ExInfo__m_frameIter + SIZEOF__StackFrameIterator;
160160
#else // TARGET_64BIT
161161
public const int SIZEOF__EHEnum = 0x10;

src/coreclr/inc/CrstTypes.def

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Crst PendingTypeLoadEntry
367367
DomainLocalBlock Exception ExecuteManRangeLock FuncPtrStubs
368368
FusionAppCtx GlobalStrLiteralMap HandleTable IbcProfile
369369
IJWFixupData IJWHash ISymUnmanagedReader Jit JumpStubCache LoaderHeap
370-
Module ModuleLookupTable PEImage SecurityStackwalkCache
370+
Module ModuleLookupTable PEImage
371371
SigConvert SingleUseLock StubDispatchCache StubUnwindInfoHeapSegments
372372
SyncBlockCache SystemDomain ThreadIdDispenser ThreadStore TypeIDMap UnresolvedClassLock
373373
SameLevelAs PendingTypeLoadEntry
@@ -426,9 +426,6 @@ End
426426
Crst SaveModuleProfileData
427427
End
428428

429-
Crst SecurityStackwalkCache
430-
End
431-
432429
Crst SigConvert
433430
AcquiredBefore LoaderHeap
434431
End

src/coreclr/inc/dacvars.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ DEFINE_DACVAR(PTR_SString, SString__s_Empty, SString::s_Empty)
124124

125125
DEFINE_DACVAR(INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero)
126126

127-
DEFINE_DACVAR(BOOL, StackwalkCache__s_Enabled, StackwalkCache::s_Enabled)
128-
129127
DEFINE_DACVAR(PTR_JITNotification, dac__g_pNotificationTable, ::g_pNotificationTable)
130128
DEFINE_DACVAR(ULONG32, dac__g_dacNotificationFlags, ::g_dacNotificationFlags)
131129
DEFINE_DACVAR(PTR_GcNotification, dac__g_pGcNotificationTable, ::g_pGcNotificationTable)

src/coreclr/inc/eetwain.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define USE_GC_INFO_DECODER
3636
#endif
3737

38-
#if (defined(TARGET_X86) && !defined(TARGET_UNIX)) || defined(TARGET_AMD64)
38+
#ifdef TARGET_AMD64
3939
#define HAS_QUICKUNWIND
4040
#endif
4141

@@ -201,8 +201,7 @@ virtual ULONG32 GetStackParameterSize(EECodeInfo* pCodeInfo) = 0;
201201
virtual bool UnwindStackFrame(PREGDISPLAY pContext,
202202
EECodeInfo *pCodeInfo,
203203
unsigned flags,
204-
CodeManState *pState,
205-
StackwalkCacheUnwindInfo *pUnwindInfo) = 0;
204+
CodeManState *pState) = 0;
206205

207206
/*
208207
Is the function currently at a "GC safe point" ?
@@ -425,8 +424,7 @@ bool UnwindStackFrame(
425424
PREGDISPLAY pContext,
426425
EECodeInfo *pCodeInfo,
427426
unsigned flags,
428-
CodeManState *pState,
429-
StackwalkCacheUnwindInfo *pUnwindInfo);
427+
CodeManState *pState);
430428

431429
#ifdef HAS_QUICKUNWIND
432430
enum QuickUnwindFlag
@@ -443,7 +441,7 @@ enum QuickUnwindFlag
443441
static
444442
void QuickUnwindStackFrame(
445443
PREGDISPLAY pRD,
446-
StackwalkCacheEntry *pCacheEntry,
444+
EECodeInfo *pCodeInfo,
447445
QuickUnwindFlag flag);
448446
#endif // HAS_QUICKUNWIND
449447

@@ -615,7 +613,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,
615613
#endif // #ifndef DACCESS_COMPILE
616614

617615
#ifdef FEATURE_EH_FUNCLETS
618-
static void EnsureCallerContextIsValid( PREGDISPLAY pRD, StackwalkCacheEntry* pCacheEntry, EECodeInfo * pCodeInfo = NULL );
616+
static void EnsureCallerContextIsValid( PREGDISPLAY pRD, EECodeInfo * pCodeInfo = NULL, unsigned flags = 0);
619617
static size_t GetCallerSp( PREGDISPLAY pRD );
620618
#ifdef TARGET_X86
621619
static size_t GetResumeSp( PCONTEXT pContext );
@@ -632,8 +630,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,
632630
bool UnwindStackFrame(PREGDISPLAY pContext,
633631
EECodeInfo *pCodeInfo,
634632
unsigned flags,
635-
CodeManState *pState,
636-
StackwalkCacheUnwindInfo *pUnwindInfo);
633+
CodeManState *pState);
637634

638635
size_t DecodeGCHdrInfo(GCInfoToken gcInfoToken,
639636
unsigned curOffset,

src/coreclr/inc/regdisp.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ inline void FillContextPointers(PT_KNONVOLATILE_CONTEXT_POINTERS pCtxPtrs, PT_CO
447447
}
448448
#endif // FEATURE_EH_FUNCLETS
449449

450-
inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pCallerCtx = NULL)
450+
inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pCallerCtx = NULL, bool fQuickUnwind = false)
451451
{
452452
WRAPPER_NO_CONTRACT;
453453

@@ -497,6 +497,16 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
497497
pRD->IsCallerSPValid = TRUE; // Don't add usage of this field. This is only temporary.
498498
}
499499

500+
#ifdef DEBUG_REGDISPLAY
501+
pRD->_pThread = NULL;
502+
#endif // DEBUG_REGDISPLAY
503+
504+
// This will setup the PC and SP
505+
SyncRegDisplayToCurrentContext(pRD);
506+
507+
if (fQuickUnwind)
508+
return;
509+
500510
FillContextPointers(&pRD->ctxPtrsOne, pctx);
501511

502512
#if defined(TARGET_ARM)
@@ -550,12 +560,6 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
550560
pRD->volatileCurrContextPointers.T6 = &pctx->T6;
551561
#endif // TARGET_RISCV64
552562

553-
#ifdef DEBUG_REGDISPLAY
554-
pRD->_pThread = NULL;
555-
#endif // DEBUG_REGDISPLAY
556-
557-
// This will setup the PC and SP
558-
SyncRegDisplayToCurrentContext(pRD);
559563
#endif // !FEATURE_EH_FUNCLETS
560564
}
561565

src/coreclr/vm/amd64/AsmHelpers.asm

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -634,18 +634,6 @@ NESTED_ENTRY ProfileTailcallNaked, _TEXT
634634
NESTED_END ProfileTailcallNaked, _TEXT
635635

636636

637-
; EXTERN_C void moveOWord(LPVOID* src, LPVOID* target);
638-
; <NOTE>
639-
; MOVDQA is not an atomic operation. You need to call this function in a crst.
640-
; </NOTE>
641-
LEAF_ENTRY moveOWord, _TEXT
642-
movdqa xmm0, [rcx]
643-
movdqa [rdx], xmm0
644-
645-
ret
646-
LEAF_END moveOWord, _TEXT
647-
648-
649637
extern JIT_InternalThrowFromHelper:proc
650638

651639
LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT

src/coreclr/vm/amd64/unixasmhelpers.S

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,6 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler
106106
TAILJMP_RAX
107107
NESTED_END NDirectImportThunk, _TEXT
108108

109-
// EXTERN_C void moveOWord(LPVOID* src, LPVOID* target);
110-
// <NOTE>
111-
// MOVDQA is not an atomic operation. You need to call this function in a crst.
112-
// </NOTE>
113-
LEAF_ENTRY moveOWord, _TEXT
114-
movdqu xmm0, xmmword ptr [rdi]
115-
movdqu xmmword ptr [rsi], xmm0
116-
117-
ret
118-
LEAF_END moveOWord, _TEXT
119-
120109
//------------------------------------------------
121110
// JIT_RareDisableHelper
122111
//

src/coreclr/vm/appdomain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ Module* SystemDomain::GetCallersModule(StackCrawlMark* stackMark)
16081608
ZeroMemory(&cdata, sizeof(CallersDataWithStackMark));
16091609
cdata.stackMark = stackMark;
16101610

1611-
GetThread()->StackWalkFrames(CallersMethodCallbackWithStackMark, &cdata, FUNCTIONSONLY | LIGHTUNWIND);
1611+
GetThread()->StackWalkFrames(CallersMethodCallbackWithStackMark, &cdata, FUNCTIONSONLY | QUICKUNWIND);
16121612

16131613
if(cdata.pFoundMethod) {
16141614
return cdata.pFoundMethod->GetModule();

src/coreclr/vm/ceemain.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,6 @@ void EEStartupHelper()
869869
// Set up the sync block
870870
SyncBlockCache::Start();
871871

872-
StackwalkCache::Init();
873-
874872
// This isn't done as part of InitializeGarbageCollector() above because it
875873
// requires write barriers to have been set up on x86, which happens as part
876874
// of InitJITHelpers1.

src/coreclr/vm/codeman.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4938,14 +4938,6 @@ void ExecutionManager::Unload(LoaderAllocator *pLoaderAllocator)
49384938
// a size of 0 is a signal to Nirvana to flush the entire cache
49394939
FlushInstructionCache(GetCurrentProcess(),0,0);
49404940

4941-
/* StackwalkCacheEntry::EIP is an address into code. Since we are
4942-
unloading the code, we need to invalidate the cache. Otherwise,
4943-
its possible that another appdomain might generate code at the very
4944-
same address, and we might incorrectly think that the old
4945-
StackwalkCacheEntry corresponds to it. So flush the cache.
4946-
*/
4947-
StackwalkCache::Invalidate(pLoaderAllocator);
4948-
49494941
JumpStubCache * pJumpStubCache = (JumpStubCache *) pLoaderAllocator->m_pJumpStubCache;
49504942
if (pJumpStubCache != NULL)
49514943
{

0 commit comments

Comments
 (0)