]> granicus.if.org Git - php/commitdiff
Make FETCH_R/IS, FETCH_DIM_R/IS, FETCH_OBJ_R/IS, FETCH_STATIC_PROP_R/IS return TMP_VA...
authorDmitry Stogov <dmitry@zend.com>
Mon, 25 Jun 2018 20:43:23 +0000 (23:43 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 25 Jun 2018 20:43:23 +0000 (23:43 +0300)
Zend/zend_compile.c
ext/opcache/tests/opt/sccp_006.phpt
ext/opcache/tests/opt/sccp_008.phpt
ext/opcache/tests/opt/sccp_022.phpt

index 4b10cbf329c21102865881a3261465afa54af1db..ac5dd26077348db2334c776ba3e875decc0a0c0a 100644 (file)
@@ -1903,12 +1903,14 @@ ZEND_API size_t zend_dirname(char *path, size_t len)
 }
 /* }}} */
 
-static void zend_adjust_for_fetch_type(zend_op *opline, uint32_t type) /* {{{ */
+static void zend_adjust_for_fetch_type(zend_op *opline, znode *result, uint32_t type) /* {{{ */
 {
        zend_uchar factor = (opline->opcode == ZEND_FETCH_STATIC_PROP_R) ? 1 : 3;
 
        switch (type) {
                case BP_VAR_R:
+                       opline->result_type = IS_TMP_VAR;
+                       result->op_type = IS_TMP_VAR;
                        return;
                case BP_VAR_W:
                        opline->opcode += 1 * factor;
@@ -1917,6 +1919,8 @@ static void zend_adjust_for_fetch_type(zend_op *opline, uint32_t type) /* {{{ */
                        opline->opcode += 2 * factor;
                        return;
                case BP_VAR_IS:
+                       opline->result_type = IS_TMP_VAR;
+                       result->op_type = IS_TMP_VAR;
                        opline->opcode += 3 * factor;
                        return;
                case BP_VAR_FUNC_ARG:
@@ -2598,7 +2602,7 @@ static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint
                opline->extended_value = ZEND_FETCH_LOCAL;
        }
 
-       zend_adjust_for_fetch_type(opline, type);
+       zend_adjust_for_fetch_type(opline, result, type);
        return opline;
 }
 /* }}} */
@@ -2617,7 +2621,11 @@ static zend_bool is_this_fetch(zend_ast *ast) /* {{{ */
 static void zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */
 {
        if (is_this_fetch(ast)) {
-               zend_emit_op(result, ZEND_FETCH_THIS, NULL, NULL);
+               zend_op *opline = zend_emit_op(result, ZEND_FETCH_THIS, NULL, NULL);
+               if ((type == BP_VAR_R) || (type == BP_VAR_IS)) {
+                       opline->result_type = IS_TMP_VAR;
+                       result->op_type = IS_TMP_VAR;
+               }
        } else if (zend_try_compile_cv(result, ast) == FAILURE) {
                zend_compile_simple_var_no_cv(result, ast, type, delayed);
        }
@@ -2676,7 +2684,7 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t
        }
 
        opline = zend_delayed_emit_op(result, ZEND_FETCH_DIM_R, &var_node, &dim_node);
-       zend_adjust_for_fetch_type(opline, type);
+       zend_adjust_for_fetch_type(opline, result, type);
        return opline;
 }
 /* }}} */
@@ -2711,7 +2719,7 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
                opline->extended_value = zend_alloc_polymorphic_cache_slot();
        }
 
-       zend_adjust_for_fetch_type(opline, type);
+       zend_adjust_for_fetch_type(opline, result, type);
        return opline;
 }
 /* }}} */
@@ -2756,7 +2764,7 @@ zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, i
                SET_NODE(opline->op2, &class_node);
        }
 
-       zend_adjust_for_fetch_type(opline, type);
+       zend_adjust_for_fetch_type(opline, result, type);
        return opline;
 }
 /* }}} */
@@ -3216,7 +3224,7 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
                                        opcode = ZEND_SEND_REF;
                                } else {
                                        zend_compile_var(&arg_node, arg, BP_VAR_R);
-                                       opcode = ZEND_SEND_VAR;
+                                       opcode = (arg_node.op_type == IS_TMP_VAR) ? ZEND_SEND_VAL : ZEND_SEND_VAR;
                                }
                        } else {
                                do {
index e8f10ef064c98e4c3699fdef54648d733616671c..88b4cd7717708479844a7daceae846d295172943 100644 (file)
@@ -28,8 +28,8 @@ L1 (3):     T2 = INIT_ARRAY 3 int(1) string("a")
 L2 (3):     T2 = ADD_ARRAY_ELEMENT int(2) string("a")
 L3 (3):     T2 = ADD_ARRAY_ELEMENT CV0($x) string("a")
 L4 (3):     CV1($a) = QM_ASSIGN T2
-L5 (4):     V2 = FETCH_DIM_R CV1($a) string("a")
-L6 (4):     ECHO V2
+L5 (4):     T2 = FETCH_DIM_R CV1($a) string("a")
+L6 (4):     ECHO T2
 L7 (5):     RETURN null
 LIVE RANGES:
         2: L2 - L4 (tmp/var)
index d5ff3ae681a17a3a9e2c596a998e686bf45eaa6d..5b886d02ba9543bca32740a9c18a611deb4aec45 100644 (file)
@@ -32,6 +32,6 @@ L1 (3):     JMPZ CV0($x) L4
 L2 (4):     CV1($a) = QM_ASSIGN array(...)
 L3 (4):     JMP L5
 L4 (6):     CV1($a) = QM_ASSIGN array(...)
-L5 (8):     V2 = FETCH_DIM_R CV1($a) int(1)
-L6 (8):     ECHO V2
+L5 (8):     T2 = FETCH_DIM_R CV1($a) int(1)
+L6 (8):     ECHO T2
 L7 (9):     RETURN null
index 551d705c11b94fcbcdbcae49214a8c32fc7ec91e..2b79707ea56e0ab8b8818629ee61ffde0bfb34ee 100644 (file)
@@ -34,6 +34,6 @@ L4 (4):     OP_DATA int(5)
 L5 (5):     ECHO int(5)
 L6 (6):     ASSIGN_OBJ CV1($a) string("foo")
 L7 (6):     OP_DATA int(5)
-L8 (7):     V2 = FETCH_DIM_R CV1($a) int(1)
-L9 (7):     ECHO V2
+L8 (7):     T2 = FETCH_DIM_R CV1($a) int(1)
+L9 (7):     ECHO T2
 L10 (8):    RETURN null