Skip to content

Commit 57bfca9

Browse files
authored
JIT support for ASSIGN_DIM[_OP] with IS_VAR op1 (php#16339)
1 parent 3da6818 commit 57bfca9

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
17411741
break;
17421742
}
17431743
if (!zend_jit_assign_dim_op(&ctx, opline,
1744-
OP1_INFO(), OP1_DEF_INFO(), OP1_REG_ADDR(),
1744+
OP1_INFO(), OP1_DEF_INFO(), OP1_REG_ADDR(), 0,
17451745
OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
17461746
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
17471747
OP1_DATA_INFO(), OP1_DATA_REG_ADDR(), OP1_DATA_RANGE(), IS_UNKNOWN,
@@ -1757,7 +1757,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
17571757
break;
17581758
}
17591759
if (!zend_jit_assign_dim(&ctx, opline,
1760-
OP1_INFO(), OP1_REG_ADDR(),
1760+
OP1_INFO(), OP1_REG_ADDR(), 0,
17611761
OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
17621762
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
17631763
OP1_DATA_INFO(), OP1_DATA_REG_ADDR(),

ext/opcache/jit/zend_jit_ir.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13179,6 +13179,7 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit,
1317913179
const zend_op *opline,
1318013180
uint32_t op1_info,
1318113181
zend_jit_addr op1_addr,
13182+
bool op1_indirect,
1318213183
uint32_t op2_info,
1318313184
zend_jit_addr op2_addr,
1318413185
zend_ssa_range *op2_range,
@@ -13271,8 +13272,8 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit,
1327113272
// JIT: value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
1327213273
if (opline->op1_type == IS_VAR
1327313274
&& Z_MODE(op3_addr) != IS_REG
13275+
&& opline->result_type == IS_UNUSED
1327413276
&& (res_addr == 0 || Z_MODE(res_addr) != IS_REG)) {
13275-
ZEND_ASSERT(opline->result_type == IS_UNUSED);
1327613277
if (!zend_jit_assign_to_variable_call(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0)) {
1327713278
return 0;
1327813279
}
@@ -13339,6 +13340,10 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit,
1333913340
ir_MERGE_list(end_inputs);
1334013341
jit_FREE_OP(jit, opline->op2_type, opline->op2, op2_info, opline);
1334113342

13343+
if (!op1_indirect) {
13344+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
13345+
}
13346+
1334213347
if (may_throw) {
1334313348
zend_jit_check_exception(jit);
1334413349
}
@@ -13351,6 +13356,7 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit,
1335113356
uint32_t op1_info,
1335213357
uint32_t op1_def_info,
1335313358
zend_jit_addr op1_addr,
13359+
bool op1_indirect,
1335413360
uint32_t op2_info,
1335513361
zend_jit_addr op2_addr,
1335613362
zend_ssa_range *op2_range,
@@ -13549,6 +13555,9 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit,
1354913555

1355013556
jit_FREE_OP(jit, (opline+1)->op1_type, (opline+1)->op1, op1_data_info, NULL);
1355113557
jit_FREE_OP(jit, opline->op2_type, opline->op2, op2_info, NULL);
13558+
if (!op1_indirect) {
13559+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, NULL);
13560+
}
1355213561
if (may_throw) {
1355313562
zend_jit_check_exception(jit);
1355413563
}

ext/opcache/jit/zend_jit_trace.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4697,15 +4697,15 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
46974697
}
46984698
op1_info = OP1_INFO();
46994699
op1_addr = OP1_REG_ADDR();
4700+
op1_indirect = 0;
47004701
if (opline->op1_type == IS_VAR) {
47014702
if (orig_op1_type != IS_UNKNOWN
47024703
&& (orig_op1_type & IS_TRACE_INDIRECT)) {
4704+
op1_indirect = 1;
47034705
if (!zend_jit_fetch_indirect_var(&ctx, opline, orig_op1_type,
47044706
&op1_info, &op1_addr, !ssa->var_info[ssa_op->op1_use].indirect_reference)) {
47054707
goto jit_failure;
47064708
}
4707-
} else {
4708-
break;
47094709
}
47104710
}
47114711
if (orig_op1_type != IS_UNKNOWN
@@ -4727,7 +4727,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
47274727
CHECK_OP1_DATA_TRACE_TYPE();
47284728
op1_def_info = OP1_DEF_INFO();
47294729
if (!zend_jit_assign_dim_op(&ctx, opline,
4730-
op1_info, op1_def_info, op1_addr,
4730+
op1_info, op1_def_info, op1_addr, op1_indirect,
47314731
op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
47324732
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
47334733
op1_data_info, OP1_DATA_REG_ADDR(), OP1_DATA_RANGE(), val_type,
@@ -5009,6 +5009,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
50095009
case ZEND_ASSIGN_DIM:
50105010
op1_info = OP1_INFO();
50115011
op1_addr = OP1_REG_ADDR();
5012+
op1_indirect = 0;
50125013
if (opline->op1_type == IS_CV
50135014
&& (opline+1)->op1_type == IS_CV
50145015
&& (opline+1)->op1.var == opline->op1.var) {
@@ -5017,14 +5018,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
50175018
}
50185019
if (opline->op1_type == IS_VAR) {
50195020
if (orig_op1_type != IS_UNKNOWN
5020-
&& (orig_op1_type & IS_TRACE_INDIRECT)
5021-
&& opline->result_type == IS_UNUSED) {
5021+
&& (orig_op1_type & IS_TRACE_INDIRECT)) {
5022+
op1_indirect = 1;
50225023
if (!zend_jit_fetch_indirect_var(&ctx, opline, orig_op1_type,
50235024
&op1_info, &op1_addr, !ssa->var_info[ssa_op->op1_use].indirect_reference)) {
50245025
goto jit_failure;
50255026
}
5026-
} else {
5027-
break;
50285027
}
50295028
}
50305029
if (orig_op1_type != IS_UNKNOWN
@@ -5045,7 +5044,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
50455044
op1_data_info = OP1_DATA_INFO();
50465045
CHECK_OP1_DATA_TRACE_TYPE();
50475046
if (!zend_jit_assign_dim(&ctx, opline,
5048-
op1_info, op1_addr,
5047+
op1_info, op1_addr, op1_indirect,
50495048
op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
50505049
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
50515050
op1_data_info, OP1_DATA_REG_ADDR(),

0 commit comments

Comments
 (0)