Skip to content

Commit ebb6e4f

Browse files
committed
Zend/zend_execute.c: add const qualifiers
1 parent 1510196 commit ebb6e4f

2 files changed

Lines changed: 52 additions & 36 deletions

File tree

Zend/zend_execute.c

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_err
646646
}
647647

648648
/* this should modify object only if it's empty */
649-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_error(const zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
649+
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)
650650
{
651651
zend_string *tmp_property_name;
652652
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
17091709
}
17101710
}
17111711

1712-
static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type EXECUTE_DATA_DC)
1712+
static zend_never_inline zend_long zend_check_string_offset(const zval *dim, int type EXECUTE_DATA_DC)
17131713
{
17141714
zend_long offset;
17151715

@@ -2184,7 +2184,7 @@ static zend_property_info *zend_get_prop_not_accepting_double(zend_reference *re
21842184
return NULL;
21852185
}
21862186

2187-
static ZEND_COLD zend_long zend_throw_incdec_ref_error(zend_property_info *error_prop OPLINE_DC)
2187+
static ZEND_COLD zend_long zend_throw_incdec_ref_error(const zend_property_info *error_prop OPLINE_DC)
21882188
{
21892189
zend_string *type_str = zend_type_to_string(error_prop->type);
21902190
if (ZEND_IS_INCREMENT(opline->opcode)) {
@@ -2206,7 +2206,7 @@ static ZEND_COLD zend_long zend_throw_incdec_ref_error(zend_property_info *error
22062206
}
22072207
}
22082208

2209-
static ZEND_COLD zend_long zend_throw_incdec_prop_error(zend_property_info *prop OPLINE_DC) {
2209+
static ZEND_COLD zend_long zend_throw_incdec_prop_error(const zend_property_info *prop OPLINE_DC) {
22102210
zend_string *type_str = zend_type_to_string(prop->type);
22112211
if (ZEND_IS_INCREMENT(opline->opcode)) {
22122212
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
22572257
}
22582258
}
22592259

2260-
static void zend_incdec_typed_prop(zend_property_info *prop_info, zval *var_ptr, zval *copy OPLINE_DC EXECUTE_DATA_DC)
2260+
static void zend_incdec_typed_prop(const zend_property_info *prop_info, zval *var_ptr, zval *copy OPLINE_DC EXECUTE_DATA_DC)
22612261
{
22622262
zval tmp;
22632263

@@ -2287,7 +2287,7 @@ static void zend_incdec_typed_prop(zend_property_info *prop_info, zval *var_ptr,
22872287
}
22882288
}
22892289

2290-
static void zend_pre_incdec_property_zval(zval *prop, zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
2290+
static void zend_pre_incdec_property_zval(zval *prop, const zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
22912291
{
22922292
if (EXPECTED(Z_TYPE_P(prop) == IS_LONG)) {
22932293
if (ZEND_IS_INCREMENT(opline->opcode)) {
@@ -2325,7 +2325,7 @@ static void zend_pre_incdec_property_zval(zval *prop, zend_property_info *prop_i
23252325
}
23262326
}
23272327

2328-
static void zend_post_incdec_property_zval(zval *prop, zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
2328+
static void zend_post_incdec_property_zval(zval *prop, const zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
23292329
{
23302330
if (EXPECTED(Z_TYPE_P(prop) == IS_LONG)) {
23312331
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
25532553
zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(method));
25542554
}
25552555

2556-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_invalid_method_call(zval *object, zval *function_name)
2556+
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_invalid_method_call(const zval *object, const zval *function_name)
25572557
{
25582558
zend_throw_error(NULL, "Call to a member function %s() on %s",
25592559
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
26172617
}
26182618
#endif /* ZEND_CHECK_STACK_LIMIT */
26192619

2620-
static ZEND_COLD void zend_binary_assign_op_dim_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
2620+
static ZEND_COLD void zend_binary_assign_op_dim_slow(const zval *container, const zval *dim OPLINE_DC EXECUTE_DATA_DC)
26212621
{
26222622
if (UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
26232623
if (opline->op2_type == IS_UNUSED) {
@@ -3051,7 +3051,7 @@ static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_UNSET(z
30513051
zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET EXECUTE_DATA_CC);
30523052
}
30533053

3054-
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)
3054+
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)
30553055
{
30563056
zval *retval;
30573057

@@ -3205,36 +3205,36 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
32053205
}
32063206
}
32073207

3208-
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)
3208+
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)
32093209
{
32103210
zval *result = EX_VAR(opline->result.var);
32113211
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R, 0, 0 EXECUTE_DATA_CC);
32123212
}
32133213

3214-
static zend_never_inline void zend_fetch_dimension_address_read_R_slow(zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
3214+
static zend_never_inline void zend_fetch_dimension_address_read_R_slow(const zval *container, zval *dim OPLINE_DC EXECUTE_DATA_DC)
32153215
{
32163216
zval *result = EX_VAR(opline->result.var);
32173217
zend_fetch_dimension_address_read(result, container, dim, IS_CV, BP_VAR_R, 0, 1 EXECUTE_DATA_CC);
32183218
}
32193219

3220-
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)
3220+
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)
32213221
{
32223222
zval *result = EX_VAR(opline->result.var);
32233223
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS, 0, 0 EXECUTE_DATA_CC);
32243224
}
32253225

3226-
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)
3226+
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)
32273227
{
32283228
zval *result = EX_VAR(opline->result.var);
32293229
zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R, 1, 0 EXECUTE_DATA_CC);
32303230
}
32313231

3232-
ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type)
3232+
ZEND_API void zend_fetch_dimension_const(zval *result, const zval *container, zval *dim, int type)
32333233
{
32343234
zend_fetch_dimension_address_read(result, container, dim, IS_TMP_VAR, type, 0, 0 NO_EXECUTE_DATA_CC);
32353235
}
32363236

