Skip to content

Commit d9e39f5

Browse files
committed
Fix JIT for INIT_STATIC_METHOD_CALL in a closure
1 parent 5009c23 commit d9e39f5

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9353,7 +9353,7 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit,
93539353
if (opline->op1_type == IS_UNUSED
93549354
&& ((opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_PARENT ||
93559355
(opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF)) {
9356-
if (op_array->fn_flags & ZEND_ACC_STATIC) {
9356+
if (!op_array->scope || (op_array->fn_flags & ZEND_ACC_STATIC)) {
93579357
scope_ref = ir_LOAD_A(jit_EX(This.value.ref));
93589358
} else {
93599359
scope_ref = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_EX(This.value.ref)), offsetof(zend_object, ce)));
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
JIT INIT_STATIC_METHOD_CALL: 001 Invalid scope
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--EXTENSIONS--
7+
opcache
8+
--FILE--
9+
<?php
10+
class C {
11+
public static function foo() {
12+
$f = function() {
13+
return call_user_func(self::bar(), 1, 2, 3, 4, 5);
14+
};
15+
return $f();
16+
}
17+
public static function bar() {
18+
return function($a, $b, $c, $d, $e) {return $a + $b + $c + $d + $e;};
19+
}
20+
}
21+
var_dump(C::foo());
22+
?>
23+
--EXPECT--
24+
int(15)

0 commit comments

Comments
 (0)