Skip to content

Commit 64f4aca

Browse files
authored
IT: Implement CPU register usage for FETCH_DIM_W (#14225)
1 parent bf7d4d7 commit 64f4aca

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,9 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
22402240
break;
22412241
}
22422242
if (!zend_jit_fetch_dim(&ctx, opline,
2243-
OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), RES_REG_ADDR(), IS_UNKNOWN)) {
2243+
OP1_INFO(), OP1_REG_ADDR(),
2244+
OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
2245+
RES_REG_ADDR(), IS_UNKNOWN)) {
22442246
goto jit_failure;
22452247
}
22462248
goto done;

ext/opcache/jit/zend_jit_ir.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12429,16 +12429,14 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit,
1242912429
uint32_t op1_info,
1243012430
zend_jit_addr op1_addr,
1243112431
uint32_t op2_info,
12432+
zend_jit_addr op2_addr,
1243212433
zend_jit_addr res_addr,
1243312434
uint8_t dim_type)
1243412435
{
12435-
zend_jit_addr op2_addr;
1243612436
int may_throw = 0;
1243712437
ir_ref end_inputs = IR_UNUSED;
1243812438
ir_ref ref, if_type = IR_UNUSED, ht_ref;
1243912439

12440-
op2_addr = (opline->op2_type != IS_UNUSED) ? OP2_ADDR() : 0;
12441-
1244212440
if (opline->opcode == ZEND_FETCH_DIM_RW) {
1244312441
jit_SET_EX_OPLINE(jit, opline);
1244412442
}
@@ -12496,7 +12494,7 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit,
1249612494
may_throw = 1;
1249712495
}
1249812496
if (!zend_jit_fetch_dimension_address_inner(jit, opline, type, op1_info,
12499-
op2_info, OP2_ADDR(), dim_type, NULL, NULL, NULL,
12497+
op2_info, op2_addr, dim_type, NULL, NULL, NULL,
1250012498
0, ht_ref, found_inputs, found_vals, &end_inputs, NULL)) {
1250112499
return 0;
1250212500
}
@@ -16572,11 +16570,15 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
1657216570
(((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) ||
1657316571
((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_STRING));
1657416572
case ZEND_ASSIGN_DIM:
16573+
case ZEND_FETCH_DIM_W:
16574+
case ZEND_FETCH_DIM_RW:
16575+
case ZEND_FETCH_LIST_W:
1657516576
op1_info = OP1_INFO();
1657616577
op2_info = OP2_INFO();
1657716578
if (trace) {
1657816579
if (opline->op1_type == IS_CV) {
16579-
if ((opline+1)->op1_type == IS_CV
16580+
if (opline->opcode == ZEND_ASSIGN_DIM
16581+
&& (opline+1)->op1_type == IS_CV
1658016582
&& (opline+1)->op1.var == opline->op1.var) {
1658116583
/* skip $a[x] = $a; */
1658216584
return 0;
@@ -16592,6 +16594,10 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
1659216594
&& (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)) == IS_ARRAY) {
1659316595
op1_info &= ~((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY);
1659416596
}
16597+
} else {
16598+
if (opline->op1_type != IS_CV) {
16599+
return 0;
16600+
}
1659516601
}
1659616602
return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) &&
1659716603
(((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) ||

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5767,7 +5767,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
57675767
CHECK_OP2_TRACE_TYPE();
57685768
op1_def_info = OP1_DEF_INFO();
57695769
if (!zend_jit_fetch_dim(&ctx, opline,
5770-
op1_info, op1_addr, op2_info, RES_REG_ADDR(), val_type)) {
5770+
op1_info, op1_addr,
5771+
op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
5772+
RES_REG_ADDR(), val_type)) {
57715773
goto jit_failure;
57725774
}
57735775
if (ssa_op->result_def > 0

0 commit comments

Comments
 (0)