Skip to content

Commit ca93e48

Browse files
committed
Uniform placing of init_fcall guards.
This fixes trcing JIT with opcache.jit=51
1 parent 81f7ef4 commit ca93e48

File tree

1 file changed

+10
-42
lines changed

1 file changed

+10
-42
lines changed

ext/opcache/jit/zend_jit_trace.c

+10-42
Original file line numberDiff line numberDiff line change
@@ -6047,7 +6047,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
60476047
case ZEND_INIT_METHOD_CALL:
60486048
if (opline->op2_type != IS_CONST
60496049
|| Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) != IS_STRING) {
6050-
goto generic_dynamic_call;
6050+
break;
60516051
}
60526052
on_this = delayed_fetch_this = 0;
60536053
ce = NULL;
@@ -6111,7 +6111,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
61116111
goto done;
61126112
case ZEND_INIT_DYNAMIC_CALL:
61136113
if (orig_op2_type != IS_OBJECT || op2_ce != zend_ce_closure) {
6114-
goto generic_dynamic_call;
6114+
break;
61156115
}
61166116
op2_info = OP2_INFO();
61176117
CHECK_OP2_TRACE_TYPE();
@@ -6120,46 +6120,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
61206120
goto jit_failure;
61216121
}
61226122
goto done;
6123-
case ZEND_INIT_STATIC_METHOD_CALL:
6124-
generic_dynamic_call:
6125-
if (!zend_jit_trace_handler(&dasm_state, op_array, opline, zend_may_throw(opline, ssa_op, op_array, ssa), p + 1)) {
6126-
goto jit_failure;
6127-
}
6128-
if ((p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func
6129-
&& (opline->opcode != ZEND_INIT_STATIC_METHOD_CALL
6130-
|| opline->op1_type != IS_CONST
6131-
|| opline->op2_type != IS_CONST
6132-
|| zend_jit_may_be_modified((p+1)->func, op_array))) {
6133-
if (!zend_jit_init_fcall_guard(&dasm_state, 0, (p+1)->func, opline+1)) {
6134-
goto jit_failure;
6135-
}
6136-
}
6137-
goto done;
6138-
case ZEND_INIT_USER_CALL:
6139-
if (!zend_jit_trace_handler(&dasm_state, op_array, opline, zend_may_throw(opline, ssa_op, op_array, ssa), p + 1)) {
6140-
goto jit_failure;
6141-
}
6142-
if ((p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func
6143-
&& (opline->op2_type != IS_CONST
6144-
|| zend_jit_may_be_modified((p+1)->func, op_array))) {
6145-
if (!zend_jit_init_fcall_guard(&dasm_state, 0, (p+1)->func, opline+1)) {
6146-
goto jit_failure;
6147-
}
6148-
}
6149-
goto done;
6150-
case ZEND_NEW:
6151-
if (!zend_jit_trace_handler(&dasm_state, op_array, opline, zend_may_throw(opline, ssa_op, op_array, ssa), p + 1)) {
6152-
goto jit_failure;
6153-
}
6154-
if ((p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func
6155-
&& (opline->op1_type != IS_CONST
6156-
|| zend_jit_may_be_modified((p+1)->func, op_array))) {
6157-
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_OBJECT, 1);
6158-
if (!zend_jit_init_fcall_guard(&dasm_state, 0, (p+1)->func, opline+1)) {
6159-
goto jit_failure;
6160-
}
6161-
}
6162-
goto done;
61636123
case ZEND_SEND_ARRAY:
61646124
case ZEND_SEND_UNPACK:
61656125
if (JIT_G(current_frame)
@@ -6198,6 +6158,14 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
61986158
zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info), p + 1)) {
61996159
goto jit_failure;
62006160
}
6161+
if ((p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) {
6162+
if (zend_jit_may_be_polymorphic_call(opline) ||
6163+
zend_jit_may_be_modified((p+1)->func, op_array)) {
6164+
if (!zend_jit_init_fcall_guard(&dasm_state, 0, (p+1)->func, opline+1)) {
6165+
goto jit_failure;
6166+
}
6167+
}
6168+
}
62016169
}
62026170

62036171
done:

0 commit comments

Comments
 (0)