3237-
static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable *ht, zval *offset EXECUTE_DATA_DC)
3237+
static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable *ht, const zval *offset EXECUTE_DATA_DC)
32383238
{
32393239
zend_ulong hval;
32403240

@@ -3289,7 +3289,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable
32893289
}
32903290
}
32913291

3292-
static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC)
3292+
static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(const zval *container, zval *offset EXECUTE_DATA_DC)
32933293
{
32943294
if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
32953295
offset = ZVAL_UNDEFINED_OP2();
@@ -3328,7 +3328,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container,
33283328
}
33293329
}
33303330

3331-
static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC)
3331+
static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(const zval *container, zval *offset EXECUTE_DATA_DC)
33323332
{
33333333
if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
33343334
offset = ZVAL_UNDEFINED_OP2();
@@ -3367,7 +3367,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *containe
33673367
}
33683368
}
33693369

3370-
static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable *ht, zval *key OPLINE_DC EXECUTE_DATA_DC)
3370+
static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable *ht, const zval *key OPLINE_DC EXECUTE_DATA_DC)
33713371
{
33723372
zend_string *str;
33733373
zend_ulong hval;
@@ -3426,7 +3426,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable
34263426
}
34273427

34283428
static ZEND_COLD void ZEND_FASTCALL zend_array_key_exists_error(
3429-
zval *subject, zval *key OPLINE_DC EXECUTE_DATA_DC)
3429+
const zval *subject, const zval *key OPLINE_DC EXECUTE_DATA_DC)
34303430
{
34313431
if (Z_TYPE_P(key) == IS_UNDEF) {
34323432
ZVAL_UNDEFINED_OP1();
@@ -3440,7 +3440,7 @@ static ZEND_COLD void ZEND_FASTCALL zend_array_key_exists_error(
34403440
}
34413441
}
34423442

3443-
static zend_always_inline bool promotes_to_array(zval *val) {
3443+
static zend_always_inline bool promotes_to_array(const zval *val) {
34443444
return Z_TYPE_P(val) <= IS_FALSE
34453445
|| (Z_ISREF_P(val) && Z_TYPE_P(Z_REFVAL_P(val)) <= IS_FALSE);
34463446
}
@@ -3504,8 +3504,18 @@ static zend_never_inline bool zend_handle_fetch_obj_flags(
35043504
return 1;
35053505
}
35063506

3507-
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)
3508-
{
3507+
static zend_always_inline void zend_fetch_property_address(
3508+
zval *result,
3509+
const zval *container,
3510+
uint32_t container_op_type,
3511+
const zval *prop_ptr,
3512+
uint32_t prop_op_type,
3513+
void **cache_slot,
3514+
int type,
3515+
uint32_t flags,
3516+
zend_property_info **prop_info_p
3517+
OPLINE_DC EXECUTE_DATA_DC
3518+
) {
35093519
zval *ptr;
35103520
zend_object *zobj;
35113521
zend_string *name, *tmp_name;
@@ -3650,8 +3660,14 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
36503660
}
36513661
}
36523662

3653-
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)
3654-
{
3663+
static zend_always_inline void zend_assign_to_property_reference(
3664+
const zval *container,
3665+
uint32_t container_op_type,
3666+
const zval *prop_ptr,
3667+
uint32_t prop_op_type,
3668+
zval *value_ptr
3669+
OPLINE_DC EXECUTE_DATA_DC
3670+
) {
36553671
zval variable, *variable_ptr = &variable;
36563672
void **cache_addr = (prop_op_type == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_RETURNS_FUNCTION) : NULL;
36573673
zend_refcounted *garbage = NULL;
@@ -3689,25 +3705,25 @@ static zend_always_inline void zend_assign_to_property_reference(zval *container
36893705
}
36903706
}
36913707

3692-
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)
3708+
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)
36933709
{
36943710
zend_assign_to_property_reference(container, IS_UNUSED, prop_ptr, IS_CONST, value_ptr
36953711
OPLINE_CC EXECUTE_DATA_CC);
36963712
}
36973713

