Skip to content

Commit bf48ef8

Browse files
committed
Cleanup
1 parent ea72fe6 commit bf48ef8

File tree

13 files changed

+309
-386
lines changed

13 files changed

+309
-386
lines changed

Zend/zend_alloc.c

Lines changed: 286 additions & 255 deletions
Large diffs are not rendered by default.

Zend/zend_alloc.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ ZEND_API void zend_memory_reset_peak_usage(void);
243243
/* Heap functions */
244244
typedef struct _zend_mm_heap zend_mm_heap;
245245

246-
ZEND_API void ZEND_FASTCALL _zend_mm_validate(zend_mm_heap *heap);
247-
ZEND_API void ZEND_FASTCALL zend_mm_validate_fast(zend_mm_heap *heap);
248-
249246
ZEND_API zend_mm_heap *zend_mm_startup(void);
250247
ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full_shutdown, bool silent);
251248
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(2);
@@ -254,8 +251,6 @@ ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size
254251
ZEND_API void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *p, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
255252
ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
256253

257-
#define zend_mm_validate(heap) _zend_mm_validate((heap))
258-
259254
#define zend_mm_alloc(heap, size) _zend_mm_alloc((heap), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
260255
#define zend_mm_free(heap, p) _zend_mm_free((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
261256
#define zend_mm_realloc(heap, p, size) _zend_mm_realloc((heap), (p), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)

Zend/zend_execute_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ void shutdown_executor(void) /* {{{ */
430430
zend_string *key;
431431
zval *zv;
432432
#if ZEND_DEBUG
433-
bool fast_shutdown = 1;
433+
bool fast_shutdown = 0;
434434
#else
435-
bool fast_shutdown = !EG(full_tables_cleanup);
435+
bool fast_shutdown = is_zend_mm() && !EG(full_tables_cleanup);
436436
#endif
437437

