Skip to content

Commit 5cdbfa8

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix cache slot assignment for ASSIGN_OBJ_OP
2 parents 1fe0b87 + d0860f6 commit 5cdbfa8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Zend/Optimizer/zend_optimizer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,16 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
448448
case ZEND_PRE_DEC_OBJ:
449449
case ZEND_POST_INC_OBJ:
450450
case ZEND_POST_DEC_OBJ:
451-
case ZEND_ASSIGN_OBJ_OP:
452451
TO_STRING_NOWARN(val);
453452
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
454453
opline->extended_value = alloc_cache_slots(op_array, 3);
455454
break;
455+
case ZEND_ASSIGN_OBJ_OP:
456+
TO_STRING_NOWARN(val);
457+
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
458+
ZEND_ASSERT((opline + 1)->opcode == ZEND_OP_DATA);
459+
(opline + 1)->extended_value = alloc_cache_slots(op_array, 3);
460+
break;
456461
case ZEND_ISSET_ISEMPTY_PROP_OBJ:
457462
TO_STRING_NOWARN(val);
458463
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
The ASSIGN_OBJ_OP cache slot is on the OP_DATA opcode
3+
--FILE--
4+
<?php
5+
function test($a) {
6+
$b = "x";
7+
$a->$b = 1;
8+
$a->$b &= 1;
9+
var_dump($a->$b);
10+
}
11+
test(new stdClass);
12+
?>
13+
--EXPECT--
14+
int(1)

0 commit comments

Comments
 (0)