3698-
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)
3714+
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)
36993715
{
37003716
zend_assign_to_property_reference(container, IS_VAR, prop_ptr, IS_CONST, value_ptr
37013717
OPLINE_CC EXECUTE_DATA_CC);
37023718
}
37033719

3704-
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)
3720+
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)
37053721
{
37063722
zend_assign_to_property_reference(container, IS_UNUSED, prop_ptr, IS_VAR, value_ptr
37073723
OPLINE_CC EXECUTE_DATA_CC);
37083724
}
37093725

3710-
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)
3726+
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)
37113727
{
37123728
zend_assign_to_property_reference(container, IS_VAR, prop_ptr, IS_VAR, value_ptr
37133729
OPLINE_CC EXECUTE_DATA_CC);
@@ -4480,7 +4496,7 @@ ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name) /*
44804496

44814497
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len) /* {{{ */
44824498
{
4483-
zval *zv = zend_hash_str_find(EG(function_table), name, len);
4499+
const zval *zv = zend_hash_str_find(EG(function_table), name, len);
44844500

44854501
if (EXPECTED(zv != NULL)) {
44864502
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,
49044920

49054921
/* Handle the split range for loop vars */
49064922
if (catch_op_num) {
4907-
zend_op *final_op = EX(func)->op_array.opcodes + range->end;
4923+
const zend_op *final_op = EX(func)->op_array.opcodes + range->end;
49084924
if (final_op->extended_value & ZEND_FREE_ON_RETURN && (final_op->opcode == ZEND_FE_FREE || final_op->opcode == ZEND_FREE)) {
49094925
if (catch_op_num < range->end + final_op->op2.num) {
49104926
continue;
@@ -5192,7 +5208,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zend_o
51925208
}
51935209
/* }}} */
51945210

5195-
static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_array *function, uint32_t num_args) /* {{{ */
5211+
static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(const zend_array *function, uint32_t num_args) /* {{{ */
51965212
{
51975213
zend_function *fbc;
51985214
void *object_or_called_scope;
@@ -5283,7 +5299,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
52835299

52845300
#define ZEND_FAKE_OP_ARRAY ((zend_op_array*)(intptr_t)-1)
52855301

5286-
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval *inc_filename_zv, int type) /* {{{ */
5302+
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(const zval *inc_filename_zv, int type) /* {{{ */
52875303
{
52885304
zend_op_array *new_op_array = NULL;
52895305
zend_string *tmp_inc_filename;

Zend/zend_execute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_l
134134
ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, uint8_t value_type, bool strict);
135135
ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *value, uint8_t value_type, bool strict, zend_refcounted **garbage_ptr);
136136

137-
static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, uint8_t value_type)
137+
static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, const zval *value, uint8_t value_type)
138138
{
139139
zend_refcounted *ref = NULL;
140140

@@ -210,7 +210,7 @@ static zend_always_inline zval* zend_assign_to_variable_ex(zval *variable_ptr, z
210210
return variable_ptr;
211211
}
212212

213-
static zend_always_inline void zend_safe_assign_to_variable_noref(zval *variable_ptr, zval *value) {
213+
static zend_always_inline void zend_safe_assign_to_variable_noref(zval *variable_ptr, const zval *value) {
214214
if (Z_REFCOUNTED_P(variable_ptr)) {
215215
ZEND_ASSERT(Z_TYPE_P(variable_ptr) != IS_REFERENCE);
216216
zend_refcounted *ref = Z_COUNTED_P(variable_ptr);
@@ -484,7 +484,7 @@ ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name);
484484
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len);
485485
ZEND_API void ZEND_FASTCALL zend_init_func_run_time_cache(zend_op_array *op_array);
486486

487-
ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type);
487+
ZEND_API void zend_fetch_dimension_const(zval *result, const zval *container, zval *dim, int type);
488488

489489
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
490490

0 commit comments

Comments
 (0)