diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 08822c6c6d4..9ff4f28ff9e 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2235,6 +2235,25 @@ static uint32_t zend_fetch_prop_type(const zend_script *script, zend_property_in return zend_convert_type(script, prop_info->type, pce); } +static bool result_may_be_separated(zend_ssa *ssa, zend_ssa_op *ssa_op) +{ + int tmp_var = ssa_op->result_def; + + if (ssa->vars[tmp_var].use_chain >= 0 + && !ssa->vars[tmp_var].phi_use_chain) { + zend_ssa_op *use_op = &ssa->ops[ssa->vars[tmp_var].use_chain]; + + /* TODO: analize instructions between ssa_op and use_op */ + if (use_op == ssa_op + 1) { + if ((use_op->op1_use == tmp_var && use_op->op1_use_chain < 0) + || (use_op->op2_use == tmp_var && use_op->op2_use_chain < 0)) { + return 0; + } + } + } + return 1; +} + static zend_always_inline int _zend_update_type_info( const zend_op_array *op_array, zend_ssa *ssa, @@ -3340,11 +3359,11 @@ static zend_always_inline int _zend_update_type_info( if (prop_info) { /* FETCH_OBJ_R/IS for plain property increments reference counter, so it can't be 1 */ - if (ce && !ce->create_object) { + if (ce && !ce->create_object && !result_may_be_separated(ssa, ssa_op)) { tmp &= ~MAY_BE_RC1; } } else { - if (ce && !ce->create_object && !ce->__get) { + if (ce && !ce->create_object && !ce->__get && !result_may_be_separated(ssa, ssa_op)) { tmp &= ~MAY_BE_RC1; } } @@ -3370,7 +3389,9 @@ static zend_always_inline int _zend_update_type_info( if (opline->result_type == IS_VAR) { tmp |= MAY_BE_REF | MAY_BE_INDIRECT; } else { - tmp &= ~MAY_BE_RC1; + if (!result_may_be_separated(ssa, ssa_op)) { + tmp &= ~MAY_BE_RC1; + } if (opline->opcode == ZEND_FETCH_STATIC_PROP_IS) { tmp |= MAY_BE_UNDEF; } diff --git a/ext/opcache/tests/jit/fetch_obj_009.phpt b/ext/opcache/tests/jit/fetch_obj_009.phpt new file mode 100644 index 00000000000..92d67de08ab --- /dev/null +++ b/ext/opcache/tests/jit/fetch_obj_009.phpt @@ -0,0 +1,21 @@ +--TEST-- +JIT: FETCH_OBJ 009 +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- +x[0] = null; + $obj->x > $obj->x[0] = null; + } +} +test(); +?> +DONE +--EXPECT-- +DONE