Skip to content

Commit a3cdb7a

Browse files
committed
FFI JIT for FETCH_DIM/OBJ_W + ASSIGN_DIM
1 parent d7b4d20 commit a3cdb7a

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
18331833
break;
18341834
}
18351835
if (!zend_jit_assign_dim(&ctx, opline,
1836-
OP1_INFO(), OP1_REG_ADDR(),
1836+
OP1_INFO(), OP1_REG_ADDR(), 0,
18371837
OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
18381838
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
18391839
OP1_DATA_INFO(), OP1_DATA_REG_ADDR(),

ext/opcache/jit/zend_jit_ir.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13636,6 +13636,7 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit,
1363613636
const zend_op *opline,
1363713637
uint32_t op1_info,
1363813638
zend_jit_addr op1_addr,
13639+
bool op1_indirect,
1363913640
uint32_t op2_info,
1364013641
zend_jit_addr op2_addr,
1364113642
zend_ssa_range *op2_range,
@@ -13728,8 +13729,8 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit,
1372813729
// JIT: value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
1372913730
if (opline->op1_type == IS_VAR
1373013731
&& Z_MODE(op3_addr) != IS_REG
13732+
&& opline->result_type == IS_UNUSED
1373113733
&& (res_addr == 0 || Z_MODE(res_addr) != IS_REG)) {
13732-
ZEND_ASSERT(opline->result_type == IS_UNUSED);
1373313734
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)) {
1373413735
return 0;
1373513736
}
@@ -13796,6 +13797,10 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit,
1379613797
ir_MERGE_list(end_inputs);
1379713798
jit_FREE_OP(jit, opline->op2_type, opline->op2, op2_info, opline);
1379813799

13800+
if (!op1_indirect) {
13801+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
13802+
}
13803+
1379913804
if (may_throw) {
1380013805
zend_jit_check_exception(jit);
1380113806
}
@@ -14049,6 +14054,7 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
1404914054
const zend_ssa_op *ssa_op,
1405014055
uint32_t op1_info,
1405114056
zend_jit_addr op1_addr,
14057+
bool op1_indirect,
1405214058
uint32_t op2_info,
1405314059
zend_jit_addr op2_addr,
1405414060
zend_ssa_range *op2_range,
@@ -14096,6 +14102,10 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
1409614102

1409714103
jit_FREE_OP(jit, (opline+1)->op1_type, (opline+1)->op1, val_info, opline);
1409814104

14105+
if (!op1_indirect) {
14106+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
14107+
}
14108+
1409914109
return 1;
1410014110
}
1410114111
#endif

ext/opcache/jit/zend_jit_trace.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5113,6 +5113,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
51135113
case ZEND_ASSIGN_DIM:
51145114
op1_info = OP1_INFO();
51155115
op1_addr = OP1_REG_ADDR();
5116+
op1_indirect = 0;
51165117
if (opline->op1_type == IS_CV
51175118
&& (opline+1)->op1_type == IS_CV
51185119
&& (opline+1)->op1.var == opline->op1.var) {
@@ -5121,14 +5122,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
51215122
}
51225123
if (opline->op1_type == IS_VAR) {
51235124
if (orig_op1_type != IS_UNKNOWN
5124-
&& (orig_op1_type & IS_TRACE_INDIRECT)
5125-
&& opline->result_type == IS_UNUSED) {
5125+
&& (orig_op1_type & IS_TRACE_INDIRECT)) {
5126+
op1_indirect = 1;
51265127
if (!zend_jit_fetch_indirect_var(&ctx, opline, orig_op1_type,
51275128
&op1_info, &op1_addr, !ssa->var_info[ssa_op->op1_use].indirect_reference)) {
51285129
goto jit_failure;
51295130
}
5130-
} else {
5131-
break;
51325131
}
51335132
}
51345133
if (orig_op1_type != IS_UNKNOWN
@@ -5158,7 +5157,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
51585157
ffi_info = zend_arena_calloc(&CG(arena), ssa->vars_count, sizeof(zend_jit_ffi_info));
51595158
}
51605159
if (!zend_jit_ffi_assign_dim(&ctx, opline, ssa, ssa_op,
5161-
op1_info, op1_addr,
5160+
op1_info, op1_addr, op1_indirect,
51625161
op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
51635162
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
51645163
op1_data_info, OP1_DATA_REG_ADDR(),
@@ -5170,7 +5169,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
51705169
} else
51715170
#endif
51725171
if (!zend_jit_assign_dim(&ctx, opline,
5173-
op1_info, op1_addr,
5172+
op1_info, op1_addr, op1_indirect,
51745173
op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
51755174
(opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
51765175
op1_data_info, OP1_DATA_REG_ADDR(),

0 commit comments

Comments
 (0)