Skip to content

Commit 7bac9de

Browse files
committed
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
1 parent fc6c49c commit 7bac9de

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Zend/zend_execute_API.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,22 +1130,20 @@ ZEND_API zend_result zend_call_method_if_exists(
11301130
zend_object *object, zend_string *method_name, zval *retval,
11311131
uint32_t param_count, zval *params)
11321132
{
1133-
zend_fcall_info fci;
1134-
fci.size = sizeof(zend_fcall_info);
1135-
fci.object = object;
1136-
ZVAL_STR(&fci.function_name, method_name);
1137-
fci.retval = retval;
1138-
fci.param_count = param_count;
1139-
fci.params = params;
1140-
fci.named_params = NULL;
1141-
1133+
zval zval_method;
11421134
zend_fcall_info_cache fcc;
1143-
if (!zend_is_callable_ex(&fci.function_name, fci.object, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) {
1135+
1136+
ZVAL_STR(&zval_method, method_name);
1137+
1138+
if (UNEXPECTED(!zend_is_callable_ex(&zval_method, object, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL))) {
11441139
ZVAL_UNDEF(retval);
11451140
return FAILURE;
11461141
}
11471142

1148-
return zend_call_function(&fci, &fcc);
1143+
zend_call_known_fcc(&fcc, retval, param_count, params, NULL);
1144+
/* Need to free potential trampoline (__call/__callStatic) copied function handler before releasing the closure */
1145+
zend_release_fcall_info_cache(&fcc);
1146+
return SUCCESS;
11491147
}
11501148

11511149
/* 0-9 a-z A-Z _ \ 0x80-0xff */

0 commit comments

Comments
 (0)