Cleanup. Removed unused functions and unimplemented prototype. Avoid useless "dtor_obj" calls.

This commit is contained in:
Dmitry Stogov 2017-06-27 12:03:06 +03:00
parent b6ee9dd490
commit 908ce66f73
3 changed files with 13 additions and 36 deletions

View file

@ -76,7 +76,7 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
ZEND_API void zend_objects_destroy_object(zend_object *object)
{
zend_function *destructor = object ? object->ce->destructor : NULL;
zend_function *destructor = object->ce->destructor;
if (destructor) {
zend_object *old_exception;

View file

@ -50,9 +50,14 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects)
if (IS_OBJ_VALID(obj)) {
if (!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
GC_REFCOUNT(obj)++;
obj->handlers->dtor_obj(obj);
GC_REFCOUNT(obj)--;
if (obj->handlers->dtor_obj
&& (obj->handlers->dtor_obj != zend_objects_destroy_object
|| obj->ce->destructor)) {
GC_REFCOUNT(obj)++;
obj->handlers->dtor_obj(obj);
GC_REFCOUNT(obj)--;
}
}
}
}
@ -149,17 +154,6 @@ ZEND_API void zend_objects_store_put(zend_object *object)
SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle], EG(objects_store).free_list_head); \
EG(objects_store).free_list_head = handle;
ZEND_API void zend_objects_store_free(zend_object *object) /* {{{ */
{
uint32_t handle = object->handle;
void *ptr = ((char*)object) - object->handlers->offset;
GC_REMOVE_FROM_BUFFER(object);
efree(ptr);
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle);
}
/* }}} */
ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
{
/* 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) /* {{{ */
if (!(GC_FLAGS(object) & IS_OBJ_DESTRUCTOR_CALLED)) {
GC_FLAGS(object) |= IS_OBJ_DESTRUCTOR_CALLED;
if (object->handlers->dtor_obj) {
if (object->handlers->dtor_obj
&& (object->handlers->dtor_obj != zend_objects_destroy_object
|| object->ce->destructor)) {
GC_REFCOUNT(object)++;
object->handlers->dtor_obj(object);
GC_REFCOUNT(object)--;
@ -204,18 +200,6 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
}
/* }}} */
/* zend_object_store_set_object:
* It is ONLY valid to call this function from within the constructor of an
* overloaded object. Its purpose is to set the object pointer for the object
* when you can't possibly know its value until you have parsed the arguments
* from the constructor function. You MUST NOT use this function for any other
* weird games, or call it at any other time after the object is constructed.
* */
ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object)
{
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zobject)] = object;
}
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void)
{
return &std_object_handlers;

View file

@ -52,15 +52,12 @@ BEGIN_EXTERN_C()
ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size);
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects);
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects);
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects, zend_bool fast_shutdown);
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
/* Store API functions */
ZEND_API void zend_objects_store_put(zend_object *object);
ZEND_API void zend_objects_store_del(zend_object *object);
ZEND_API void zend_objects_store_free(zend_object *object);
/* See comment in zend_objects_API.c before you use this */
ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object);
/* Called when the ctor was terminated by an exception */
static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
@ -68,12 +65,8 @@ static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
}
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects, zend_bool fast_shutdown);
#define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj
ZEND_API zend_object *zend_object_create_proxy(zval *object, zval *member);
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
END_EXTERN_C()