Skip to content

Commit d0860f6

Browse files
committed
Fix cache slot assignment for ASSIGN_OBJ_OP
ASSIGN_OBJ_OP stores the cache slot in OP_DATA, so this ended up overwriting the binop opcode instread.
1 parent 512dfab commit d0860f6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
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)

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,16 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
451451
case ZEND_PRE_DEC_OBJ:
452452
case ZEND_POST_INC_OBJ:
453453
case ZEND_POST_DEC_OBJ:
454-
case ZEND_ASSIGN_OBJ_OP:
455454
TO_STRING_NOWARN(val);
456455
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
457456
opline->extended_value = alloc_cache_slots(op_array, 3);
458457
break;
458+
case ZEND_ASSIGN_OBJ_OP:
459+
TO_STRING_NOWARN(val);
460+
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
461+
ZEND_ASSERT((opline + 1)->opcode == ZEND_OP_DATA);
462+
(opline + 1)->extended_value = alloc_cache_slots(op_array, 3);
463+
break;
459464
case ZEND_ISSET_ISEMPTY_PROP_OBJ:
460465
TO_STRING_NOWARN(val);
461466
opline->op2.constant = zend_optimizer_add_literal(op_array, val);

0 commit comments

Comments
 (0)