Skip to content

Commit d0f7f8c

Browse files
committed
Zend/zend_execute.c: add const qualifiers
1 parent 2568744 commit d0f7f8c

File tree

2 files changed

+46
-35
lines changed

2 files changed

+46
-35
lines changed

Zend/zend_execute.c

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_err
647647
}
648648

649649
/* this should modify object only if it's empty */
650-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_error(const zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
650+
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)
651651
{
652652
zend_string *tmp_property_name;
653653
zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
@@ -1710,7 +1710,7 @@ static zend_never_inline void zend_binary_assign_op_typed_prop(const zend_proper
17101710
}
17111711
}
17121712

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

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

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

2210-
static ZEND_COLD zend_long zend_throw_incdec_prop_error(zend_property_info *prop OPLINE_DC) {
2210+
static ZEND_COLD zend_long zend_throw_incdec_prop_error(const zend_property_info *prop OPLINE_DC) {
22112211
zend_string *type_str = zend_type_to_string(prop->type);
22122212
if (ZEND_IS_INCREMENT(opline->opcode)) {
22132213
zend_type_error("Cannot increment property %s::$%s of type %s past its maximal value",
@@ -2258,7 +2258,7 @@ static void zend_incdec_typed_ref(zend_reference *ref, zval *copy OPLINE_DC EXEC
22582258
}
22592259
}
22602260

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

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

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

2329-
static void zend_post_incdec_property_zval(zval *prop, zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
2329+
static void zend_post_incdec_property_zval(zval *prop, const zend_property_info *prop_info OPLINE_DC EXECUTE_DATA_DC)
23302330
{
23312331
if (EXPECTED(Z_TYPE_P(prop) == IS_LONG)) {
23322332
ZVAL_LONG(EX_VAR(opline->result.var), Z_LVAL_P(prop));
@@ -2554,7 +2554,7 @@ ZEND_API zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_method(co
25542554
zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(method));
25552555
}
25562556

2557-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_invalid_method_call(zval *object, zval *function_name)
2557+
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_invalid_method_call(const zval *object, const zval *function_name)
25582558
{
25592559
zend_throw_error(NULL, "Call to a member function %s() on %s",
25602560
Z_STRVAL_P(function_name), zend_zval_value_name(object));
@@ -2618,7 +2618,7 @@ ZEND_API zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_call_stack_size_err
26182618
}
26192619
#endif /* ZEND_CHECK_STACK_LIMIT */
26202620

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

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

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

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

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

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

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

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

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

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

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

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

3371-
static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable *ht, zval *key OPLINE_DC EXECUTE_DATA_DC)
3371+
static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable *ht, const zval *key OPLINE_DC EXECUTE_DATA_DC)
33723372
{
33733373
zend_string *str;
33743374
zend_ulong hval;
@@ -3427,7 +3427,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable
34273427
}
34283428

34293429
static ZEND_COLD void ZEND_FASTCALL zend_array_key_exists_error(
3430-
zval *subject, zval *key OPLINE_DC EXECUTE_DATA_DC)
3430+
const zval *subject, const zval *key OPLINE_DC EXECUTE_DATA_DC)
34313431
{
34323432
if (Z_TYPE_P(key) == IS_UNDEF) {
34333433
ZVAL_UNDEFINED_OP1();
@@ -3441,7 +3441,7 @@ static ZEND_COLD void ZEND_FASTCALL zend_array_key_exists_error(
34413441
}
34423442
}
34433443

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

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

3654-
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)
3664+
static zend_always_inline void zend_assign_to_property_reference(const zval *container, uint32_t container_op_type,
3665+
const zval *prop_ptr, uint32_t prop_op_type, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
36553666
{
36563667
zval variable, *variable_ptr = &variable;
36573668
void **cache_addr = (prop_op_type == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_RETURNS_FUNCTION) : NULL;
@@ -3690,25 +3701,25 @@ static zend_always_inline void zend_assign_to_property_reference(zval *container
36903701
}
36913702
}
36923703

3693-
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)
3704+
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)
36943705
{
36953706
zend_assign_to_property_reference(container, IS_UNUSED, prop_ptr, IS_CONST, value_ptr
36963707
OPLINE_CC EXECUTE_DATA_CC);
36973708
}
36983709

3699-
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)
3710+
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)
37003711
{
37013712
zend_assign_to_property_reference(container, IS_VAR, prop_ptr, IS_CONST, value_ptr
37023713
OPLINE_CC EXECUTE_DATA_CC);
37033714
}
37043715

3705-
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)
3716+
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)
37063717
{
37073718
zend_assign_to_property_reference(container, IS_UNUSED, prop_ptr, IS_VAR, value_ptr
37083719
OPLINE_CC EXECUTE_DATA_CC);
37093720
}
37103721

3711-
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)
3722+
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)
37123723
{
37133724
zend_assign_to_property_reference(container, IS_VAR, prop_ptr, IS_VAR, value_ptr
37143725
OPLINE_CC EXECUTE_DATA_CC);
@@ -4481,7 +4492,7 @@ ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name) /*
44814492

44824493
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len) /* {{{ */
44834494
{
4484-
zval *zv = zend_hash_str_find(EG(function_table), name, len);
4495+
const zval *zv = zend_hash_str_find(EG(function_table), name, len);
44854496

44864497
if (EXPECTED(zv != NULL)) {
44874498
zend_function *fbc = Z_FUNC_P(zv);
@@ -4905,7 +4916,7 @@ static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num,
49054916

49064917
/* Handle the split range for loop vars */
49074918
if (catch_op_num) {
4908-
zend_op *final_op = EX(func)->op_array.opcodes + range->end;
4919+
const zend_op *final_op = EX(func)->op_array.opcodes + range->end;
49094920
if (final_op->extended_value & ZEND_FREE_ON_RETURN && (final_op->opcode == ZEND_FE_FREE || final_op->opcode == ZEND_FREE)) {
49104921
if (catch_op_num < range->end + final_op->op2.num) {
49114922
continue;
@@ -5193,7 +5204,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zend_o
51935204
}
51945205
/* }}} */
51955206

5196-
static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_array *function, uint32_t num_args) /* {{{ */
5207+
static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(const zend_array *function, uint32_t num_args) /* {{{ */
51975208
{
51985209
zend_function *fbc;
51995210
void *object_or_called_scope;
@@ -5284,7 +5295,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
52845295

52855296
#define ZEND_FAKE_OP_ARRAY ((zend_op_array*)(intptr_t)-1)
52865297

5287-
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval *inc_filename_zv, int type) /* {{{ */
5298+
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(const zval *inc_filename_zv, int type) /* {{{ */
52885299
{
52895300
zend_op_array *new_op_array = NULL;
52905301
zend_string *tmp_inc_filename;

Zend/zend_execute.h

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

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

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

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

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

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

0 commit comments

Comments
 (0)