Skip to content

Commit

Permalink
JIT for FETCH_LIST_R
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 8, 2020
1 parent 3b0fecd commit 02b645e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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));
Expand Down
20 changes: 11 additions & 9 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 02b645e

Please sign in to comment.