diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-10-27 01:28:58 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-10-27 01:28:58 +0300 |
commit | 49ea143bbd8d0bfcd393d0b5308a5d7833fc087c (patch) | |
tree | 071b08e8067e5a6a1e9726e3d76dfe81cc42d6b0 /Zend/zend_objects_API.c | |
parent | 1ab0d820dabc612b7d371d6ed524f60f68101d0f (diff) | |
download | php-git-49ea143bbd8d0bfcd393d0b5308a5d7833fc087c.tar.gz |
Encapsulate reference-counting primitives.
Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead.
Added mactros to validate reference-counting (disabled for now).
These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads.
Diffstat (limited to 'Zend/zend_objects_API.c')
-rw-r--r-- | Zend/zend_objects_API.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index d4de16fde1..2739ed23e7 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -54,9 +54,9 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects) if (obj->handlers->dtor_obj && (obj->handlers->dtor_obj != zend_objects_destroy_object || obj->ce->destructor)) { - GC_REFCOUNT(obj)++; + GC_ADDREF(obj); obj->handlers->dtor_obj(obj); - GC_REFCOUNT(obj)--; + GC_DELREF(obj); } } } @@ -101,9 +101,9 @@ ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects if (!(GC_FLAGS(obj) & IS_OBJ_FREE_CALLED)) { GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED; if (obj->handlers->free_obj && obj->handlers->free_obj != zend_object_std_dtor) { - GC_REFCOUNT(obj)++; + GC_ADDREF(obj); obj->handlers->free_obj(obj); - GC_REFCOUNT(obj)--; + GC_DELREF(obj); } } } @@ -116,9 +116,9 @@ ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects if (!(GC_FLAGS(obj) & IS_OBJ_FREE_CALLED)) { GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED; if (obj->handlers->free_obj) { - GC_REFCOUNT(obj)++; + GC_ADDREF(obj); obj->handlers->free_obj(obj); - GC_REFCOUNT(obj)--; + GC_DELREF(obj); } } } @@ -169,9 +169,9 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */ if (object->handlers->dtor_obj && (object->handlers->dtor_obj != zend_objects_destroy_object || object->ce->destructor)) { - GC_REFCOUNT(object)++; + GC_ADDREF(object); object->handlers->dtor_obj(object); - GC_REFCOUNT(object)--; + GC_DELREF(object); } } @@ -183,9 +183,9 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */ if (!(GC_FLAGS(object) & IS_OBJ_FREE_CALLED)) { GC_FLAGS(object) |= IS_OBJ_FREE_CALLED; if (object->handlers->free_obj) { - GC_REFCOUNT(object)++; + GC_ADDREF(object); object->handlers->free_obj(object); - GC_REFCOUNT(object)--; + GC_DELREF(object); } } ptr = ((char*)object) - object->handlers->offset; @@ -194,7 +194,7 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */ ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle); } } else { - GC_REFCOUNT(object)--; + GC_DELREF(object); } } } |