Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  Fix cache slot assignment for ASSIGN_OBJ_OP
This commit is contained in:
Nikita Popov 2021-09-30 14:34:50 +02:00
commit 5cdbfa897c
2 changed files with 20 additions and 1 deletions

View File

@ -448,11 +448,16 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
case ZEND_PRE_DEC_OBJ:
case ZEND_POST_INC_OBJ:
case ZEND_POST_DEC_OBJ:
case ZEND_ASSIGN_OBJ_OP:
TO_STRING_NOWARN(val);
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
opline->extended_value = alloc_cache_slots(op_array, 3);
break;
case ZEND_ASSIGN_OBJ_OP:
TO_STRING_NOWARN(val);
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
ZEND_ASSERT((opline + 1)->opcode == ZEND_OP_DATA);
(opline + 1)->extended_value = alloc_cache_slots(op_array, 3);
break;
case ZEND_ISSET_ISEMPTY_PROP_OBJ:
TO_STRING_NOWARN(val);
opline->op2.constant = zend_optimizer_add_literal(op_array, val);

View File

@ -0,0 +1,14 @@
--TEST--
The ASSIGN_OBJ_OP cache slot is on the OP_DATA opcode
--FILE--
<?php
function test($a) {
$b = "x";
$a->$b = 1;
$a->$b &= 1;
var_dump($a->$b);
}
test(new stdClass);
?>
--EXPECT--
int(1)