From d9e39f5c6f70a4de3c201b436f447dc069d49e0e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Mar 2025 21:53:45 +0300 Subject: [PATCH] Fix JIT for INIT_STATIC_METHOD_CALL in a closure --- ext/opcache/jit/zend_jit_ir.c | 2 +- .../jit/init_static_method_call_001.phpt | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/jit/init_static_method_call_001.phpt diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 4ef32415abe..a3aae9b921f 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -9353,7 +9353,7 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit, if (opline->op1_type == IS_UNUSED && ((opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_PARENT || (opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF)) { - if (op_array->fn_flags & ZEND_ACC_STATIC) { + if (!op_array->scope || (op_array->fn_flags & ZEND_ACC_STATIC)) { scope_ref = ir_LOAD_A(jit_EX(This.value.ref)); } else { scope_ref = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_EX(This.value.ref)), offsetof(zend_object, ce))); diff --git a/ext/opcache/tests/jit/init_static_method_call_001.phpt b/ext/opcache/tests/jit/init_static_method_call_001.phpt new file mode 100644 index 00000000000..b6f1b95cc1e --- /dev/null +++ b/ext/opcache/tests/jit/init_static_method_call_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +JIT INIT_STATIC_METHOD_CALL: 001 Invalid scope +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +--EXTENSIONS-- +opcache +--FILE-- + +--EXPECT-- +int(15)