Skip to content

Commit b35255a

Browse files
committed
More accurate reference-counter inference
1 parent 48eb635 commit b35255a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,15 +1972,15 @@ uint32_t zend_array_element_type(uint32_t t1, int write, int insert)
19721972
if (tmp & MAY_BE_ARRAY) {
19731973
tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
19741974
}
1975-
if (t1 & MAY_BE_ARRAY_OF_REF) {
1975+
if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
19761976
if (!write) {
19771977
/* can't be REF because of ZVAL_COPY_DEREF() usage */
1978-
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
1979-
} else {
1978+
tmp |= MAY_BE_RCN;
1979+
} else if (t1 & MAY_BE_ARRAY_OF_REF) {
19801980
tmp |= MAY_BE_REF | MAY_BE_RC1 | MAY_BE_RCN;
1981+
} else {
1982+
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
19811983
}
1982-
} else if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
1983-
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
19841984
}
19851985
}
19861986
if (write) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5567,6 +5567,9 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze
55675567
if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) {
55685568
var_info |= MAY_BE_REF;
55695569
}
5570+
if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
5571+
var_info |= MAY_BE_RC1;
5572+
}
55705573
| // value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
55715574
if (!zend_jit_assign_to_variable(Dst, opline, op_array, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) {
55725575
return 0;
@@ -5777,6 +5780,9 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const
57775780
if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) {
57785781
var_info |= MAY_BE_REF;
57795782
}
5783+
if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
5784+
var_info |= MAY_BE_RC1;
5785+
}
57805786

57815787
if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_RW, op1_info, op2_info, 8, 8, NULL, NULL)) {
57825788
return 0;
@@ -11126,7 +11132,8 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1112611132
|9: // END
1112711133
if (opline->op1_type != IS_UNUSED && !use_this && !op1_indirect) {
1112811134
if (opline->op1_type == IS_VAR
11129-
&& opline->opcode == ZEND_FETCH_OBJ_W) {
11135+
&& opline->opcode == ZEND_FETCH_OBJ_W
11136+
&& (op1_info & MAY_BE_RC1)) {
1113011137
zend_jit_addr orig_op1_addr = OP1_ADDR();
1113111138

1113211139
| IF_NOT_ZVAL_REFCOUNTED orig_op1_addr, >1

0 commit comments

Comments
 (0)