Commit ebb6e4f5f8d for php.net
commit ebb6e4f5f8d6e10c853b533da423eaf86e0e7a1d
Author: Gina Peter Banyard <girgias@php.net>
Date: Thu Apr 2 17:09:36 2026 +0100
Zend/zend_execute.c: add const qualifiers
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index a4871bc3beb..8b688c4adc7 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -646,7 +646,7 @@ static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_err
}
/* this should modify object only if it's empty */
-static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_error(const zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_error(const zval *object, const zval *property OPLINE_DC EXECUTE_DATA_DC)
{
zend_string *tmp_property_name;
zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
@@ -1709,7 +1709,7 @@ static zend_never_inline void zend_binary_assign_op_typed_prop(const zend_proper
}
}
-static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type EXECUTE_DATA_DC)
+static zend_never_inline zend_long zend_check_string_offset(const zval *dim, int type EXECUTE_DATA_DC)
{
zend_long offset;
@@ -2184,7 +2184,7 @@ static zend_property_info *zend_get_prop_not_accepting_double(zend_reference *re
return NULL;
}
-static ZEND_COLD zend_long zend_throw_incdec_ref_error(zend_property_info *error_prop OPLINE_DC)
+static ZEND_COLD zend_long zend_throw_incdec_ref_error(const zend_property_info *error_prop OPLINE_DC)
{
zend_string *type_str = zend_type_to_string(error_prop->type);
if (ZEND_IS_INCREMENT(opline->opcode)) {
@@ -2206,7 +2206,7 @@ static ZEND_COLD zend_long zend_throw_incdec_ref_error(zend_property_info *error
}
}
-static ZEND_COLD zend_long zend_throw_incdec_prop_error(zend_property_info *prop OPLINE_DC) {
+static ZEND_COLD zend_long zend_throw_incdec_prop_error(const zend_property_info *prop OPLINE_DC) {
zend_string *type_str = zend_type_to_string(prop->type);
if (ZEND_IS_INCREMENT(opline->opcode)) {
zend_type_error("Cannot increment property %s::$%s of type %s past its maximal value",
@@ -2257,7 +2257,7 @@ static void zend_incdec_typed_ref(zend_reference *ref, zval *copy OPLINE_DC EXEC
}
}
-static void zend_incdec_typed_prop(zend_property_info *prop_info, zval *var_ptr, zval *copy OPLINE_DC EXECUTE_DATA_DC)
+static void zend_incdec_typed_prop(const zend_property_info *prop_info, zval *var_ptr, zval *copy OPLINE_DC EXECUTE_DATA_DC)
{
zval tmp;
@@ -2287,7 +2287,7 @@ static void zend_incdec_typed_prop(zend_property_info *prop_info, zval *var_ptr,
}
}
-static void zend_pre_incdec_property_zval(zval *prop, zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
+static void zend_pre_incdec_property_zval(zval *prop, const zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
{
if (EXPECTED(Z_TYPE_P(prop) == IS_LONG)) {
if (ZEND_IS_INCREMENT(opline->opcode)) {
@@ -2325,7 +2325,7 @@ static void zend_pre_incdec_property_zval(zval *prop, zend_property_info *prop_i
}
}
-static void zend_post_incdec_property_zval(zval *prop, zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
+static void zend_post_incdec_property_zval(zval *prop, const zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
{
if (EXPECTED(Z_TYPE_P(prop) == IS_LONG)) {
ZVAL_LONG(EX_VAR(opline->result.var), Z_LVAL_P(prop));
@@ -2553,7 +2553,7 @@ ZEND_API zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_method(co
zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(method));
}
-static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_invalid_method_call(zval *object, zval *function_name)
+static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_invalid_method_call(const zval *object, const zval *function_name)
{
zend_throw_error(NULL, "Call to a member function %s() on %s",
Z_STRVAL_P(function_name), zend_zval_value_name(object));
@@ -2617,7 +2617,7 @@ ZEND_API zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_call_stack_size_err
}
#endif /* ZEND_CHECK_STACK_LIMIT */
-static ZEND_COLD void zend_binary_assign_op_dim_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
+static ZEND_COLD void zend_binary_assign_op_dim_slow(const zval *container, const zval *dim OPLINE_DC EXECUTE_DATA_DC)
{
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
if (opline->op2_type == IS_UNUSED) {
@@ -3051,7 +3051,7 @@ static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_UNSET(z
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET EXECUTE_DATA_CC);
}
-static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type, bool is_list, bool slow EXECUTE_DATA_DC)
+static zend_always_inline void zend_fetch_dimension_address_read(zval *result, const zval *container, zval *dim, int dim_type, int type, bool is_list, bool slow EXECUTE_DATA_DC)
{
zval *retval;
@@ -3205,36 +3205,36 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
}
}
-static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_read_R(zval *container, zval *dim, int dim_type OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_read_R(const zval *container, zval *dim, int dim_type OPLINE_DC EXECUTE_DATA_DC)
{
zval *result = EX_VAR(opline->result.var);
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R, 0, 0 EXECUTE_DATA_CC);
}
-static zend_never_inline void zend_fetch_dimension_address_read_R_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void zend_fetch_dimension_address_read_R_slow(const zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
{
zval *result = EX_VAR(opline->result.var);
zend_fetch_dimension_address_read(result, container, dim, IS_CV, BP_VAR_R, 0, 1 EXECUTE_DATA_CC);
}
-static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_read_IS(zval *container, zval *dim, int dim_type OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_read_IS(const zval *container, zval *dim, int dim_type OPLINE_DC EXECUTE_DATA_DC)
{
zval *result = EX_VAR(opline->result.var);
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS, 0, 0 EXECUTE_DATA_CC);
}
-static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_LIST_r(zval *container, zval *dim, int dim_type OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_LIST_r(const zval *container, zval *dim, int dim_type OPLINE_DC EXECUTE_DATA_DC)
{
zval *result = EX_VAR(opline->result.var);
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R, 1, 0 EXECUTE_DATA_CC);
}
-ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type)
+ZEND_API void zend_fetch_dimension_const(zval *result, const zval *container, zval *dim, int type)
{
zend_fetch_dimension_address_read(result, container, dim, IS_TMP_VAR, type, 0, 0 NO_EXECUTE_DATA_CC);
}
-static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable *ht, zval *offset EXECUTE_DATA_DC)
+static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable *ht, const zval *offset EXECUTE_DATA_DC)
{
zend_ulong hval;
@@ -3289,7 +3289,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable
}
}
-static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC)
+static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(const zval *container, zval *offset EXECUTE_DATA_DC)
{
if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
offset = ZVAL_UNDEFINED_OP2();
@@ -3328,7 +3328,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container,
}
}
-static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC)
+static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(const zval *container, zval *offset EXECUTE_DATA_DC)
{
if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
offset = ZVAL_UNDEFINED_OP2();
@@ -3367,7 +3367,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *containe
}
}
-static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable *ht, zval *key OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable *ht, const zval *key OPLINE_DC EXECUTE_DATA_DC)
{
zend_string *str;
zend_ulong hval;
@@ -3426,7 +3426,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable
}
static ZEND_COLD void ZEND_FASTCALL zend_array_key_exists_error(
- zval *subject, zval *key OPLINE_DC EXECUTE_DATA_DC)
+ const zval *subject, const zval *key OPLINE_DC EXECUTE_DATA_DC)
{
if (Z_TYPE_P(key) == IS_UNDEF) {
ZVAL_UNDEFINED_OP1();
@@ -3440,7 +3440,7 @@ static ZEND_COLD void ZEND_FASTCALL zend_array_key_exists_error(
}
}
-static zend_always_inline bool promotes_to_array(zval *val) {
+static zend_always_inline bool promotes_to_array(const zval *val) {
return Z_TYPE_P(val) <= IS_FALSE
|| (Z_ISREF_P(val) && Z_TYPE_P(Z_REFVAL_P(val)) <= IS_FALSE);
}
@@ -3504,8 +3504,18 @@ static zend_never_inline bool zend_handle_fetch_obj_flags(
return 1;
}
-static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type, uint32_t flags, zend_property_info **prop_info_p OPLINE_DC EXECUTE_DATA_DC)
-{
+static zend_always_inline void zend_fetch_property_address(
+ zval *result,
+ const zval *container,
+ uint32_t container_op_type,
+ const zval *prop_ptr,
+ uint32_t prop_op_type,
+ void **cache_slot,
+ int type,
+ uint32_t flags,
+ zend_property_info **prop_info_p
+ OPLINE_DC EXECUTE_DATA_DC
+) {
zval *ptr;
zend_object *zobj;
zend_string *name, *tmp_name;
@@ -3650,8 +3660,14 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
}
}
-static zend_always_inline void zend_assign_to_property_reference(zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
-{
+static zend_always_inline void zend_assign_to_property_reference(
+ const zval *container,
+ uint32_t container_op_type,
+ const zval *prop_ptr,
+ uint32_t prop_op_type,
+ zval *value_ptr
+ OPLINE_DC EXECUTE_DATA_DC
+) {
zval variable, *variable_ptr = &variable;
void **cache_addr = (prop_op_type == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_RETURNS_FUNCTION) : NULL;
zend_refcounted *garbage = NULL;
@@ -3689,25 +3705,25 @@ static zend_always_inline void zend_assign_to_property_reference(zval *container
}
}
-static zend_never_inline void zend_assign_to_property_reference_this_const(zval *container, zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void zend_assign_to_property_reference_this_const(const zval *container, const zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
{
zend_assign_to_property_reference(container, IS_UNUSED, prop_ptr, IS_CONST, value_ptr
OPLINE_CC EXECUTE_DATA_CC);
}
-static zend_never_inline void zend_assign_to_property_reference_var_const(zval *container, zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void zend_assign_to_property_reference_var_const(const zval *container, const zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
{
zend_assign_to_property_reference(container, IS_VAR, prop_ptr, IS_CONST, value_ptr
OPLINE_CC EXECUTE_DATA_CC);
}
-static zend_never_inline void zend_assign_to_property_reference_this_var(zval *container, zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void zend_assign_to_property_reference_this_var(const zval *container, const zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
{
zend_assign_to_property_reference(container, IS_UNUSED, prop_ptr, IS_VAR, value_ptr
OPLINE_CC EXECUTE_DATA_CC);
}
-static zend_never_inline void zend_assign_to_property_reference_var_var(zval *container, zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
+static zend_never_inline void zend_assign_to_property_reference_var_var(const zval *container, const zval *prop_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
{
zend_assign_to_property_reference(container, IS_VAR, prop_ptr, IS_VAR, value_ptr
OPLINE_CC EXECUTE_DATA_CC);
@@ -4480,7 +4496,7 @@ ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name) /*
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len) /* {{{ */
{
- zval *zv = zend_hash_str_find(EG(function_table), name, len);
+ const zval *zv = zend_hash_str_find(EG(function_table), name, len);
if (EXPECTED(zv != NULL)) {
zend_function *fbc = Z_FUNC_P(zv);
@@ -4904,7 +4920,7 @@ static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num,
/* Handle the split range for loop vars */
if (catch_op_num) {
- zend_op *final_op = EX(func)->op_array.opcodes + range->end;
+ const zend_op *final_op = EX(func)->op_array.opcodes + range->end;
if (final_op->extended_value & ZEND_FREE_ON_RETURN && (final_op->opcode == ZEND_FE_FREE || final_op->opcode == ZEND_FREE)) {
if (catch_op_num < range->end + final_op->op2.num) {
continue;
@@ -5192,7 +5208,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zend_o
}
/* }}} */
-static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_array *function, uint32_t num_args) /* {{{ */
+static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(const zend_array *function, uint32_t num_args) /* {{{ */
{
zend_function *fbc;
void *object_or_called_scope;
@@ -5283,7 +5299,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
#define ZEND_FAKE_OP_ARRAY ((zend_op_array*)(intptr_t)-1)
-static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval *inc_filename_zv, int type) /* {{{ */
+static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(const zval *inc_filename_zv, int type) /* {{{ */
{
zend_op_array *new_op_array = NULL;
zend_string *tmp_inc_filename;
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index cb2c9e14480..92ce8a0dcbb 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -134,7 +134,7 @@ ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_l
ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, uint8_t value_type, bool strict);
ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *value, uint8_t value_type, bool strict, zend_refcounted **garbage_ptr);
-static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, uint8_t value_type)
+static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, const zval *value, uint8_t value_type)
{
zend_refcounted *ref = NULL;
@@ -210,7 +210,7 @@ static zend_always_inline zval* zend_assign_to_variable_ex(zval *variable_ptr, z
return variable_ptr;
}
-static zend_always_inline void zend_safe_assign_to_variable_noref(zval *variable_ptr, zval *value) {
+static zend_always_inline void zend_safe_assign_to_variable_noref(zval *variable_ptr, const zval *value) {
if (Z_REFCOUNTED_P(variable_ptr)) {
ZEND_ASSERT(Z_TYPE_P(variable_ptr) != IS_REFERENCE);
zend_refcounted *ref = Z_COUNTED_P(variable_ptr);
@@ -484,7 +484,7 @@ ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name);
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len);
ZEND_API void ZEND_FASTCALL zend_init_func_run_time_cache(zend_op_array *op_array);
-ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type);
+ZEND_API void zend_fetch_dimension_const(zval *result, const zval *container, zval *dim, int type);
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);