]> granicus.if.org Git - php/commitdiff
Fixed return operand type (Use IS_TMP_VAR instead of IS_VAR in the same way as it...
authorDmitry Stogov <dmitry@zend.com>
Tue, 26 Aug 2014 10:22:03 +0000 (14:22 +0400)
committerDmitry Stogov <dmitry@zend.com>
Tue, 26 Aug 2014 10:22:03 +0000 (14:22 +0400)
Zend/zend_compile.c
ext/opcache/Optimizer/pass1_5.c

index 81c05965781e324a455f89ab13e0ddd844d95275..f5adb4f100a316b725dde8f8214c6f45c828751c 100644 (file)
@@ -3970,12 +3970,17 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) {
                if (zend_is_variable(arg)) {
                        if (zend_is_call(arg)) {
                                zend_compile_var(&arg_node, arg, BP_VAR_R TSRMLS_CC);
-                               opcode = ZEND_SEND_VAR_NO_REF;
-                               flags |= ZEND_ARG_SEND_FUNCTION;
-                               if (fbc && ARG_SHOULD_BE_SENT_BY_REF(fbc, arg_num)) {
-                                       flags |= ZEND_ARG_SEND_BY_REF;
-                                       if (ARG_MAY_BE_SENT_BY_REF(fbc, arg_num)) {
-                                               flags |= ZEND_ARG_SEND_SILENT;
+                               if (arg_node.op_type & (IS_CONST|IS_TMP_VAR)) {
+                                       /* Function call was converted into builtin instruction */
+                                       opcode = ZEND_SEND_VAL;
+                               } else {
+                                       opcode = ZEND_SEND_VAR_NO_REF;
+                                       flags |= ZEND_ARG_SEND_FUNCTION;
+                                       if (fbc && ARG_SHOULD_BE_SENT_BY_REF(fbc, arg_num)) {
+                                               flags |= ZEND_ARG_SEND_BY_REF;
+                                               if (ARG_MAY_BE_SENT_BY_REF(fbc, arg_num)) {
+                                                       flags |= ZEND_ARG_SEND_SILENT;
+                                               }
                                        }
                                }
                        } else if (fbc) {
@@ -4108,7 +4113,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args TSRMLS_DC) {
        }
 
        zend_compile_expr(&arg_node, args->child[0] TSRMLS_CC);
-       zend_emit_op(result, ZEND_STRLEN, &arg_node, NULL TSRMLS_CC);
+       zend_emit_op_tmp(result, ZEND_STRLEN, &arg_node, NULL TSRMLS_CC);
        return SUCCESS;
 }
 
@@ -4121,7 +4126,7 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ
        }
        
        zend_compile_expr(&arg_node, args->child[0] TSRMLS_CC);
-       opline = zend_emit_op(result, ZEND_TYPE_CHECK, &arg_node, NULL TSRMLS_CC);
+       opline = zend_emit_op_tmp(result, ZEND_TYPE_CHECK, &arg_node, NULL TSRMLS_CC);
        opline->extended_value = type;
        return SUCCESS;
 }
@@ -4140,7 +4145,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args TSRMLS_DC) {
                return FAILURE;
        }
 
-       opline = zend_emit_op(result, ZEND_DEFINED, NULL, NULL TSRMLS_CC);
+       opline = zend_emit_op_tmp(result, ZEND_DEFINED, NULL, NULL TSRMLS_CC);
        opline->op1_type = IS_CONST;
        LITERAL_STR(opline->op1, name);
        zend_alloc_cache_slot(opline->op1.constant TSRMLS_CC);
@@ -6857,7 +6862,7 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast TSRMLS_DC) {
                EMPTY_SWITCH_DEFAULT_CASE()
        }
 
-       opline->result_type = IS_TMP_VAR;
+       result->op_type = opline->result_type = IS_TMP_VAR;
        opline->extended_value |= ast->kind == ZEND_AST_ISSET ? ZEND_ISSET : ZEND_ISEMPTY;
 }
 
index cae4d0445d01805f934493617499486dd6ea3826..de09e891230f76ef10e1e40aeb851b1ad77ada5b 100644 (file)
@@ -472,7 +472,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
                                zval t;
 
                                ZVAL_LONG(&t, Z_STRLEN(ZEND_OP1_LITERAL(opline)));
-                               replace_var_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC);
+                               replace_tmp_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC);
                                literal_dtor(&ZEND_OP1_LITERAL(opline));
                                MAKE_NOP(opline);
                        }
@@ -485,7 +485,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
                                        break;
                                }
                                ZVAL_TRUE(&c);
-                               replace_var_by_const(op_array, opline, tv, &c TSRMLS_CC);
+                               replace_tmp_by_const(op_array, opline, tv, &c TSRMLS_CC);
                                literal_dtor(&ZEND_OP1_LITERAL(opline));
                                MAKE_NOP(opline);
                        }