Skip to content

Commit 14a1e66

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Avoid refcounting when return CV (similar to optimization in VM).
2 parents a9b986a + 5572318 commit 14a1e66

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4494,16 +4494,19 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
44944494
uint32_t info;
44954495
zend_uchar type;
44964496

4497+
info = zend_ssa_cv_info(op_array, op_array_ssa, j);
4498+
type = STACK_TYPE(stack, j);
4499+
info = zend_jit_trace_type_to_info_ex(type, info);
44974500
if (opline->op1_type == IS_CV
44984501
&& EX_VAR_TO_NUM(opline->op1.var) == j
44994502
&& !(op1_info & MAY_BE_REF)
4500-
&& JIT_G(current_frame)
4501-
&& TRACE_FRAME_IS_RETURN_VALUE_USED(JIT_G(current_frame))) {
4502-
continue;
4503+
&& JIT_G(current_frame)) {
4504+
if (TRACE_FRAME_IS_RETURN_VALUE_USED(JIT_G(current_frame))) {
4505+
continue;
4506+
} else if ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != MAY_BE_OBJECT) {
4507+
info |= MAY_BE_NULL;
4508+
}
45034509
}
4504-
info = zend_ssa_cv_info(op_array, op_array_ssa, j);
4505-
type = STACK_TYPE(stack, j);
4506-
info = zend_jit_trace_type_to_info_ex(type, info);
45074510
if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
45084511
if (!left_frame) {
45094512
left_frame = 1;

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11387,8 +11387,17 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o
1138711387
}
1138811388
| ZVAL_COPY_VALUE ret_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_R0, ZREG_R2
1138911389
if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || (op1_info & MAY_BE_REF) || (return_value_used != 1)) {
11390-
| // TODO: JIT: if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) ZVAL_NULL(retval_ptr); ???
11391-
| TRY_ADDREF op1_info, ah, r2
11390+
if (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
11391+
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE
11392+
&& !(op1_info & MAY_BE_REF)
11393+
&& op_array->function_name
11394+
&& (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != MAY_BE_OBJECT) {
11395+
| // if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) ZVAL_NULL(retval_ptr);
11396+
| SET_ZVAL_TYPE_INFO op1_addr, IS_NULL
11397+
} else {
11398+
| TRY_ADDREF op1_info, ah, r2
11399+
}
11400+
}
1139211401
}
1139311402
} else {
1139411403
if (op1_info & MAY_BE_REF) {

0 commit comments

Comments
 (0)