Skip to content

Commit 25bc7e8

Browse files
committed
Revert "Zend: use type uint32_t for default_properties_count CE field"
This reverts commit 6bcc093.
1 parent 2db66f2 commit 25bc7e8

File tree

9 files changed

+39
-28
lines changed

9 files changed

+39
-28
lines changed

Zend/zend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct _zend_class_entry {
156156
uint32_t ce_flags;
157157
uint32_t ce_flags2;
158158

159-
uint32_t default_properties_count;
159+
int default_properties_count;
160160
uint32_t default_static_members_count;
161161
zval *default_properties_table;
162162
zval *default_static_members_table;

Zend/zend_lazy_objects.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,12 @@ ZEND_API zend_object *zend_object_make_lazy(zend_object *obj,
269269
obj = zend_objects_new(reflection_ce);
270270

271271
/* Iterate in reverse to avoid overriding Z_PROP_FLAG_P() of child props with added hooks (GH-17870). */
272-
for (uint32_t i = obj->ce->default_properties_count - 1; i > 0; i--) {
273-
uint32_t index = i - 1;
274-
zval *p = &obj->properties_table[index];
272+
for (int i = obj->ce->default_properties_count - 1; i >= 0; i--) {
273+
zval *p = &obj->properties_table[i];
275274
ZVAL_UNDEF(p);
276275
Z_PROP_FLAG_P(p) = 0;
277276

278-
zend_property_info *prop_info = obj->ce->properties_info_table[index];
277+
zend_property_info *prop_info = obj->ce->properties_info_table[i];
279278
if (prop_info) {
280279
zval *p = &obj->properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
281280
Z_PROP_FLAG_P(p) = IS_PROP_UNINIT | IS_PROP_LAZY;
@@ -327,7 +326,7 @@ ZEND_API zend_object *zend_object_make_lazy(zend_object *obj,
327326
}
328327

329328
/* unset() declared properties */
330-
for (uint32_t i = 0; i < reflection_ce->default_properties_count; i++) {
329+
for (int i = 0; i < reflection_ce->default_properties_count; i++) {
331330
zend_property_info *prop_info = obj->ce->properties_info_table[i];
332331
if (EXPECTED(prop_info)) {
333332
zval *p = &obj->properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
@@ -391,7 +390,7 @@ ZEND_API zend_object *zend_lazy_object_mark_as_initialized(zend_object *obj)
391390

392391
OBJ_EXTRA_FLAGS(obj) &= ~(IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY);
393392

394-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
393+
for (int i = 0; i < ce->default_properties_count; i++) {
395394
if (Z_PROP_FLAG_P(&properties_table[i]) & IS_PROP_LAZY) {
396395
ZVAL_COPY_PROP(&properties_table[i], &default_properties_table[i]);
397396
}
@@ -411,7 +410,7 @@ static void zend_lazy_object_revert_init(zend_object *obj, zval *properties_tabl
411410
ZEND_ASSERT(properties_table_snapshot);
412411
zval *properties_table = obj->properties_table;
413412

414-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
413+
for (int i = 0; i < ce->default_properties_count; i++) {
415414
zend_property_info *prop_info = ce->properties_info_table[i];
416415
if (!prop_info) {
417416
continue;
@@ -533,7 +532,7 @@ static zend_object *zend_lazy_object_init_proxy(zend_object *obj)
533532
zend_object_dtor_dynamic_properties(obj);
534533
obj->properties = NULL;
535534

536-
for (uint32_t i = 0; i < Z_OBJ(retval)->ce->default_properties_count; i++) {
535+
for (int i = 0; i < Z_OBJ(retval)->ce->default_properties_count; i++) {
537536
zend_property_info *prop_info = Z_OBJ(retval)->ce->properties_info_table[i];
538537
if (EXPECTED(prop_info)) {
539538
zval *prop = &obj->properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
@@ -609,7 +608,7 @@ ZEND_API zend_object *zend_lazy_object_init(zend_object *obj)
609608
zval *properties_table = obj->properties_table;
610609
properties_table_snapshot = emalloc(sizeof(*properties_table_snapshot) * ce->default_properties_count);
611610

612-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
611+
for (int i = 0; i < ce->default_properties_count; i++) {
613612
ZVAL_COPY_PROP(&properties_table_snapshot[i], &properties_table[i]);
614613
if (Z_PROP_FLAG_P(&properties_table[i]) & IS_PROP_LAZY) {
615614
ZVAL_COPY_PROP(&properties_table[i], &default_properties_table[i]);
@@ -641,7 +640,7 @@ ZEND_API zend_object *zend_lazy_object_init(zend_object *obj)
641640
}
642641

643642
if (properties_table_snapshot) {
644-
for (uint32_t i = 0; i < obj->ce->default_properties_count; i++) {
643+
for (int i = 0; i < obj->ce->default_properties_count; i++) {
645644
zval *p = &properties_table_snapshot[i];
646645
/* Use zval_ptr_dtor directly here (not zend_object_dtor_property),
647646
* as any reference type_source will have already been deleted in
@@ -682,7 +681,7 @@ void zend_lazy_object_realize(zend_object *obj)
682681
zend_lazy_object_del_info(obj);
683682

684683
#if ZEND_DEBUG
685-
for (uint32_t i = 0; i < obj->ce->default_properties_count; i++) {
684+
for (int i = 0; i < obj->ce->default_properties_count; i++) {
686685
ZEND_ASSERT(!(Z_PROP_FLAG_P(&obj->properties_table[i]) & IS_PROP_LAZY));
687686
}
688687
#endif
@@ -733,13 +732,12 @@ zend_object *zend_lazy_object_clone(zend_object *old_obj)
733732
zend_object *new_proxy = zend_objects_new(ce);
734733

735734
/* Iterate in reverse to avoid overriding Z_PROP_FLAG_P() of child props with added hooks (GH-17870). */
736-
for (uint32_t i = ce->default_properties_count; i > 0; i--) {
737-
uint32_t index = i - 1;
738-
zval *p = &new_proxy->properties_table[index];
735+
for (int i = ce->default_properties_count - 1; i >= 0; i--) {
736+
zval *p = &new_proxy->properties_table[i];
739737
ZVAL_UNDEF(p);
740738
Z_PROP_FLAG_P(p) = 0;
741739

742-
zend_property_info *prop_info = ce->properties_info_table[index];
740+
zend_property_info *prop_info = ce->properties_info_table[i];
743741
if (prop_info) {
744742
zval *p = &new_proxy->properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
745743
Z_PROP_FLAG_P(p) = IS_PROP_UNINIT | IS_PROP_LAZY;

Zend/zend_object_handlers.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ ZEND_API HashTable *rebuild_object_properties_internal(zend_object *zobj) /* {{{
7777
if (!zobj->properties) {
7878
zend_property_info *prop_info;
7979
zend_class_entry *ce = zobj->ce;
80+
int i;
8081

8182
zobj->properties = zend_new_array(ce->default_properties_count);
8283
if (ce->default_properties_count) {
8384
zend_hash_real_init_mixed(zobj->properties);
84-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
85+
for (i = 0; i < ce->default_properties_count; i++) {
8586
prop_info = ce->properties_info_table[i];
8687

8788
if (!prop_info) {
@@ -109,13 +110,14 @@ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /*
109110
zend_class_entry *ce = zobj->ce;
110111
HashTable *ht;
111112
zval* prop;
113+
int i;
112114

113115
ZEND_ASSERT(!(zend_object_is_lazy_proxy(zobj) && zend_lazy_object_initialized(zobj)));
114116
ZEND_ASSERT(!zobj->properties);
115117
ht = zend_new_array(ce->default_properties_count);
116118
if (ce->default_properties_count) {
117119
zend_hash_real_init_mixed(ht);
118-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
120+
for (i = 0; i < ce->default_properties_count; i++) {
119121
prop_info = ce->properties_info_table[i];
120122

121123
if (!prop_info) {
@@ -2188,6 +2190,7 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
21882190
if (!zobj1->properties && !zobj2->properties
21892191
&& !zend_object_is_lazy(zobj1) && !zend_object_is_lazy(zobj2)) {
21902192
zend_property_info *info;
2193+
int i;
21912194

21922195
if (!zobj1->ce->default_properties_count) {
21932196
return 0;
@@ -2208,7 +2211,7 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
22082211
GC_ADDREF(zobj2);
22092212
int ret;
22102213

2211-
for (uint32_t i = 0; i < zobj1->ce->default_properties_count; i++) {
2214+
for (i = 0; i < zobj1->ce->default_properties_count; i++) {
22122215
zval *p1, *p2;
22132216

22142217
info = zobj1->ce->properties_info_table[i];

ext/json/json_encoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options,
147147

148148
++encoder->depth;
149149

150-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
150+
for (int i = 0; i < ce->default_properties_count; i++) {
151151
zend_property_info *prop_info = ce->properties_info_table[i];
152152
if (!prop_info) {
153153
continue;

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3903,9 +3903,10 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
39033903
ce->ce_flags &= ~ZEND_ACC_HAS_AST_CONSTANTS;
39043904
}
39053905
if (ce->default_properties_count) {
3906+
uint32_t i;
39063907
bool resolved = true;
39073908

3908-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
3909+
for (i = 0; i < ce->default_properties_count; i++) {
39093910
zend_property_info *prop = ce->properties_info_table[i];
39103911
if (!prop) {
39113912
continue;

ext/opcache/zend_file_cache.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,13 +813,14 @@ static void zend_file_cache_serialize_class(zval *zv,
813813
zend_file_cache_serialize_hash(&ce->properties_info, script, info, buf, zend_file_cache_serialize_prop_info);
814814

815815
if (ce->properties_info_table) {
816+
uint32_t i;
816817
zend_property_info **table;
817818

818819
SERIALIZE_PTR(ce->properties_info_table);
819820
table = ce->properties_info_table;
820821
UNSERIALIZE_PTR(table);
821822

822-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
823+
for (i = 0; i < ce->default_properties_count; i++) {
823824
SERIALIZE_PTR(table[i]);
824825
}
825826
}
@@ -1697,9 +1698,10 @@ static void zend_file_cache_unserialize_class(zval *zv,
16971698
script, buf, zend_file_cache_unserialize_prop_info, NULL);
16981699

16991700
if (ce->properties_info_table) {
1701+
uint32_t i;
17001702
UNSERIALIZE_PTR(ce->properties_info_table);
17011703

1702-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
1704+
for (i = 0; i < ce->default_properties_count; i++) {
17031705
UNSERIALIZE_PTR(ce->properties_info_table[i]);
17041706
}
17051707
}

ext/opcache/zend_persist.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,10 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce)
959959
} ZEND_HASH_FOREACH_END();
960960
HT_FLAGS(&ce->function_table) &= (HASH_FLAG_UNINITIALIZED | HASH_FLAG_STATIC_KEYS);
961961
if (ce->default_properties_table) {
962+
int i;
963+
962964
ce->default_properties_table = zend_shared_memdup_free(ce->default_properties_table, sizeof(zval) * ce->default_properties_count);
963-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
965+
for (i = 0; i < ce->default_properties_count; i++) {
964966
zend_persist_zval(&ce->default_properties_table[i]);
965967
}
966968
}
@@ -1012,12 +1014,14 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce)
10121014
HT_FLAGS(&ce->properties_info) &= (HASH_FLAG_UNINITIALIZED | HASH_FLAG_STATIC_KEYS);
10131015

10141016
if (ce->properties_info_table) {
1017+
int i;
1018+
10151019
size_t size = sizeof(zend_property_info *) * ce->default_properties_count;
10161020
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED);
10171021
ce->properties_info_table = zend_shared_memdup(
10181022
ce->properties_info_table, size);
10191023

1020-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
1024+
for (i = 0; i < ce->default_properties_count; i++) {
10211025
if (ce->properties_info_table[i]) {
10221026
zend_property_info *prop_info = zend_shared_alloc_get_xlat_entry(
10231027
ce->properties_info_table[i]);

ext/opcache/zend_persist_calc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,10 @@ void zend_persist_class_entry_calc(zend_class_entry *ce)
471471
zend_persist_class_method_calc(Z_PTR(p->val));
472472
} ZEND_HASH_FOREACH_END();
473473
if (ce->default_properties_table) {
474+
int i;
475+
474476
ADD_SIZE(sizeof(zval) * ce->default_properties_count);
475-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
477+
for (i = 0; i < ce->default_properties_count; i++) {
476478
zend_persist_zval_calc(&ce->default_properties_table[i]);
477479
}
478480
}

ext/standard/var.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,9 +1243,10 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
12431243
zend_class_entry *ce = obj->ce;
12441244
zend_property_info *prop_info;
12451245
zval *prop;
1246+
int i;
12461247

12471248
count = ce->default_properties_count;
1248-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
1249+
for (i = 0; i < ce->default_properties_count; i++) {
12491250
prop_info = ce->properties_info_table[i];
12501251
if (!prop_info) {
12511252
count--;
@@ -1260,7 +1261,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
12601261
if (count) {
12611262
smart_str_append_unsigned(buf, count);
12621263
smart_str_appendl(buf, ":{", 2);
1263-
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
1264+
for (i = 0; i < ce->default_properties_count; i++) {
12641265
prop_info = ce->properties_info_table[i];
12651266
if (!prop_info) {
12661267
continue;

0 commit comments

Comments
 (0)