mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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.
This commit is contained in:
parent
1ab0d820da
commit
49ea143bbd
66 changed files with 408 additions and 345 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue