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:
Dmitry Stogov 2017-10-27 01:28:58 +03:00
parent 1ab0d820da
commit 49ea143bbd
66 changed files with 408 additions and 345 deletions

View file

@ -1850,7 +1850,7 @@ ZEND_METHOD(reflection_function, getStaticVariables)
array_init(return_value);
if (GC_REFCOUNT(fptr->op_array.static_variables) > 1) {
if (!(GC_FLAGS(fptr->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
GC_REFCOUNT(fptr->op_array.static_variables)--;
GC_DELREF(fptr->op_array.static_variables);
}
fptr->op_array.static_variables = zend_array_dup(fptr->op_array.static_variables);
}
@ -2278,7 +2278,7 @@ ZEND_METHOD(reflection_generator, getExecutingGenerator)
REFLECTION_CHECK_VALID_GENERATOR(ex)
current = zend_generator_get_current(generator);
++GC_REFCOUNT(&current->std);
GC_ADDREF(&current->std);
ZVAL_OBJ(return_value, (zend_object *) current);
}