]> granicus.if.org Git - php/commitdiff
More accurate reference-counter inference
authorDmitry Stogov <dmitry@zend.com>
Mon, 6 Jul 2020 12:53:28 +0000 (15:53 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 6 Jul 2020 12:53:28 +0000 (15:53 +0300)
ext/opcache/Optimizer/zend_inference.c
ext/opcache/jit/zend_jit_x86.dasc

index e131a3ee58df278c8e5a26214d62ec3b85f739ba..0f79e92a9f8be297e15308aa3f9c625c03c6bd88 100644 (file)
@@ -1972,15 +1972,15 @@ uint32_t zend_array_element_type(uint32_t t1, int write, int insert)
                        if (tmp & MAY_BE_ARRAY) {
                                tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
                        }
-                       if (t1 & MAY_BE_ARRAY_OF_REF) {
+                       if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
                                if (!write) {
                                        /* can't be REF  because of ZVAL_COPY_DEREF() usage */
-                                       tmp |= MAY_BE_RC1 | MAY_BE_RCN;
-                               } else {
+                                       tmp |= MAY_BE_RCN;
+                               } else if (t1 & MAY_BE_ARRAY_OF_REF) {
                                        tmp |= MAY_BE_REF | MAY_BE_RC1 | MAY_BE_RCN;
+                               } else {
+                                       tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                                }
-                       } else if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
-                               tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                        }
                }
                if (write) {
index e6be17a3c9cabb03edba4b6d4a128d49cfff73b9..feabefba4de499473e829e58e25d54067cf292ad 100644 (file)
@@ -5567,6 +5567,9 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze
                        if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) {
                                var_info |= MAY_BE_REF;
                        }
+                       if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
+                               var_info |= MAY_BE_RC1;
+                       }
                        |       // value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
                        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)) {
                                return 0;
@@ -5777,6 +5780,9 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const
                        if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) {
                                var_info |= MAY_BE_REF;
                        }
+                       if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
+                               var_info |= MAY_BE_RC1;
+                       }
 
                        if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_RW, op1_info, op2_info, 8, 8, NULL, NULL)) {
                                return 0;
@@ -11126,7 +11132,8 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
        |9: // END
        if (opline->op1_type != IS_UNUSED && !use_this && !op1_indirect) {
                if (opline->op1_type == IS_VAR
-                && opline->opcode == ZEND_FETCH_OBJ_W) {
+                && opline->opcode == ZEND_FETCH_OBJ_W
+                && (op1_info & MAY_BE_RC1)) {
                        zend_jit_addr orig_op1_addr = OP1_ADDR();
 
                        |       IF_NOT_ZVAL_REFCOUNTED orig_op1_addr, >1