Skip to content

Commit

Permalink
JIT: Fixed incorrect FETCH_OBJ_W code for typed property
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Oct 13, 2021
1 parent 8cfd7e2 commit afeadc6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -12839,7 +12839,11 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
|.cold_code
|1:
| test dword [FCARG2a + offsetof(zend_property_info, flags)], ZEND_ACC_READONLY
| jz >3
if (flags) {
| jz >3
} else {
| jz >4
}
| IF_NOT_Z_TYPE FCARG1a, IS_OBJECT, >2
| GET_Z_PTR r0, FCARG1a
| GC_ADDREF r0
Expand Down Expand Up @@ -12873,6 +12877,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
ZEND_ASSERT(flags == 0);
}
|.code
|4:
}
} else {
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1, prop_info->offset);
Expand Down
31 changes: 31 additions & 0 deletions ext/opcache/tests/jit/fetch_obj_007.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
JIT: FETCH_OBJ 007
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
class C {
public ?C $prop = null;
}
function foo($obj) {
$obj->prop->prop = null;
}

$obj = new C;
$obj->prop = new C;
for ($i = 0; $i < 10; $i++) {
foo($obj);
}
var_dump($obj);
?>
--EXPECT--
object(C)#1 (1) {
["prop"]=>
object(C)#2 (1) {
["prop"]=>
NULL
}
}

0 comments on commit afeadc6

Please sign in to comment.