Patch-Source: https://github.com/php/php-src/commit/95d52d52da50f4a9302a5d3ef9aed6acfb26ddbd From 95d52d52da50f4a9302a5d3ef9aed6acfb26ddbd Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 29 Aug 2025 13:05:23 +0200 Subject: [PATCH] Fix JIT stack setup on aarch64/clang On aarch64 we must set IR_USE_FRAME_POINTER to ensure that LR/x30 is saved. Also, fixed_stack_frame_size must be n*16, not n*16+8 like on x86. Fixes GH-19601 Closes GH-19630 --- NEWS | 1 + ext/opcache/jit/zend_jit_ir.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index fcfe1bffa744..57f7e189e6c4 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -2734,7 +2734,15 @@ static void zend_jit_init_ctx(zend_jit_ctx *jit, uint32_t flags) /* Stack must be 16 byte aligned */ /* TODO: select stack size ??? */ #if ZEND_VM_KIND == ZEND_VM_KIND_TAILCALL +# if defined(IR_TARGET_AARCH64) + /* Must save LR */ + jit->ctx.flags |= IR_USE_FRAME_POINTER; + /* Same as HYBRID VM */ + jit->ctx.fixed_stack_frame_size = sizeof(void*) * 4; /* 4 spill slots */ +# else + /* Same as HYBRID VM, plus 1 slot for re-alignment (caller pushes return address, frame is not aligned on entry) */ jit->ctx.fixed_stack_frame_size = sizeof(void*) * 5; /* 5 spill slots (8 bytes) or 10 spill slots (4 bytes) */ +# endif #elif defined(IR_TARGET_AARCH64) jit->ctx.flags |= IR_USE_FRAME_POINTER; jit->ctx.fixed_stack_frame_size = sizeof(void*) * 16; /* 10 saved registers and 6 spill slots (8 bytes) */