Skip to content

Commit afeadc6

Browse files
committed
JIT: Fixed incorrect FETCH_OBJ_W code for typed property
1 parent 8cfd7e2 commit afeadc6

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12839,7 +12839,11 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1283912839
|.cold_code
1284012840
|1:
1284112841
| test dword [FCARG2a + offsetof(zend_property_info, flags)], ZEND_ACC_READONLY
12842-
| jz >3
12842+
if (flags) {
12843+
| jz >3
12844+
} else {
12845+
| jz >4
12846+
}
1284312847
| IF_NOT_Z_TYPE FCARG1a, IS_OBJECT, >2
1284412848
| GET_Z_PTR r0, FCARG1a
1284512849
| GC_ADDREF r0
@@ -12873,6 +12877,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1287312877
ZEND_ASSERT(flags == 0);
1287412878
}
1287512879
|.code
12880+
|4:
1287612881
}
1287712882
} else {
1287812883
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1, prop_info->offset);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
JIT: FETCH_OBJ 007
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
class C {
11+
public ?C $prop = null;
12+
}
13+
function foo($obj) {
14+
$obj->prop->prop = null;
15+
}
16+
17+
$obj = new C;
18+
$obj->prop = new C;
19+
for ($i = 0; $i < 10; $i++) {
20+
foo($obj);
21+
}
22+
var_dump($obj);
23+
?>
24+
--EXPECT--
25+
object(C)#1 (1) {
26+
["prop"]=>
27+
object(C)#2 (1) {
28+
["prop"]=>
29+
NULL
30+
}
31+
}

0 commit comments

Comments
 (0)