Skip to content

Commit 908ce66

Browse files
committed
Cleanup. Removed unused functions and unimplemented prototype. Avoid useless "dtor_obj" calls.
1 parent b6ee9dd commit 908ce66

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

Zend/zend_objects.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
7676

7777
ZEND_API void zend_objects_destroy_object(zend_object *object)
7878
{
79-
zend_function *destructor = object ? object->ce->destructor : NULL;
79+
zend_function *destructor = object->ce->destructor;
8080

8181
if (destructor) {
8282
zend_object *old_exception;

Zend/zend_objects_API.c

+11-27
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects)
5050
if (IS_OBJ_VALID(obj)) {
5151
if (!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
5252
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
53-
GC_REFCOUNT(obj)++;
54-
obj->handlers->dtor_obj(obj);
55-
GC_REFCOUNT(obj)--;
53+
54+
if (obj->handlers->dtor_obj
55+
&& (obj->handlers->dtor_obj != zend_objects_destroy_object
56+
|| obj->ce->destructor)) {
57+
GC_REFCOUNT(obj)++;
58+
obj->handlers->dtor_obj(obj);
59+
GC_REFCOUNT(obj)--;
60+
}
5661
}
5762
}
5863
}
@@ -149,17 +154,6 @@ ZEND_API void zend_objects_store_put(zend_object *object)
149154
SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle], EG(objects_store).free_list_head); \
150155
EG(objects_store).free_list_head = handle;
151156

152-
ZEND_API void zend_objects_store_free(zend_object *object) /* {{{ */
153-
{
154-
uint32_t handle = object->handle;
155-
void *ptr = ((char*)object) - object->handlers->offset;
156-
157-
GC_REMOVE_FROM_BUFFER(object);
158-
efree(ptr);
159-
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle);
160-
}
161-
/* }}} */
162-
163157
ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
164158
{
165159
/* Make sure we hold a reference count during the destructor call
@@ -172,7 +166,9 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
172166
if (!(GC_FLAGS(object) & IS_OBJ_DESTRUCTOR_CALLED)) {
173167
GC_FLAGS(object) |= IS_OBJ_DESTRUCTOR_CALLED;
174168

175-
if (object->handlers->dtor_obj) {
169+
if (object->handlers->dtor_obj
170+
&& (object->handlers->dtor_obj != zend_objects_destroy_object
171+
|| object->ce->destructor)) {
176172
GC_REFCOUNT(object)++;
177173
object->handlers->dtor_obj(object);
178174
GC_REFCOUNT(object)--;
@@ -204,18 +200,6 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
204200
}
205201
/* }}} */
206202

207-
/* zend_object_store_set_object:
208-
* It is ONLY valid to call this function from within the constructor of an
209-
* overloaded object. Its purpose is to set the object pointer for the object
210-
* when you can't possibly know its value until you have parsed the arguments
211-
* from the constructor function. You MUST NOT use this function for any other
212-
* weird games, or call it at any other time after the object is constructed.
213-
* */
214-
ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object)
215-
{
216-
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zobject)] = object;
217-
}
218-
219203
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void)
220204
{
221205
return &std_object_handlers;

Zend/zend_objects_API.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,21 @@ BEGIN_EXTERN_C()
5252
ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size);
5353
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects);
5454
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects);
55+
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects, zend_bool fast_shutdown);
5556
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
5657

5758
/* Store API functions */
5859
ZEND_API void zend_objects_store_put(zend_object *object);
5960
ZEND_API void zend_objects_store_del(zend_object *object);
60-
ZEND_API void zend_objects_store_free(zend_object *object);
61-
62-
/* See comment in zend_objects_API.c before you use this */
63-
ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object);
6461

6562
/* Called when the ctor was terminated by an exception */
6663
static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
6764
{
6865
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
6966
}
7067

71-
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects, zend_bool fast_shutdown);
72-
7368
#define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj
7469

75-
ZEND_API zend_object *zend_object_create_proxy(zval *object, zval *member);
76-
7770
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
7871
END_EXTERN_C()
7972

0 commit comments

Comments
 (0)