Skip to content

Commit c792847

Browse files
authored
JIT: Avoid object type check if the object is known to be a type (#24086)
1 parent 0dcfd99 commit c792847

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎ext/opcache/jit/zend_jit_ir.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10850,7 +10850,6 @@ static int zend_jit_verify_arg_type(zend_jit_ctx *jit, const zend_op *opline, ze
1085010850
}
1085110851

1085210852
if (!ZEND_ARG_SEND_MODE(arg_info)
10853-
&& (type == IS_UNKNOWN || type == IS_OBJECT)
1085410853
&& zend_jit_class_satisfies_type(known_ce, arg_info->type)) {
1085510854
zend_jit_known_class_type_fast_path(jit, ref, type == IS_OBJECT, known_ce, &end_inputs);
1085610855
}
@@ -10864,7 +10863,8 @@ static int zend_jit_verify_arg_type(zend_jit_ctx *jit, const zend_op *opline, ze
1086410863
}
1086510864
}
1086610865

10867-
if (type_mask != 0) {
10866+
/* A known type is not in type_mask here (see above), so the mask check would always fail */
10867+
if (type_mask != 0 && type == IS_UNKNOWN) {
1086810868
if (is_power_of_two(type_mask)) {
1086910869
uint32_t type_code = concrete_type(type_mask);
1087010870
ir_ref if_ok = jit_if_Z_TYPE_ref(jit, ref, ir_CONST_U8(type_code));

‎ext/opcache/jit/zend_jit_trace.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,12 @@ static void zend_jit_trace_send_type(const zend_op *opline, zend_jit_trace_stack
489489
ZEND_ASSERT(arg_num <= op_array->num_args);
490490
arg_info = &op_array->arg_info[arg_num-1];
491491

492-
if (ZEND_TYPE_IS_SET(arg_info->type)) {
493-
if (!(ZEND_TYPE_FULL_MASK(arg_info->type) & (1u << type))) {
494-
return;
495-
}
492+
/* Record scalars and object class types, even if there's no "object" type declaration.
493+
* This allows RECV to record and skip object type checks. */
494+
if (ZEND_TYPE_IS_SET(arg_info->type)
495+
&& !(ZEND_TYPE_FULL_MASK(arg_info->type) & (1u << type))
496+
&& !(type == IS_OBJECT && call->func->type == ZEND_USER_FUNCTION)) {
497+
return;
496498
}
497499
}
498500
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), type, 1);

0 commit comments

Comments
 (0)