Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 11 additions & 11 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@ 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) {
ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_VARIADIC);
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);

Expand Down Expand Up @@ -1140,7 +1140,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",
Expand Down Expand Up @@ -3703,12 +3703,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;
Expand Down Expand Up @@ -3812,7 +3812,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;
Expand Down Expand Up @@ -4058,7 +4058,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)) {
Expand Down Expand Up @@ -4092,7 +4092,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));
Expand Down Expand Up @@ -4123,7 +4123,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;
Expand Down Expand Up @@ -4236,7 +4236,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;
}
Expand Down Expand Up @@ -5314,7 +5314,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) {
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,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);
Expand Down Expand Up @@ -900,7 +900,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) {
Expand Down Expand Up @@ -931,7 +931,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()

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,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;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_closures.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 9 additions & 9 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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++);
}
Expand Down Expand Up @@ -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. */
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines -456 to +458
Copy link
Member

Choose a reason for hiding this comment

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

These changes may affect third-party extensions. Fixes are going to be trivial.

Copy link
Member Author

Choose a reason for hiding this comment

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

Add an entry in UPGRADING.INTERNALS 23162d8

{
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 {
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down
Loading