Zend: refactor zend_call_method_if_exists() API

The objective of this is to stop relying on the fci.function_name zval field,
to see if in the future we can get rid of said field and fit an FCI/FCC pair in a single cache line
This commit is contained in:
Gina Peter Banyard 2025-07-12 19:39:24 +01:00
parent fc6c49cbf4
commit 7bac9de94a

View file

@ -1130,22 +1130,20 @@ ZEND_API zend_result zend_call_method_if_exists(
zend_object *object, zend_string *method_name, zval *retval,
uint32_t param_count, zval *params)
{
zend_fcall_info fci;
fci.size = sizeof(zend_fcall_info);
fci.object = object;
ZVAL_STR(&fci.function_name, method_name);
fci.retval = retval;
fci.param_count = param_count;
fci.params = params;
fci.named_params = NULL;
zval zval_method;
zend_fcall_info_cache fcc;
if (!zend_is_callable_ex(&fci.function_name, fci.object, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) {
ZVAL_STR(&zval_method, method_name);
if (UNEXPECTED(!zend_is_callable_ex(&zval_method, object, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL))) {
ZVAL_UNDEF(retval);
return FAILURE;
}
return zend_call_function(&fci, &fcc);
zend_call_known_fcc(&fcc, retval, param_count, params, NULL);
/* Need to free potential trampoline (__call/__callStatic) copied function handler before releasing the closure */
zend_release_fcall_info_cache(&fcc);
return SUCCESS;
}
/* 0-9 a-z A-Z _ \ 0x80-0xff */