Skip to content

Commit 8e9df32

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17868: Cannot allocate memory with tracing JIT on 8.4.4
2 parents 2b6c9b6 + 5ede541 commit 8e9df32

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_jit_init_func_run_tim
4242
{
4343
void **run_time_cache;
4444

45-
if (op_array->type == ZEND_USER_FUNCTION && !RUN_TIME_CACHE(op_array)) {
45+
if (!RUN_TIME_CACHE(op_array)) {
4646
run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
4747
memset(run_time_cache, 0, op_array->cache_size);
4848
ZEND_MAP_PTR_SET(op_array->run_time_cache, run_time_cache);

ext/opcache/jit/zend_jit_ir.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8691,6 +8691,7 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co
86918691
ir_STORE(jit_CALL(rx, This), IR_NULL);
86928692
} else {
86938693
ir_ref object_or_called_scope, call_info, call_info2, object, if_cond;
8694+
ir_ref if_cond_user = IR_UNUSED;
86948695

86958696
if (opline->op2_type == IS_CV) {
86968697
// JIT: GC_ADDREF(closure);
@@ -8728,15 +8729,22 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co
87288729
// JIT: Z_PTR(call->This) = object_or_called_scope;
87298730
ir_STORE(jit_CALL(rx, This.value.ptr), object_or_called_scope);
87308731

8731-
// JIT: if (closure->func.op_array.run_time_cache__ptr)
8732-
if_cond = ir_IF(ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func.op_array.run_time_cache__ptr))));
8733-
ir_IF_FALSE(if_cond);
8732+
if (!func) {
8733+
// JIT: if (closure->func.common.type & ZEND_USER_FUNCTION)
8734+
ir_ref type = ir_LOAD_U8(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func.type)));
8735+
if_cond_user = ir_IF(ir_AND_U8(type, ir_CONST_U8(ZEND_USER_FUNCTION)));
8736+
ir_IF_TRUE(if_cond_user);
8737+
}
87348738

8735-
// JIT: zend_jit_init_func_run_time_cache_helper(closure->func);
8736-
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_init_func_run_time_cache_helper),
8737-
ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func)));
8739+
if (!func || func->common.type == ZEND_USER_FUNCTION) {
8740+
// JIT: zend_jit_init_func_run_time_cache_helper(closure->func);
8741+
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_init_func_run_time_cache_helper),
8742+
ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func)));
8743+
}
87388744

8739-
ir_MERGE_WITH_EMPTY_TRUE(if_cond);
8745+
if (!func) {
8746+
ir_MERGE_WITH_EMPTY_FALSE(if_cond_user);
8747+
}
87408748
}
87418749

87428750
// JIT: ZEND_CALL_NUM_ARGS(call) = num_args;

0 commit comments

Comments
 (0)