summaryrefslogtreecommitdiff
path: root/Zend/zend_objects.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-10-27 01:28:58 +0300
committerDmitry Stogov <dmitry@zend.com>2017-10-27 01:28:58 +0300
commit49ea143bbd8d0bfcd393d0b5308a5d7833fc087c (patch)
tree071b08e8067e5a6a1e9726e3d76dfe81cc42d6b0 /Zend/zend_objects.c
parent1ab0d820dabc612b7d371d6ed524f60f68101d0f (diff)
downloadphp-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.c')
-rw-r--r--Zend/zend_objects.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index 123e5db238..cda43ba806 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -29,7 +29,7 @@
ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce)
{
- GC_REFCOUNT(object) = 1;
+ GC_SET_REFCOUNT(object, 1);
GC_TYPE_INFO(object) = IS_OBJECT | (GC_COLLECTABLE << GC_FLAGS_SHIFT);
object->ce = ce;
object->properties = NULL;
@@ -46,7 +46,7 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
if (object->properties) {
if (EXPECTED(!(GC_FLAGS(object->properties) & IS_ARRAY_IMMUTABLE))) {
- if (EXPECTED(--GC_REFCOUNT(object->properties) == 0)) {
+ if (EXPECTED(GC_DELREF(object->properties) == 0)) {
zend_array_destroy(object->properties);
}
}
@@ -125,7 +125,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
}
}
- GC_REFCOUNT(object)++;
+ GC_ADDREF(object);
ZVAL_OBJ(&obj, object);
/* Make sure that destructors are protected from previously thrown exceptions.
@@ -183,7 +183,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o
/* fast copy */
if (EXPECTED(old_object->handlers == &std_object_handlers)) {
if (EXPECTED(!(GC_FLAGS(old_object->properties) & IS_ARRAY_IMMUTABLE))) {
- GC_REFCOUNT(old_object->properties)++;
+ GC_ADDREF(old_object->properties);
}
new_object->properties = old_object->properties;
return;