Skip to content

Commit 98302a3

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Use footer address which is loaded into frame pointer to find generator frames
Summary: On ARM the callee is preserving the frame register - so when a JITed function calls out with it's frame register pointing at the footer data that's the value that we will see in our callees saved register. So to identify the IP of the JIT generator function we look for the footer rather than the original frame. Reviewed By: kddnewton Differential Revision: D93525511 fbshipit-source-id: 0612a4144396fa455017a0e33296b37ba8705a50
1 parent 1e1525b commit 98302a3

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cinderx/Jit/frame.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,17 @@ uintptr_t getIP(_PyInterpreterFrame* frame, int frame_size) {
100100
auto footer = jitGenDataFooter(gen);
101101
if (footer->yieldPoint == nullptr) {
102102
// The generator is running.
103+
#if defined(__x86_64__)
104+
// On x86, we read the return address from a fixed offset on the real
105+
// stack relative to the resume function's RBP.
103106
frame_base = footer->originalFramePointer;
107+
#elif defined(__aarch64__)
108+
// On ARM64, we walk the frame pointer chain to find the JIT frame.
109+
// During generator execution, FP is set to the GenDataFooter pointer
110+
// (gi_jit_data), so that's what callees save as their frame pointer
111+
// and what we need to match against in the chain.
112+
frame_base = reinterpret_cast<uintptr_t>(footer);
113+
#endif
104114
} else {
105115
// The generator is suspended.
106116
return footer->yieldPoint->resumeTarget();

0 commit comments

Comments
 (0)