Skip to content

Commit

Permalink
Fixed SSA construction
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Oct 5, 2021
1 parent c958adc commit 22ef1fb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ext/opcache/Optimizer/zend_ssa.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
break;
case ZEND_ASSIGN_DIM:
case ZEND_ASSIGN_OBJ:
if (opline->op1_type == IS_CV) {
ssa_ops[k].op1_def = ssa_vars_count;
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
ssa_vars_count++;
//NEW_SSA_VAR(opline->op1.var)
}
next = opline + 1;
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
Expand All @@ -612,11 +618,14 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
//NEW_SSA_VAR(next->op1.var)
}
}
if (opline->op1_type == IS_CV) {
goto add_op1_def;
}
break;
case ZEND_ASSIGN_OBJ_REF:
if (opline->op1_type == IS_CV) {
ssa_ops[k].op1_def = ssa_vars_count;
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
ssa_vars_count++;
//NEW_SSA_VAR(opline->op1.var)
}
next = opline + 1;
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
Expand All @@ -628,9 +637,6 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
//NEW_SSA_VAR(next->op1.var)
}
}
if (opline->op1_type == IS_CV) {
goto add_op1_def;
}
break;
case ZEND_ASSIGN_STATIC_PROP:
next = opline + 1;
Expand Down Expand Up @@ -667,14 +673,17 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
break;
case ZEND_ASSIGN_DIM_OP:
case ZEND_ASSIGN_OBJ_OP:
if (opline->op1_type == IS_CV) {
ssa_ops[k].op1_def = ssa_vars_count;
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
ssa_vars_count++;
//NEW_SSA_VAR(opline->op1.var)
}
next = opline + 1;
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
//USE_SSA_VAR(op_array->last_var + next->op1.var);
}
if (opline->op1_type == IS_CV) {
goto add_op1_def;
}
break;
case ZEND_ASSIGN_OP:
case ZEND_PRE_INC:
Expand Down
21 changes: 21 additions & 0 deletions ext/opcache/tests/jit/assign_obj_ref_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
JIT ASSIGN_OBJ_REF: 001
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
function test() {
$obj = new stdClass;
$obj->prop =& $obj;
var_dump($obj->prop);
}
test();
?>
--EXPECT--
object(stdClass)#1 (1) {
["prop"]=>
*RECURSION*
}

0 comments on commit 22ef1fb

Please sign in to comment.