Skip to content

Commit 22ef1fb

Browse files
committed
Fixed SSA construction
1 parent c958adc commit 22ef1fb

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,12 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
601601
break;
602602
case ZEND_ASSIGN_DIM:
603603
case ZEND_ASSIGN_OBJ:
604+
if (opline->op1_type == IS_CV) {
605+
ssa_ops[k].op1_def = ssa_vars_count;
606+
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
607+
ssa_vars_count++;
608+
//NEW_SSA_VAR(opline->op1.var)
609+
}
604610
next = opline + 1;
605611
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
606612
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
@@ -612,11 +618,14 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
612618
//NEW_SSA_VAR(next->op1.var)
613619
}
614620
}
615-
if (opline->op1_type == IS_CV) {
616-
goto add_op1_def;
617-
}
618621
break;
619622
case ZEND_ASSIGN_OBJ_REF:
623+
if (opline->op1_type == IS_CV) {
624+
ssa_ops[k].op1_def = ssa_vars_count;
625+
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
626+
ssa_vars_count++;
627+
//NEW_SSA_VAR(opline->op1.var)
628+
}
620629
next = opline + 1;
621630
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
622631
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
@@ -628,9 +637,6 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
628637
//NEW_SSA_VAR(next->op1.var)
629638
}
630639
}
631-
if (opline->op1_type == IS_CV) {
632-
goto add_op1_def;
633-
}
634640
break;
635641
case ZEND_ASSIGN_STATIC_PROP:
636642
next = opline + 1;
@@ -667,14 +673,17 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
667673
break;
668674
case ZEND_ASSIGN_DIM_OP:
669675
case ZEND_ASSIGN_OBJ_OP:
676+
if (opline->op1_type == IS_CV) {
677+
ssa_ops[k].op1_def = ssa_vars_count;
678+
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
679+
ssa_vars_count++;
680+
//NEW_SSA_VAR(opline->op1.var)
681+
}
670682
next = opline + 1;
671683
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
672684
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
673685
//USE_SSA_VAR(op_array->last_var + next->op1.var);
674686
}
675-
if (opline->op1_type == IS_CV) {
676-
goto add_op1_def;
677-
}
678687
break;
679688
case ZEND_ASSIGN_OP:
680689
case ZEND_PRE_INC:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
JIT ASSIGN_OBJ_REF: 001
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+
function test() {
11+
$obj = new stdClass;
12+
$obj->prop =& $obj;
13+
var_dump($obj->prop);
14+
}
15+
test();
16+
?>
17+
--EXPECT--
18+
object(stdClass)#1 (1) {
19+
["prop"]=>
20+
*RECURSION*
21+
}

0 commit comments

Comments
 (0)