Skip to content

Commit 85fb1b9

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Fix deferred compile trampoline using blr instead of br
Summary: The AArch64 JitHelpers indirection stub for deferred function compilation used `blr` (branch with link) to call the failed_deferred_compile_trampoline, which clobbered the link register (x30) with the address of the next instruction (the resume entry point). When the trampoline returned, it jumped to the resume entry instead of returning to the original call site in the JIT-compiled function. The x86 version correctly uses `jmp` (no return address push). Changed the AArch64 version to use `br` (branch without link) to match, preserving the original return address in x30 so the trampoline returns to the correct call site. This fixes segfaults in async/await tests and other tests involving unjitable functions called from JIT-compiled code (e.g., test_awaited_invoke_function_unjitable). Reviewed By: kddnewton Differential Revision: D93875145 fbshipit-source-id: 98126def5763ad2a2103bffb118f76a0634d3546
1 parent 1f07568 commit 85fb1b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cinderx/Jit/codegen/gen_asm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,7 @@ void NativeGenerator::generateEpilogue(BaseNode* epilogue_cursor) {
21762176
as_->bind(trampoline);
21772177
as_->mov(a64::x10, reinterpret_cast<uint64_t>(x.first));
21782178
as_->mov(arch::reg_scratch_br, failed_deferred_compile_trampoline_);
2179-
as_->blr(arch::reg_scratch_br);
2179+
as_->br(arch::reg_scratch_br);
21802180
x.second.trampoline = trampoline;
21812181
}
21822182
env_.addAnnotation("JitHelpers", jit_helpers);

0 commit comments

Comments
 (0)