From b8472f788f0489e5df2f5ca24d3bb2c5fa789125 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 24 Feb 2025 19:52:57 +0100 Subject: [PATCH] Backport GH-17869 to PHP 8.3 JIT --- ext/opcache/jit/zend_jit_arm64.dasc | 17 ++++++++++++----- ext/opcache/jit/zend_jit_x86.dasc | 16 +++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ext/opcache/jit/zend_jit_arm64.dasc b/ext/opcache/jit/zend_jit_arm64.dasc index ec6fae8819fcd..985c08f0512ea 100644 --- a/ext/opcache/jit/zend_jit_arm64.dasc +++ b/ext/opcache/jit/zend_jit_arm64.dasc @@ -8655,11 +8655,18 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, con | str TMP1w, EX:RX->This.u1.type_info | // Z_PTR(call->This) = object_or_called_scope; | str REG1, EX:RX->This.value.ptr - | ldr TMP1, [REG0, #offsetof(zend_closure, func.op_array.run_time_cache__ptr)] - | cbnz TMP1, >1 - | add FCARG1x, REG0, #offsetof(zend_closure, func) - | EXT_CALL zend_jit_init_func_run_time_cache_helper, REG0 - |1: + if (!func) { + | ldrb TMP1w, [REG0, #offsetof(zend_closure, func.type)] + | cmp TMP1w, #ZEND_USER_FUNCTION + | beq >1 + } + if (!func || func->common.type == ZEND_USER_FUNCTION) { + | add FCARG1x, REG0, #offsetof(zend_closure, func) + | EXT_CALL zend_jit_init_func_run_time_cache_helper, REG0 + } + if (!func) { + |1: + } } | // ZEND_CALL_NUM_ARGS(call) = num_args; | LOAD_32BIT_VAL TMP1w, opline->extended_value diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index f65dc769db57d..1f1abb59a1c24 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -9255,11 +9255,17 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, con | or dword EX:RX->This.u1.type_info, edx | // Z_PTR(call->This) = object_or_called_scope; | mov aword EX:RX->This.value.ptr, r1 - | cmp aword [r0 + offsetof(zend_closure, func.op_array.run_time_cache__ptr)], 0 - | jnz >1 - | lea FCARG1a, aword [r0 + offsetof(zend_closure, func)] - | EXT_CALL zend_jit_init_func_run_time_cache_helper, r0 - |1: + if (!func) { + | cmp byte [r0 + offsetof(zend_closure, func.type)], ZEND_USER_FUNCTION + | jnz >1 + } + if (!func || func->common.type == ZEND_USER_FUNCTION) { + | lea FCARG1a, aword [r0 + offsetof(zend_closure, func)] + | EXT_CALL zend_jit_init_func_run_time_cache_helper, r0 + } + if (!func) { + |1: + } } | // ZEND_CALL_NUM_ARGS(call) = num_args; | mov dword EX:RX->This.u2.num_args, opline->extended_value