From d9f5ea691fef7686061e081034bd52c9cc1db444 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 27 Dec 2017 15:15:03 +0300 Subject: [PATCH] zend_fcall_info_cache.initialized is removed (zend_fcall_info_cache is initialized if zend_fcall_info_cache.function_handler is set). --- UPGRADING.INTERNALS | 4 ++++ Zend/zend_API.c | 8 ++------ Zend/zend_API.h | 3 +-- Zend/zend_closures.c | 2 -- Zend/zend_execute_API.c | 7 +++---- Zend/zend_interfaces.c | 1 - ext/mysqli/mysqli.c | 1 - ext/pdo/pdo_dbh.c | 1 - ext/pdo/pdo_stmt.c | 1 - ext/pgsql/pgsql.c | 1 - ext/reflection/php_reflection.c | 6 ------ ext/spl/php_spl.c | 1 - ext/spl/spl_directory.c | 1 - ext/spl/spl_engine.h | 1 - main/streams/userspace.c | 1 - 15 files changed, 10 insertions(+), 29 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 7b03440a53..040498e387 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -11,6 +11,7 @@ PHP 7.3 INTERNALS UPGRADE NOTES h. zend_register_persistent_resource() i. RAND_RANGE() j. cast_object() with _IS_NUMBER + k. zend_fcall_info_cache.initialized 2. Build system changes a. Unix build system changes @@ -91,6 +92,9 @@ PHP 7.3 INTERNALS UPGRADE NOTES handler should return either an integer or float value in this case, whichever is more appropriate. + k. zend_fcall_info_cache.initialized is removed. zend_fcall_info_cache is + initialized if zend_fcall_info_cache.function_handler is set. + ======================== 2. Build system changes ======================== diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 4fea589dfc..12a302b6b9 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -668,7 +668,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons if (check_null && Z_TYPE_P(arg) == IS_NULL) { fci->size = 0; - fcc->initialized = 0; + fcc->function_handler = 0; break; } @@ -2931,7 +2931,6 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca zv = zend_hash_find(EG(function_table), lmname); if (EXPECTED(zv != NULL)) { fcc->function_handler = Z_PTR_P(zv); - fcc->initialized = 1; if (lmname != Z_STR_P(callable)) { ZSTR_ALLOCA_FREE(lmname, use_heap); } @@ -2946,7 +2945,6 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca zv = zend_hash_find(EG(function_table), lmname); if (zv != NULL) { fcc->function_handler = Z_PTR_P(zv); - fcc->initialized = 1; ZSTR_ALLOCA_FREE(lmname, use_heap); return 1; } @@ -3178,7 +3176,7 @@ get_function_via_handler: fcc->called_scope = fcc->object->ce; } if (retval) { - fcc->initialized = 1; +//??? fcc->initialized = 1; } return retval; } @@ -3271,7 +3269,6 @@ static zend_bool zend_is_callable_impl(zval *callable, zend_object *object, uint *error = NULL; } - fcc->initialized = 0; fcc->calling_scope = NULL; fcc->called_scope = NULL; fcc->function_handler = NULL; @@ -3380,7 +3377,6 @@ again: case IS_OBJECT: if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { fcc->called_scope = fcc->calling_scope; - fcc->initialized = 1; return 1; } if (error) zend_spprintf(error, 0, "no array or string given"); diff --git a/Zend/zend_API.h b/Zend/zend_API.h index c05a527e6e..8417582193 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -52,7 +52,6 @@ typedef struct _zend_fcall_info { } zend_fcall_info; typedef struct _zend_fcall_info_cache { - zend_bool initialized; zend_function *function_handler; zend_class_entry *calling_scope; zend_class_entry *called_scope; @@ -1290,7 +1289,7 @@ static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *de { if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { dest_fci->size = 0; - dest_fcc->initialized = 0; + dest_fcc->function_handler = NULL; *error = NULL; } else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error) != SUCCESS)) { return 0; diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 63cb4192bc..758c96bea4 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -141,7 +141,6 @@ ZEND_METHOD(Closure, call) fci.params = my_params; fci.param_count = my_param_count; fci.object = fci_cache.object = newobj; - fci_cache.initialized = 1; fci_cache.called_scope = Z_OBJCE_P(newthis); if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) { @@ -247,7 +246,6 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { fci.size = sizeof(zend_fcall_info); fci.retval = return_value; - fcc.initialized = 1; fcc.function_handler = (zend_function *) EX(func)->common.arg_info; fci.params = params; fci.param_count = 2; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f2f9b55009..674354acf7 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -675,7 +675,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / EG(current_execute_data) = &dummy_execute_data; } - if (!fci_cache || !fci_cache->initialized) { + if (!fci_cache || !fci_cache->function_handler) { char *error = NULL; if (!fci_cache) { @@ -792,7 +792,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / EG(opline_before_exception) = current_opline_before_exception; if (call_via_handler) { /* We must re-initialize function again */ - fci_cache->initialized = 0; + fci_cache->function_handler = NULL; } } else if (func->type == ZEND_INTERNAL_FUNCTION) { int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; @@ -816,7 +816,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / if (call_via_handler) { /* We must re-initialize function again */ - fci_cache->initialized = 0; + fci_cache->function_handler = NULL; } } else { /* ZEND_OVERLOADED_FUNCTION */ ZVAL_NULL(fci->retval); @@ -952,7 +952,6 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k fcall_info.object = NULL; fcall_info.no_separation = 1; - fcall_cache.initialized = 1; fcall_cache.function_handler = EG(autoload_func); fcall_cache.calling_scope = NULL; fcall_cache.called_scope = NULL; diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 430e3b9715..33b811abed 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -63,7 +63,6 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun zend_fcall_info_cache fcic; ZVAL_UNDEF(&fci.function_name); /* Unused */ - fcic.initialized = 1; if (!obj_ce) { obj_ce = object ? Z_OBJCE_P(object) : NULL; } diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 59f324c36e..b5737da56b 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1303,7 +1303,6 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags } } - fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(return_value); diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index f5b822bd73..9fbfc1ff57 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -442,7 +442,6 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt zend_fcall_info_args(&fci, ctor_args); - fcc.initialized = 1; fcc.function_handler = dbstmt_ce->constructor; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(object); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index f05cfce9c6..4805af76bf 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -731,7 +731,6 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */ zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args); - fcc->initialized = 1; fcc->function_handler = ce->constructor; fcc->calling_scope = zend_get_executed_scope(); fcc->called_scope = ce; diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 06142f2bba..ac153a68e2 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2840,7 +2840,6 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ } } - fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(return_value); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 4444c6ef7b..4a5674710f 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1353,7 +1353,6 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c fci.params = params; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = ce_ptr->constructor; fcc.calling_scope = ce_ptr; fcc.called_scope = Z_OBJCE(reflector); @@ -1880,7 +1879,6 @@ ZEND_METHOD(reflection_function, invoke) fci.params = params; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = fptr; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = NULL; @@ -1941,7 +1939,6 @@ ZEND_METHOD(reflection_function, invokeArgs) fci.params = params; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = fptr; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = NULL; @@ -3208,7 +3205,6 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic) fci.params = params; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = mptr; fcc.calling_scope = obj_ce; fcc.called_scope = intern->ce; @@ -4770,7 +4766,6 @@ ZEND_METHOD(reflection_class, newInstance) fci.params = params; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = constructor; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(return_value); @@ -4872,7 +4867,6 @@ ZEND_METHOD(reflection_class, newInstanceArgs) fci.params = params; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = constructor; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(return_value); diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 7abe14b129..9fbf772ffc 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -416,7 +416,6 @@ PHP_FUNCTION(spl_autoload_call) fci.no_separation = 1; ZVAL_UNDEF(&fci.function_name); /* Unused */ - fcic.initialized = 1; zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &pos); while (zend_hash_get_current_key_ex(SPL_G(autoload_functions), &func_name, &num_idx, &pos) == HASH_KEY_IS_STRING) { diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 4a012d74ea..be72c75746 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2082,7 +2082,6 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function fci.no_separation = 1; ZVAL_STR(&fci.function_name, func_ptr->common.function_name); - fcic.initialized = 1; fcic.function_handler = func_ptr; fcic.calling_scope = NULL; fcic.called_scope = NULL; diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h index 6b50c6bd45..24e9fa965f 100644 --- a/ext/spl/spl_engine.h +++ b/ext/spl/spl_engine.h @@ -69,7 +69,6 @@ static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval *retval, in fci.params = argv; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = func; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = pce; diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 893820cb90..7c31e4533b 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -311,7 +311,6 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php fci.params = NULL; fci.no_separation = 1; - fcc.initialized = 1; fcc.function_handler = uwrap->ce->constructor; fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(object); -- 2.50.1