Skip to content

Commit

Permalink
Remove no_separation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jul 7, 2020
1 parent e93aca7 commit 302933d
Show file tree
Hide file tree
Showing 27 changed files with 10 additions and 50 deletions.
6 changes: 6 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES
p. ARG_COUNT() macro removed
q. GC_COLLECTABLE flag
r. Cannot implement Traversable only
s. zend_fcall_info no_separation flag removed

2. Build system changes
a. Abstract
Expand Down Expand Up @@ -135,6 +136,11 @@ PHP 8.0 INTERNALS UPGRADE NOTES
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
}

s. The zend_fcall_info no_separation flag has been removed, and separation is
never allowed. If you wish to pass (or allow passing) arguments by
reference, explicitly create those arguments as references using
ZEND_MAKE_REF.

========================
2. Build system changes
========================
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,6 @@ ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fca
fci->retval = NULL;
fci->param_count = 0;
fci->params = NULL;
fci->no_separation = 1;

return SUCCESS;
}
Expand Down
7 changes: 2 additions & 5 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ typedef struct _zend_fcall_info {
zval *retval;
zval *params;
zend_object *object;
zend_bool no_separation;
uint32_t param_count;
} zend_fcall_info;

Expand Down Expand Up @@ -498,12 +497,10 @@ ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zv
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)


ZEND_API int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation);
ZEND_API int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]);

#define call_user_function(_unused, object, function_name, retval_ptr, param_count, params) \
_call_user_function_ex(object, function_name, retval_ptr, param_count, params, 1)
#define call_user_function_ex(_unused, object, function_name, retval_ptr, param_count, params, no_separation, _unused2) \

This comment has been minimized.

Copy link
@Jan-E

Jan-E Jul 7, 2020

Contributor

@nikic Side effect of this commit is that call_user_function_ex is vanished. There are at least 2 extensions that use call_user_function_ex(): msgpack and yaml. IMHO, it should be documented in UPGRADING.INTERNALS.

This comment has been minimized.

Copy link
@andypost

andypost Jul 12, 2020

Contributor

igbinary/igbinary#277 already merged

_call_user_function_ex(object, function_name, retval_ptr, param_count, params, no_separation)
_call_user_function_ex(object, function_name, retval_ptr, param_count, params)

ZEND_API extern const zend_fcall_info empty_fcall_info;
ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ ZEND_METHOD(Closure, call)
fci.size = sizeof(fci);
ZVAL_OBJ(&fci.function_name, &closure->std);
fci.retval = &closure_result;
fci.no_separation = 1;

if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(closure_result) != IS_UNDEF) {
if (Z_ISREF(closure_result)) {
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ ZEND_METHOD(Exception, __toString)
fci.retval = &trace;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;

zend_call_function(&fci, NULL);

Expand Down
9 changes: 2 additions & 7 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ ZEND_API int zval_update_constant(zval *pp) /* {{{ */
}
/* }}} */

int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation) /* {{{ */
int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]) /* {{{ */
{
zend_fcall_info fci;

Expand All @@ -629,7 +629,6 @@ int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr,
fci.retval = retval_ptr;
fci.param_count = param_count;
fci.params = params;
fci.no_separation = (zend_bool) no_separation;

return zend_call_function(&fci, NULL);
}
Expand Down Expand Up @@ -737,10 +736,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /

