Skip to content

Commit 52749b6

Browse files
committed
Zend: add _ex variants for calling known functions/FCC
To permit setting the consumed_arg FCI field
1 parent c290dfd commit 52749b6

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

Zend/zend_API.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,19 @@ static zend_always_inline zend_result zend_call_function_with_return_value(
854854
* If retval_ptr is NULL, the return value is discarded.
855855
* If object is NULL, this must be a free function or static call.
856856
* called_scope must be provided for instance and static method calls. */
857-
ZEND_API void zend_call_known_function(
857+
ZEND_API void zend_call_known_function_ex(
858858
zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
859-
uint32_t param_count, zval *params, HashTable *named_params);
859+
uint32_t param_count, zval *params, HashTable *named_params, uint32_t consumed_args);
860860

861-
static zend_always_inline void zend_call_known_fcc(
862-
const zend_fcall_info_cache *fcc, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params)
861+
static zend_always_inline void zend_call_known_function(
862+
zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
863+
uint32_t param_count, zval *params, HashTable *named_params) {
864+
zend_call_known_function_ex(fn, object, called_scope, retval_ptr, param_count, params, named_params, 0);
865+
}
866+
867+
static zend_always_inline void zend_call_known_fcc_ex(
868+
const zend_fcall_info_cache *fcc, zval *retval_ptr,
869+
uint32_t param_count, zval *params, HashTable *named_params, uint32_t consumed_args)
863870
{
864871
zend_function *func = fcc->function_handler;
865872
/* Need to copy trampolines as they get released after they are called */
@@ -868,7 +875,13 @@ static zend_always_inline void zend_call_known_fcc(
868875
memcpy(func, fcc->function_handler, sizeof(zend_function));
869876
zend_string_addref(func->op_array.function_name);
870877
}
871-
zend_call_known_function(func, fcc->object, fcc->called_scope, retval_ptr, param_count, params, named_params);
878+
zend_call_known_function_ex(func, fcc->object, fcc->called_scope, retval_ptr, param_count, params, named_params, consumed_args);
879+
}
880+
881+
static zend_always_inline void zend_call_known_fcc(
882+
const zend_fcall_info_cache *fcc, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params)
883+
{
884+
zend_call_known_fcc_ex(fcc, retval_ptr, param_count, params, named_params, 0);
872885
}
873886

874887
/* Call the provided zend_function instance method on an object. */

Zend/zend_execute_API.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,9 +1100,9 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
11001100
}
11011101
/* }}} */
11021102

1103-
ZEND_API void zend_call_known_function(
1103+
ZEND_API void zend_call_known_function_ex(
11041104
zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
1105-
uint32_t param_count, zval *params, HashTable *named_params)
1105+
uint32_t param_count, zval *params, HashTable *named_params, uint32_t consumed_args)
11061106
{
11071107
zval retval;
11081108
zend_fcall_info fci;
@@ -1116,7 +1116,7 @@ ZEND_API void zend_call_known_function(
11161116
fci.param_count = param_count;
11171117
fci.params = params;
11181118
fci.named_params = named_params;
1119-
fci.consumed_args = 0;
1119+
fci.consumed_args = consumed_args;
11201120
ZVAL_UNDEF(&fci.function_name); /* Unused */
11211121

11221122
fcic.function_handler = fn;

0 commit comments

Comments
 (0)