From: Dmitry Stogov Date: Tue, 8 Sep 2020 13:47:15 +0000 (+0300) Subject: JIT for FETCH_LIST_R X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02b645e47a3cd5812175b155edb31c64190e8306;p=php JIT for FETCH_LIST_R --- diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 48a37a0e51..9abd39dcec 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2812,6 +2812,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto done; case ZEND_FETCH_DIM_R: case ZEND_FETCH_DIM_IS: + case ZEND_FETCH_LIST_R: if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 5e09b2dd7c..f79710daf8 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1526,6 +1526,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin /* break missing intentionally */ case ZEND_FETCH_DIM_R: case ZEND_FETCH_DIM_IS: + case ZEND_FETCH_LIST_R: ADD_OP1_TRACE_GUARD(); ADD_OP2_TRACE_GUARD(); @@ -4219,6 +4220,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par /* break missing intentionally */ case ZEND_FETCH_DIM_R: case ZEND_FETCH_DIM_IS: + case ZEND_FETCH_LIST_R: op1_info = OP1_INFO(); op1_addr = OP1_REG_ADDR(); if (orig_op1_type != IS_UNKNOWN @@ -4261,8 +4263,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par (op1_info & MAY_BE_ANY) != MAY_BE_ARRAY || (op2_info & (MAY_BE_ANY - (MAY_BE_LONG|MAY_BE_STRING))) != 0 || ((op1_info & MAY_BE_UNDEF) != 0 && - opline->opcode == ZEND_FETCH_DIM_R) || - ((opline->op1_type & (IS_TMP_VAR|IS_VAR)) != 0 && + opline->opcode != ZEND_FETCH_DIM_IS) || + (opline->opcode != ZEND_FETCH_LIST_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 || @@ -6216,6 +6219,7 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf if (t->exit_info[exit_num].flags & ZEND_JIT_EXIT_FREE_OP2) { ZEND_ASSERT((opline-1)->opcode == ZEND_FETCH_DIM_R || (opline-1)->opcode == ZEND_FETCH_DIM_IS + || (opline-1)->opcode == ZEND_FETCH_LIST_R || (opline-1)->opcode == ZEND_FETCH_DIM_FUNC_ARG); EX(opline) = opline-1; zval_ptr_dtor_nogc(EX_VAR((opline-1)->op2.var)); diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 566c052181..26751aa7fc 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10662,6 +10662,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const void *not_found_exit_addr = NULL; const void *res_exit_addr = NULL; zend_bool result_avoid_refcounting = 0; + uint32_t may_be_string = (opline->opcode != ZEND_FETCH_LIST_R) ? MAY_BE_STRING : 0; orig_op1_addr = OP1_ADDR(); op2_addr = OP2_ADDR(); @@ -10684,7 +10685,8 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, zend_jit_trace_stack *stack = JIT_G(current_frame)->stack; int32_t exit_point; - if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) + if (opline->opcode != ZEND_FETCH_LIST_R + && (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !op1_avoid_refcounting) { flags |= ZEND_JIT_EXIT_FREE_OP1; } @@ -10747,7 +10749,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, if (op1_info & MAY_BE_ARRAY) { if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY)) { - if (exit_addr && !(op1_info & (MAY_BE_OBJECT|MAY_BE_STRING))) { + if (exit_addr && !(op1_info & (MAY_BE_OBJECT|may_be_string))) { | IF_NOT_ZVAL_TYPE op1_addr, IS_ARRAY, &exit_addr } else { | IF_NOT_ZVAL_TYPE op1_addr, IS_ARRAY, >7 @@ -10765,7 +10767,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, |7: } - if (op1_info & MAY_BE_STRING) { + if (opline->opcode != ZEND_FETCH_LIST_R && (op1_info & MAY_BE_STRING)) { if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING))) { if (exit_addr && !(op1_info & MAY_BE_OBJECT)) { | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, &exit_addr @@ -10800,7 +10802,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, } if (op1_info & MAY_BE_OBJECT) { - if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT))) { + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_OBJECT|may_be_string))) { if (exit_addr) { | IF_NOT_ZVAL_TYPE op1_addr, IS_OBJECT, &exit_addr } else { @@ -10832,7 +10834,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, | add r4, 12 |.endif if ((op1_info & MAY_BE_ARRAY) || - (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT)))) { + (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_OBJECT|may_be_string)))) { | jmp >9 // END } |6: @@ -10856,10 +10858,10 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, } } - if ((op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT))) + if ((op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_OBJECT|may_be_string))) && !exit_addr) { - if (opline->opcode != ZEND_FETCH_DIM_IS) { - if ((opline->opcode != ZEND_FETCH_DIM_IS && (op1_info & MAY_BE_UNDEF)) || (op2_info & MAY_BE_UNDEF)) { + if (opline->opcode != ZEND_FETCH_DIM_IS && opline->opcode != ZEND_FETCH_LIST_R) { + if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) { | LOAD_ZVAL_ADDR FCARG1a, orig_op1_addr } else { | SET_EX_OPLINE opline, r0 @@ -10935,7 +10937,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, #endif | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline - if (!op1_avoid_refcounting) { + if (opline->opcode != ZEND_FETCH_LIST_R && !op1_avoid_refcounting) { | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline }