From a146e6eea7aeb395cfac9e706d81107a97009ed1 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 3 Apr 2019 23:37:25 +0300 Subject: [PATCH] jump optimization --- ext/opcache/jit/zend_jit.c | 38 ++++++++++++++++++++++++++-- ext/opcache/jit/zend_jit_x86.dasc | 42 ------------------------------- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index fffab897c2..84defa0028 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -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: diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 3b2da998cf..770aca2336 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -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; -- 2.40.0