Skip to content

Commit 282265b

Browse files
committed
JIT for SEND_FUNC_ARG
1 parent 8ea143a commit 282265b

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
24622462
case ZEND_SEND_VAR_EX:
24632463
case ZEND_SEND_VAR_NO_REF:
24642464
case ZEND_SEND_VAR_NO_REF_EX:
2465+
case ZEND_SEND_FUNC_ARG:
24652466
if ((opline->opcode == ZEND_SEND_VAR_EX
24662467
|| opline->opcode == ZEND_SEND_VAR_NO_REF_EX)
24672468
&& opline->op2.num > MAX_ARG_FLAG_NUM) {

ext/opcache/jit/zend_jit_trace.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
12631263
case ZEND_SEND_VAR_EX:
12641264
case ZEND_SEND_VAR_NO_REF:
12651265
case ZEND_SEND_VAR_NO_REF_EX:
1266+
case ZEND_SEND_FUNC_ARG:
12661267
if (tssa->ops[idx].op1_use >= 0 && op1_type != IS_UNKNOWN) {
12671268
zend_ssa_var_info *info = &ssa_var_info[ssa_ops[idx].op1_use];
12681269
if ((info->type & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << op1_type)) {
@@ -1481,7 +1482,8 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
14811482
ssa_var_info[v].type = MAY_BE_UNDEF;
14821483
}
14831484
}
1484-
if (i < op_array->num_args) {
1485+
if (!(op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
1486+
&& i < op_array->num_args) {
14851487
/* Propagate argument type */
14861488
ssa_var_info[v].type &= frame->stack[i];
14871489
}
@@ -2202,6 +2204,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
22022204
case ZEND_SEND_VAR_EX:
22032205
case ZEND_SEND_VAR_NO_REF:
22042206
case ZEND_SEND_VAR_NO_REF_EX:
2207+
case ZEND_SEND_FUNC_ARG:
22052208
if ((opline->opcode == ZEND_SEND_VAR_EX
22062209
|| opline->opcode == ZEND_SEND_VAR_NO_REF_EX)
22072210
&& opline->op2.num > MAX_ARG_FLAG_NUM) {
@@ -2223,7 +2226,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
22232226
}
22242227
if (frame->call
22252228
&& frame->call->func->type == ZEND_USER_FUNCTION) {
2226-
if (opline->opcode == ZEND_SEND_VAR_EX
2229+
if ((opline->opcode == ZEND_SEND_VAR_EX
2230+
|| opline->opcode == ZEND_SEND_FUNC_ARG)
22272231
&& ARG_SHOULD_BE_SENT_BY_REF(frame->call->func, opline->op2.num)) {
22282232
// TODO: this may require invalidation, if caller is changed ???
22292233
goto done;

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8634,6 +8634,28 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend
86348634
| jmp >7
86358635
}
86368636

8637+
|.code
8638+
}
8639+
} else if (opline->opcode == ZEND_SEND_FUNC_ARG) {
8640+
if (zend_jit_trigger == ZEND_JIT_ON_HOT_TRACE
8641+
&& JIT_G(current_frame)
8642+
&& JIT_G(current_frame)->call
8643+
&& JIT_G(current_frame)->call->func) {
8644+
if (ARG_SHOULD_BE_SENT_BY_REF(JIT_G(current_frame)->call->func, arg_num)) {
8645+
if (!zend_jit_send_ref(Dst, opline, op_array, op1_info, 0)) {
8646+
return 0;
8647+
}
8648+
return 1;
8649+
}
8650+
} else {
8651+
| test dword [RX + offsetof(zend_execute_data, This.u1.type_info)], ZEND_CALL_SEND_ARG_BY_REF
8652+
| jnz >1
8653+
|.cold_code
8654+
|1:
8655+
if (!zend_jit_send_ref(Dst, opline, op_array, op1_info, 1)) {
8656+
return 0;
8657+
}
8658+
| jmp >7
86378659
|.code
86388660
}
86398661
}
@@ -8677,7 +8699,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend
86778699
return 0;
86788700
}
86798701
}
8680-
} else if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
8702+
} else {
86818703
if (op1_info & MAY_BE_REF) {
86828704
if (opline->op1_type == IS_CV) {
86838705
zend_jit_addr val_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);

0 commit comments

Comments
 (0)