diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index f14a4d1b0c9f8..3869677779716 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -39,6 +39,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES needs to be obtained use the zend_get_callable_zval_from_fcc() function instead. If this was used to store a callable, then an FCC should be stored instead. + . The zend_active_function{_ex}() functions now return a const zend_function + pointer. ======================== 2. Build system changes diff --git a/Zend/zend.c b/Zend/zend.c index 82b6e189108cd..4d024444a4be9 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1501,12 +1501,10 @@ ZEND_API ZEND_COLD void zend_error_zstr_at( /* Report about uncaught exception in case of fatal errors */ if (EG(exception)) { - zend_execute_data *ex; - const zend_op *opline; - if (type & E_FATAL_ERRORS) { - ex = EG(current_execute_data); - opline = NULL; + zend_execute_data *ex = EG(current_execute_data); + const zend_op *opline = NULL; + while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { ex = ex->prev_execute_data; } diff --git a/Zend/zend_API.c b/Zend/zend_API.c index d9c951c928896..7897ac1473601 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -480,7 +480,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **p /* }}} */ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32_t arg_num) { - zend_function *func = zend_active_function(); + const zend_function *func = zend_active_function(); ZEND_ASSERT(arg_num > 0); uint32_t arg_offset = arg_num - 1; if (arg_offset >= func->common.num_args) { @@ -488,7 +488,7 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32 arg_offset = func->common.num_args; } - zend_arg_info *arg_info = &func->common.arg_info[arg_offset]; + const zend_arg_info *arg_info = &func->common.arg_info[arg_offset]; zend_string *func_name = get_active_function_or_method_name(); const char *arg_name = get_active_function_arg_name(arg_num); @@ -1118,7 +1118,7 @@ ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg } static ZEND_COLD void zend_parse_parameters_debug_error(const char *msg) { - zend_function *active_function = EG(current_execute_data)->func; + const zend_function *active_function = EG(current_execute_data)->func; const char *class_name = active_function->common.scope ? ZSTR_VAL(active_function->common.scope->name) : ""; zend_error_noreturn(E_CORE_ERROR, "%s%s%s(): %s", @@ -3681,12 +3681,12 @@ ZEND_API void zend_disable_functions(const char *function_list) /* {{{ */ } /* }}} */ -static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame) +static zend_always_inline zend_class_entry *get_scope(const zend_execute_data *frame) { return frame && frame->func ? frame->func->common.scope : NULL; } -static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */ +static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, const zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */ { bool ret = false; zend_class_entry *ce; @@ -3790,7 +3790,7 @@ ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc) { } } -static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */ +static zend_always_inline bool zend_is_callable_check_func(zval *callable, const zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; bool retval = false; @@ -4036,7 +4036,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ } /* }}} */ -ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object) /* {{{ */ +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, const zend_object *object) /* {{{ */ { try_again: switch (Z_TYPE_P(callable)) { @@ -4070,7 +4070,7 @@ ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *obj } case IS_OBJECT: { - zend_class_entry *ce = Z_OBJCE_P(callable); + const zend_class_entry *ce = Z_OBJCE_P(callable); if (ce == zend_ce_closure) { const zend_function *fn = zend_get_closure_method_def(Z_OBJ_P(callable)); @@ -4101,7 +4101,7 @@ ZEND_API zend_string *zend_get_callable_name(zval *callable) /* {{{ */ /* }}} */ ZEND_API bool zend_is_callable_at_frame( - zval *callable, zend_object *object, zend_execute_data *frame, + zval *callable, zend_object *object, const zend_execute_data *frame, uint32_t check_flags, zend_fcall_info_cache *fcc, char **error) /* {{{ */ { bool ret; @@ -4214,7 +4214,7 @@ ZEND_API bool zend_is_callable_at_frame( ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error) /* {{{ */ { /* Determine callability at the first parent user frame. */ - zend_execute_data *frame = EG(current_execute_data); + const zend_execute_data *frame = EG(current_execute_data); while (frame && (!frame->func || !ZEND_USER_CODE(frame->func->type))) { frame = frame->prev_execute_data; } @@ -5274,7 +5274,7 @@ static zend_string *try_parse_string(const char *str, size_t len, char quote) { } ZEND_API zend_result zend_get_default_from_internal_arg_info( - zval *default_value_zval, zend_internal_arg_info *arg_info) + zval *default_value_zval, const zend_internal_arg_info *arg_info) { const char *default_value = arg_info->default_value; if (!default_value) { diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 440a1874adff1..d322fd485ca64 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -410,10 +410,10 @@ ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property); #define IS_CALLABLE_SUPPRESS_DEPRECATIONS (1<<1) ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc); -ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object); +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, const zend_object *object); ZEND_API zend_string *zend_get_callable_name(zval *callable); ZEND_API bool zend_is_callable_at_frame( - zval *callable, zend_object *object, zend_execute_data *frame, + zval *callable, zend_object *object, const zend_execute_data *frame, uint32_t check_flags, zend_fcall_info_cache *fcc, char **error); ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error); ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name); @@ -896,7 +896,7 @@ ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval * static zend_always_inline zend_result zend_forbid_dynamic_call(void) { - zend_execute_data *ex = EG(current_execute_data); + const zend_execute_data *ex = EG(current_execute_data); ZEND_ASSERT(ex != NULL && ex->func != NULL); if (ZEND_CALL_INFO(ex) & ZEND_CALL_DYNAMIC) { @@ -927,7 +927,7 @@ ZEND_API bool zend_is_iterable(const zval *iterable); ZEND_API bool zend_is_countable(const zval *countable); ZEND_API zend_result zend_get_default_from_internal_arg_info( - zval *default_value_zval, zend_internal_arg_info *arg_info); + zval *default_value_zval, const zend_internal_arg_info *arg_info); END_EXTERN_C() diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 948139a865905..4ecb6b2c493b9 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -888,7 +888,7 @@ ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_clas /* __call and __callStatic name the arguments "$arguments" in the docs. */ static zend_internal_arg_info trampoline_arg_info[] = {ZEND_ARG_VARIADIC_TYPE_INFO(false, arguments, IS_MIXED, false)}; -void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* {{{ */ +void zend_closure_from_frame(zval *return_value, const zend_execute_data *call) { /* {{{ */ zval instance; zend_internal_function trampoline; zend_function *mptr = call->func; diff --git a/Zend/zend_closures.h b/Zend/zend_closures.h index ced1b5ba48c15..8bea4ffb051e8 100644 --- a/Zend/zend_closures.h +++ b/Zend/zend_closures.h @@ -31,7 +31,7 @@ BEGIN_EXTERN_C() void zend_register_closure_ce(void); void zend_closure_bind_var(zval *closure_zv, zend_string *var_name, zval *var); void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val); -void zend_closure_from_frame(zval *closure_zv, zend_execute_data *frame); +void zend_closure_from_frame(zval *closure_zv, const zend_execute_data *frame); extern ZEND_API zend_class_entry *zend_ce_closure; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 69665c5bbbb1f..d411dcbc3b953 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -4346,7 +4346,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_fcall_interrupt(zend_execute_data *ca */ static zend_never_inline void zend_copy_extra_args(EXECUTE_DATA_D) { - zend_op_array *op_array = &EX(func)->op_array; + const zend_op_array *op_array = &EX(func)->op_array; uint32_t first_extra_arg = op_array->num_args; uint32_t num_args = EX_NUM_ARGS(); zval *src; @@ -4926,7 +4926,7 @@ static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, zval_ptr_dtor_nogc(var); } else if (kind == ZEND_LIVE_ROPE) { zend_string **rope = (zend_string **)var; - zend_op *last = EX(func)->op_array.opcodes + op_num; + const zend_op *last = EX(func)->op_array.opcodes + op_num; while ((last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT) || last->result.var != var_num) { ZEND_ASSERT(last >= EX(func)->op_array.opcodes); @@ -4982,7 +4982,7 @@ ZEND_API HashTable *zend_unfinished_execution_gc_ex(zend_execute_data *execute_d return NULL; } - zend_op_array *op_array = &EX(func)->op_array; + const zend_op_array *op_array = &EX(func)->op_array; if (!(EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE)) { uint32_t i, num_cvs = EX(func)->op_array.last_var; @@ -4993,7 +4993,7 @@ ZEND_API HashTable *zend_unfinished_execution_gc_ex(zend_execute_data *execute_d if (EX_CALL_INFO() & ZEND_CALL_FREE_EXTRA_ARGS) { zval *zv = EX_VAR_NUM(op_array->last_var + op_array->T); - zval *end = zv + (EX_NUM_ARGS() - op_array->num_args); + const zval *end = zv + (EX_NUM_ARGS() - op_array->num_args); while (zv != end) { zend_get_gc_buffer_add_zval(gc_buffer, zv++); } @@ -5462,7 +5462,7 @@ static zend_never_inline zend_result ZEND_FASTCALL zend_quick_check_constant( } /* }}} */ static zend_always_inline uint32_t zend_get_arg_offset_by_name( - zend_function *fbc, zend_string *arg_name, void **cache_slot) { + const zend_function *fbc, const zend_string *arg_name, void **cache_slot) { /* Due to closures, the `fbc` address isn't unique if the memory address is reused. * The argument info will be however and uniquely positions the arguments. * We do support NULL arg_info, so we have to distinguish that from an uninitialized cache slot. */ @@ -5477,7 +5477,7 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name( if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) || EXPECTED(fbc->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { for (uint32_t i = 0; i < num_args; i++) { - zend_arg_info *arg_info = &fbc->common.arg_info[i]; + const zend_arg_info *arg_info = &fbc->common.arg_info[i]; if (zend_string_equals(arg_name, arg_info->name)) { if (fbc->type == ZEND_USER_FUNCTION && (!fbc->op_array.refcount || !(fbc->op_array.fn_flags & ZEND_ACC_CLOSURE))) { *cache_slot = unique_id; @@ -5489,7 +5489,7 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name( } else { ZEND_ASSERT(num_args == 0 || fbc->internal_function.arg_info); for (uint32_t i = 0; i < num_args; i++) { - zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i]; + const zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i]; size_t len = strlen(arg_info->name); if (zend_string_equals_cstr(arg_name, arg_info->name, len)) { *cache_slot = unique_id; @@ -5517,7 +5517,7 @@ zval * ZEND_FASTCALL zend_handle_named_arg( zend_execute_data **call_ptr, zend_string *arg_name, uint32_t *arg_num_ptr, void **cache_slot) { zend_execute_data *call = *call_ptr; - zend_function *fbc = call->func; + const zend_function *fbc = call->func; uint32_t arg_offset = zend_get_arg_offset_by_name(fbc, arg_name, cache_slot); if (UNEXPECTED(arg_offset == (uint32_t) -1)) { zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name)); @@ -5603,7 +5603,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal continue; } - zend_op *opline = &op_array->opcodes[i]; + const zend_op *opline = &op_array->opcodes[i]; if (EXPECTED(opline->opcode == ZEND_RECV_INIT)) { zval *default_value = RT_CONSTANT(opline, opline->op2); if (Z_OPT_TYPE_P(default_value) == IS_CONSTANT_AST) { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 920c702785ca4..4715fd00fd463 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -453,11 +453,11 @@ ZEND_API const char *get_active_class_name(const char **space); ZEND_API const char *get_active_function_name(void); ZEND_API const char *get_active_function_arg_name(uint32_t arg_num); ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num); -ZEND_API zend_function *zend_active_function_ex(const zend_execute_data *execute_data); +ZEND_API const zend_function *zend_active_function_ex(const zend_execute_data *execute_data); -static zend_always_inline zend_function *zend_active_function(void) +static zend_always_inline const zend_function *zend_active_function(void) { - zend_function *func = EG(current_execute_data)->func; + const zend_function *func = EG(current_execute_data)->func; if (ZEND_USER_CODE(func->type)) { return zend_active_function_ex(EG(current_execute_data)); } else { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f174aac49ef4d..660975f9bc1b5 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -601,9 +601,9 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ } /* }}} */ -ZEND_API zend_function *zend_active_function_ex(const zend_execute_data *execute_data) +ZEND_API const zend_function *zend_active_function_ex(const zend_execute_data *execute_data) { - zend_function *func = EX(func); + const zend_function *func = EX(func); /* Resolve function if op is a frameless call. */ if (ZEND_USER_CODE(func->type)) { @@ -717,7 +717,7 @@ ZEND_API uint32_t zend_get_executed_lineno(void) /* {{{ */ ZEND_API zend_class_entry *zend_get_executed_scope(void) /* {{{ */ { - zend_execute_data *ex = EG(current_execute_data); + const zend_execute_data *ex = EG(current_execute_data); while (1) { if (!ex) { diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 79be10572d3bf..68daa207ee6e4 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -680,7 +680,7 @@ static ZEND_FUNCTION(zend_parent_hook_set_trampoline); static bool zend_is_in_hook(const zend_property_info *prop_info) { - zend_execute_data *execute_data = EG(current_execute_data); + const zend_execute_data *execute_data = EG(current_execute_data); if (!execute_data || !EX(func) || !EX(func)->common.prop_info) { return false; } @@ -996,7 +996,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int /* }}} */ static zend_always_inline bool property_uses_strict_types(void) { - zend_execute_data *execute_data = EG(current_execute_data); + const zend_execute_data *execute_data = EG(current_execute_data); return execute_data && execute_data->func && ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)); diff --git a/Zend/zend_observer.c b/Zend/zend_observer.c index 15722eb6b2eb3..bee20bdbc20dc 100644 --- a/Zend/zend_observer.c +++ b/Zend/zend_observer.c @@ -115,8 +115,8 @@ ZEND_API void zend_observer_shutdown(void) static void zend_observer_fcall_install(zend_execute_data *execute_data) { - zend_llist *list = &zend_observers_fcall_list; - zend_function *function = execute_data->func; + const zend_llist *list = &zend_observers_fcall_list; + const zend_function *function = execute_data->func; ZEND_ASSERT(RUN_TIME_CACHE(&function->common)); zend_observer_fcall_begin_handler *begin_handlers = ZEND_OBSERVER_DATA(function), *begin_handlers_start = begin_handlers; @@ -126,7 +126,7 @@ static void zend_observer_fcall_install(zend_execute_data *execute_data) *end_handlers = ZEND_OBSERVER_NOT_OBSERVED; bool has_handlers = false; - for (zend_llist_element *element = list->head; element; element = element->next) { + for (const zend_llist_element *element = list->head; element; element = element->next) { zend_observer_fcall_init init; memcpy(&init, element->data, sizeof init); zend_observer_fcall_handlers handlers = init(execute_data); @@ -157,7 +157,7 @@ static void zend_observer_fcall_install(zend_execute_data *execute_data) * the previous next handler is now at the place where the current handler was. * Hence, the next handler executed will be the one after the next handler. * Callees must thus invoke the next handler themselves, with the same arguments they were passed. */ -static bool zend_observer_remove_handler(void **first_handler, void *old_handler, void **next_handler) { +static bool zend_observer_remove_handler(void **first_handler, const void *old_handler, void **next_handler) { size_t registered_observers = zend_observers_fcall_list.count; void **last_handler = first_handler + registered_observers - 1; @@ -179,7 +179,7 @@ static bool zend_observer_remove_handler(void **first_handler, void *old_handler return false; } -ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin) { +ZEND_API void zend_observer_add_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin) { size_t registered_observers = zend_observers_fcall_list.count; zend_observer_fcall_begin_handler *first_handler = ZEND_OBSERVER_DATA(function), *last_handler = first_handler + registered_observers - 1; if (*first_handler == ZEND_OBSERVER_NOT_OBSERVED || *first_handler == ZEND_OBSERVER_NONE_OBSERVED) { @@ -196,7 +196,7 @@ ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_obse } } -ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next) { +ZEND_API bool zend_observer_remove_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next) { void **begin_handlers = (void **)ZEND_OBSERVER_DATA(function); if (zend_observer_remove_handler(begin_handlers, begin, (void**)next)) { // Ensure invariant: ZEND_OBSERVER_NONE_OBSERVED in begin_handlers if both are not observed @@ -211,7 +211,7 @@ ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_o return false; } -ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observer_fcall_end_handler end) { +ZEND_API void zend_observer_add_end_handler(const zend_function *function, zend_observer_fcall_end_handler end) { size_t registered_observers = zend_observers_fcall_list.count; void **begin_handler = (void **)ZEND_OBSERVER_DATA(function); zend_observer_fcall_end_handler *end_handler = (zend_observer_fcall_end_handler *)begin_handler + registered_observers; @@ -226,7 +226,7 @@ ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observ *end_handler = end; } -ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next) { +ZEND_API bool zend_observer_remove_end_handler(const zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next) { size_t registered_observers = zend_observers_fcall_list.count; void **begin_handlers = (void **)ZEND_OBSERVER_DATA(function); void **end_handlers = begin_handlers + registered_observers; @@ -241,7 +241,7 @@ ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_obs } static inline zend_execute_data **prev_observed_frame(zend_execute_data *execute_data) { - zend_function *func = EX(func); + const zend_function *func = EX(func); ZEND_ASSERT(func); return (zend_execute_data **)&Z_PTR_P(EX_VAR_NUM((ZEND_USER_CODE(func->type) ? func->op_array.last_var : ZEND_CALL_NUM_ARGS(execute_data)) + func->common.T - 1)); } @@ -256,7 +256,7 @@ static void ZEND_FASTCALL _zend_observe_fcall_begin(zend_execute_data *execute_d ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_data *execute_data, zend_observer_fcall_begin_handler *handler) { - zend_observer_fcall_begin_handler *possible_handlers_end = handler + zend_observers_fcall_list.count; + const zend_observer_fcall_begin_handler *possible_handlers_end = handler + zend_observers_fcall_list.count; if (!*handler) { zend_observer_fcall_install(execute_data); @@ -265,7 +265,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_da } } - zend_observer_fcall_end_handler *end_handler = (zend_observer_fcall_end_handler *)possible_handlers_end; + const zend_observer_fcall_end_handler *end_handler = (const zend_observer_fcall_end_handler *)possible_handlers_end; if (*end_handler != ZEND_OBSERVER_NOT_OBSERVED) { *prev_observed_frame(execute_data) = EG(current_observed_frame); EG(current_observed_frame) = execute_data; @@ -294,7 +294,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(zend_execute_data *execute } static inline void call_end_observers(zend_execute_data *execute_data, zval *return_value) { - zend_function *func = EX(func); + const zend_function *func = EX(func); ZEND_ASSERT(func); zend_observer_fcall_end_handler *handler = (zend_observer_fcall_end_handler *)ZEND_OBSERVER_DATA(func) + zend_observers_fcall_list.count; @@ -340,7 +340,7 @@ ZEND_API void ZEND_FASTCALL _zend_observer_function_declared_notify(zend_op_arra return; } - for (zend_llist_element *element = zend_observer_function_declared_callbacks.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_function_declared_callbacks.head; element; element = element->next) { zend_observer_function_declared_cb callback = *(zend_observer_function_declared_cb *) (element->data); callback(op_array, name); } @@ -358,7 +358,7 @@ ZEND_API void ZEND_FASTCALL _zend_observer_class_linked_notify(zend_class_entry return; } - for (zend_llist_element *element = zend_observer_class_linked_callbacks.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_class_linked_callbacks.head; element; element = element->next) { zend_observer_class_linked_cb callback = *(zend_observer_class_linked_cb *) (element->data); callback(ce, name); } @@ -372,7 +372,7 @@ ZEND_API void zend_observer_error_register(zend_observer_error_cb cb) ZEND_API void _zend_observer_error_notify(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message) { - for (zend_llist_element *element = zend_observer_error_callbacks.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_error_callbacks.head; element; element = element->next) { zend_observer_error_cb callback = *(zend_observer_error_cb *) (element->data); callback(type, error_filename, error_lineno, message); } @@ -395,12 +395,11 @@ ZEND_API void zend_observer_fiber_destroy_register(zend_observer_fiber_destroy_h ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context *initializing) { - zend_llist_element *element; zend_observer_fiber_init_handler callback; initializing->top_observed_frame = NULL; - for (element = zend_observer_fiber_init.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_fiber_init.head; element; element = element->next) { callback = *(zend_observer_fiber_init_handler *) element->data; callback(initializing); } @@ -408,14 +407,13 @@ ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context * ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context *from, zend_fiber_context *to) { - zend_llist_element *element; zend_observer_fiber_switch_handler callback; if (from->status == ZEND_FIBER_STATUS_DEAD) { zend_observer_fcall_end_all(); // fiber is either finished (call will do nothing) or has bailed out } - for (element = zend_observer_fiber_switch.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_fiber_switch.head; element; element = element->next) { callback = *(zend_observer_fiber_switch_handler *) element->data; callback(from, to); } @@ -426,10 +424,9 @@ ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context ZEND_API void ZEND_FASTCALL zend_observer_fiber_destroy_notify(zend_fiber_context *destroying) { - zend_llist_element *element; zend_observer_fiber_destroy_handler callback; - for (element = zend_observer_fiber_destroy.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_fiber_destroy.head; element; element = element->next) { callback = *(zend_observer_fiber_destroy_handler *) element->data; callback(destroying); } diff --git a/Zend/zend_observer.h b/Zend/zend_observer.h index bb8964692c370..cfec5200055af 100644 --- a/Zend/zend_observer.h +++ b/Zend/zend_observer.h @@ -74,10 +74,10 @@ ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init); // Call during runtime, but only if you have used zend_observer_fcall_register. // You must not have more than one begin and one end handler active at the same time. Remove the old one first, if there is an existing one. -ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin); -ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next); -ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observer_fcall_end_handler end); -ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next); +ZEND_API void zend_observer_add_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin); +ZEND_API bool zend_observer_remove_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next); +ZEND_API void zend_observer_add_end_handler(const zend_function *function, zend_observer_fcall_end_handler end); +ZEND_API bool zend_observer_remove_end_handler(const zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next); ZEND_API void zend_observer_startup(void); // Called by engine before MINITs ZEND_API void zend_observer_post_startup(void); // Called by engine after MINITs @@ -88,13 +88,13 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(zend_execute_data *execute /* prechecked: the call is actually observed. */ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_data *execute_data, zend_observer_fcall_begin_handler *observer_data); -static zend_always_inline bool zend_observer_handler_is_unobserved(zend_observer_fcall_begin_handler *handler) { +static zend_always_inline bool zend_observer_handler_is_unobserved(const zend_observer_fcall_begin_handler *handler) { return *handler == ZEND_OBSERVER_NONE_OBSERVED; } /* Initial check for observers has not happened yet or no observers are installed. */ -static zend_always_inline bool zend_observer_fcall_has_no_observers(zend_execute_data *execute_data, bool allow_generator, zend_observer_fcall_begin_handler **handler) { - zend_function *function = EX(func); +static zend_always_inline bool zend_observer_fcall_has_no_observers(const zend_execute_data *execute_data, bool allow_generator, zend_observer_fcall_begin_handler **handler) { + const zend_function *function = EX(func); void *ZEND_MAP_PTR(runtime_cache) = ZEND_MAP_PTR(function->common.run_time_cache); if (function->common.fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE | (allow_generator ? 0 : ZEND_ACC_GENERATOR))) { diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 34d759ae30e4b..ceb182a0a258d 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -2788,7 +2788,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons case IS_FALSE: case IS_LONG: case IS_DOUBLE: - ZVAL_COPY(&entry_tmp, entry); + ZVAL_COPY_VALUE(&entry_tmp, entry); break; case IS_ARRAY: chash = php_mb_convert_encoding_recursive(