Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT/ARM] Initialize R12 pointer from context in StackFrameIterator #97903

Merged
merged 1 commit into from
Feb 3, 2024
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/nativeaot/Runtime/StackFrameIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ void StackFrameIterator::InternalInit(Thread * pThreadToWalk, PInvokeTransitionF

#ifdef TARGET_ARM
m_RegDisplay.pLR = (PTR_UIntNative)PTR_HOST_MEMBER(PInvokeTransitionFrame, pFrame, m_RIP);
m_RegDisplay.pR11 = (PTR_UIntNative)PTR_HOST_MEMBER(PInvokeTransitionFrame, pFrame, m_ChainPointer);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We initialize pR11 few lines below. The whole code around m_ChainPointer is probably dead and can be removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like a left over from Windows Arm convention for frame-pointer chains.


if (pFrame->m_Flags & PTFF_SAVE_R4) { m_RegDisplay.pR4 = pPreservedRegsCursor++; }
if (pFrame->m_Flags & PTFF_SAVE_R5) { m_RegDisplay.pR5 = pPreservedRegsCursor++; }
Expand Down Expand Up @@ -632,6 +631,7 @@ void StackFrameIterator::InternalInit(Thread * pThreadToWalk, NATIVE_CONTEXT* pC
m_RegDisplay.pR9 = (PTR_UIntNative)PTR_TO_REG(pCtx, R9);
m_RegDisplay.pR10 = (PTR_UIntNative)PTR_TO_REG(pCtx, R10);
m_RegDisplay.pR11 = (PTR_UIntNative)PTR_TO_REG(pCtx, R11);
m_RegDisplay.pR12 = (PTR_UIntNative)PTR_TO_REG(pCtx, R12);
m_RegDisplay.pLR = (PTR_UIntNative)PTR_TO_REG(pCtx, Lr);
#else
PORTABILITY_ASSERT("StackFrameIterator::InternalInit");
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/nativeaot/Runtime/unix/UnixContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
#define MCREG_R9(mc) ((mc).arm_r9)
#define MCREG_R10(mc) ((mc).arm_r10)
#define MCREG_R11(mc) ((mc).arm_fp)
#define MCREG_R12(mc) ((mc).arm_ip)

#elif defined(HOST_X86)

Expand Down Expand Up @@ -526,6 +527,7 @@ uint64_t GetPC(void* context)
uint64_t& UNIX_CONTEXT::R9(){ return (uint64_t&)MCREG_R9(ctx.uc_mcontext); }
uint64_t& UNIX_CONTEXT::R10(){ return (uint64_t&)MCREG_R10(ctx.uc_mcontext); }
uint64_t& UNIX_CONTEXT::R11(){ return (uint64_t&)MCREG_R11(ctx.uc_mcontext); }
uint64_t& UNIX_CONTEXT::R12(){ return (uint64_t&)MCREG_R12(ctx.uc_mcontext); }

#else
PORTABILITY_ASSERT("UNIX_CONTEXT");
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/nativeaot/Runtime/unix/UnixContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ struct UNIX_CONTEXT
uint64_t& R9();
uint64_t& R10();
uint64_t& R11();
uint64_t& R12();

uintptr_t GetIp() { return (uintptr_t)Pc(); }
uintptr_t GetSp() { return (uintptr_t)Sp(); }
Expand All @@ -155,6 +156,7 @@ struct UNIX_CONTEXT
lambda((size_t*)&R9());
lambda((size_t*)&R10());
lambda((size_t*)&R11());
lambda((size_t*)&R12());
}
#else
PORTABILITY_ASSERT("UNIX_CONTEXT");
Expand Down
Loading