if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) {
if (UNEXPECTED(!Z_ISREF_P(arg))) {
if (!fci->no_separation) {
/* Separation is enabled -- create a ref */
ZVAL_NEW_REF(arg, arg);
} else if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) {
if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) {
/* By-value send is not allowed -- emit a warning,
* but still perform the call with a by-value send. */
zend_param_must_be_ref(func, i + 1);
Expand Down Expand Up @@ -866,7 +862,6 @@ ZEND_API void zend_call_known_function(
fci.retval = retval_ptr ? retval_ptr : &retval;
fci.param_count = param_count;
fci.params = params;
fci.no_separation = 1;
ZVAL_UNDEF(&fci.function_name); /* Unused */

fcic.function_handler = fn;
Expand Down
5 changes: 0 additions & 5 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,6 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
fci.retval = &retval;
fci.param_count = 2;
fci.params = argv;
fci.no_separation = 1;

ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
Expand Down Expand Up @@ -1432,7 +1431,6 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
fci.retval = &retval;
fci.param_count = 3;
fci.params = argv;
fci.no_separation = 1;

ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
Expand Down Expand Up @@ -1485,7 +1483,6 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
fci.retval = &retval;
fci.param_count = 5;
fci.params = argv;
fci.no_separation = 1;

ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
Expand Down Expand Up @@ -1541,7 +1538,6 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
fci.retval = &retval;
fci.param_count = 3;
fci.params = argv;
fci.no_separation = 1;

ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
Expand Down Expand Up @@ -1603,7 +1599,6 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
fci.retval = &retval;
fci.param_count = 2;
fci.params = argv;
fci.no_separation = 1;

ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
Expand Down
1 change: 0 additions & 1 deletion ext/dom/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,

fci.object = NULL;
fci.retval = &retval;
fci.no_separation = 1;

if (!zend_make_callable(&fci.function_name, &callable)) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
Expand Down
1 change: 0 additions & 1 deletion ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
fci.retval = &retval;
fci.params = do_alloca(sizeof(zval) *callback_data->arg_count, use_heap);
fci.object = NULL;
fci.no_separation = 1;
fci.param_count = callback_data->arg_count;

if (callback_data->type->func.args) {
Expand Down
2 changes: 0 additions & 2 deletions ext/intl/converter/converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ static void php_converter_to_u_callback(const void *context,
objval->to_cb.param_count = 4;
objval->to_cb.params = zargs;
objval->to_cb.retval = &retval;
objval->to_cb.no_separation = 1;
if (zend_call_function(&(objval->to_cb), &(objval->to_cache)) == FAILURE) {
/* Unlikely */
php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR, "Unexpected failure calling toUCallback()");
Expand Down Expand Up @@ -312,7 +311,6 @@ static void php_converter_from_u_callback(const void *context,
objval->from_cb.param_count = 4;
objval->from_cb.params = zargs;
objval->from_cb.retval = &retval;
objval->from_cb.no_separation = 1;
if (zend_call_function(&(objval->from_cb), &(objval->from_cache)) == FAILURE) {
/* Unlikely */
php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR, "Unexpected failure calling fromUCallback()");
Expand Down
1 change: 0 additions & 1 deletion ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
fci->retval = &retval;
fci->params = params;
fci->param_count = sizeof(params)/sizeof(*params);
fci->no_separation = 1;

status = zend_call_function(fci, &LIBXML(entity_loader).fcc);
if (status != SUCCESS || Z_ISUNDEF(retval)) {
Expand Down
1 change: 0 additions & 1 deletion ext/mysqli/mysqli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,6 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
fci.retval = &retval;
fci.params = NULL;
fci.param_count = 0;
fci.no_separation = 1;

if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
if (zend_fcall_info_args(&fci, ctor_params) == FAILURE) {
Expand Down
1 change: 0 additions & 1 deletion ext/pcre/php_pcre.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,6 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
fci->retval = &retval;
fci->param_count = 1;
fci->params = &arg;
fci->no_separation = 1;

if (zend_call_function(fci, fcc) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {
Expand Down
1 change: 0 additions & 1 deletion ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
fci.retval = &retval;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;

zend_fcall_info_args(&fci, ctor_args);

Expand Down
1 change: 0 additions & 1 deletion ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */
fci->retval = &stmt->fetch.cls.retval;
fci->param_count = 0;
fci->params = NULL;
fci->no_separation = 1;

zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args);

Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2584,7 +2584,6 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
fci.retval = &retval;
fci.params = NULL;
fci.param_count = 0;
fci.no_separation = 1;

if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
if (zend_fcall_info_args(&fci, ctor_params) == FAILURE) {
Expand Down
3 changes: 0 additions & 3 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,6 @@ ZEND_METHOD(ReflectionFunction, invoke)
fci.retval = &retval;
fci.param_count = num_args;
fci.params = params;
fci.no_separation = 1;

fcc.function_handler = fptr;
fcc.called_scope = NULL;
Expand Down Expand Up @@ -1878,7 +1877,6 @@ ZEND_METHOD(ReflectionFunction, invokeArgs)
fci.retval = &retval;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;

fcc.function_handler = fptr;
fcc.called_scope = NULL;
Expand Down Expand Up @@ -3206,7 +3204,6 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
fci.retval = &retval;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;

fcc.function_handler = mptr;
fcc.called_scope = intern->ce;
Expand Down
1 change: 0 additions & 1 deletion ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ PHP_METHOD(SoapFault, __toString)
fci.retval = &trace;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;

zend_call_function(&fci, NULL);

Expand Down
1 change: 0 additions & 1 deletion ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,6 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
fci.retval = return_value;
fci.param_count = num_args;
fci.params = params;
fci.no_separation = 1;
ZVAL_STR(&fci.function_name, func_ptr->common.function_name);

fcic.function_handler = func_ptr;
Expand Down
1 change: 0 additions & 1 deletion ext/spl/spl_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval *retval, in
fci.retval = &dummy;
fci.param_count = argc;
fci.params = argv;
fci.no_separation = 1;

fcc.function_handler = func;
fcc.called_scope = pce;
Expand Down
1 change: 0 additions & 1 deletion ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,6 @@ PHP_METHOD(CallbackFilterIterator, accept)
fci->retval = return_value;
fci->param_count = 3;
fci->params = params;
fci->no_separation = 1;

if (zend_call_function(fci, fcc) != SUCCESS || Z_ISUNDEF_P(return_value)) {
RETURN_FALSE;
Expand Down
1 change: 0 additions & 1 deletion ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,6 @@ static int php_sqlite3_authorizer(void *autharg, int action, const char *arg1, c
fci->retval = &retval;
fci->param_count = 5;
fci->params = argv;
fci->no_separation = 1;

int authreturn = SQLITE_DENY;

Expand Down
8 changes: 0 additions & 8 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ static inline int php_array_user_compare_unstable(Bucket *f, Bucket *s) /* {{{ *
BG(user_compare_fci).param_count = 2;
BG(user_compare_fci).params = args;
BG(user_compare_fci).retval = &retval;
BG(user_compare_fci).no_separation = 1;
call_failed = zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE || Z_TYPE(retval) == IS_UNDEF;
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
Expand Down Expand Up @@ -1063,7 +1062,6 @@ static inline int php_array_user_key_compare_unstable(Bucket *f, Bucket *s) /* {
BG(user_compare_fci).param_count = 2;
BG(user_compare_fci).params = args;
BG(user_compare_fci).retval = &retval;
BG(user_compare_fci).no_separation = 1;
call_failed = zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE || Z_TYPE(retval) == IS_UNDEF;
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
Expand Down Expand Up @@ -1374,7 +1372,6 @@ static int php_array_walk(zval *array, zval *userdata, int recursive) /* {{{ */
BG(array_walk_fci).retval = &retval;
BG(array_walk_fci).param_count = userdata ? 3 : 2;
BG(array_walk_fci).params = args;
BG(array_walk_fci).no_separation = 1;

zend_hash_internal_pointer_reset_ex(target_hash, &pos);
ht_iter = zend_hash_iterator_add(target_hash, pos);
Expand Down Expand Up @@ -4546,7 +4543,6 @@ static int zval_user_compare(zval *a, zval *b) /* {{{ */
BG(user_compare_fci).param_count = 2;
BG(user_compare_fci).params = args;
BG(user_compare_fci).retval = &retval;
BG(user_compare_fci).no_separation = 1;

if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache)) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
zend_long ret = zval_get_long(&retval);
Expand Down Expand Up @@ -5906,7 +5902,6 @@ PHP_FUNCTION(array_reduce)

fci.retval = &retval;
fci.param_count = 2;
fci.no_separation = 1;

ZEND_HASH_FOREACH_VAL(htbl, operand) {
ZVAL_COPY_VALUE(&args[0], return_value);
Expand Down Expand Up @@ -5959,7 +5954,6 @@ PHP_FUNCTION(array_filter)

if (ZEND_FCI_INITIALIZED(fci)) {
have_callback = 1;
fci.no_separation = 1;
fci.retval = &retval;
if (use_type == ARRAY_FILTER_USE_BOTH) {
fci.param_count = 2;
Expand Down Expand Up @@ -6062,7 +6056,6 @@ PHP_FUNCTION(array_map)
fci.retval = &result;
fci.param_count = 1;
fci.params = &arg;
fci.no_separation = 1;

ZVAL_COPY(&arg, zv);
ret = zend_call_function(&fci, &fci_cache);
Expand Down Expand Up @@ -6151,7 +6144,6 @@ PHP_FUNCTION(array_map)
fci.retval = &result;
fci.param_count = n_arrays;
fci.params = params;
fci.no_separation = 1;

if (zend_call_function(&fci, &fci_cache) != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
efree(array_pos);
Expand Down
1 change: 0 additions & 1 deletion ext/xml/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ static void xml_call_handler(xml_parser *parser, zval *handler, zend_function *f
fci.retval = retval;
fci.param_count = argc;
fci.params = argv;
fci.no_separation = 1;

result = zend_call_function(&fci, NULL);
if (result == FAILURE) {
Expand Down
1 change: 0 additions & 1 deletion ext/xsl/xsltprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
ZVAL_COPY_VALUE(&fci.function_name, &handler);
fci.object = NULL;
fci.retval = &retval;
fci.no_separation = 1;
if (!zend_make_callable(&handler, &callable)) {
if (!EG(exception)) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
Expand Down
1 change: 0 additions & 1 deletion main/streams/userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php
fci.retval = &retval;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;

fcc.function_handler = uwrap->ce->constructor;
fcc.called_scope = Z_OBJCE_P(object);
Expand Down
1 change: 0 additions & 1 deletion sapi/phpdbg/phpdbg_prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
//???fci.symbol_table = zend_rebuild_symbol_table();
fci.object = NULL;
fci.retval = &fretval;
fci.no_separation = 1;

if (name->next) {
zval params;
Expand Down

2 comments on commit 302933d

@andypost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glensc
Copy link
Contributor

@glensc glensc commented on 302933d Nov 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.