Skip to content

Commit 36439c5

Browse files
authored
Fix redundant MethodInfo lookup in UnixNativeCodeManager (#87664)
Fixes #75807
1 parent be6a138 commit 36439c5

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,23 @@ bool UnixNativeCodeManager::UnwindStackFrame(MethodInfo * pMethodInfo,
368368

369369
bool UnixNativeCodeManager::IsUnwindable(PTR_VOID pvAddress)
370370
{
371+
MethodInfo * pMethodInfo = NULL;
372+
373+
#if defined(TARGET_ARM64)
374+
MethodInfo methodInfo;
375+
FindMethodInfo(pvAddress, &methodInfo);
376+
pMethodInfo = &methodInfo;
377+
#endif
378+
371379
// VirtualUnwind can't unwind epilogues.
372-
return TrailingEpilogueInstructionsCount(pvAddress) == 0;
380+
return TrailingEpilogueInstructionsCount(pMethodInfo, pvAddress) == 0;
373381
}
374382

375383
// when stopped in an epilogue, returns the count of remaining stack-consuming instructions
376384
// otherwise returns
377385
// 0 - not in epilogue,
378386
// -1 - unknown.
379-
int UnixNativeCodeManager::TrailingEpilogueInstructionsCount(PTR_VOID pvAddress)
387+
int UnixNativeCodeManager::TrailingEpilogueInstructionsCount(MethodInfo * pMethodInfo, PTR_VOID pvAddress)
380388
{
381389
#ifdef TARGET_AMD64
382390

@@ -598,9 +606,8 @@ int UnixNativeCodeManager::TrailingEpilogueInstructionsCount(PTR_VOID pvAddress)
598606
#define BEGS_BITS 0x14000000
599607
#define BEGS_MASK 0x1C000000
600608

601-
MethodInfo pMethodInfo;
602-
FindMethodInfo(pvAddress, &pMethodInfo);
603-
UnixNativeMethodInfo* pNativeMethodInfo = (UnixNativeMethodInfo*)&pMethodInfo;
609+
UnixNativeMethodInfo * pNativeMethodInfo = (UnixNativeMethodInfo *)pMethodInfo;
610+
ASSERT(pNativeMethodInfo != NULL);
604611

605612
uint32_t* start = (uint32_t*)pNativeMethodInfo->pMethodStartAddress;
606613

@@ -699,7 +706,7 @@ bool UnixNativeCodeManager::GetReturnAddressHijackInfo(MethodInfo * pMethodIn
699706
GcInfoDecoder decoder(GCInfoToken(p), flags);
700707
*pRetValueKind = GetGcRefKind(decoder.GetReturnKind());
701708

702-
int epilogueInstructions = TrailingEpilogueInstructionsCount((PTR_VOID)pRegisterSet->IP);
709+
int epilogueInstructions = TrailingEpilogueInstructionsCount(pMethodInfo, (PTR_VOID)pRegisterSet->IP);
703710
if (epilogueInstructions < 0)
704711
{
705712
// can't figure, possibly a breakpoint instruction

src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ class UnixNativeCodeManager : public ICodeManager
5959
PInvokeTransitionFrame** ppPreviousTransitionFrame); // out
6060

6161
uintptr_t GetConservativeUpperBoundForOutgoingArgs(MethodInfo * pMethodInfo,
62-
REGDISPLAY * pRegisterSet);
62+
REGDISPLAY * pRegisterSet);
6363

6464
bool IsUnwindable(PTR_VOID pvAddress);
6565

66-
int TrailingEpilogueInstructionsCount(PTR_VOID pvAddress);
66+
int TrailingEpilogueInstructionsCount(MethodInfo * pMethodInfo, PTR_VOID pvAddress);
6767

6868
bool GetReturnAddressHijackInfo(MethodInfo * pMethodInfo,
6969
REGDISPLAY * pRegisterSet, // in

0 commit comments

Comments
 (0)