Skip to content

Commit 02b645e

Browse files
committed
JIT for FETCH_LIST_R
1 parent 3b0fecd commit 02b645e

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,6 +2812,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
28122812
goto done;
28132813
case ZEND_FETCH_DIM_R:
28142814
case ZEND_FETCH_DIM_IS:
2815+
case ZEND_FETCH_LIST_R:
28152816
if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) {
28162817
break;
28172818
}

ext/opcache/jit/zend_jit_trace.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
15261526
/* break missing intentionally */
15271527
case ZEND_FETCH_DIM_R:
15281528
case ZEND_FETCH_DIM_IS:
1529+
case ZEND_FETCH_LIST_R:
15291530
ADD_OP1_TRACE_GUARD();
15301531
ADD_OP2_TRACE_GUARD();
15311532

@@ -4219,6 +4220,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42194220
/* break missing intentionally */
42204221
case ZEND_FETCH_DIM_R:
42214222
case ZEND_FETCH_DIM_IS:
4223+
case ZEND_FETCH_LIST_R:
42224224
op1_info = OP1_INFO();
42234225
op1_addr = OP1_REG_ADDR();
42244226
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
42614263
(op1_info & MAY_BE_ANY) != MAY_BE_ARRAY ||
42624264
(op2_info & (MAY_BE_ANY - (MAY_BE_LONG|MAY_BE_STRING))) != 0 ||
42634265
((op1_info & MAY_BE_UNDEF) != 0 &&
4264-
opline->opcode == ZEND_FETCH_DIM_R) ||
4265-
((opline->op1_type & (IS_TMP_VAR|IS_VAR)) != 0 &&
4266+
opline->opcode != ZEND_FETCH_DIM_IS) ||
4267+
(opline->opcode != ZEND_FETCH_LIST_R &&
4268+
(opline->op1_type & (IS_TMP_VAR|IS_VAR)) != 0 &&
42664269
(op1_info & MAY_BE_RC1) &&
42674270
(op1_info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) != 0) ||
42684271
(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
62166219
if (t->exit_info[exit_num].flags & ZEND_JIT_EXIT_FREE_OP2) {
62176220
ZEND_ASSERT((opline-1)->opcode == ZEND_FETCH_DIM_R
62186221
|| (opline-1)->opcode == ZEND_FETCH_DIM_IS
6222+
|| (opline-1)->opcode == ZEND_FETCH_LIST_R
62196223
|| (opline-1)->opcode == ZEND_FETCH_DIM_FUNC_ARG);
62206224
EX(opline) = opline-1;
62216225
zval_ptr_dtor_nogc(EX_VAR((opline-1)->op2.var));

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10662,6 +10662,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1066210662
const void *not_found_exit_addr = NULL;
1066310663
const void *res_exit_addr = NULL;
1066410664
zend_bool result_avoid_refcounting = 0;
10665+
uint32_t may_be_string = (opline->opcode != ZEND_FETCH_LIST_R) ? MAY_BE_STRING : 0;
1066510666

1066610667
orig_op1_addr = OP1_ADDR();
1066710668
op2_addr = OP2_ADDR();
@@ -10684,7 +10685,8 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1068410685
zend_jit_trace_stack *stack = JIT_G(current_frame)->stack;
1068510686
int32_t exit_point;
1068610687

10687-
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))
10688+
if (opline->opcode != ZEND_FETCH_LIST_R
10689+
&& (opline->op1_type & (IS_VAR|IS_TMP_VAR))
1068810690
&& !op1_avoid_refcounting) {
1068910691
flags |= ZEND_JIT_EXIT_FREE_OP1;
1069010692
}
@@ -10747,7 +10749,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1074710749

1074810750
if (op1_info & MAY_BE_ARRAY) {
1074910751
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY)) {
10750-
if (exit_addr && !(op1_info & (MAY_BE_OBJECT|MAY_BE_STRING))) {
10752+
if (exit_addr && !(op1_info & (MAY_BE_OBJECT|may_be_string))) {
1075110753
| IF_NOT_ZVAL_TYPE op1_addr, IS_ARRAY, &exit_addr
1075210754
} else {
1075310755
| IF_NOT_ZVAL_TYPE op1_addr, IS_ARRAY, >7
@@ -10765,7 +10767,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1076510767
|7:
1076610768
}
1076710769

10768-
if (op1_info & MAY_BE_STRING) {
10770+
if (opline->opcode != ZEND_FETCH_LIST_R && (op1_info & MAY_BE_STRING)) {
1076910771
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING))) {
1077010772
if (exit_addr && !(op1_info & MAY_BE_OBJECT)) {
1077110773
| IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, &exit_addr
@@ -10800,7 +10802,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1080010802
}
1080110803

1080210804
if (op1_info & MAY_BE_OBJECT) {
10803-
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT))) {
10805+
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_OBJECT|may_be_string))) {
1080410806
if (exit_addr) {
1080510807
| IF_NOT_ZVAL_TYPE op1_addr, IS_OBJECT, &exit_addr
1080610808
} else {
@@ -10832,7 +10834,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1083210834
| add r4, 12
1083310835
|.endif
1083410836
if ((op1_info & MAY_BE_ARRAY) ||
10835-
(op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT)))) {
10837+
(op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_OBJECT|may_be_string)))) {
1083610838
| jmp >9 // END
1083710839
}
1083810840
|6:
@@ -10856,10 +10858,10 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1085610858
}
1085710859
}
1085810860

10859-
if ((op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT)))
10861+
if ((op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_OBJECT|may_be_string)))
1086010862
&& !exit_addr) {
10861-
if (opline->opcode != ZEND_FETCH_DIM_IS) {
10862-
if ((opline->opcode != ZEND_FETCH_DIM_IS && (op1_info & MAY_BE_UNDEF)) || (op2_info & MAY_BE_UNDEF)) {
10863+
if (opline->opcode != ZEND_FETCH_DIM_IS && opline->opcode != ZEND_FETCH_LIST_R) {
10864+
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
1086310865
| LOAD_ZVAL_ADDR FCARG1a, orig_op1_addr
1086410866
} else {
1086510867
| SET_EX_OPLINE opline, r0
@@ -10935,7 +10937,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst,
1093510937
#endif
1093610938

1093710939
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline
10938-
if (!op1_avoid_refcounting) {
10940+
if (opline->opcode != ZEND_FETCH_LIST_R && !op1_avoid_refcounting) {
1093910941
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline
1094010942
}
1094110943

0 commit comments

Comments
 (0)