Fix JIT for INIT_STATIC_METHOD_CALL in a closure

This commit is contained in:
Dmitry Stogov 2025-03-06 21:53:45 +03:00
parent 5009c236fc
commit d9e39f5c6f
No known key found for this signature in database
2 changed files with 25 additions and 1 deletions

View file

@ -9353,7 +9353,7 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit,
if (opline->op1_type == IS_UNUSED 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_PARENT ||
(opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF)) { (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)); scope_ref = ir_LOAD_A(jit_EX(This.value.ref));
} else { } else {
scope_ref = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_EX(This.value.ref)), offsetof(zend_object, ce))); scope_ref = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_EX(This.value.ref)), offsetof(zend_object, ce)));

View file

@ -0,0 +1,24 @@
--TEST--
JIT INIT_STATIC_METHOD_CALL: 001 Invalid scope
--INI--
opcache.enable=1
opcache.enable_cli=1
--EXTENSIONS--
opcache
--FILE--
<?php
class C {
public static function foo() {
$f = function() {
return call_user_func(self::bar(), 1, 2, 3, 4, 5);
};
return $f();
}
public static function bar() {
return function($a, $b, $c, $d, $e) {return $a + $b + $c + $d + $e;};
}
}
var_dump(C::foo());
?>
--EXPECT--
int(15)