Skip to content

Commit 04209de

Browse files
committed
JIT: Fixed warning when assign undefined variable to property
1 parent 70e9437 commit 04209de

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6016,6 +6016,28 @@ static int zend_jit_assign_to_variable_call(dasm_State **Dst,
60166016
zend_jit_addr __res_addr,
60176017
zend_bool __check_exception)
60186018
{
6019+
if (val_info & MAY_BE_UNDEF) {
6020+
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
6021+
int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);
6022+
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
6023+
6024+
if (!exit_addr) {
6025+
return 0;
6026+
}
6027+
6028+
| IF_ZVAL_TYPE val_addr, IS_UNDEF, &exit_addr
6029+
} else {
6030+
| IF_ZVAL_TYPE val_addr, IS_UNDEF, >1
6031+
|.cold_code
6032+
|1:
6033+
| SET_EX_OPLINE opline, r0
6034+
| mov FCARG1d, Z_OFFSET(val_addr)
6035+
| EXT_CALL zend_jit_undefined_op_helper, r0
6036+
| jmp >1
6037+
|.code
6038+
|1:
6039+
}
6040+
}
60196041
if (Z_MODE(var_addr) != IS_MEM_ZVAL || Z_REG(var_addr) != ZREG_FCARG1a || Z_OFFSET(var_addr) != 0) {
60206042
| LOAD_ZVAL_ADDR FCARG1a, var_addr
60216043
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT ASSIGN_OBJ: Assign undefined vatiable to property
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.jit=function
9+
--FILE--
10+
<?php
11+
class Test {
12+
public $prop;
13+
}
14+
function test() {
15+
$o = new Test;
16+
$o->prop = $undef;
17+
}
18+
test();
19+
?>
20+
DONE
21+
--EXPECTF--
22+
Warning: Undefined variable $undef in %sassign_obj_002.php on line 7
23+
DONE

0 commit comments

Comments
 (0)