]> granicus.if.org Git - php/commitdiff
Use RT_CONSTANT() or CT_CONSTANT() macro depending on ZEND_ACC_DONE_PASS_TWO flag
authorDmitry Stogov <dmitry@zend.com>
Fri, 11 Oct 2019 09:28:20 +0000 (12:28 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 11 Oct 2019 09:54:07 +0000 (12:54 +0300)
14 files changed:
ext/opcache/Optimizer/escape_analysis.c
ext/opcache/Optimizer/optimize_func_calls.c
ext/opcache/Optimizer/zend_call_graph.c
ext/opcache/Optimizer/zend_call_graph.h
ext/opcache/Optimizer/zend_cfg.h
ext/opcache/Optimizer/zend_dump.c
ext/opcache/Optimizer/zend_func_info.c
ext/opcache/Optimizer/zend_inference.c
ext/opcache/Optimizer/zend_inference.h
ext/opcache/Optimizer/zend_optimizer.c
ext/opcache/Optimizer/zend_optimizer_internal.h
ext/opcache/Optimizer/zend_ssa.c
ext/opcache/Optimizer/zend_ssa.h
ext/opcache/jit/zend_jit.c

index c561bec9dcab81d1264c71a709942c4e58fb5fcf..a13f69cdf0071a927cb600ffc8d9d5ce3c819230 100644 (file)
@@ -176,7 +176,7 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in
                        case ZEND_NEW:
                            /* objects with destructors should escape */
                                if (opline->op1_type == IS_CONST) {
-                                       zend_class_entry *ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants)+1));
+                                       zend_class_entry *ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT(opline->op1)+1));
                                        uint32_t forbidden_flags = ZEND_ACC_INHERITED
                                                /* These flags will always cause an exception */
                                                | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
