]> granicus.if.org Git - php/commitdiff
jump optimization
authorDmitry Stogov <dmitry@zend.com>
Wed, 3 Apr 2019 20:37:25 +0000 (23:37 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 3 Apr 2019 20:37:25 +0000 (23:37 +0300)
ext/opcache/jit/zend_jit.c
ext/opcache/jit/zend_jit_x86.dasc

index fffab897c25e79aca45320b1dfc59a617d0c39db..84defa0028f307d4631278233b25b5803a1f5659 100644 (file)
@@ -2472,8 +2472,42 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op *rt_op
                                        }
                                        break;
                                case ZEND_NEW:
-                                       if (!zend_jit_new(&dasm_state, opline, &i, op_array, ssa, call_level)) {
-                                               goto jit_failure;
+                                       if (!zend_jit_handler(&dasm_state, opline, 1)) {
+                                               return 0;
+                                       }
+                                       if (opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL) {
+                                               zend_class_entry *ce = NULL;
+
+                                               if (zend_jit_level >= ZEND_JIT_LEVEL_OPT_FUNC) {
+                                                       if (ssa->ops && ssa->var_info) {
+                                                               zend_ssa_var_info *res_ssa = &ssa->var_info[ssa->ops[opline - op_array->opcodes].result_def];
+                                                               if (res_ssa->ce && !res_ssa->is_instanceof) {
+                                                                       ce = res_ssa->ce;
+                                                               }
+                                                       }
+                                               } else {
+                                                       if (opline->op1_type == IS_CONST) {
+                                                               zval *zv = RT_CONSTANT(opline, opline->op1);
+                                                               if (Z_TYPE_P(zv) == IS_STRING) {
+                                                                       zval *lc = zv + 1;
+                                                                       ce = (zend_class_entry*)zend_hash_find_ptr(EG(class_table), Z_STR_P(lc));
+                                                               }
+                                                       }
+                                               }
+
+                                               i++;
+
+                                               if (!ce || !(ce->ce_flags & ZEND_ACC_LINKED) || ce->constructor) {
+                                                       const zend_op *next_opline = opline + 1;
+
+                                                       zend_jit_cond_jmp(&dasm_state, next_opline, ssa->cfg.blocks[b].successors[0]);
+                                                       if (zend_jit_level < ZEND_JIT_LEVEL_INLINE) {
+                                                               zend_jit_call(&dasm_state, next_opline);
+                                                               is_terminated = 1;
+                                                       } else {
+                                                               zend_jit_do_fcall(&dasm_state, next_opline, op_array, ssa, call_level);
+                                                       }
+                                               }
                                        }
                                        break;
                                default:
index 3b2da998cf2b19f6ade51b3d08d711ad00ce3cfb..770aca2336adf6839802a2083876f1c491557f60 100644 (file)
@@ -7812,48 +7812,6 @@ fallback:
        }
 }
 
-static int zend_jit_new(dasm_State **Dst, const zend_op *opline, int *opnum, zend_op_array *op_array, zend_ssa *ssa, int call_level)
-{
-       if (!zend_jit_handler(Dst, opline, 1)) {
-               return 0;
-       }
-       if (opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL) {
-               zend_class_entry *ce = NULL;
-
-               if (zend_jit_level >= ZEND_JIT_LEVEL_OPT_FUNC) {
-                       if (ssa->ops && ssa->var_info) {
-                               zend_ssa_var_info *res_ssa = &ssa->var_info[ssa->ops[opline - op_array->opcodes].result_def];
-                               if (res_ssa->ce && !res_ssa->is_instanceof) {
-                                       ce = res_ssa->ce;
-                               }
-                       }
-               } else {
-                       if (opline->op1_type == IS_CONST) {
-                               zval *zv = RT_CONSTANT(opline, opline->op1);
-                               if (Z_TYPE_P(zv) == IS_STRING) {
-                                       zval *lc = zv + 1;
-                                       ce = (zend_class_entry*)zend_hash_find_ptr(EG(class_table), Z_STR_P(lc));
-                               }
-                       }
-               }
-
-               (*opnum)++;
-               if (!ce || !(ce->ce_flags & ZEND_ACC_LINKED) || ce->constructor) {
-                       const zend_op *next_opline = opline + 1;
-
-                       |       CMP_IP next_opline
-                       |       jne >6
-                       if (zend_jit_level < ZEND_JIT_LEVEL_INLINE) {
-                               zend_jit_call(Dst, next_opline);
-                       } else {
-                               zend_jit_do_fcall(Dst, next_opline, op_array, ssa, call_level);
-                       }
-                       |6:
-               }
-       }
-       return 1;
-}
-
 static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, zend_op_array *op_array, zend_ssa *ssa, zend_lifetime_interval **ra)
 {
        uint32_t op1_info;