]> granicus.if.org Git - php/commitdiff
Eliminate useless exception checks
authorDmitry Stogov <dmitry@zend.com>
Fri, 17 Jul 2020 07:13:23 +0000 (10:13 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 17 Jul 2020 07:13:23 +0000 (10:13 +0300)
ext/opcache/Optimizer/zend_inference.c
ext/opcache/jit/zend_jit_trace.c
ext/opcache/jit/zend_jit_x86.dasc

index e0388a0b9cf8004a0ca0e5f69935d4454a6e9895..8e885e378d13ebc383e4392c61a0214ab971f318 100644 (file)
@@ -4312,7 +4312,8 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
                        }
                }
        } else if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
-               if (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) {
+               if ((t1 & MAY_BE_RC1)
+                && (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY))) {
                        switch (opline->opcode) {
                                case ZEND_CASE:
                                case ZEND_CASE_STRICT:
@@ -4350,7 +4351,8 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
                        }
                }
        } else if (opline->op2_type & (IS_TMP_VAR|IS_VAR)) {
-               if (t2 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) {
+               if ((t2 & MAY_BE_RC1)
+                && (t2 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY))) {
                        switch (opline->opcode) {
                                case ZEND_ASSIGN:
                                        break;
index 8fa1bca0542941172234fc12654fe00cfe713f95..b73177ee5858bbfaeaeb7fc58a0e9bdd400d46a7 100644 (file)
@@ -3765,9 +3765,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
                                                                        ((op1_info & MAY_BE_UNDEF) != 0 &&
                                                                                opline->opcode == ZEND_FETCH_DIM_R) ||
                                                                        ((opline->op1_type & (IS_TMP_VAR|IS_VAR)) != 0 &&
+                                                                               (op1_info & MAY_BE_RC1) &&
                                                                                (op1_info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) != 0) ||
                                                                        (op2_info & MAY_BE_UNDEF) != 0 ||
                                                                        ((opline->op2_type & (IS_TMP_VAR|IS_VAR)) != 0 &&
+                                                                               (op2_info & MAY_BE_RC1) &&
                                                                                (op2_info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) != 0)))) {
                                                        goto jit_failure;
                                                }
index 91cecf30e668271cd7d85b401fd84eda3bf70351..75f7131f80d699a5bf386377b3ba0ae90213a779 100644 (file)
@@ -10595,7 +10595,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c
                if (exit_addr
                 && !(op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_ARRAY))
                 && !may_throw
-                && !(opline->op1_type & (IS_TMP_VAR|IS_VAR))
+                && (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || (op1_info & AVOID_REFCOUNTING))
                 && (!(opline->op2_type & (IS_TMP_VAR|IS_VAR)) || !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)))) {
                        if (smart_branch_opcode == ZEND_JMPNZ) {
                                found_exit_addr = exit_addr;