[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 30 Oct 2026 14:35:48 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143009@lists.php.net to get a copy of this message
Author: Bob Weinand (bwoebi) Date: 2026-10-30T15:35:29+01:00 Commit: https://github.com/php/php-src/commit/83917486679d8d122cbf824e073970fe1c25af28 Raw diff: https://github.com/php/php-src/commit/83917486679d8d122cbf824e073970fe1c25af28.diff Merge branch 'PHP-8.6' * PHP-8.6: Load DECLARE_LAMBDA_FUNCTION cache slot once (#24598) Fix assertion in VM when taking ref-returning fcall by-value Changed paths: M Zend/zend_execute.c M Zend/zend_execute.h M Zend/zend_execute_API.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h M ext/zend_test/test.c M ext/zend_test/test.stub.php M ext/zend_test/test_arginfo.h M ext/zend_test/test_decl.h M ext/zend_test/test_legacy_arginfo.h Diff: diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 10db2e6247f6..885b7672678a 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -6004,26 +6004,7 @@ ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode ZEND_API void zend_return_unwrap_ref(zend_execute_data *execute_data, zval *return_value) { - if (!return_value || !Z_ISREF_P(return_value)) { - return; - } - - zend_execute_data *prev_ex = EX(prev_execute_data); - if (!prev_ex || !prev_ex->func || !ZEND_USER_CODE(prev_ex->func->type)) { - return; + if (return_value && Z_ISREF_P(return_value) && zend_return_should_unwrap_ref(execute_data)) { + zend_unwrap_reference(return_value); } - - const zend_op *do_opline = prev_ex->opline; - if (do_opline->result_type != IS_TMP_VAR) { - return; - } - - if (do_opline->opcode != ZEND_DO_FCALL - && do_opline->opcode != ZEND_DO_FCALL_BY_NAME - && do_opline->opcode != ZEND_DO_ICALL - && do_opline->opcode != ZEND_DO_UCALL) { - return; - } - - zend_unwrap_reference(return_value); } diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 78f33e2b5bd8..3e750e8cf30a 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -676,6 +676,24 @@ static zend_always_inline void *zend_get_bad_ptr(void) return NULL; } +static zend_always_inline bool zend_return_should_unwrap_ref(const zend_execute_data *call) +{ + const zend_execute_data *prev_ex = call->prev_execute_data; + if (!prev_ex || !prev_ex->func || !ZEND_USER_CODE(prev_ex->func->type)) { + return false; + } + + const zend_op *do_opline = prev_ex->opline; + if (do_opline->result_type != IS_TMP_VAR) { + return false; + } + + return do_opline->opcode == ZEND_DO_FCALL + || do_opline->opcode == ZEND_DO_FCALL_BY_NAME + || do_opline->opcode == ZEND_DO_ICALL + || do_opline->opcode == ZEND_DO_UCALL; +} + ZEND_API void zend_return_unwrap_ref(zend_execute_data *call, zval *return_value); END_EXTERN_C() diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 7c836c77dcaa..d8cf2d016ee8 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1103,7 +1103,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ bool result = zend_verify_internal_return_type(call->func, fci->retval); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(fci->retval) : !Z_ISREF_P(fci->retval)); ZEND_ASSERT(!(call->func->common.fn_flags2 & ZEND_ACC2_FORBID_DYN_CALLS)); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index cea13f11e680..e543054935d6 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4160,7 +4160,7 @@ ZEND_VM_HOT_HANDLER(129, ZEND_DO_ICALL, ANY, ANY, SPEC(RETVAL,OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -4293,7 +4293,7 @@ ZEND_VM_HOT_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY, SPEC(RETVAL,OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -4426,7 +4426,7 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL,OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -8424,9 +8424,10 @@ ZEND_VM_HANDLER(142, ZEND_DECLARE_LAMBDA_FUNCTION, UNUSED, NUM, NUM|CACHE_SLOT) zend_function *func; zend_object *object; zend_class_entry *called_scope; + uint32_t cache_slot = opline->extended_value; - if (opline->extended_value != (uint32_t)-1) { - zend_object *closure = CACHED_PTR(opline->extended_value); + if (cache_slot != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(cache_slot); if (closure) { ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); ZEND_VM_NEXT_OPCODE(); @@ -8449,10 +8450,10 @@ ZEND_VM_HANDLER(142, ZEND_DECLARE_LAMBDA_FUNCTION, UNUSED, NUM, NUM|CACHE_SLOT) SAVE_OPLINE(); zend_create_closure(EX_VAR(opline->result.var), func, EX(func)->op_array.scope, called_scope, object); - if (opline->extended_value != (uint32_t)-1) { + if (cache_slot != (uint32_t)-1) { zend_object *closure = Z_OBJ_P(EX_VAR(opline->result.var)); GC_ADDREF(closure); - CACHE_PTR(opline->extended_value, closure); + CACHE_PTR(cache_slot, closure); zend_stack_push(&EG(lambda_cache), &closure); } ZEND_VM_NEXT_OPCODE(); @@ -9184,7 +9185,7 @@ ZEND_VM_HANDLER(158, ZEND_CALL_TRAMPOLINE, ANY, ANY, SPEC(OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -9854,9 +9855,10 @@ ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED, NUM|CACHE_SLOT) { USE_OPLINE zend_execute_data *call = EX(call); + uint32_t cache_slot = opline->extended_value; - if (opline->extended_value != (uint32_t)-1) { - zend_object *closure = CACHED_PTR(opline->extended_value); + if (cache_slot != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(cache_slot); if (closure) { ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); } else { @@ -9871,7 +9873,7 @@ ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED, NUM|CACHE_SLOT) ZEND_ASSERT(Z_TYPE_P(closure_zv) == IS_OBJECT); closure = Z_OBJ_P(closure_zv); ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); - CACHE_PTR(opline->extended_value, closure); + CACHE_PTR(cache_slot, closure); } } else { zend_closure_from_frame(EX_VAR(opline->result.var), call); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 6d32bed15ac0..bf5d6e74264b 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1331,7 +1331,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1401,7 +1401,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1471,7 +1471,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1657,7 +1657,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1775,7 +1775,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1892,7 +1892,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -2028,7 +2028,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -2163,7 +2163,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -2295,7 +2295,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -3686,7 +3686,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALL_TRAMPOLI bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -3834,7 +3834,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALL_TRAMPOLI bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -32933,9 +32933,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_DECLARE_LAMBD zend_function *func; zend_object *object; zend_class_entry *called_scope; + uint32_t cache_slot = opline->extended_value; - if (opline->extended_value != (uint32_t)-1) { - zend_object *closure = CACHED_PTR(opline->extended_value); + if (cache_slot != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(cache_slot); if (closure) { ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); ZEND_VM_NEXT_OPCODE(); @@ -32958,10 +32959,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_DECLARE_LAMBD SAVE_OPLINE(); zend_create_closure(EX_VAR(opline->result.var), func, EX(func)->op_array.scope, called_scope, object); - if (opline->extended_value != (uint32_t)-1) { + if (cache_slot != (uint32_t)-1) { zend_object *closure = Z_OBJ_P(EX_VAR(opline->result.var)); GC_ADDREF(closure); - CACHE_PTR(opline->extended_value, closure); + CACHE_PTR(cache_slot, closure); zend_stack_push(&EG(lambda_cache), &closure); } ZEND_VM_NEXT_OPCODE(); @@ -37680,9 +37681,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALLABLE_CONV { USE_OPLINE zend_execute_data *call = EX(call); + uint32_t cache_slot = opline->extended_value; - if (opline->extended_value != (uint32_t)-1) { - zend_object *closure = CACHED_PTR(opline->extended_value); + if (cache_slot != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(cache_slot); if (closure) { ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); } else { @@ -37697,7 +37699,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALLABLE_CONV ZEND_ASSERT(Z_TYPE_P(closure_zv) == IS_OBJECT); closure = Z_OBJ_P(closure_zv); ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); - CACHE_PTR(opline->extended_value, closure); + CACHE_PTR(cache_slot, closure); } } else { zend_closure_from_frame(EX_VAR(opline->result.var), call); @@ -54326,7 +54328,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_ICA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54396,7 +54398,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_ICA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54466,7 +54468,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_IC bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54652,7 +54654,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54770,7 +54772,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54887,7 +54889,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FC bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -55023,7 +55025,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -55158,7 +55160,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -55290,7 +55292,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FC bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -56565,7 +56567,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALL_TRAMPOLINE_SP bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -56713,7 +56715,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALL_TRAMPOLINE_SP bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -85610,9 +85612,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DECLARE_LAMBDA_FUN zend_function *func; zend_object *object; zend_class_entry *called_scope; + uint32_t cache_slot = opline->extended_value; - if (opline->extended_value != (uint32_t)-1) { - zend_object *closure = CACHED_PTR(opline->extended_value); + if (cache_slot != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(cache_slot); if (closure) { ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); ZEND_VM_NEXT_OPCODE(); @@ -85635,10 +85638,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DECLARE_LAMBDA_FUN SAVE_OPLINE(); zend_create_closure(EX_VAR(opline->result.var), func, EX(func)->op_array.scope, called_scope, object); - if (opline->extended_value != (uint32_t)-1) { + if (cache_slot != (uint32_t)-1) { zend_object *closure = Z_OBJ_P(EX_VAR(opline->result.var)); GC_ADDREF(closure); - CACHE_PTR(opline->extended_value, closure); + CACHE_PTR(cache_slot, closure); zend_stack_push(&EG(lambda_cache), &closure); } ZEND_VM_NEXT_OPCODE(); @@ -90357,9 +90360,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALLABLE_CONVERT_S { USE_OPLINE zend_execute_data *call = EX(call); + uint32_t cache_slot = opline->extended_value; - if (opline->extended_value != (uint32_t)-1) { - zend_object *closure = CACHED_PTR(opline->extended_value); + if (cache_slot != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(cache_slot); if (closure) { ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); } else { @@ -90374,7 +90378,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALLABLE_CONVERT_S ZEND_ASSERT(Z_TYPE_P(closure_zv) == IS_OBJECT); closure = Z_OBJ_P(closure_zv); ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); - CACHE_PTR(opline->extended_value, closure); + CACHE_PTR(cache_slot, closure); } } else { zend_closure_from_frame(EX_VAR(opline->result.var), call); diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index c1ede5c60437..02f09a5a7ab8 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -132,6 +132,18 @@ static void pass2(zend_script *script, void *context) php_printf("pass2\n"); } +static ZEND_FUNCTION(zend_test_forward_reference) +{ + zval *value; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + + ZVAL_COPY(return_value, value); + zend_return_unwrap_ref(execute_data, return_value); +} + static ZEND_FUNCTION(zend_test_deprecated) { zval *arg1; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 8137b911a352..8719c6935a33 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -265,6 +265,8 @@ function zend_test_nullable_array_return(): null|array {} function zend_test_void_return(): void {} + function &zend_test_forward_reference(mixed &$value): mixed {} + function zend_test_compile_string(string $source_string, string $filename, int $position): void {} /** @deprecated */ diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 184bcdbae147..d6fa8896c42b 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a49cfced20b16588283149be5d01212924c925fd + * Stub hash: 55bb2e6d209ea4030e3edfd604fc5ce4d14267f0 * Has decl header: yes */ #include "zend_attributes.h" @@ -20,6 +20,10 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_void_return, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_forward_reference, 1, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(1, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_compile_string, 0, 3, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, source_string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -457,6 +461,7 @@ static ZEND_FUNCTION(zend_trigger_bailout); static ZEND_FUNCTION(zend_test_array_return); static ZEND_FUNCTION(zend_test_nullable_array_return); static ZEND_FUNCTION(zend_test_void_return); +static ZEND_FUNCTION(zend_test_forward_reference); static ZEND_FUNCTION(zend_test_compile_string); static ZEND_FUNCTION(zend_test_deprecated); static ZEND_FUNCTION(zend_test_deprecated_attr); @@ -606,6 +611,7 @@ static const zend_function_entry ext_functions[] = { #endif #endif ZEND_FE(zend_test_void_return, arginfo_zend_test_void_return) + ZEND_FE(zend_test_forward_reference, arginfo_zend_test_forward_reference) ZEND_FE(zend_test_compile_string, arginfo_zend_test_compile_string) #if (PHP_VERSION_ID >= 80400) ZEND_RAW_FENTRY("zend_test_deprecated", zif_zend_test_deprecated, arginfo_zend_test_deprecated, ZEND_ACC_DEPRECATED, NULL, NULL) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index cab05e40a40b..35e929d1a306 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a49cfced20b16588283149be5d01212924c925fd */ + * Stub hash: 55bb2e6d209ea4030e3edfd604fc5ce4d14267f0 */ -#ifndef ZEND_TEST_DECL_a49cfced20b16588283149be5d01212924c925fd_H -#define ZEND_TEST_DECL_a49cfced20b16588283149be5d01212924c925fd_H +#ifndef ZEND_TEST_DECL_55bb2e6d209ea4030e3edfd604fc5ce4d14267f0_H +#define ZEND_TEST_DECL_55bb2e6d209ea4030e3edfd604fc5ce4d14267f0_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_a49cfced20b16588283149be5d01212924c925fd_H */ +#endif /* ZEND_TEST_DECL_55bb2e6d209ea4030e3edfd604fc5ce4d14267f0_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index d58dc5d26220..9bb20c85e95a 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a49cfced20b16588283149be5d01212924c925fd + * Stub hash: 55bb2e6d209ea4030e3edfd604fc5ce4d14267f0 * Has decl header: yes */ #include "zend_constants.h" @@ -16,6 +16,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_test_void_return arginfo_zend_trigger_bailout +ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_test_forward_reference, 0, 1, 1) + ZEND_ARG_INFO(1, value) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_test_compile_string, 0, 0, 3) ZEND_ARG_INFO(0, source_string) ZEND_ARG_INFO(0, filename) @@ -381,6 +385,7 @@ static ZEND_FUNCTION(zend_trigger_bailout); static ZEND_FUNCTION(zend_test_array_return); static ZEND_FUNCTION(zend_test_nullable_array_return); static ZEND_FUNCTION(zend_test_void_return); +static ZEND_FUNCTION(zend_test_forward_reference); static ZEND_FUNCTION(zend_test_compile_string); static ZEND_FUNCTION(zend_test_deprecated); static ZEND_FUNCTION(zend_test_deprecated_attr); @@ -522,6 +527,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_test_array_return, arginfo_zend_test_array_return) ZEND_FE(zend_test_nullable_array_return, arginfo_zend_test_nullable_array_return) ZEND_FE(zend_test_void_return, arginfo_zend_test_void_return) + ZEND_FE(zend_test_forward_reference, arginfo_zend_test_forward_reference) ZEND_FE(zend_test_compile_string, arginfo_zend_test_compile_string) #if (PHP_VERSION_ID >= 80400) ZEND_RAW_FENTRY("zend_test_deprecated", zif_zend_test_deprecated, arginfo_zend_test_deprecated, ZEND_ACC_DEPRECATED, NULL, NULL)

« previous php.cvs (#143009) next »