@@ -191,7 +191,7 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in
                                break;
                        case ZEND_QM_ASSIGN:
                                if (opline->op1_type == IS_CONST
-                                && Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants)) == IS_ARRAY) {
+                                && Z_TYPE_P(CRT_CONSTANT(opline->op1)) == IS_ARRAY) {
                                        return 1;
                                }
                                if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_ARRAY)) {
@@ -208,7 +208,7 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in
                switch (opline->opcode) {
                        case ZEND_ASSIGN:
                                if (opline->op2_type == IS_CONST
-                                && Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants)) == IS_ARRAY) {
+                                && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_ARRAY) {
                                        return 1;
                                }
                                if (opline->op2_type == IS_CV && (OP2_INFO() & MAY_BE_ARRAY)) {
@@ -245,7 +245,7 @@ static int is_local_def(zend_op_array *op_array, zend_ssa *ssa, int def, int var
                        case ZEND_NEW:
                                /* objects with destructors should escape */
                                if (opline->op1_type == IS_CONST) {
-                                       zend_class_entry *ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants)+1));
+                                       zend_class_entry *ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT(opline->op1)+1));
                                        if (ce && !ce->create_object && !ce->constructor &&
                                            !ce->destructor && !ce->__get && !ce->__set &&
                                            !(ce->ce_flags & ZEND_ACC_INHERITED)) {
index ae707a24097c047bc4b8383492d59002f6886948..ea2b904a0f4e67a8c5bfb0570a810fd72ffe6330 100644 (file)
@@ -126,7 +126,7 @@ static void zend_try_inline_call(zend_op_array *op_array, zend_op *fcall, zend_o
                                i = fcall->extended_value;
 
                                do {
-                                       if (Z_TYPE_P(RT_CONSTANT(&func->op_array.opcodes[i], func->op_array.opcodes[i].op2)) == IS_CONSTANT_AST) {
+                                       if (Z_TYPE_P(CRT_CONSTANT_EX(&func->op_array, &func->op_array.opcodes[i], func->op_array.opcodes[i].op2)) == IS_CONSTANT_AST) {
                                                return;
                                        }
                                        i++;
@@ -136,7 +136,7 @@ static void zend_try_inline_call(zend_op_array *op_array, zend_op *fcall, zend_o
                        if (RETURN_VALUE_USED(opline)) {
                                zval zv;
 
-                               ZVAL_COPY(&zv, RT_CONSTANT(ret_opline, ret_opline->op1));
+                               ZVAL_COPY(&zv, CRT_CONSTANT_EX(&func->op_array, ret_opline, ret_opline->op1));
                                opline->opcode = ZEND_QM_ASSIGN;
                                opline->op1_type = IS_CONST;
                                opline->op1.constant = zend_optimizer_add_literal(op_array, &zv);
@@ -173,7 +173,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
                        case ZEND_INIT_FCALL:
                        case ZEND_NEW:
                                call_stack[call].func = zend_optimizer_get_called_func(
-                                       ctx->script, op_array, opline, 0);
+                                       ctx->script, op_array, opline);
                                call_stack[call].try_inline = opline->opcode != ZEND_NEW;
                                /* break missing intentionally */
                        case ZEND_INIT_DYNAMIC_CALL:
index a98dd99d35597ec810f530d30f493246500420dd..28b20d10b804ede80ec0c05f99ed79bff4ac7827 100644 (file)
@@ -103,7 +103,7 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f
                        case ZEND_INIT_STATIC_METHOD_CALL:
                                call_stack[call] = call_info;
                                func = zend_optimizer_get_called_func(
-                                       script, op_array, opline, (build_flags & ZEND_RT_CONSTANTS) != 0);
+                                       script, op_array, opline);
                                if (func) {
                                        call_info = zend_arena_calloc(arena, 1, sizeof(zend_call_info) + (sizeof(zend_send_arg_info) * ((int)opline->extended_value - 1)));
                                        call_info->caller_op_array = op_array;
@@ -267,12 +267,12 @@ int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_gra
 }
 /* }}} */
 
-void zend_analyze_call_graph(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_call_graph *call_graph) /* {{{ */
+void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph) /* {{{ */
 {
        int i;
 
        for (i = 0; i < call_graph->op_arrays_count; i++) {
-               zend_analyze_calls(arena, script, build_flags, call_graph->op_arrays[i], call_graph->func_infos + i);
+               zend_analyze_calls(arena, script, 0, call_graph->op_arrays[i], call_graph->func_infos + i);
        }
        zend_analyze_recursion(call_graph);
        zend_sort_op_arrays(call_graph);
index cfad3358fdfdd6024a1cbd399bfccb364962ff62..8d2b866fd0a94caad66417f0c33149293074b763 100644 (file)
@@ -70,7 +70,7 @@ typedef struct _zend_call_graph {
 BEGIN_EXTERN_C()
 
 int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
-void zend_analyze_call_graph(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_call_graph *call_graph);
+void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
 zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, zend_op_array *op_array);
 int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info);
 
index 7d6ef25eee70c055ea0e4f7d5bf45c3229362cdf..ec7a10462c0fb52ac0e22ff0523d87905c07ebb6 100644 (file)
@@ -92,7 +92,6 @@ typedef struct _zend_cfg {
 } zend_cfg;
 
 /* Build Flags */
-#define ZEND_RT_CONSTANTS              (1U<<31)
 #define ZEND_CFG_STACKLESS             (1<<30)
 #define ZEND_SSA_DEBUG_LIVENESS        (1<<29)
 #define ZEND_SSA_DEBUG_PHI_PLACEMENT   (1<<28)
@@ -102,15 +101,15 @@ typedef struct _zend_cfg {
 #define ZEND_CALL_TREE                 (1<<23)
 #define ZEND_SSA_USE_CV_RESULTS        (1<<22)
 
-#define CRT_CONSTANT_EX(op_array, opline, node, rt_constants) \
-       ((rt_constants) ? \
+#define CRT_CONSTANT_EX(op_array, opline, node) \
+       (((op_array)->fn_flags & ZEND_ACC_DONE_PASS_TWO) ? \
                RT_CONSTANT(opline, (node)) \
        : \
                CT_CONSTANT_EX(op_array, (node).constant) \
        )
 
 #define CRT_CONSTANT(node) \
-       CRT_CONSTANT_EX(op_array, opline, node, (build_flags & ZEND_RT_CONSTANTS))
+       CRT_CONSTANT_EX(op_array, opline, node)
 
 #define RETURN_VALUE_USED(opline) \
        ((opline)->result_type != IS_UNUSED)
index 7ec76438bf2e373d536dab99ffc78c9c53d8beea..68b3d4a99f452051ca528bd87438d179c6603f58 100644 (file)
@@ -585,7 +585,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *
        }
 
        if (opline->op1_type == IS_CONST) {
-               zend_dump_const(CRT_CONSTANT_EX(op_array, opline, opline->op1, (dump_flags & ZEND_DUMP_RT_CONSTANTS)));
+               zend_dump_const(CRT_CONSTANT(opline->op1));
        } else if (opline->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
                if (ssa && ssa->ops) {
                        int ssa_var_num = ssa->ops[opline - op_array->opcodes].op1_use;
@@ -621,7 +621,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *
        }
 
        if (opline->op2_type == IS_CONST) {
-               zval *op = CRT_CONSTANT_EX(op_array, opline, opline->op2, (dump_flags & ZEND_DUMP_RT_CONSTANTS));
+               zval *op = CRT_CONSTANT(opline->op2);
                if (opline->opcode == ZEND_SWITCH_LONG || opline->opcode == ZEND_SWITCH_STRING) {
                        HashTable *jumptable = Z_ARRVAL_P(op);
                        zend_string *key;
@@ -687,7 +687,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *
                }
        }
        if (opline->result_type == IS_CONST) {
-               zend_dump_const(CRT_CONSTANT_EX(op_array, opline, opline->result, (dump_flags & ZEND_DUMP_RT_CONSTANTS)));
+               zend_dump_const(CRT_CONSTANT(opline->result));
 #if 0
        } else if (opline->result_type & IS_SMART_BRANCH_JMPZ) {
                fprintf(stderr, " jmpz");
index d21e9a48b463898f8d498cc8250d06f0b52ed3ff..96fe6594f933261b377473f62f711a7410f602d4 100644 (file)
@@ -1222,7 +1222,7 @@ uint32_t zend_get_func_info(const zend_call_info *call_info, const zend_ssa *ssa
 
        if (callee_func->type == ZEND_INTERNAL_FUNCTION) {
                zval *zv;
-               zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2, ssa->rt_constants));
+               zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2));
 
                zv = zend_hash_find_ex(&func_info, lcname, 1);
                if (zv) {
index c16652b8b614599d3cdd0ac7034f0125223e5a82..b8bd667e74fc3240c863d53793ec01a283b26612 100644 (file)
@@ -2314,7 +2314,7 @@ static zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, z
                }
                if (ce) {
                        prop_info = lookup_prop_info(ce,
-                               Z_STR_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants)),
+                               Z_STR_P(CRT_CONSTANT(opline->op2)),
                                op_array->scope);
                        if (prop_info && (prop_info->flags & ZEND_ACC_STATIC)) {
                                prop_info = NULL;
@@ -2345,12 +2345,12 @@ static zend_property_info *zend_fetch_static_prop_info(const zend_script *script
                                        break;
                        }
                } else if (opline->op2_type == IS_CONST) {
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants);
+                       zval *zv = CRT_CONSTANT(opline->op2);
                        ce = get_class_entry(script, Z_STR_P(zv + 1));
                }
 
                if (ce) {
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants);
+                       zval *zv = CRT_CONSTANT(opline->op1);
                        prop_info = lookup_prop_info(ce, Z_STR_P(zv), op_array->scope);
                        if (prop_info && !(prop_info->flags & ZEND_ACC_STATIC)) {
                                prop_info = NULL;
@@ -3136,7 +3136,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
                }
                case ZEND_DECLARE_ANON_CLASS:
                        UPDATE_SSA_TYPE(MAY_BE_CLASS, ssa_ops[i].result_def);
-                       if (script && (ce = zend_hash_find_ptr(&script->class_table, Z_STR_P(CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants)))) != NULL) {
+                       if (script && (ce = zend_hash_find_ptr(&script->class_table, Z_STR_P(CRT_CONSTANT(opline->op1)))) != NULL) {
                                UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
                        }
                        break;
@@ -3164,7 +3164,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
                                                break;
                                }
                        } else if (opline->op2_type == IS_CONST) {
-                               zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants);
+                               zval *zv = CRT_CONSTANT(opline->op2);
                                if (Z_TYPE_P(zv) == IS_STRING) {
                                        ce = get_class_entry(script, Z_STR_P(zv+1));
                                        UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
@@ -3178,7 +3178,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
                case ZEND_NEW:
                        tmp = MAY_BE_RC1|MAY_BE_RCN|MAY_BE_OBJECT;
                        if (opline->op1_type == IS_CONST &&
-                           (ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants)+1))) != NULL) {
+                           (ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT(opline->op1)+1))) != NULL) {
                                UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
                        } else if ((t1 & MAY_BE_CLASS) && ssa_ops[i].op1_use >= 0 && ssa_var_info[ssa_ops[i].op1_use].ce) {
                                UPDATE_SSA_OBJ_TYPE(ssa_var_info[ssa_ops[i].op1_use].ce, ssa_var_info[ssa_ops[i].op1_use].is_instanceof, ssa_ops[i].result_def);
@@ -3845,7 +3845,7 @@ static zend_bool can_convert_to_double(
                                ZVAL_COPY_VALUE(&orig_op1, value);
                                ZVAL_DOUBLE(&dval_op1, (double) Z_LVAL_P(value));
                        } else if (opline->op1_type == IS_CONST) {
-                               zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->op1, ssa->rt_constants);
+                               zval *zv = CRT_CONSTANT(opline->op1);
                                if (Z_TYPE_P(zv) == IS_LONG || Z_TYPE_P(zv) == IS_DOUBLE) {
                                        ZVAL_COPY_VALUE(&orig_op1, zv);
                                        ZVAL_COPY_VALUE(&dval_op1, zv);
@@ -3858,7 +3858,7 @@ static zend_bool can_convert_to_double(
                                ZVAL_COPY_VALUE(&orig_op2, value);
                                ZVAL_DOUBLE(&dval_op2, (double) Z_LVAL_P(value));
                        } else if (opline->op2_type == IS_CONST) {
-                               zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants);
+                               zval *zv = CRT_CONSTANT(opline->op2);
                                if (Z_TYPE_P(zv) == IS_LONG || Z_TYPE_P(zv) == IS_DOUBLE) {
                                        ZVAL_COPY_VALUE(&orig_op2, zv);
                                        ZVAL_COPY_VALUE(&dval_op2, zv);
@@ -3946,7 +3946,7 @@ static int zend_type_narrowing(const zend_op_array *op_array, const zend_script
                 * doubles instead, in the hope that we'll narrow long|double to double. */
                if (opline->opcode == ZEND_ASSIGN && opline->result_type == IS_UNUSED &&
                                opline->op1_type == IS_CV && opline->op2_type == IS_CONST) {
-                       zval *value = CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants);
+                       zval *value = CRT_CONSTANT(opline->op2);
 
                        zend_bitset_clear(visited, bitset_len);
                        if (can_convert_to_double(op_array, ssa, v, value, visited)) {
@@ -4098,7 +4098,7 @@ void zend_func_return_info(const zend_op_array   *op_array,
                                }
 
                                if (opline->op1_type == IS_CONST) {
-                                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->op1, info->ssa.rt_constants);
+                                       zval *zv = CRT_CONSTANT(opline->op1);
 
                                        if (Z_TYPE_P(zv) == IS_NULL) {
                                                if (tmp_has_range < 0) {
@@ -4577,7 +4577,7 @@ int zend_may_throw(const zend_op *opline, zend_op_array *op_array, zend_ssa *ssa
 
                                        if (opline->op2_type == IS_CONST) {
                                                prop_info = zend_hash_find_ptr(&ce->properties_info,
-                                                       Z_STR_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants)));
+                                                       Z_STR_P(CRT_CONSTANT(opline->op2)));
                                                if (prop_info && !(prop_info->flags & ZEND_ACC_PUBLIC)) {
                                                        return 1;
                                                }
@@ -4607,7 +4607,7 @@ int zend_may_throw(const zend_op *opline, zend_op_array *op_array, zend_ssa *ssa
                case ZEND_COUNT:
                        return (t1 & MAY_BE_ANY) != MAY_BE_ARRAY;
                case ZEND_RECV_INIT:
-                       if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants)) == IS_CONSTANT_AST) {
+                       if (Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_CONSTANT_AST) {
                                return 1;
                        }
                        if (op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
index 2e5a44d0bed10078474c4f25175e04b16b3a3b0d..2061d48ebd19fda5f1602bb555dbd8dd47cfb57e 100644 (file)
@@ -40,7 +40,7 @@
        static zend_always_inline zend_bool _ssa_##opN##_has_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline) \
        { \
                if (opline->opN##_type == IS_CONST) { \
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->opN, ssa->rt_constants); \
+                       zval *zv = CRT_CONSTANT(opline->opN); \
                        return (Z_TYPE_P(zv) == IS_LONG || Z_TYPE_P(zv) == IS_TRUE || Z_TYPE_P(zv) == IS_FALSE || Z_TYPE_P(zv) == IS_NULL); \
                } else { \
                        return (opline->opN##_type != IS_UNUSED && \
@@ -56,7 +56,7 @@
        static zend_always_inline zend_long _ssa_##opN##_min_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline) \
        { \
                if (opline->opN##_type == IS_CONST) { \
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->opN, ssa->rt_constants); \
+                       zval *zv = CRT_CONSTANT(opline->opN); \
                        if (Z_TYPE_P(zv) == IS_LONG) { \
                                return Z_LVAL_P(zv); \
                        } else if (Z_TYPE_P(zv) == IS_TRUE) { \
@@ -80,7 +80,7 @@
        static zend_always_inline zend_long _ssa_##opN##_max_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline) \
        { \
                if (opline->opN##_type == IS_CONST) { \
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->opN, ssa->rt_constants); \
+                       zval *zv = CRT_CONSTANT(opline->opN); \
                        if (Z_TYPE_P(zv) == IS_LONG) { \
                                return Z_LVAL_P(zv); \
                        } else if (Z_TYPE_P(zv) == IS_TRUE) { \
        static zend_always_inline char _ssa_##opN##_range_underflow(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline) \
        { \
                if (opline->opN##_type == IS_CONST) { \
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->opN, ssa->rt_constants); \
+                       zval *zv = CRT_CONSTANT(opline->opN); \
                        if (Z_TYPE_P(zv) == IS_LONG || Z_TYPE_P(zv) == IS_TRUE || Z_TYPE_P(zv) == IS_FALSE || Z_TYPE_P(zv) == IS_NULL) { \
                                return 0; \
                        } \
        static zend_always_inline char _ssa_##opN##_range_overflow(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline) \
        { \
                if (opline->opN##_type == IS_CONST) { \
-                       zval *zv = CRT_CONSTANT_EX(op_array, opline, opline->opN, ssa->rt_constants); \
+                       zval *zv = CRT_CONSTANT(opline->opN); \
                        if (Z_TYPE_P(zv) == IS_LONG || Z_TYPE_P(zv) == IS_TRUE || Z_TYPE_P(zv) == IS_FALSE || Z_TYPE_P(zv) == IS_NULL) { \
                                return 0; \
                        } \
@@ -207,7 +207,7 @@ static zend_always_inline uint32_t get_ssa_var_info(const zend_ssa *ssa, int ssa
        static zend_always_inline uint32_t _ssa_##opN##_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline) \
        {                                                                                                                                               \
                if (opline->opN##_type == IS_CONST) {                                                   \
-                       return _const_op_type(CRT_CONSTANT_EX(op_array, opline, opline->opN, ssa->rt_constants)); \
+                       return _const_op_type(CRT_CONSTANT(opline->opN)); \
                } else { \
                        return get_ssa_var_info(ssa, ssa->ops ? ssa->ops[opline - op_array->opcodes].opN##_use : -1); \
                } \
index 96ed33aa9790fb26b87933d05fc744890c10d5c0..d5028bc3b259ea436640814e28265c3a1aaf009d 100644 (file)
@@ -773,9 +773,9 @@ void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_
 }
 
 static zend_class_entry *get_class_entry_from_op1(
-               zend_script *script, zend_op_array *op_array, zend_op *opline, zend_bool rt_constants) {
+               zend_script *script, zend_op_array *op_array, zend_op *opline) {
        if (opline->op1_type == IS_CONST) {
-               zval *op1 = CRT_CONSTANT_EX(op_array, opline, opline->op1, rt_constants);
+               zval *op1 = CRT_CONSTANT(opline->op1);
                if (Z_TYPE_P(op1) == IS_STRING) {
                        zend_string *class_name = Z_STR_P(op1 + 1);
                        zend_class_entry *ce;
@@ -800,13 +800,12 @@ static zend_class_entry *get_class_entry_from_op1(
 }
 
 zend_function *zend_optimizer_get_called_func(
-               zend_script *script, zend_op_array *op_array, zend_op *opline, zend_bool rt_constants)
+               zend_script *script, zend_op_array *op_array, zend_op *opline)
 {
-#define GET_OP(op) CRT_CONSTANT_EX(op_array, opline, opline->op, rt_constants)
        switch (opline->opcode) {
                case ZEND_INIT_FCALL:
                {
-                       zend_string *function_name = Z_STR_P(GET_OP(op2));
+                       zend_string *function_name = Z_STR_P(CRT_CONSTANT(opline->op2));
                        zend_function *func;
                        if (script && (func = zend_hash_find_ptr(&script->function_table, function_name)) != NULL) {
                                return func;
@@ -823,8 +822,8 @@ zend_function *zend_optimizer_get_called_func(
                }
                case ZEND_INIT_FCALL_BY_NAME:
                case ZEND_INIT_NS_FCALL_BY_NAME:
-                       if (opline->op2_type == IS_CONST && Z_TYPE_P(GET_OP(op2)) == IS_STRING) {
-                               zval *function_name = GET_OP(op2) + 1;
+                       if (opline->op2_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_STRING) {
+                               zval *function_name = CRT_CONSTANT(opline->op2) + 1;
                                zend_function *func;
                                if (script && (func = zend_hash_find_ptr(&script->function_table, Z_STR_P(function_name)))) {
                                        return func;
@@ -840,11 +839,11 @@ zend_function *zend_optimizer_get_called_func(
                        }
                        break;
                case ZEND_INIT_STATIC_METHOD_CALL:
-                       if (opline->op2_type == IS_CONST && Z_TYPE_P(GET_OP(op2)) == IS_STRING) {
+                       if (opline->op2_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_STRING) {
                                zend_class_entry *ce = get_class_entry_from_op1(
-                                       script, op_array, opline, rt_constants);
+                                       script, op_array, opline);
                                if (ce) {
-                                       zend_string *func_name = Z_STR_P(GET_OP(op2) + 1);
+                                       zend_string *func_name = Z_STR_P(CRT_CONSTANT(opline->op2) + 1);
                                        zend_function *fbc = zend_hash_find_ptr(&ce->function_table, func_name);
                                        if (fbc) {
                                                zend_bool is_public = (fbc->common.fn_flags & ZEND_ACC_PUBLIC) != 0;
@@ -858,9 +857,9 @@ zend_function *zend_optimizer_get_called_func(
                        break;
                case ZEND_INIT_METHOD_CALL:
                        if (opline->op1_type == IS_UNUSED
-                                       && opline->op2_type == IS_CONST && Z_TYPE_P(GET_OP(op2)) == IS_STRING
+                                       && opline->op2_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_STRING
                                        && op_array->scope && !(op_array->scope->ce_flags & ZEND_ACC_TRAIT)) {
-                               zend_string *method_name = Z_STR_P(GET_OP(op2) + 1);
+                               zend_string *method_name = Z_STR_P(CRT_CONSTANT(opline->op2) + 1);
                                zend_function *fbc = zend_hash_find_ptr(
                                        &op_array->scope->function_table, method_name);
                                if (fbc) {
@@ -877,7 +876,7 @@ zend_function *zend_optimizer_get_called_func(
                case ZEND_NEW:
                {
                        zend_class_entry *ce = get_class_entry_from_op1(
-                               script, op_array, opline, rt_constants);
+                               script, op_array, opline);
                        if (ce && ce->type == ZEND_USER_CLASS) {
                                return ce->constructor;
                        }
@@ -885,7 +884,6 @@ zend_function *zend_optimizer_get_called_func(
                }
        }
        return NULL;
-#undef GET_OP
 }
 
 uint32_t zend_optimizer_classify_function(zend_string *name, uint32_t num_args) {
@@ -1040,6 +1038,8 @@ static void zend_revert_pass_two(zend_op_array *op_array)
 {
        zend_op *opline, *end;
 
+       ZEND_ASSERT((op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) != 0);
+
        opline = op_array->opcodes;
        end = opline + op_array->last;
        while (opline < end) {
@@ -1060,6 +1060,8 @@ static void zend_revert_pass_two(zend_op_array *op_array)
                op_array->literals = literals;
        }
 #endif
+
+       op_array->fn_flags &= ~ZEND_ACC_DONE_PASS_TWO;
 }
 
 static void zend_redo_pass_two(zend_op_array *op_array)
@@ -1069,6 +1071,8 @@ static void zend_redo_pass_two(zend_op_array *op_array)
        zend_op *old_opcodes = op_array->opcodes;
 #endif
 
+       ZEND_ASSERT((op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) == 0);
+
 #if !ZEND_USE_ABS_CONST_ADDR
        if (op_array->last_literal) {
                op_array->opcodes = (zend_op *) erealloc(op_array->opcodes,
@@ -1095,77 +1099,77 @@ static void zend_redo_pass_two(zend_op_array *op_array)
                if (opline->op2_type == IS_CONST) {
                        ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op2);
                }
-               if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) {
-                       /* fix jumps to point to new array */
-                       switch (opline->opcode) {
+               /* fix jumps to point to new array */
+               switch (opline->opcode) {
 #if ZEND_USE_ABS_JMP_ADDR && !ZEND_USE_ABS_CONST_ADDR
-                               case ZEND_JMP:
-                               case ZEND_FAST_CALL:
-                                       opline->op1.jmp_addr = &op_array->opcodes[opline->op1.jmp_addr - old_opcodes];
-                                       break;
-                               case ZEND_JMPZNZ:
-                                       /* relative extended_value don't have to be changed */
-                                       /* break omitted intentionally */
-                               case ZEND_JMPZ:
-                               case ZEND_JMPNZ:
-                               case ZEND_JMPZ_EX:
-                               case ZEND_JMPNZ_EX:
-                               case ZEND_JMP_SET:
-                               case ZEND_COALESCE:
-                               case ZEND_FE_RESET_R:
-                               case ZEND_FE_RESET_RW:
-                               case ZEND_ASSERT_CHECK:
+                       case ZEND_JMP:
+                       case ZEND_FAST_CALL:
+                               opline->op1.jmp_addr = &op_array->opcodes[opline->op1.jmp_addr - old_opcodes];
+                               break;
+                       case ZEND_JMPZNZ:
+                               /* relative extended_value don't have to be changed */
+                               /* break omitted intentionally */
+                       case ZEND_JMPZ:
+                       case ZEND_JMPNZ:
+                       case ZEND_JMPZ_EX:
+                       case ZEND_JMPNZ_EX:
+                       case ZEND_JMP_SET:
+                       case ZEND_COALESCE:
+                       case ZEND_FE_RESET_R:
+                       case ZEND_FE_RESET_RW:
+                       case ZEND_ASSERT_CHECK:
+                               opline->op2.jmp_addr = &op_array->opcodes[opline->op2.jmp_addr - old_opcodes];
+                               break;
+                       case ZEND_CATCH:
+                               if (!(opline->extended_value & ZEND_LAST_CATCH)) {
                                        opline->op2.jmp_addr = &op_array->opcodes[opline->op2.jmp_addr - old_opcodes];
-                                       break;
-                               case ZEND_CATCH:
-                                       if (!(opline->extended_value & ZEND_LAST_CATCH)) {
-                                               opline->op2.jmp_addr = &op_array->opcodes[opline->op2.jmp_addr - old_opcodes];
-                                       }
-                                       break;
-                               case ZEND_FE_FETCH_R:
-                               case ZEND_FE_FETCH_RW:
-                               case ZEND_SWITCH_LONG:
-                               case ZEND_SWITCH_STRING:
-                                       /* relative extended_value don't have to be changed */
-                                       break;
+                               }
+                               break;
+                       case ZEND_FE_FETCH_R:
+                       case ZEND_FE_FETCH_RW:
+                       case ZEND_SWITCH_LONG:
+                       case ZEND_SWITCH_STRING:
+                               /* relative extended_value don't have to be changed */
+                               break;
 #endif
-                               case ZEND_IS_IDENTICAL:
-                               case ZEND_IS_NOT_IDENTICAL:
-                               case ZEND_IS_EQUAL:
-                               case ZEND_IS_NOT_EQUAL:
-                               case ZEND_IS_SMALLER:
-                               case ZEND_IS_SMALLER_OR_EQUAL:
-                               case ZEND_CASE:
-                               case ZEND_ISSET_ISEMPTY_CV:
-                               case ZEND_ISSET_ISEMPTY_VAR:
-                               case ZEND_ISSET_ISEMPTY_DIM_OBJ:
-                               case ZEND_ISSET_ISEMPTY_PROP_OBJ:
-                               case ZEND_ISSET_ISEMPTY_STATIC_PROP:
-                               case ZEND_INSTANCEOF:
-                               case ZEND_TYPE_CHECK:
-                               case ZEND_DEFINED:
-                               case ZEND_IN_ARRAY:
-                               case ZEND_ARRAY_KEY_EXISTS:
-                                       if (opline->result_type & IS_TMP_VAR) {
-                                               /* reinitialize result_type of smart branch instructions */
-                                               if (opline + 1 < end) {
-                                                       if ((opline+1)->opcode == ZEND_JMPZ
-                                                        && (opline+1)->op1_type == IS_TMP_VAR
-                                                        && (opline+1)->op1.var == opline->result.var) {
-                                                               opline->result_type = IS_SMART_BRANCH_JMPZ | IS_TMP_VAR;
-                                                       } else if ((opline+1)->opcode == ZEND_JMPNZ
-                                                        && (opline+1)->op1_type == IS_TMP_VAR
-                                                        && (opline+1)->op1.var == opline->result.var) {
-                                                               opline->result_type = IS_SMART_BRANCH_JMPNZ | IS_TMP_VAR;
-                                                       }
+                       case ZEND_IS_IDENTICAL:
+                       case ZEND_IS_NOT_IDENTICAL:
+                       case ZEND_IS_EQUAL:
+                       case ZEND_IS_NOT_EQUAL:
+                       case ZEND_IS_SMALLER:
+                       case ZEND_IS_SMALLER_OR_EQUAL:
+                       case ZEND_CASE:
+                       case ZEND_ISSET_ISEMPTY_CV:
+                       case ZEND_ISSET_ISEMPTY_VAR:
+                       case ZEND_ISSET_ISEMPTY_DIM_OBJ:
+                       case ZEND_ISSET_ISEMPTY_PROP_OBJ:
+                       case ZEND_ISSET_ISEMPTY_STATIC_PROP:
+                       case ZEND_INSTANCEOF:
+                       case ZEND_TYPE_CHECK:
+                       case ZEND_DEFINED:
+                       case ZEND_IN_ARRAY:
+                       case ZEND_ARRAY_KEY_EXISTS:
+                               if (opline->result_type & IS_TMP_VAR) {
+                                       /* reinitialize result_type of smart branch instructions */
+                                       if (opline + 1 < end) {
+                                               if ((opline+1)->opcode == ZEND_JMPZ
+                                                && (opline+1)->op1_type == IS_TMP_VAR
+                                                && (opline+1)->op1.var == opline->result.var) {
+                                                       opline->result_type = IS_SMART_BRANCH_JMPZ | IS_TMP_VAR;
+                                               } else if ((opline+1)->opcode == ZEND_JMPNZ
+                                                && (opline+1)->op1_type == IS_TMP_VAR
+                                                && (opline+1)->op1.var == opline->result.var) {
+                                                       opline->result_type = IS_SMART_BRANCH_JMPNZ | IS_TMP_VAR;
                                                }
                                        }
-                                       break;
-                       }
+                               }
+                               break;
                }
                ZEND_VM_SET_OPCODE_HANDLER(opline);
                opline++;
        }
+
+       op_array->fn_flags |= ZEND_ACC_DONE_PASS_TWO;
 }
 
 static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa)
@@ -1175,6 +1179,8 @@ static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa)
        zend_op *old_opcodes = op_array->opcodes;
 #endif
 
+       ZEND_ASSERT((op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) == 0);
+
 #if !ZEND_USE_ABS_CONST_ADDR
        if (op_array->last_literal) {
                op_array->opcodes = (zend_op *) erealloc(op_array->opcodes,
@@ -1212,77 +1218,77 @@ static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa)
                        ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op2);
                }
 
-               if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) {
-                       /* fix jumps to point to new array */
-                       switch (opline->opcode) {
+               /* fix jumps to point to new array */
+               switch (opline->opcode) {
 #if ZEND_USE_ABS_JMP_ADDR && !ZEND_USE_ABS_CONST_ADDR
-                               case ZEND_JMP:
-                               case ZEND_FAST_CALL:
-                                       opline->op1.jmp_addr = &op_array->opcodes[opline->op1.jmp_addr - old_opcodes];
-                                       break;
-                               case ZEND_JMPZNZ:
-                                       /* relative extended_value don't have to be changed */
-                                       /* break omitted intentionally */
-                               case ZEND_JMPZ:
-                               case ZEND_JMPNZ:
-                               case ZEND_JMPZ_EX:
-                               case ZEND_JMPNZ_EX:
-                               case ZEND_JMP_SET:
-                               case ZEND_COALESCE:
-                               case ZEND_FE_RESET_R:
-                               case ZEND_FE_RESET_RW:
-                               case ZEND_ASSERT_CHECK:
+                       case ZEND_JMP:
+                       case ZEND_FAST_CALL:
+                               opline->op1.jmp_addr = &op_array->opcodes[opline->op1.jmp_addr - old_opcodes];
+                               break;
+                       case ZEND_JMPZNZ:
+                               /* relative extended_value don't have to be changed */
+                               /* break omitted intentionally */
+                       case ZEND_JMPZ:
+                       case ZEND_JMPNZ:
+                       case ZEND_JMPZ_EX:
+                       case ZEND_JMPNZ_EX:
+                       case ZEND_JMP_SET:
+                       case ZEND_COALESCE:
+                       case ZEND_FE_RESET_R:
+                       case ZEND_FE_RESET_RW:
+                       case ZEND_ASSERT_CHECK:
+                               opline->op2.jmp_addr = &op_array->opcodes[opline->op2.jmp_addr - old_opcodes];
+                               break;
+                       case ZEND_CATCH:
+                               if (!(opline->extended_value & ZEND_LAST_CATCH)) {
                                        opline->op2.jmp_addr = &op_array->opcodes[opline->op2.jmp_addr - old_opcodes];
-                                       break;
-                               case ZEND_CATCH:
-                                       if (!(opline->extended_value & ZEND_LAST_CATCH)) {
-                                               opline->op2.jmp_addr = &op_array->opcodes[opline->op2.jmp_addr - old_opcodes];
-                                       }
-                                       break;
-                               case ZEND_FE_FETCH_R:
-                               case ZEND_FE_FETCH_RW:
-                               case ZEND_SWITCH_LONG:
-                               case ZEND_SWITCH_STRING:
-                                       /* relative extended_value don't have to be changed */
-                                       break;
+                               }
+                               break;
+                       case ZEND_FE_FETCH_R:
+                       case ZEND_FE_FETCH_RW:
+                       case ZEND_SWITCH_LONG:
+                       case ZEND_SWITCH_STRING:
+                               /* relative extended_value don't have to be changed */
+                               break;
 #endif
-                               case ZEND_IS_IDENTICAL:
-                               case ZEND_IS_NOT_IDENTICAL:
-                               case ZEND_IS_EQUAL:
-                               case ZEND_IS_NOT_EQUAL:
-                               case ZEND_IS_SMALLER:
-                               case ZEND_IS_SMALLER_OR_EQUAL:
-                               case ZEND_CASE:
-                               case ZEND_ISSET_ISEMPTY_CV:
-                               case ZEND_ISSET_ISEMPTY_VAR:
-                               case ZEND_ISSET_ISEMPTY_DIM_OBJ:
-                               case ZEND_ISSET_ISEMPTY_PROP_OBJ:
-                               case ZEND_ISSET_ISEMPTY_STATIC_PROP:
-                               case ZEND_INSTANCEOF:
-                               case ZEND_TYPE_CHECK:
-                               case ZEND_DEFINED:
-                               case ZEND_IN_ARRAY:
-                               case ZEND_ARRAY_KEY_EXISTS:
-                                       if (opline->result_type & IS_TMP_VAR) {
-                                               /* reinitialize result_type of smart branch instructions */
-                                               if (opline + 1 < end) {
-                                                       if ((opline+1)->opcode == ZEND_JMPZ
-                                                        && (opline+1)->op1_type == IS_TMP_VAR
-                                                        && (opline+1)->op1.var == opline->result.var) {
-                                                               opline->result_type = IS_SMART_BRANCH_JMPZ | IS_TMP_VAR;
-                                                       } else if ((opline+1)->opcode == ZEND_JMPNZ
-                                                        && (opline+1)->op1_type == IS_TMP_VAR
-                                                        && (opline+1)->op1.var == opline->result.var) {
-                                                               opline->result_type = IS_SMART_BRANCH_JMPNZ | IS_TMP_VAR;
-                                                       }
+                       case ZEND_IS_IDENTICAL:
+                       case ZEND_IS_NOT_IDENTICAL:
+                       case ZEND_IS_EQUAL:
+                       case ZEND_IS_NOT_EQUAL:
+                       case ZEND_IS_SMALLER:
+                       case ZEND_IS_SMALLER_OR_EQUAL:
+                       case ZEND_CASE:
+                       case ZEND_ISSET_ISEMPTY_CV:
+                       case ZEND_ISSET_ISEMPTY_VAR:
+                       case ZEND_ISSET_ISEMPTY_DIM_OBJ:
+                       case ZEND_ISSET_ISEMPTY_PROP_OBJ:
+                       case ZEND_ISSET_ISEMPTY_STATIC_PROP:
+                       case ZEND_INSTANCEOF:
+                       case ZEND_TYPE_CHECK:
+                       case ZEND_DEFINED:
+                       case ZEND_IN_ARRAY:
+                       case ZEND_ARRAY_KEY_EXISTS:
+                               if (opline->result_type & IS_TMP_VAR) {
+                                       /* reinitialize result_type of smart branch instructions */
+                                       if (opline + 1 < end) {
+                                               if ((opline+1)->opcode == ZEND_JMPZ
+                                                && (opline+1)->op1_type == IS_TMP_VAR
+                                                && (opline+1)->op1.var == opline->result.var) {
+                                                       opline->result_type = IS_SMART_BRANCH_JMPZ | IS_TMP_VAR;
+                                               } else if ((opline+1)->opcode == ZEND_JMPNZ
+                                                && (opline+1)->op1_type == IS_TMP_VAR
+                                                && (opline+1)->op1.var == opline->result.var) {
+                                                       opline->result_type = IS_SMART_BRANCH_JMPNZ | IS_TMP_VAR;
                                                }
                                        }
-                                       break;
-                       }
+                               }
+                               break;
                }
                zend_vm_set_opcode_handler_ex(opline, op1_info, op2_info, res_info);
                opline++;
        }
+
+       op_array->fn_flags |= ZEND_ACC_DONE_PASS_TWO;
 }
 
 static void zend_optimize_op_array(zend_op_array      *op_array,
@@ -1378,7 +1384,7 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
                        zend_optimize(call_graph.op_arrays[i], &ctx);
                }
 
-           zend_analyze_call_graph(&ctx.arena, script, 0, &call_graph);
+           zend_analyze_call_graph(&ctx.arena, script, &call_graph);
 
                for (i = 0; i < call_graph.op_arrays_count; i++) {
                        func_info = ZEND_FUNC_INFO(call_graph.op_arrays[i]);
@@ -1529,11 +1535,11 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
        if ((debug_level & ZEND_DUMP_AFTER_OPTIMIZER) &&
            (ZEND_OPTIMIZER_PASS_7 & optimization_level)) {
                zend_dump_op_array(&script->main_op_array,
-                       ZEND_DUMP_RT_CONSTANTS | ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
+                       ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
 
                ZEND_HASH_FOREACH_PTR(&script->function_table, op_array) {
                        zend_dump_op_array(op_array,
-                               ZEND_DUMP_RT_CONSTANTS | ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
+                               ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
                } ZEND_HASH_FOREACH_END();
 
                ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
@@ -1542,7 +1548,7 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
                                 && op_array->type == ZEND_USER_FUNCTION
                                 && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
                                        zend_dump_op_array(op_array,
-                                               ZEND_DUMP_RT_CONSTANTS | ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
+                                               ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
                                }
                        } ZEND_HASH_FOREACH_END();
                } ZEND_HASH_FOREACH_END();
index d3ec873e4ab260ce5756ecc63a68015013ed1ef8..43ac1ea07fff7757053a8058a657c9f6b48fc915 100644 (file)
@@ -105,7 +105,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
 void zend_optimizer_compact_vars(zend_op_array *op_array);
 int zend_optimizer_is_disabled_func(const char *name, size_t len);
 zend_function *zend_optimizer_get_called_func(
-               zend_script *script, zend_op_array *op_array, zend_op *opline, zend_bool rt_constants);
+               zend_script *script, zend_op_array *op_array, zend_op *opline);
 uint32_t zend_optimizer_classify_function(zend_string *name, uint32_t num_args);
 void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, zend_op *opline);
 void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_t *shiftlist);
index 4ef7afe7051c31c611de3783ad500773f68fa245..99d577dd2c3ee8c6b356d4ce290c458db1d5d37d 100644 (file)
@@ -192,14 +192,14 @@ static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_f
                        }
                } else if (op->opcode == ZEND_ADD) {
                        if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
-                               zv = CRT_CONSTANT_EX(op_array, op, op->op2, (build_flags & ZEND_RT_CONSTANTS));
+                               zv = CRT_CONSTANT_EX(op_array, op, op->op2);
                                if (Z_TYPE_P(zv) == IS_LONG
                                 && Z_LVAL_P(zv) != ZEND_LONG_MIN) {
                                        *adjustment = -Z_LVAL_P(zv);
                                        return EX_VAR_TO_NUM(op->op1.var);
                                }
                        } else if (op->op2_type == IS_CV && op->op1_type == IS_CONST) {
-                               zv = CRT_CONSTANT_EX(op_array, op, op->op1, (build_flags & ZEND_RT_CONSTANTS));
+                               zv = CRT_CONSTANT_EX(op_array, op, op->op1);
                                if (Z_TYPE_P(zv) == IS_LONG
                                 && Z_LVAL_P(zv) != ZEND_LONG_MIN) {
                                        *adjustment = -Z_LVAL_P(zv);
@@ -208,7 +208,7 @@ static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_f
                        }
                } else if (op->opcode == ZEND_SUB) {
                        if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
-                               zv = CRT_CONSTANT_EX(op_array, op, op->op2, (build_flags & ZEND_RT_CONSTANTS));
+                               zv = CRT_CONSTANT_EX(op_array, op, op->op2);
                                if (Z_TYPE_P(zv) == IS_LONG) {
                                        *adjustment = Z_LVAL_P(zv);
                                        return EX_VAR_TO_NUM(op->op1.var);
@@ -293,7 +293,7 @@ static void place_essa_pis(
                        } else if (var1 >= 0 && var2 < 0) {
                                zend_long add_val2 = 0;
                                if ((opline-1)->op2_type == IS_CONST) {
-                                       zval *zv = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op2, (build_flags & ZEND_RT_CONSTANTS));
+                                       zval *zv = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op2);
 
                                        if (Z_TYPE_P(zv) == IS_LONG) {
                                                add_val2 = Z_LVAL_P(zv);
@@ -315,9 +315,9 @@ static void place_essa_pis(
                        } else if (var1 < 0 && var2 >= 0) {
                                zend_long add_val1 = 0;
                                if ((opline-1)->op1_type == IS_CONST) {
-                                       zval *zv = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op1, (build_flags & ZEND_RT_CONSTANTS));
+                                       zval *zv = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op1);
                                        if (Z_TYPE_P(zv) == IS_LONG) {
-                                               add_val1 = Z_LVAL_P(CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op1, (build_flags & ZEND_RT_CONSTANTS)));
+                                               add_val1 = Z_LVAL_P(CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op1));
                                        } else if (Z_TYPE_P(zv) == IS_FALSE) {
                                                add_val1 = 0;
                                        } else if (Z_TYPE_P(zv) == IS_TRUE) {
@@ -463,10 +463,10 @@ static void place_essa_pis(
                        uint32_t type_mask;
                        if ((opline-1)->op1_type == IS_CV && (opline-1)->op2_type == IS_CONST) {
                                var = EX_VAR_TO_NUM((opline-1)->op1.var);
-                               val = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op2, (build_flags & ZEND_RT_CONSTANTS));
+                               val = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op2);
                        } else if ((opline-1)->op1_type == IS_CONST && (opline-1)->op2_type == IS_CV) {
                                var = EX_VAR_TO_NUM((opline-1)->op2.var);
-                               val = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op1, (build_flags & ZEND_RT_CONSTANTS));
+                               val = CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op1);
                        } else {
                                continue;
                        }
@@ -497,7 +497,7 @@ static void place_essa_pis(
                                   opline->op1.var == (opline-1)->result.var && (opline-1)->op1_type == IS_CV &&
                                   (opline-1)->op2_type == IS_CONST) {
                        int var = EX_VAR_TO_NUM((opline-1)->op1.var);
-                       zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op2, (build_flags & ZEND_RT_CONSTANTS)) + 1);
+                       zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(op_array, (opline-1), (opline-1)->op2) + 1);
                        zend_class_entry *ce = script ? zend_hash_find_ptr(&script->class_table, lcname) : NULL;
                        if (!ce) {
                                ce = zend_hash_find_ptr(CG(class_table), lcname);
@@ -881,7 +881,6 @@ int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_
                return FAILURE;
        }
 
-       ssa->rt_constants = (build_flags & ZEND_RT_CONSTANTS);
        ssa_blocks = zend_arena_calloc(arena, blocks_count, sizeof(zend_ssa_block));
        ssa->blocks = ssa_blocks;
 
index 9b53b73e7e578c023c1782418bf4a349ac893e03..1987a47fc4d82a309de7c76bee787731df6128e3 100644 (file)
@@ -131,12 +131,11 @@ typedef struct _zend_ssa_var_info {
 
 typedef struct _zend_ssa {
        zend_cfg               cfg;            /* control flow graph             */
-       int                    rt_constants;   /* run-time or compile-time       */
        int                    vars_count;     /* number of SSA variables        */
+       int                    sccs;           /* number of SCCs                 */
        zend_ssa_block        *blocks;         /* array of SSA blocks            */
        zend_ssa_op           *ops;            /* array of SSA instructions      */
        zend_ssa_var          *vars;           /* use/def chain of SSA variables */
-       int                    sccs;           /* number of SCCs                 */
        zend_ssa_var_info     *var_info;
 } zend_ssa;
 
index 6d34b51f4c17d638faead32382b646c0661116df..3805ea207675e80aa5fdb859e7302c900fa8ad28 100644 (file)
@@ -575,7 +575,7 @@ static int zend_jit_build_cfg(zend_op_array *op_array, zend_cfg *cfg)
 {
        uint32_t flags;
 
-       flags = ZEND_CFG_STACKLESS | ZEND_RT_CONSTANTS | ZEND_CFG_NO_ENTRY_PREDECESSORS | ZEND_SSA_RC_INFERENCE_FLAG | ZEND_SSA_USE_CV_RESULTS | ZEND_CFG_RECV_ENTRY;
+       flags = ZEND_CFG_STACKLESS | ZEND_CFG_NO_ENTRY_PREDECESSORS | ZEND_SSA_RC_INFERENCE_FLAG | ZEND_SSA_USE_CV_RESULTS | ZEND_CFG_RECV_ENTRY;
 
        if (zend_build_cfg(&CG(arena), op_array, flags, cfg) != SUCCESS) {
                return FAILURE;
@@ -623,7 +623,7 @@ static int zend_jit_op_array_analyze1(zend_op_array *op_array, zend_script *scri
         && op_array->last_try_catch == 0
         && !(op_array->fn_flags & ZEND_ACC_GENERATOR)
         && !(ssa->cfg.flags & ZEND_FUNC_INDIRECT_VAR_ACCESS)) {
-               if (zend_build_ssa(&CG(arena), script, op_array, ZEND_RT_CONSTANTS | ZEND_SSA_RC_INFERENCE | ZEND_SSA_USE_CV_RESULTS, ssa) != SUCCESS) {
+               if (zend_build_ssa(&CG(arena), script, op_array, ZEND_SSA_RC_INFERENCE | ZEND_SSA_USE_CV_RESULTS, ssa) != SUCCESS) {
                        return FAILURE;
                }
 
@@ -638,8 +638,6 @@ static int zend_jit_op_array_analyze1(zend_op_array *op_array, zend_script *scri
                if (zend_ssa_find_sccs(op_array, ssa) != SUCCESS){
                        return FAILURE;
                }
-       } else {
-               ssa->rt_constants = 1;
        }
 
        return SUCCESS;
@@ -2567,7 +2565,7 @@ static int zend_jit_collect_calls(zend_op_array *op_array, zend_script *script)
        ZEND_SET_FUNC_INFO(op_array, func_info);
        func_info->num_args = -1;
        func_info->return_value_used = -1;
-       return zend_analyze_calls(&CG(arena), script, ZEND_RT_CONSTANTS | ZEND_CALL_TREE, op_array, func_info);
+       return zend_analyze_calls(&CG(arena), script, ZEND_CALL_TREE, op_array, func_info);
 }
 
 static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, const zend_op *rt_opline)
@@ -2593,7 +2591,7 @@ static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, cons
        }
 
        if (ZCG(accel_directives).jit_debug & ZEND_JIT_DEBUG_SSA) {
-               zend_dump_op_array(op_array, ZEND_DUMP_HIDE_UNREACHABLE|ZEND_DUMP_RC_INFERENCE|ZEND_DUMP_SSA|ZEND_DUMP_RT_CONSTANTS, "JIT", &ssa);
+               zend_dump_op_array(op_array, ZEND_DUMP_HIDE_UNREACHABLE|ZEND_DUMP_RC_INFERENCE|ZEND_DUMP_SSA, "JIT", &ssa);
        }
 
        if (zend_jit_level >= ZEND_JIT_LEVEL_OPT_FUNCS) {
@@ -2832,7 +2830,7 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
                goto jit_failure;
        }
 
-       zend_analyze_call_graph(&CG(arena), script, ZEND_RT_CONSTANTS, &call_graph);
+       zend_analyze_call_graph(&CG(arena), script, &call_graph);
 
        if (zend_jit_trigger == ZEND_JIT_ON_FIRST_EXEC ||
            zend_jit_trigger == ZEND_JIT_ON_PROF_REQUEST ||
@@ -2900,7 +2898,7 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
                                }
                                info = ZEND_FUNC_INFO(call_graph.op_arrays[i]);
                                if (info) {
-                                       zend_dump_op_array(call_graph.op_arrays[i], ZEND_DUMP_HIDE_UNREACHABLE|ZEND_DUMP_RC_INFERENCE|ZEND_DUMP_SSA|ZEND_DUMP_RT_CONSTANTS, "JIT", &info->ssa);
+                                       zend_dump_op_array(call_graph.op_arrays[i], ZEND_DUMP_HIDE_UNREACHABLE|ZEND_DUMP_RC_INFERENCE|ZEND_DUMP_SSA, "JIT", &info->ssa);
                                }
                        }
                }