438438
zend_try {

Zend/zend_gc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,6 @@ ZEND_API int zend_gc_collect_cycles(void)
20452045
/* Modify current before calling free_obj (bug #78811: free_obj() can cause the root buffer (with current) to be reallocated.) */
20462046
current->ref = GC_MAKE_GARBAGE(((char*)obj) - obj->handlers->offset);
20472047
if (!(OBJ_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
2048-
printf("Invoking free on %p inside GC\n", obj);
20492048
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
20502049
GC_ADDREF(obj);
20512050
obj->handlers->free_obj(obj);

Zend/zend_objects_API.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_mark_destructed(zend_objects_stor
8282

8383
ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_store *objects, bool fast_shutdown)
8484
{
85-
zend_object **obj_ptr, **end, *obj, *obj_next;
85+
zend_object **obj_ptr, **end, *obj;
8686

8787
if (objects->top <= 1) {
8888
return;
@@ -94,41 +94,18 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
9494
obj_ptr = objects->object_buckets + objects->top;
9595

9696
if (fast_shutdown) {
97-
bool first = true;
98-
ptrdiff_t cnt = 1;
99-
ptrdiff_t total = obj_ptr-end;
10097
do {
10198
obj_ptr--;
10299
obj = *obj_ptr;
103100
if (IS_OBJ_VALID(obj)) {
104101
if (!(OBJ_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
105-
printf("Freeing object %td/%td: %s\n", cnt++, total, ZSTR_VAL(obj->ce->name));
106-
107-
//zend_mm_validate(zend_mm_get_heap());
108-
//puts("Pre flags OK\n");
109-
110-
printf("Invoking free on %p during free_object_storage\n", obj);
111102
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
112-
113-
//zend_mm_validate(zend_mm_get_heap());
114-
//puts("Post flags OK\n");
115-
116103
if (obj->handlers->free_obj != zend_object_std_dtor) {
117104
GC_ADDREF(obj);
118-
119-
//zend_mm_validate(zend_mm_get_heap());
120-
//puts("Pre validation OK\n");
121-
122105
obj->handlers->free_obj(obj);
123-
} else {
124-
printf("Skipping free on %p during free_object_storage\n", obj);
125106
}
126-
127-
//zend_mm_validate(zend_mm_get_heap());
128-
//puts("Post validation OK\n");
129107
}
130108
}
131-
first = false;
132109
} while (obj_ptr != end);
133110
} else {
134111
do {
@@ -139,7 +116,6 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
139116
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
140117
GC_ADDREF(obj);
141118
obj->handlers->free_obj(obj);
142-
printf("Invoking free on %p\n", obj);
143119
}
144120
}
145121
} while (obj_ptr != end);
@@ -216,9 +192,6 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *
216192
GC_ADD_FLAGS(object, IS_OBJ_FREE_CALLED);
217193
GC_SET_REFCOUNT(object, 1);
218194
object->handlers->free_obj(object);
219-
printf("Freeing %p and invoking free\n", object);
220-
} else {
221-
printf("Freeing %p without invoking free (%d)\n", object, OBJ_FLAGS(object));
222195
}
223196
ptr = ((char*)object) - object->handlers->offset;
224197
GC_REMOVE_FROM_BUFFER(object);

Zend/zend_variables.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr)
4242
if (Z_REFCOUNTED_P(zval_ptr)) {
4343
zend_refcounted *ref = Z_COUNTED_P(zval_ptr);
4444
if (!GC_DELREF(ref)) {
45-
//printf("Freeing %p\n", zval_ptr);
46-
//fflush(stdout);
4745
rc_dtor_func(ref);
4846
} else {
4947
gc_check_possible_root(ref);

Zend/zend_vm_execute.h

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Zend/zend_vm_execute.skl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *ex)
1313
#endif
1414
{
1515
DCL_OPLINE
16-
if (ex != NULL) {
17-
//zend_mm_validate(zend_mm_get_heap());
18-
}
1916

2017
#if defined(__GNUC__) && defined(__aarch64__)
2118
__asm__ __volatile__ (""::: "v8","v9","v10","v11","v12","v13","v14","v15");

Zend/zend_weakrefs.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ static void zend_weakref_unregister(zend_object *object, void *payload, bool wea
124124
zend_ulong obj_key = zend_object_to_weakref_key(object);
125125
void *tagged_ptr = zend_hash_index_find_ptr(&EG(weakrefs), obj_key);
126126
ZEND_ASSERT(tagged_ptr && "Weakref not registered?");
127-
zend_mm_validate(zend_mm_get_heap());
128127

129128
void *ptr = ZEND_WEAKREF_GET_PTR(tagged_ptr);
130129
uintptr_t tag = ZEND_WEAKREF_GET_TAG(tagged_ptr);
@@ -142,27 +141,20 @@ zend_mm_validate(zend_mm_get_heap());
142141
}
143142
return;
144143
}
145-
zend_mm_validate(zend_mm_get_heap());
146144

147145
HashTable *ht = ptr;
148-
146+
#if ZEND_DEBUG
149147
void *old_payload = zend_hash_index_find_ptr(ht, (zend_ulong) payload);
150-
if (!(old_payload && "Weakref not registered?")) {
151-
abort();
152-
}
153-
if (!(old_payload == payload)) {
154-
abort();
155-
}
156-
zend_mm_validate(zend_mm_get_heap());
148+
ZEND_ASSERT(old_payload && "Weakref not registered?");
149+
ZEND_ASSERT(old_payload == payload);
150+
#endif
157151
zend_hash_index_del(ht, (zend_ulong) payload);
158-
zend_mm_validate(zend_mm_get_heap());
159152
if (zend_hash_num_elements(ht) == 0) {
160153
GC_DEL_FLAGS(object, IS_OBJ_WEAKLY_REFERENCED);
161154
zend_hash_destroy(ht);
162155
FREE_HASHTABLE(ht);
163156
zend_hash_index_del(&EG(weakrefs), obj_key);
164157
}
165-
zend_mm_validate(zend_mm_get_heap());
166158

167159
/* Do this last, as it may destroy the object. */
168160
if (weakref_free) {
@@ -172,7 +164,6 @@ zend_mm_validate(zend_mm_get_heap());
172164
/* The optimization of skipping unref is only used in the destructor of WeakMap */
173165
ZEND_ASSERT(ZEND_WEAKREF_GET_TAG(payload) == ZEND_WEAKREF_TAG_MAP);
174166
}
175-
zend_mm_validate(zend_mm_get_heap());
176167
}
177168

178169
ZEND_API zval *zend_weakrefs_hash_add(HashTable *ht, zend_object *key, zval *pData) {
@@ -199,8 +190,6 @@ void zend_weakrefs_init(void) {
199190
/* This is called when the object is garbage collected
200191
* to remove all WeakReference and WeakMap entries weakly referencing that object. */
201192
void zend_weakrefs_notify(zend_object *object) {
202-
printf("Notify from %p\n", object);
203-
204193
/* Annoyingly we can't use the HT destructor here, because we need access to the key (which
205194
* is the object address), which is not provided to the dtor. */
206195
const zend_ulong obj_key = zend_object_to_weakref_key(object);
@@ -339,28 +328,17 @@ static zend_object *zend_weakmap_create_object(zend_class_entry *ce)
339328

340329
static void zend_weakmap_free_obj(zend_object *object)
341330
{
342-
zend_mm_validate(zend_mm_get_heap());
343331
zend_weakmap *wm = zend_weakmap_from(object);
344-
zend_mm_validate(zend_mm_get_heap());
345332
zend_ulong obj_key;
346333
ZEND_HASH_MAP_FOREACH_NUM_KEY(&wm->ht, obj_key) {
347334
/* Optimization: Don't call zend_weakref_unref_single to free individual entries from wm->ht when unregistering (which would do a hash table lookup, call zend_hash_index_del, and skip over any bucket collisions).
348335
* Let freeing the corresponding values for WeakMap entries be done in zend_hash_destroy, freeing objects sequentially.
349336
* The performance difference is notable for larger WeakMaps with worse cache locality. */
350-
zend_mm_validate(zend_mm_get_heap());
351-
zend_object *a = zend_weakref_key_to_object(obj_key);
352-
zend_mm_validate(zend_mm_get_heap());
353-
void *p = ZEND_WEAKREF_ENCODE(&wm->ht, ZEND_WEAKREF_TAG_MAP);
354-
zend_mm_validate(zend_mm_get_heap());
355-
zend_weakref_unregister(a, p, 0);
356-
//zend_mm_validate(zend_mm_get_heap());
337+
zend_weakref_unregister(
338+
zend_weakref_key_to_object(obj_key), ZEND_WEAKREF_ENCODE(&wm->ht, ZEND_WEAKREF_TAG_MAP), 0);
357339
} ZEND_HASH_FOREACH_END();
358-
//zend_mm_validate(zend_mm_get_heap());
359340
zend_hash_destroy(&wm->ht);
360-
//zend_mm_validate_fast(zend_mm_get_heap());
361-
//zend_mm_validate(zend_mm_get_heap());
362341
zend_object_std_dtor(&wm->std);
363-
//zend_mm_validate(zend_mm_get_heap());
364342
}
365343

366344
static zval *zend_weakmap_read_dimension(zend_object *object, zval *offset, int type, zval *rv)

ext/standard/basic_functions_arginfo.h

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)