]> granicus.if.org Git - php/commitdiff
Improve JIT code for smart branches
authorDmitry Stogov <dmitry@zend.com>
Tue, 2 Apr 2019 23:00:54 +0000 (02:00 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 2 Apr 2019 23:00:54 +0000 (02:00 +0300)
ext/opcache/jit/zend_jit.c
ext/opcache/jit/zend_jit_x86.dasc

index a9d16711667b85c1f09e4f507734098bcaf03cf8..4a1a27dbbf581bd1f5c7cecacc83442f55391167 100644 (file)
@@ -2058,58 +2058,6 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op *rt_op
 
                is_terminated = 0;
 
-               if (ssa->cfg.blocks[b].len == 1 &&
-                   ssa->cfg.blocks[b].start != 0 &&
-                   zend_is_smart_branch(&op_array->opcodes[ssa->cfg.blocks[b].start-1])) {
-
-                       /* Special handling for splitted smart branch instruction pairs */
-                       opline = &op_array->opcodes[ssa->cfg.blocks[b].start];
-                       if (zend_jit_level >= ZEND_JIT_LEVEL_INLINE) {
-                               if ((opline->opcode == ZEND_JMPZ ||
-                                    opline->opcode == ZEND_JMPNZ ||
-                                    opline->opcode == ZEND_JMPZNZ ||
-                                    opline->opcode == ZEND_JMPZ_EX ||
-                                    opline->opcode == ZEND_JMPNZ_EX) &&
-                                   ((opline-1)->opcode == ZEND_IS_EQUAL ||
-                                    (opline-1)->opcode == ZEND_IS_NOT_EQUAL ||
-                                    (opline-1)->opcode == ZEND_IS_SMALLER ||
-                                    (opline-1)->opcode == ZEND_IS_SMALLER_OR_EQUAL ||
-                                    (opline-1)->opcode == ZEND_CASE)) {
-                                       zend_jit_jmp(&dasm_state, b + 1);
-                               } else if (opline->opcode == ZEND_JMPZ ||
-                                                  opline->opcode == ZEND_JMPNZ) {
-                                           /* smart branch */
-                                       if (!zend_jit_cond_jmp(&dasm_state, opline + 1, ssa->cfg.blocks[b].successors[0])) {
-                                               goto jit_failure;
-                                       }
-                                       zend_jit_jmp(&dasm_state, b + 1);
-                               }
-                       } else {
-                               if (opline->opcode == ZEND_JMPZ ||
-                                   opline->opcode == ZEND_JMPNZ) {
-                                   opline--;
-                                       if ((opline->opcode == ZEND_IS_EQUAL ||
-                                            opline->opcode == ZEND_IS_NOT_EQUAL ||
-                                            opline->opcode == ZEND_IS_SMALLER ||
-                                            opline->opcode == ZEND_IS_SMALLER_OR_EQUAL ||
-                                            opline->opcode == ZEND_CASE) &&
-                                           ((OP1_INFO() & (MAY_BE_ANY-(MAY_BE_LONG|MAY_BE_DOUBLE))) ||
-                                            (OP2_INFO() & (MAY_BE_ANY-(MAY_BE_LONG|MAY_BE_DOUBLE))))) {
-                                               /* might be smart branch */
-                                               if (!zend_jit_smart_branch(&dasm_state, opline + 1, (b + 1), ssa->cfg.blocks[b].successors[0])) {
-                                                       goto jit_failure;
-                                               }
-                                       } else {
-                                               /* smart branch */
-                                               if (!zend_jit_cond_jmp(&dasm_state, opline + 2, ssa->cfg.blocks[b].successors[0])) {
-                                                       goto jit_failure;
-                                               }
-                                               zend_jit_jmp(&dasm_state, b + 1);
-                                       }
-                               }
-                       }
-               }
-
                zend_jit_label(&dasm_state, b);
                if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) {
                        if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) {
@@ -2446,30 +2394,7 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op *rt_op
                                case ZEND_JMPZ:
                                case ZEND_JMPNZ:
                                        if (i != ssa->cfg.blocks[b].start) {
-                                               if ((opline-1)->opcode == ZEND_IS_EQUAL ||
-                                                   (opline-1)->opcode == ZEND_IS_NOT_EQUAL ||
-                                                   (opline-1)->opcode == ZEND_IS_SMALLER ||
-                                                   (opline-1)->opcode == ZEND_IS_SMALLER_OR_EQUAL ||
-                                                   (opline-1)->opcode == ZEND_CASE) {
-
-                                                       uint32_t t1 = _ssa_op1_info(op_array, ssa, (opline-1));
-                                                       uint32_t t2 = _ssa_op2_info(op_array, ssa, (opline-1));
-
-                                                       if ((t1 & (MAY_BE_ANY-(MAY_BE_LONG|MAY_BE_DOUBLE))) ||
-                                                           (t2 & (MAY_BE_ANY-(MAY_BE_LONG|MAY_BE_DOUBLE)))) {
-                                                               /* might be smart branch */
-                                                               if (!zend_jit_smart_branch(&dasm_state, opline, (b + 1), ssa->cfg.blocks[b].successors[0])) {
-                                                                       goto jit_failure;
-                                                               }
-                                                               /* break missing intentionally */
-                                                       } else {
-                                                               /* smart branch */
-                                                               if (!zend_jit_cond_jmp(&dasm_state, opline + 1, ssa->cfg.blocks[b].successors[0])) {
-                                                                       goto jit_failure;
-                                                               }
-                                                               break;
-                                                       }
-                                               } else if (zend_is_smart_branch(opline-1)) {
+                                               if (zend_is_smart_branch(opline-1)) {
                                                    /* smart branch */
                                                        if (!zend_jit_cond_jmp(&dasm_state, opline + 1, ssa->cfg.blocks[b].successors[0])) {
                                                                goto jit_failure;
@@ -2485,6 +2410,10 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op *rt_op
                                case ZEND_FE_RESET_R:
                                case ZEND_FE_RESET_RW:
                                case ZEND_ASSERT_CHECK:
+                               case ZEND_FE_FETCH_R:
+                               case ZEND_FE_FETCH_RW:
+                               case ZEND_DECLARE_ANON_CLASS:
+                               case ZEND_DECLARE_ANON_INHERITED_CLASS:
                                        if (!zend_jit_handler(&dasm_state, opline, zend_may_throw(opline, op_array, ssa)) ||
                                            !zend_jit_cond_jmp(&dasm_state, opline + 1, ssa->cfg.blocks[b].successors[0])) {
                                                goto jit_failure;
@@ -2495,15 +2424,6 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op *rt_op
                                                goto jit_failure;
                                        }
                                        break;
-                               case ZEND_FE_FETCH_R:
-                               case ZEND_FE_FETCH_RW:
-                               case ZEND_DECLARE_ANON_CLASS:
-                               case ZEND_DECLARE_ANON_INHERITED_CLASS:
-                                       if (!zend_jit_handler(&dasm_state, opline, zend_may_throw(opline, op_array, ssa)) ||
-                                           !zend_jit_cond_jmp(&dasm_state, opline + 1, ssa->cfg.blocks[b].successors[0])) {
-                                               goto jit_failure;
-                                       }
-                                       break;
                                default:
                                        if (!zend_jit_handler(&dasm_state, opline, zend_may_throw(opline, op_array, ssa))) {
                                                goto jit_failure;
index 1a1b5209dee074980cfc7083c85c0ee4a43c24c7..cefef3cb8a5afbb6da8c574bec16c268878a3dcf 100644 (file)
@@ -2816,19 +2816,6 @@ static int zend_jit_cond_jmp(dasm_State **Dst, const zend_op *next_opline, unsig
        return 1;
 }
 
-static int zend_jit_smart_branch(dasm_State **Dst, const zend_op *opline, unsigned int next_label, unsigned int target_label)
-{
-       const zend_op *next_opline = opline + 1;
-       const zend_op *target_opline = OP_JMP_ADDR(opline, opline->op2);
-
-       |       CMP_IP next_opline
-       |       je =>next_label
-       |       CMP_IP target_opline
-       |       je =>target_label
-
-       return 1;
-}
-
 #ifdef CONTEXT_THREADED_JIT
 static int zend_jit_context_threaded_call(dasm_State **Dst, const zend_op *opline)
 {