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 | |
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.
66 files changed, 408 insertions, 345 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index f881c6c038..fc2b15b54b 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -83,6 +83,10 @@ void (*zend_on_timeout)(int seconds); static void (*zend_message_dispatcher_p)(zend_long message, const void *data); static zval *(*zend_get_configuration_directive_p)(zend_string *name); +#if ZEND_RC_DEBUG +ZEND_API zend_bool zend_rc_debug = 0; +#endif + static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */ { if (!new_value) { diff --git a/Zend/zend_API.h b/Zend/zend_API.h index df9e136e4a..fdc26f3344 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1250,7 +1250,7 @@ static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **des && Z_OBJ_P(arg)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(arg)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(arg)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(arg)->properties)--; + GC_DELREF(Z_OBJ_P(arg)->properties); } Z_OBJ_P(arg)->properties = zend_array_dup(Z_OBJ_P(arg)->properties); } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 9ace0790d5..1dcf5e31e1 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -559,7 +559,7 @@ ZEND_API zend_ast_ref *zend_ast_copy(zend_ast *ast) tree_size = zend_ast_tree_size(ast) + sizeof(zend_ast_ref); ref = emalloc(tree_size); zend_ast_tree_copy(ast, GC_AST(ref)); - GC_REFCOUNT(ref) = 1; + GC_SET_REFCOUNT(ref, 1); GC_TYPE_INFO(ref) = IS_CONSTANT_AST; return ref; } diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 57d91c6635..ee7b38224e 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -171,7 +171,7 @@ ZEND_METHOD(Closure, call) if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) { /* copied upon generator creation */ - --GC_REFCOUNT(&closure->std); + GC_DELREF(&closure->std); } else if (ZEND_USER_CODE(my_function.type) && closure->func.common.scope != Z_OBJCE_P(newthis)) { efree(my_function.op_array.run_time_cache); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 96be2c60b2..11c56cc60c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1061,7 +1061,7 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */ } if (op_array->static_variables) { if (!(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) { - GC_REFCOUNT(op_array->static_variables)++; + GC_ADDREF(op_array->static_variables); } } op_array->run_time_cache = NULL; @@ -4256,7 +4256,7 @@ static void zend_compile_static_var_common(zend_ast *var_ast, zval *value, zend_ if (GC_REFCOUNT(CG(active_op_array)->static_variables) > 1) { if (!(GC_FLAGS(CG(active_op_array)->static_variables) & IS_ARRAY_IMMUTABLE)) { - GC_REFCOUNT(CG(active_op_array)->static_variables)--; + GC_DELREF(CG(active_op_array)->static_variables); } CG(active_op_array)->static_variables = zend_array_dup(CG(active_op_array)->static_variables); } diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index d9ea885a62..c892f701e3 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -100,7 +100,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo previous = zend_read_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv); if (Z_TYPE_P(previous) == IS_NULL) { zend_update_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), &pv); - GC_REFCOUNT(add_previous)--; + GC_DELREF(add_previous); return; } ex = previous; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 8f04518d15..2cc7727863 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -593,11 +593,11 @@ static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *v } ref = Z_REF_P(value_ptr); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); if (Z_REFCOUNTED_P(variable_ptr)) { zend_refcounted *garbage = Z_COUNTED_P(variable_ptr); - if (--GC_REFCOUNT(garbage) == 0) { + if (GC_DELREF(garbage) == 0) { ZVAL_REF(variable_ptr, ref); zval_dtor_func(garbage); return; @@ -1894,7 +1894,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } else if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -2080,7 +2080,7 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec while (EXPECTED(cv != end)) { if (Z_REFCOUNTED_P(cv)) { zend_refcounted *r = Z_COUNTED_P(cv); - if (!--GC_REFCOUNT(r)) { + if (!GC_DELREF(r)) { ZVAL_NULL(cv); zval_dtor_func(r); } else { @@ -2428,7 +2428,7 @@ static void cleanup_unfinished_calls(zend_execute_data *execute_data, uint32_t o if (ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS) { if (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR) { - GC_REFCOUNT(Z_OBJ(call->This))--; + GC_DELREF(Z_OBJ(call->This)); if (GC_REFCOUNT(Z_OBJ(call->This)) == 1) { zend_object_store_ctor_failed(Z_OBJ(call->This)); } @@ -2618,14 +2618,14 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zval * if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ ZEND_ASSERT(GC_TYPE((zend_object*)fbc->common.prototype) == IS_OBJECT); - GC_REFCOUNT((zend_object*)fbc->common.prototype)++; + GC_ADDREF((zend_object*)fbc->common.prototype); call_info |= ZEND_CALL_CLOSURE; if (fbc->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { call_info |= ZEND_CALL_FAKE_CLOSURE; } } else if (object) { call_info |= ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(object)++; /* For $this pointer */ + GC_ADDREF(object); /* For $this pointer */ } } else { zend_throw_error(NULL, "Function name must be a string"); @@ -2721,7 +2721,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar object = NULL; } else { call_info |= ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(object)++; /* For $this pointer */ + GC_ADDREF(object); /* For $this pointer */ } } } else { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 39fce43ccc..44524beded 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -85,19 +85,19 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) { if (value_type == IS_VAR && ref) { ZEND_ASSERT(GC_REFCOUNT(ref) > 1); - --GC_REFCOUNT(ref); + GC_DELREF(ref); } return variable_ptr; } garbage = Z_COUNTED_P(variable_ptr); - if (--GC_REFCOUNT(garbage) == 0) { + if (GC_DELREF(garbage) == 0) { ZVAL_COPY_VALUE(variable_ptr, value); if (value_type & (IS_CONST|IS_CV)) { if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) { Z_ADDREF_P(variable_ptr); } } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) { - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(variable_ptr)) { Z_ADDREF_P(variable_ptr); @@ -120,7 +120,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval Z_ADDREF_P(variable_ptr); } } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) { - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(variable_ptr)) { Z_ADDREF_P(variable_ptr); @@ -223,7 +223,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_in p--; if (Z_REFCOUNTED_P(p)) { zend_refcounted *r = Z_COUNTED_P(p); - if (!--GC_REFCOUNT(r)) { + if (!GC_DELREF(r)) { ZVAL_NULL(p); zval_dtor_func(r); } else { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index e69a84ba6b..2eb4d11920 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -774,7 +774,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / uint32_t call_info; ZEND_ASSERT(GC_TYPE((zend_object*)func->op_array.prototype) == IS_OBJECT); - GC_REFCOUNT((zend_object*)func->op_array.prototype)++; + GC_ADDREF((zend_object*)func->op_array.prototype); call_info = ZEND_CALL_CLOSURE; if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { call_info |= ZEND_CALL_FAKE_CLOSURE; diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index 818539ae75..437c0801e4 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -282,9 +282,9 @@ ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref) if (!GC_G(gc_enabled)) { return; } - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); gc_collect_cycles(); - GC_REFCOUNT(ref)--; + GC_DELREF(ref); if (UNEXPECTED(GC_REFCOUNT(ref)) == 0) { zval_dtor_func(ref); return; @@ -397,7 +397,7 @@ tail_call: while (zv != end) { if (Z_REFCOUNTED_P(zv)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); if (GC_REF_GET_COLOR(ref) != GC_BLACK) { gc_scan_black(ref); } @@ -406,7 +406,7 @@ tail_call: } if (EXPECTED(!ht)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); if (GC_REF_GET_COLOR(ref) != GC_BLACK) { goto tail_call; } @@ -424,7 +424,7 @@ tail_call: } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { ref = Z_COUNTED(((zend_reference*)ref)->val); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); if (GC_REF_GET_COLOR(ref) != GC_BLACK) { goto tail_call; } @@ -455,7 +455,7 @@ tail_call: } if (Z_REFCOUNTED_P(zv)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); if (GC_REF_GET_COLOR(ref) != GC_BLACK) { gc_scan_black(ref); } @@ -467,7 +467,7 @@ tail_call: zv = Z_INDIRECT_P(zv); } ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); if (GC_REF_GET_COLOR(ref) != GC_BLACK) { goto tail_call; } @@ -507,14 +507,14 @@ tail_call: while (zv != end) { if (Z_REFCOUNTED_P(zv)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)--; + GC_DELREF(ref); gc_mark_grey(ref); } zv++; } if (EXPECTED(!ht)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)--; + GC_DELREF(ref); goto tail_call; } } else { @@ -530,7 +530,7 @@ tail_call: } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { ref = Z_COUNTED(((zend_reference*)ref)->val); - GC_REFCOUNT(ref)--; + GC_DELREF(ref); goto tail_call; } return; @@ -559,7 +559,7 @@ tail_call: } if (Z_REFCOUNTED_P(zv)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)--; + GC_DELREF(ref); gc_mark_grey(ref); } p++; @@ -569,7 +569,7 @@ tail_call: zv = Z_INDIRECT_P(zv); } ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)--; + GC_DELREF(ref); goto tail_call; } } @@ -799,7 +799,7 @@ tail_call: while (zv != end) { if (Z_REFCOUNTED_P(zv)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); count += gc_collect_white(ref, flags); /* count non-refcounted for compatibility ??? */ } else if (Z_TYPE_P(zv) != IS_UNDEF) { @@ -809,7 +809,7 @@ tail_call: } if (EXPECTED(!ht)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); goto tail_call; } } else { @@ -828,7 +828,7 @@ tail_call: } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { ref = Z_COUNTED(((zend_reference*)ref)->val); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); goto tail_call; } return count; @@ -861,7 +861,7 @@ tail_call: } if (Z_REFCOUNTED_P(zv)) { ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); count += gc_collect_white(ref, flags); /* count non-refcounted for compatibility ??? */ } else if (Z_TYPE_P(zv) != IS_UNDEF) { @@ -874,7 +874,7 @@ tail_call: zv = Z_INDIRECT_P(zv); } ref = Z_COUNTED_P(zv); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); goto tail_call; } return count; @@ -1118,9 +1118,9 @@ ZEND_API int zend_gc_collect_cycles(void) 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); } } } @@ -1154,9 +1154,9 @@ ZEND_API int zend_gc_collect_cycles(void) 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); } } SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[obj->handle], EG(objects_store).free_list_head); diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index ce7f4374cf..43dfc00e10 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -514,7 +514,7 @@ static void zend_generator_add_child(zend_generator *generator, zend_generator * if (was_leaf) { zend_generator *next = generator->node.parent; leaf->node.ptr.root = generator->node.ptr.root; - ++GC_REFCOUNT(&generator->std); /* we need to increment the generator refcount here as it became integrated into the tree (no leaf), but we must not increment the refcount of the *whole* path in tree */ + GC_ADDREF(&generator->std); /* we need to increment the generator refcount here as it became integrated into the tree (no leaf), but we must not increment the refcount of the *whole* path in tree */ generator->node.ptr.leaf = leaf; while (next) { @@ -592,7 +592,7 @@ void zend_generator_yield_from(zend_generator *generator, zend_generator *from) generator->node.parent = from; zend_generator_get_current(generator); - --GC_REFCOUNT(&from->std); + GC_DELREF(&from->std); } ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator, zend_generator *leaf) @@ -658,7 +658,7 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator } else { do { root = root->node.parent; - ++GC_REFCOUNT(&root->std); + GC_ADDREF(&root->std); } while (root->node.parent); } } diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 9f829ff994..123f2c0884 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -173,7 +173,7 @@ ZEND_API const HashTable zend_empty_array = { static zend_always_inline void _zend_hash_init_int(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent) { - GC_REFCOUNT(ht) = 1; + GC_SET_REFCOUNT(ht, 1); GC_TYPE_INFO(ht) = IS_ARRAY | (persistent ? (GC_PERSISTENT << GC_FLAGS_SHIFT) : (GC_COLLECTABLE << GC_FLAGS_SHIFT)); ht->u.flags = HASH_FLAG_STATIC_KEYS; ht->nTableMask = HT_MIN_MASK; @@ -1746,7 +1746,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source) IS_CONSISTENT(source); ALLOC_HASHTABLE(target); - GC_REFCOUNT(target) = 1; + GC_SET_REFCOUNT(target, 1); GC_TYPE_INFO(target) = IS_ARRAY | (GC_COLLECTABLE << GC_FLAGS_SHIFT); target->nTableSize = source->nTableSize; @@ -2500,7 +2500,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht) } ZEND_HASH_FOREACH_END(); if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) { - GC_REFCOUNT(ht)++; + GC_ADDREF(ht); } return ht; @@ -2558,7 +2558,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, zend } if (EXPECTED(!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(ht)++; + GC_ADDREF(ht); } return ht; diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index b607efa5c9..02b1810f2e 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -79,7 +79,7 @@ static zend_function *zend_duplicate_function(zend_function *func, zend_class_en return func; } if (!(GC_FLAGS(func->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) { - GC_REFCOUNT(func->op_array.static_variables)++; + GC_ADDREF(func->op_array.static_variables); } new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); memcpy(new_function, func, sizeof(zend_op_array)); diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c index efbd3d028c..d08de65e7c 100644 --- a/Zend/zend_iterators.c +++ b/Zend/zend_iterators.c @@ -81,7 +81,7 @@ ZEND_API void zend_iterator_init(zend_object_iterator *iter) ZEND_API void zend_iterator_dtor(zend_object_iterator *iter) { - if (--GC_REFCOUNT(&iter->std) > 0) { + if (GC_DELREF(&iter->std) > 0) { return; } diff --git a/Zend/zend_list.c b/Zend/zend_list.c index c816b94b61..25e185946e 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -46,7 +46,7 @@ ZEND_API zval *zend_list_insert(void *ptr, int type) ZEND_API int zend_list_delete(zend_resource *res) { - if (--GC_REFCOUNT(res) <= 0) { + if (GC_DELREF(res) <= 0) { return zend_hash_index_del(&EG(regular_list), res->handle); } else { return SUCCESS; diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 27177a80fc..37336cd214 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -713,7 +713,7 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -923,7 +923,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, if (EXPECTED(zobj->properties)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -987,7 +987,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo && EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } 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; 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); } } } diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index c26284affe..c21d1a3b0a 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -72,7 +72,7 @@ END_EXTERN_C() static zend_always_inline void zend_object_release(zend_object *obj) { - if (--GC_REFCOUNT(obj) == 0) { + if (GC_DELREF(obj) == 0) { zend_objects_store_del(obj); } else if (UNEXPECTED(GC_MAY_LEAK((zend_refcounted*)obj))) { gc_possible_root((zend_refcounted*)obj); diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 8a29807412..7eafbc05e1 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -376,7 +376,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array) if (op_array->static_variables && !(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) { - if (--GC_REFCOUNT(op_array->static_variables) == 0) { + if (GC_DELREF(op_array->static_variables) == 0) { zend_array_destroy(op_array->static_variables); } } diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 46c5ad818e..a5ecd411ba 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -137,7 +137,7 @@ static zend_always_inline zend_string *zend_add_interned_string(zend_string *str { zval val; - GC_REFCOUNT(str) = 1; + GC_SET_REFCOUNT(str, 1); GC_FLAGS(str) |= IS_STR_INTERNED | flags; ZVAL_INTERNED_STR(&val, str); diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 7f5b108383..9a8bce015e 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -78,7 +78,7 @@ END_EXTERN_C() #define ZSTR_ALLOCA_ALLOC(str, _len, use_heap) do { \ (str) = (zend_string *)do_alloca(ZEND_MM_ALIGNED_SIZE_EX(_ZSTR_STRUCT_SIZE(_len), 8), (use_heap)); \ - GC_REFCOUNT(str) = 1; \ + GC_SET_REFCOUNT(str, 1); \ GC_TYPE_INFO(str) = IS_STRING; \ zend_string_forget_hash_val(str); \ ZSTR_LEN(str) = _len; \ @@ -118,7 +118,7 @@ static zend_always_inline uint32_t zend_string_refcount(const zend_string *s) static zend_always_inline uint32_t zend_string_addref(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { - return ++GC_REFCOUNT(s); + return GC_ADDREF(s); } return 1; } @@ -126,7 +126,7 @@ static zend_always_inline uint32_t zend_string_addref(zend_string *s) static zend_always_inline uint32_t zend_string_delref(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { - return --GC_REFCOUNT(s); + return GC_DELREF(s); } return 1; } @@ -135,7 +135,7 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, int persist { zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); - GC_REFCOUNT(ret) = 1; + GC_SET_REFCOUNT(ret, 1); #if 1 /* optimized single assignment */ GC_TYPE_INFO(ret) = IS_STRING | ((persistent ? IS_STR_PERSISTENT : 0) << 8); @@ -153,7 +153,7 @@ static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m { zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); - GC_REFCOUNT(ret) = 1; + GC_SET_REFCOUNT(ret, 1); #if 1 /* optimized single assignment */ GC_TYPE_INFO(ret) = IS_STRING | ((persistent ? IS_STR_PERSISTENT : 0) << 8); @@ -179,7 +179,7 @@ static zend_always_inline zend_string *zend_string_init(const char *str, size_t static zend_always_inline zend_string *zend_string_copy(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { - GC_REFCOUNT(s)++; + GC_ADDREF(s); } return s; } @@ -204,7 +204,7 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_ zend_string_forget_hash_val(ret); return ret; } else { - GC_REFCOUNT(s)--; + GC_DELREF(s); } } ret = zend_string_alloc(len, persistent); @@ -224,7 +224,7 @@ static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t zend_string_forget_hash_val(ret); return ret; } else { - GC_REFCOUNT(s)--; + GC_DELREF(s); } } ret = zend_string_alloc(len, persistent); @@ -244,7 +244,7 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size zend_string_forget_hash_val(ret); return ret; } else { - GC_REFCOUNT(s)--; + GC_DELREF(s); } } ret = zend_string_alloc(len, persistent); @@ -263,7 +263,7 @@ static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, zend_string_forget_hash_val(ret); return ret; } else { - GC_REFCOUNT(s)--; + GC_DELREF(s); } } ret = zend_string_safe_alloc(n, m, l, persistent); @@ -282,7 +282,7 @@ static zend_always_inline void zend_string_free(zend_string *s) static zend_always_inline void zend_string_release(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { - if (--GC_REFCOUNT(s) == 0) { + if (GC_DELREF(s) == 0) { pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT); } } diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 4f073d4719..56217d579e 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -431,7 +431,13 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define Z_TYPE_FLAGS_SHIFT 8 -#define GC_REFCOUNT(p) (p)->gc.refcount +#define GC_REFCOUNT(p) zend_gc_refcount(&(p)->gc) +#define GC_SET_REFCOUNT(p, rc) zend_gc_set_refcount(&(p)->gc, rc) +#define GC_ADDREF(p) zend_gc_addref(&(p)->gc) +#define GC_DELREF(p) zend_gc_delref(&(p)->gc) +#define GC_ADDREF_EX(p, rc) zend_gc_addref_ex(&(p)->gc, rc) +#define GC_DELREF_EX(p, rc) zend_gc_delref_ex(&(p)->gc, rc) + #define GC_TYPE(p) (p)->gc.u.v.type #define GC_FLAGS(p) (p)->gc.u.v.flags #define GC_INFO(p) (p)->gc.u.v.gc_info @@ -704,10 +710,10 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { zend_string *__s = (s); \ Z_STR_P(__z) = __s; \ /* interned strings support */ \ - if (ZSTR_IS_INTERNED(__s)) { \ + if (ZSTR_IS_INTERNED(__s)) { \ Z_TYPE_INFO_P(__z) = IS_INTERNED_STRING_EX; \ } else { \ - GC_REFCOUNT(__s)++; \ + GC_ADDREF(__s); \ Z_TYPE_INFO_P(__z) = IS_STRING_EX; \ } \ } while (0) @@ -751,7 +757,7 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { zend_resource *_res = \ (zend_resource *) emalloc(sizeof(zend_resource)); \ zval *__z; \ - GC_REFCOUNT(_res) = 1; \ + GC_SET_REFCOUNT(_res, 1); \ GC_TYPE_INFO(_res) = IS_RESOURCE; \ _res->handle = (h); \ _res->type = (t); \ @@ -765,7 +771,7 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { zend_resource *_res = \ (zend_resource *) malloc(sizeof(zend_resource)); \ zval *__z; \ - GC_REFCOUNT(_res) = 1; \ + GC_SET_REFCOUNT(_res, 1); \ GC_TYPE_INFO(_res) = IS_RESOURCE; \ _res->handle = (h); \ _res->type = (t); \ @@ -784,7 +790,7 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define ZVAL_NEW_EMPTY_REF(z) do { \ zend_reference *_ref = \ (zend_reference *) emalloc(sizeof(zend_reference)); \ - GC_REFCOUNT(_ref) = 1; \ + GC_SET_REFCOUNT(_ref, 1); \ GC_TYPE_INFO(_ref) = IS_REFERENCE; \ Z_REF_P(z) = _ref; \ Z_TYPE_INFO_P(z) = IS_REFERENCE_EX; \ @@ -793,7 +799,7 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define ZVAL_NEW_REF(z, r) do { \ zend_reference *_ref = \ (zend_reference *) emalloc(sizeof(zend_reference)); \ - GC_REFCOUNT(_ref) = 1; \ + GC_SET_REFCOUNT(_ref, 1); \ GC_TYPE_INFO(_ref) = IS_REFERENCE; \ ZVAL_COPY_VALUE(&_ref->val, r); \ Z_REF_P(z) = _ref; \ @@ -803,7 +809,7 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define ZVAL_NEW_PERSISTENT_REF(z, r) do { \ zend_reference *_ref = \ (zend_reference *) malloc(sizeof(zend_reference)); \ - GC_REFCOUNT(_ref) = 1; \ + GC_SET_REFCOUNT(_ref, 1); \ GC_TYPE_INFO(_ref) = IS_REFERENCE; \ ZVAL_COPY_VALUE(&_ref->val, r); \ Z_REF_P(z) = _ref; \ @@ -865,24 +871,69 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define Z_TRY_ADDREF(z) Z_TRY_ADDREF_P(&(z)) #define Z_TRY_DELREF(z) Z_TRY_DELREF_P(&(z)) -static zend_always_inline uint32_t zval_refcount_p(zval* pz) { +#ifndef ZEND_RC_DEBUG +# define ZEND_RC_DEBUG 0 +#endif + +#if ZEND_RC_DEBUG +extern ZEND_API zend_bool zend_rc_debug; +# define ZEND_RC_MOD_CHECK(p) \ + ZEND_ASSERT(!zend_rc_debug || \ + ((p)->u.v.flags & (GC_IMMUTABLE | GC_PERSISTENT)) == 0) +#else +# define ZEND_RC_MOD_CHECK(p) \ + do { } while (0) +#endif + +static zend_always_inline uint32_t zend_gc_refcount(const zend_refcounted_h *p) { + return p->refcount; +} + +static zend_always_inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc) { + p->refcount = rc; + return p->refcount; +} + +static zend_always_inline uint32_t zend_gc_addref(zend_refcounted_h *p) { + ZEND_RC_MOD_CHECK(p); + return ++(p->refcount); +} + +static zend_always_inline uint32_t zend_gc_delref(zend_refcounted_h *p) { + ZEND_RC_MOD_CHECK(p); + return --(p->refcount); +} + +static zend_always_inline uint32_t zend_gc_addref_ex(zend_refcounted_h *p, uint32_t rc) { + ZEND_RC_MOD_CHECK(p); + p->refcount += rc; + return p->refcount; +} + +static zend_always_inline uint32_t zend_gc_delref_ex(zend_refcounted_h *p, uint32_t rc) { + ZEND_RC_MOD_CHECK(p); + p->refcount -= rc; + return p->refcount; +} + +static zend_always_inline uint32_t zval_refcount_p(const zval* pz) { ZEND_ASSERT(Z_REFCOUNTED_P(pz) || Z_COPYABLE_P(pz)); return GC_REFCOUNT(Z_COUNTED_P(pz)); } static zend_always_inline uint32_t zval_set_refcount_p(zval* pz, uint32_t rc) { ZEND_ASSERT(Z_REFCOUNTED_P(pz)); - return GC_REFCOUNT(Z_COUNTED_P(pz)) = rc; + return GC_SET_REFCOUNT(Z_COUNTED_P(pz), rc); } static zend_always_inline uint32_t zval_addref_p(zval* pz) { ZEND_ASSERT(Z_REFCOUNTED_P(pz)); - return ++GC_REFCOUNT(Z_COUNTED_P(pz)); + return GC_ADDREF(Z_COUNTED_P(pz)); } static zend_always_inline uint32_t zval_delref_p(zval* pz) { ZEND_ASSERT(Z_REFCOUNTED_P(pz)); - return --GC_REFCOUNT(Z_COUNTED_P(pz)); + return GC_DELREF(Z_COUNTED_P(pz)); } #if SIZEOF_SIZE_T == 4 @@ -920,7 +971,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { uint32_t _t = Z_TYPE_INFO_P(_z2); \ ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \ if ((_t & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0) { \ - GC_REFCOUNT(_gc)++; \ + GC_ADDREF(_gc); \ } \ } while (0) @@ -935,7 +986,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { if ((_t & (IS_TYPE_COPYABLE << Z_TYPE_FLAGS_SHIFT)) != 0) { \ _zval_copy_ctor_func(_z1 ZEND_FILE_LINE_CC); \ } else { \ - GC_REFCOUNT(_gc)++; \ + GC_ADDREF(_gc); \ } \ } \ } while (0) @@ -1000,7 +1051,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { zend_array *_arr = Z_ARR_P(_zv); \ if (UNEXPECTED(GC_REFCOUNT(_arr) > 1)) { \ if (Z_REFCOUNTED_P(_zv)) { \ - GC_REFCOUNT(_arr)--; \ + GC_DELREF(_arr); \ } \ ZVAL_ARR(_zv, zend_array_dup(_arr)); \ } \ diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h index f63379003f..e26e3e03c5 100644 --- a/Zend/zend_variables.h +++ b/Zend/zend_variables.h @@ -45,7 +45,7 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) { if (Z_REFCOUNTED_P(zval_ptr)) { zend_refcounted *ref = Z_COUNTED_P(zval_ptr); - if (!--GC_REFCOUNT(ref)) { + if (!GC_DELREF(ref)) { _zval_dtor_func(ref ZEND_FILE_LINE_RELAY_CC); } else { gc_check_possible_root(ref); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9bed9f86bb..5496464691 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2138,7 +2138,7 @@ ZEND_VM_C_LABEL(fast_assign_obj): if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -2161,7 +2161,7 @@ ZEND_VM_C_LABEL(fast_assign_obj): if (Z_ISREF_P(value)) { if (OP_DATA_TYPE == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -2412,7 +2412,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) #else if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -2443,7 +2443,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) #else if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -3096,7 +3096,7 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, CONST|T } else if (OP1_TYPE & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } FREE_OP2(); @@ -3389,14 +3389,14 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM) if (func->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT); - GC_REFCOUNT((zend_object*)func->common.prototype)++; + GC_ADDREF((zend_object*)func->common.prototype); call_info |= ZEND_CALL_CLOSURE; if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { call_info |= ZEND_CALL_FAKE_CLOSURE; } } else if (object) { call_info |= ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(object)++; /* For $this pointer */ + GC_ADDREF(object); /* For $this pointer */ } FREE_OP2(); @@ -3756,7 +3756,7 @@ ZEND_VM_C_LABEL(fcall_end): #else if (UNEXPECTED(EG(exception) != NULL) && (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -3874,7 +3874,7 @@ ZEND_VM_HOT_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY) retval_ptr = Z_REFVAL_P(retval_ptr); ZVAL_COPY_VALUE(return_value, retval_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) { Z_ADDREF_P(retval_ptr); @@ -4049,7 +4049,7 @@ ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, CONST|TMP|VAR|CV, ANY) retval = Z_REFVAL_P(retval); ZVAL_COPY_VALUE(&generator->retval, retval); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval)) { Z_ADDREF_P(retval); @@ -4153,7 +4153,7 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ADDR) zval_ptr_dtor(ex); ZVAL_OBJ(ex, EG(exception)); if (UNEXPECTED(EG(exception) != exception)) { - GC_REFCOUNT(EG(exception))++; + GC_ADDREF(EG(exception)); HANDLE_EXCEPTION(); } else { EG(exception) = NULL; @@ -4235,7 +4235,7 @@ ZEND_VM_HOT_HANDLER(117, ZEND_SEND_VAR, VAR|CV, NUM) varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -4372,7 +4372,7 @@ ZEND_VM_C_LABEL(send_var_by_ref): varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -5184,7 +5184,7 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUSE zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -5430,7 +5430,7 @@ ZEND_VM_HANDLER(196, ZEND_UNSET_CV, CV, UNUSED) ZVAL_UNDEF(var); SAVE_OPLINE(); - if (!--GC_REFCOUNT(garbage)) { + if (!GC_DELREF(garbage)) { zval_dtor_func(garbage); } else { gc_check_possible_root(garbage); @@ -5688,7 +5688,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET_R, CONST|TMP|VAR|CV, JMP_ADDR) if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -5811,7 +5811,7 @@ ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR) if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -6050,7 +6050,7 @@ ZEND_VM_C_LABEL(fe_fetch_r_exit): ZVAL_COPY_VALUE_EX(res, value, gc, value_type); if (EXPECTED((value_type & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)) { - GC_REFCOUNT(gc)++; + GC_ADDREF(gc); } } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -6219,7 +6219,7 @@ ZEND_VM_C_LABEL(fe_fetch_w_exit): zend_reference *ref; ref = Z_REF_P(value); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); zval_ptr_dtor(variable_ptr); ZVAL_REF(variable_ptr, ref); } @@ -6669,7 +6669,7 @@ ZEND_VM_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, JMP_ADDR) } else if (OP1_TYPE == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -6710,7 +6710,7 @@ ZEND_VM_HANDLER(169, ZEND_COALESCE, CONST|TMP|VAR|CV, JMP_ADDR) } else if (OP1_TYPE == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -7607,21 +7607,21 @@ ZEND_VM_C_LABEL(check_indirect): if (UNEXPECTED(!Z_ISREF_P(value))) { ref = (zend_reference*)emalloc(sizeof(zend_reference)); - GC_REFCOUNT(ref) = 2; + GC_SET_REFCOUNT(ref, 2); GC_TYPE_INFO(ref) = IS_REFERENCE; ZVAL_COPY_VALUE(&ref->val, value); Z_REF_P(value) = ref; Z_TYPE_INFO_P(value) = IS_REFERENCE_EX; } else { ref = Z_REF_P(value); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); } variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W); if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) { zend_refcounted *ref = Z_COUNTED_P(variable_ptr); - uint32_t refcnt = --GC_REFCOUNT(ref); + uint32_t refcnt = GC_DELREF(ref); if (EXPECTED(variable_ptr != value)) { if (refcnt == 0) { @@ -7971,7 +7971,7 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, CONST, REF) ZEND_ASSERT(ht != NULL); if (GC_REFCOUNT(ht) > 1) { if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) { - GC_REFCOUNT(ht)--; + GC_DELREF(ht); } EX(func)->op_array.static_variables = ht = zend_array_dup(ht); } @@ -7989,7 +7989,7 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, CONST, REF) } if (UNEXPECTED(!Z_ISREF_P(value))) { zend_reference *ref = (zend_reference*)emalloc(sizeof(zend_reference)); - GC_REFCOUNT(ref) = 2; + GC_SET_REFCOUNT(ref, 2); GC_TYPE_INFO(ref) = IS_REFERENCE; ZVAL_COPY_VALUE(&ref->val, value); Z_REF_P(value) = ref; @@ -8065,7 +8065,7 @@ ZEND_VM_HANDLER(51, ZEND_MAKE_REF, VAR|CV, UNUSED) if (EXPECTED(!Z_ISREF_P(op1))) { ZVAL_MAKE_REF(op1); } - GC_REFCOUNT(Z_REF_P(op1))++; + GC_ADDREF(Z_REF_P(op1)); ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(op1)); } else { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), op1); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index e04ddeb2f1..087610b10f 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -444,7 +444,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_ #else if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -475,7 +475,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_ #else if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -952,7 +952,7 @@ fcall_end: #else if (UNEXPECTED(EG(exception) != NULL) && (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -1077,7 +1077,7 @@ fcall_end: #else if (UNEXPECTED(EG(exception) != NULL) && (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR)) { #endif - GC_REFCOUNT(object)--; + GC_DELREF(object); zend_object_store_ctor_failed(object); } OBJ_RELEASE(object); @@ -2924,7 +2924,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_CONST_ retval_ptr = Z_REFVAL_P(retval_ptr); ZVAL_COPY_VALUE(return_value, retval_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) { Z_ADDREF_P(retval_ptr); @@ -3022,7 +3022,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_CONST_HA retval = Z_REFVAL_P(retval); ZVAL_COPY_VALUE(&generator->retval, retval); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval)) { Z_ADDREF_P(retval); @@ -3532,7 +3532,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CONST_HANDLER( if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -3652,7 +3652,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_CONST_HANDLER if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -3802,7 +3802,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CONST_HANDLER(ZEN } else if (IS_CONST == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -3842,7 +3842,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_CONST_HANDLER(ZE } else if (IS_CONST == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -5438,7 +5438,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CONST_CO } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } @@ -5642,14 +5642,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CONS if (func->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT); - GC_REFCOUNT((zend_object*)func->common.prototype)++; + GC_ADDREF((zend_object*)func->common.prototype); call_info |= ZEND_CALL_CLOSURE; if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { call_info |= ZEND_CALL_FAKE_CLOSURE; } } else if (object) { call_info |= ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(object)++; /* For $this pointer */ + GC_ADDREF(object); /* For $this pointer */ } if ((IS_CONST & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) { @@ -5867,7 +5867,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_C zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -7647,7 +7647,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_U zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -9528,7 +9528,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CONST_CV } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } @@ -9732,14 +9732,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CV_H if (func->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT); - GC_REFCOUNT((zend_object*)func->common.prototype)++; + GC_ADDREF((zend_object*)func->common.prototype); call_info |= ZEND_CALL_CLOSURE; if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { call_info |= ZEND_CALL_FAKE_CLOSURE; } } else if (object) { call_info |= ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(object)++; /* For $this pointer */ + GC_ADDREF(object); /* For $this pointer */ } if ((IS_CV & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) { @@ -9822,7 +9822,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE zval_ptr_dtor(ex); ZVAL_OBJ(ex, EG(exception)); if (UNEXPECTED(EG(exception) != exception)) { - GC_REFCOUNT(EG(exception))++; + GC_ADDREF(EG(exception)); HANDLE_EXCEPTION(); } else { EG(exception) = NULL; @@ -9927,7 +9927,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_C zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -11593,7 +11593,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CONST_TM } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op2); @@ -11798,14 +11798,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMPV if (func->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT); - GC_REFCOUNT((zend_object*)func->common.prototype)++; + GC_ADDREF((zend_object*)func->common.prototype); call_info |= ZEND_CALL_CLOSURE; if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { call_info |= ZEND_CALL_FAKE_CLOSURE; } } else if (object) { call_info |= ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(object)++; /* For $this pointer */ + GC_ADDREF(object); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op2); @@ -11939,7 +11939,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_T zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -12749,7 +12749,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_TMP_HA retval_ptr = Z_REFVAL_P(retval_ptr); ZVAL_COPY_VALUE(return_value, retval_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) { Z_ADDREF_P(retval_ptr); @@ -12847,7 +12847,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_TMP_HAND retval = Z_REFVAL_P(retval); ZVAL_COPY_VALUE(&generator->retval, retval); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval)) { Z_ADDREF_P(retval); @@ -13100,7 +13100,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_TMP_HANDLER(ZE if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -13221,7 +13221,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_TMP_HANDLER(Z if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -13352,7 +13352,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_ } else if (IS_TMP_VAR == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -13393,7 +13393,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_TMP_HANDLER(ZEND } else if (IS_TMP_VAR == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -13907,7 +13907,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CON zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -14632,7 +14632,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNU zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -15275,7 +15275,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_ zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -15818,7 +15818,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -16177,7 +16177,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HA retval_ptr = Z_REFVAL_P(retval_ptr); ZVAL_COPY_VALUE(return_value, retval_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) { Z_ADDREF_P(retval_ptr); @@ -16276,7 +16276,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_VAR_HAND retval = Z_REFVAL_P(retval); ZVAL_COPY_VALUE(&generator->retval, retval); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval)) { Z_ADDREF_P(retval); @@ -16359,7 +16359,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_ varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -16536,7 +16536,7 @@ send_var_by_ref: varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -16585,7 +16585,7 @@ send_var_by_ref: varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -16806,7 +16806,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_VAR_HANDLER(ZE if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -16929,7 +16929,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_VAR_HANDLER(Z if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -17168,7 +17168,7 @@ fe_fetch_r_exit: ZVAL_COPY_VALUE_EX(res, value, gc, value_type); if (EXPECTED((value_type & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)) { - GC_REFCOUNT(gc)++; + GC_ADDREF(gc); } } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -17337,7 +17337,7 @@ fe_fetch_w_exit: zend_reference *ref; ref = Z_REF_P(value); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); zval_ptr_dtor(variable_ptr); ZVAL_REF(variable_ptr, ref); } @@ -17385,7 +17385,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_ } else if (IS_VAR == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -17426,7 +17426,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_VAR_HANDLER(ZEND } else if (IS_VAR == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -18669,7 +18669,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -18692,7 +18692,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -18827,7 +18827,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -18850,7 +18850,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -18985,7 +18985,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -19008,7 +19008,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -19143,7 +19143,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -19166,7 +19166,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -19916,7 +19916,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CON zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -21668,7 +21668,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNU zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -21925,7 +21925,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MAKE_REF_SPEC_VAR_UNUSED_HANDL if (EXPECTED(!Z_ISREF_P(op1))) { ZVAL_MAKE_REF(op1); } - GC_REFCOUNT(Z_REF_P(op1))++; + GC_ADDREF(Z_REF_P(op1)); ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(op1)); } else { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), op1); @@ -23008,7 +23008,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -23031,7 +23031,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -23166,7 +23166,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -23189,7 +23189,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -23324,7 +23324,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -23347,7 +23347,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -23482,7 +23482,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -23505,7 +23505,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -24227,7 +24227,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_ zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -25630,7 +25630,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -25653,7 +25653,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -25788,7 +25788,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -25811,7 +25811,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -25946,7 +25946,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -25969,7 +25969,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -26104,7 +26104,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -26127,7 +26127,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -26736,7 +26736,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -27797,7 +27797,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -27820,7 +27820,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -27955,7 +27955,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -27978,7 +27978,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -28113,7 +28113,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -28136,7 +28136,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -28271,7 +28271,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -28294,7 +28294,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -28495,7 +28495,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } @@ -30453,7 +30453,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -30476,7 +30476,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -30611,7 +30611,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -30634,7 +30634,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -30769,7 +30769,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -30792,7 +30792,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -30927,7 +30927,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -30950,7 +30950,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -31151,7 +31151,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } @@ -32213,7 +32213,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -32236,7 +32236,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -32371,7 +32371,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -32394,7 +32394,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -32529,7 +32529,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -32552,7 +32552,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -32687,7 +32687,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -32710,7 +32710,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -32911,7 +32911,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op2); @@ -33679,7 +33679,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_CV_HAN retval_ptr = Z_REFVAL_P(retval_ptr); ZVAL_COPY_VALUE(return_value, retval_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) { Z_ADDREF_P(retval_ptr); @@ -33777,7 +33777,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_CV_HANDL retval = Z_REFVAL_P(retval); ZVAL_COPY_VALUE(&generator->retval, retval); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(retval)) { Z_ADDREF_P(retval); @@ -33860,7 +33860,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_H varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -33937,7 +33937,7 @@ send_var_by_ref: varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -33986,7 +33986,7 @@ send_var_by_ref: varptr = Z_REFVAL_P(varptr); ZVAL_COPY_VALUE(arg, varptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); @@ -34301,7 +34301,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CV_HANDLER(ZEN if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -34421,7 +34421,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_CV_HANDLER(ZE if (Z_OBJ_P(array_ptr)->properties && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties)--; + GC_DELREF(Z_OBJ_P(array_ptr)->properties); } Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); } @@ -34571,7 +34571,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CV_HANDLER(ZEND_O } else if (IS_CV == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -34611,7 +34611,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_CV_HANDLER(ZEND_ } else if (IS_CV == IS_VAR && ref) { zend_reference *r = Z_REF_P(ref); - if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) { + if (UNEXPECTED(GC_DELREF(r) == 0)) { efree_size(r, sizeof(zend_reference)); } else if (Z_OPT_REFCOUNTED_P(result)) { Z_ADDREF_P(result); @@ -36791,7 +36791,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -36814,7 +36814,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -36949,7 +36949,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -36972,7 +36972,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -37107,7 +37107,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -37130,7 +37130,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -37265,7 +37265,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -37288,7 +37288,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -37987,7 +37987,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CONST } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } @@ -38100,7 +38100,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONS zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -38874,21 +38874,21 @@ check_indirect: if (UNEXPECTED(!Z_ISREF_P(value))) { ref = (zend_reference*)emalloc(sizeof(zend_reference)); - GC_REFCOUNT(ref) = 2; + GC_SET_REFCOUNT(ref, 2); GC_TYPE_INFO(ref) = IS_REFERENCE; ZVAL_COPY_VALUE(&ref->val, value); Z_REF_P(value) = ref; Z_TYPE_INFO_P(value) = IS_REFERENCE_EX; } else { ref = Z_REF_P(value); - GC_REFCOUNT(ref)++; + GC_ADDREF(ref); } variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(opline->op1.var EXECUTE_DATA_CC); if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) { zend_refcounted *ref = Z_COUNTED_P(variable_ptr); - uint32_t refcnt = --GC_REFCOUNT(ref); + uint32_t refcnt = GC_DELREF(ref); if (EXPECTED(variable_ptr != value)) { if (refcnt == 0) { @@ -38925,7 +38925,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_CONST_HAND ZEND_ASSERT(ht != NULL); if (GC_REFCOUNT(ht) > 1) { if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) { - GC_REFCOUNT(ht)--; + GC_DELREF(ht); } EX(func)->op_array.static_variables = ht = zend_array_dup(ht); } @@ -38943,7 +38943,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_CONST_HAND } if (UNEXPECTED(!Z_ISREF_P(value))) { zend_reference *ref = (zend_reference*)emalloc(sizeof(zend_reference)); - GC_REFCOUNT(ref) = 2; + GC_SET_REFCOUNT(ref, 2); GC_TYPE_INFO(ref) = IS_REFERENCE; ZVAL_COPY_VALUE(&ref->val, value); Z_REF_P(value) = ref; @@ -40798,7 +40798,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUS zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -40893,7 +40893,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_CV_SPEC_CV_UNUSED_HANDLE ZVAL_UNDEF(var); SAVE_OPLINE(); - if (!--GC_REFCOUNT(garbage)) { + if (!GC_DELREF(garbage)) { zval_dtor_func(garbage); } else { gc_check_possible_root(garbage); @@ -41358,7 +41358,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MAKE_REF_SPEC_CV_UNUSED_HANDLE if (EXPECTED(!Z_ISREF_P(op1))) { ZVAL_MAKE_REF(op1); } - GC_REFCOUNT(Z_REF_P(op1))++; + GC_ADDREF(Z_REF_P(op1)); ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(op1)); } else { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), op1); @@ -43266,7 +43266,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -43289,7 +43289,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -43424,7 +43424,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -43447,7 +43447,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -43582,7 +43582,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -43605,7 +43605,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -43740,7 +43740,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -43763,7 +43763,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -44518,7 +44518,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } @@ -44631,7 +44631,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_H zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -46981,7 +46981,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -47004,7 +47004,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CONST == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -47139,7 +47139,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -47162,7 +47162,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_TMP_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -47297,7 +47297,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -47320,7 +47320,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_VAR == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -47455,7 +47455,7 @@ fast_assign_obj: if (EXPECTED(zobj->properties != NULL)) { if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(zobj->properties)--; + GC_DELREF(zobj->properties); } zobj->properties = zend_array_dup(zobj->properties); } @@ -47478,7 +47478,7 @@ fast_assign_obj: if (Z_ISREF_P(value)) { if (IS_CV == IS_VAR) { zend_reference *ref = Z_REF_P(value); - if (--GC_REFCOUNT(ref) == 0) { + if (GC_DELREF(ref) == 0) { ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value)); efree_size(ref, sizeof(zend_reference)); value = &tmp; @@ -48121,7 +48121,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op2); @@ -48235,7 +48235,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMPV zend_refcounted *ref = Z_COUNTED_P(expr_ptr); expr_ptr = Z_REFVAL_P(expr_ptr); - if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; efree_size(ref, sizeof(zend_reference)); @@ -50324,7 +50324,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op1); @@ -52685,7 +52685,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op1); @@ -54040,7 +54040,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS; - GC_REFCOUNT(obj)++; /* For $this pointer */ + GC_ADDREF(obj); /* For $this pointer */ } zval_ptr_dtor_nogc(free_op2); diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index ff7e28a525..d8445d295f 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -231,7 +231,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, self->stream = innerstream; if (innerstream) { - GC_REFCOUNT(innerstream->res)++; + GC_ADDREF(innerstream->res); } self->bz_file = bz; diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c index 6ddbe63594..3938decb75 100644 --- a/ext/com_dotnet/com_persist.c +++ b/ext/com_dotnet/com_persist.c @@ -281,7 +281,7 @@ PHP_COM_DOTNET_API IStream *php_com_wrapper_export_stream(php_stream *stream) stm->refcount = 1; stm->stream = stream; - GC_REFCOUNT(stream->res)++; + GC_ADDREF(stream->res); tmp = zend_list_insert(stm, le_istream); stm->res = Z_RES_P(tmp); diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 5dd03e86d7..671cb293e3 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -695,7 +695,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) info = (dba_info *)le->ptr; - GC_REFCOUNT(le)++; + GC_ADDREF(le); RETURN_RES(zend_register_resource(info, le_pdb)); return; } diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 9892285cbb..00c8b40cb3 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1199,7 +1199,7 @@ PHP_DOM_EXPORT zend_bool php_dom_create_object(xmlNodePtr obj, zval *return_valu } if ((intern = (dom_object *) php_dom_object_get_data((void *) obj))) { - GC_REFCOUNT(&intern->std)++; + GC_ADDREF(&intern->std); ZVAL_OBJ(return_value, &intern->std); return 1; } diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 25edf66a74..be79035bba 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -567,7 +567,7 @@ PHP_FUNCTION(enchant_broker_request_dict) pbroker->dict[pos] = dict; dict->rsrc = zend_register_resource(dict, le_enchant_dict); - pbroker->rsrc->gc.refcount++; + GC_ADDREF(pbroker->rsrc); RETURN_RES(dict->rsrc); } else { RETURN_FALSE; @@ -614,7 +614,7 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict) pbroker->dict[pos] = dict; dict->rsrc = zend_register_resource(dict, le_enchant_dict); - pbroker->rsrc->gc.refcount++; + GC_ADDREF(pbroker->rsrc); RETURN_RES(dict->rsrc); } else { RETURN_FALSE; diff --git a/ext/interbase/ibase_events.c b/ext/interbase/ibase_events.c index 001c43dded..919d912d5b 100644 --- a/ext/interbase/ibase_events.c +++ b/ext/interbase/ibase_events.c @@ -328,7 +328,7 @@ PHP_FUNCTION(ibase_set_event_handler) event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0); TSRMLS_SET_CTX(event->thread_ctx); event->link_res = link_res; - GC_REFCOUNT(link_res)++; + GC_ADDREF(link_res); event->link = ib_link; event->event_count = 0; event->state = NEW; diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp index 0531a6b933..b38ae9aa60 100644 --- a/ext/intl/common/common_enum.cpp +++ b/ext/intl/common/common_enum.cpp @@ -183,7 +183,7 @@ static zend_object_iterator *IntlIterator_get_iterator( return NULL; } - ++GC_REFCOUNT(&ii->iterator->std); + GC_ADDREF(&ii->iterator->std); return ii->iterator; } diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c index 4325a45d06..9eb2304c5e 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.c @@ -58,7 +58,7 @@ int transliterator_object_construct( zval *object, ZVAL_NEW_STR(&tmp, u8str); zend_update_property(Transliterator_ce_ptr, object, "id", sizeof( "id" ) - 1, &tmp ); - GC_REFCOUNT(u8str)--; + GC_DELREF(u8str); return SUCCESS; } /* }}} */ diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 74a1736894..86a0e7eb27 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -654,7 +654,7 @@ is_string: "input buffer"); } else { /* make stream not being closed when the zval is freed */ - ++GC_REFCOUNT(stream->res); + GC_ADDREF(stream->res); pib->context = stream; pib->readcallback = php_libxml_streams_IO_read; pib->closecallback = php_libxml_streams_IO_close; diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 8a26cf66ca..9d65685170 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1456,7 +1456,7 @@ void php_oci_column_hash_dtor(zval *data) if (GC_REFCOUNT(column->descid) == 1) zend_list_close(column->descid); else - GC_REFCOUNT(column->descid)--; + GC_DELREF(column->descid); } if (column->data) { @@ -1878,7 +1878,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char (memcmp(ZSTR_VAL(tmp->hash_key), ZSTR_VAL(hashed_details.s), ZSTR_LEN(tmp->hash_key)) == 0)) { connection = tmp; - ++GC_REFCOUNT(connection->id); + GC_ADDREF(connection->id); } } else { PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection); @@ -1888,7 +1888,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char * decremented in the persistent helper */ if (OCI_G(old_oci_close_semantics)) { - ++GC_REFCOUNT(connection->id); + GC_ADDREF(connection->id); } } smart_str_free(&hashed_details); @@ -1899,7 +1899,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } else { /* we do not ping non-persistent connections */ smart_str_free(&hashed_details); - ++GC_REFCOUNT(connection->id); + GC_ADDREF(connection->id); return connection; } } /* is_open is true? */ @@ -2051,7 +2051,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char * refcount is decremented in the persistent helper */ if (OCI_G(old_oci_close_semantics)) { - ++GC_REFCOUNT(connection->id); + GC_ADDREF(connection->id); } zend_hash_update_mem(&EG(persistent_list), connection->hash_key, (void *)&new_le, sizeof(zend_resource)); OCI_G(num_persistent)++; @@ -2448,7 +2448,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode) if (column->is_cursor) { /* REFCURSOR -> simply return the statement id */ ZVAL_RES(value, column->stmtid); - ++GC_REFCOUNT(column->stmtid); + GC_ADDREF(column->stmtid); } else if (column->is_descr) { if (column->data_type != SQLT_RDD) { @@ -2492,7 +2492,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode) /* return the locator */ object_init_ex(value, oci_lob_class_entry_ptr); add_property_resource(value, "descriptor", column->descid); - ++GC_REFCOUNT(column->descid); + GC_ADDREF(column->descid); } } else { switch (column->retcode) { diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index 9e0ea69120..83426e5975 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -52,7 +52,7 @@ php_oci_collection *php_oci_collection_create(php_oci_connection *connection, ch collection->connection = connection; collection->collection = NULL; - ++GC_REFCOUNT(collection->connection->id); + GC_ADDREF(collection->connection->id); /* get type handle by name */ PHP_OCI_CALL_RETURN(errstatus, OCITypeByName, diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index 5e3107edfc..349338cf0f 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -67,7 +67,7 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, zend_lon descriptor = ecalloc(1, sizeof(php_oci_descriptor)); descriptor->type = (ub4) type; descriptor->connection = connection; - ++GC_REFCOUNT(descriptor->connection->id); + GC_ADDREF(descriptor->connection->id); PHP_OCI_CALL_RETURN(errstatus, OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0)); diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index f0cb16425a..1564e303e0 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -111,7 +111,7 @@ php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char statement->impres_child_stmt = NULL; statement->impres_count = 0; statement->impres_flag = PHP_OCI_IMPRES_UNKNOWN; /* may or may not have Implicit Result Set children */ - ++GC_REFCOUNT(statement->connection->id); + GC_ADDREF(statement->connection->id); if (OCI_G(default_prefetch) >= 0) { php_oci_statement_set_prefetch(statement, (ub4)OCI_G(default_prefetch)); @@ -171,8 +171,8 @@ php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement) statement2->has_descr = 0; statement2->stmttype = 0; - GC_REFCOUNT(statement->id)++; - GC_REFCOUNT(statement2->connection->id)++; + GC_ADDREF(statement->id); + GC_ADDREF(statement2->connection->id); php_oci_statement_set_prefetch(statement2, statement->prefetch_count); @@ -433,7 +433,7 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf return OCI_ERROR; } nested_stmt->parent_stmtid = outcol->statement->id; - ++GC_REFCOUNT(outcol->statement->id); + GC_ADDREF(outcol->statement->id); outcol->nested_statement = nested_stmt; outcol->stmtid = nested_stmt->id; diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 010eaa6a18..be8fd12e11 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2652,7 +2652,7 @@ try_and_get_another_connection: p = zend_hash_index_find_ptr(&EG(regular_list), conn_id); /* check if the connection is still there */ if (p && p->ptr && (p->type == le_conn || p->type == le_pconn)) { - GC_REFCOUNT(p)++; + GC_ADDREF(p); RETVAL_RES(p); efree(hashed_details); return; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 5e0ab19e57..02de091a58 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -471,7 +471,7 @@ zend_string *accel_new_interned_string(zend_string *str) p->key = (zend_string*) ZCSG(interned_strings_top); ZCSG(interned_strings_top) += ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(ZSTR_LEN(str))); p->h = h; - GC_REFCOUNT(p->key) = 1; + GC_SET_REFCOUNT(p->key, 1); #if 1 /* optimized single assignment */ GC_TYPE_INFO(p->key) = IS_STRING | ((IS_STR_INTERNED | IS_STR_PERMANENT) << 8); diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 6926798ab6..27e1a17f92 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -47,7 +47,7 @@ static void zend_accel_destroy_zend_function(zval *zv) if (function->type == ZEND_USER_FUNCTION) { if (function->op_array.static_variables) { if (!(GC_FLAGS(function->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) { - if (--GC_REFCOUNT(function->op_array.static_variables) == 0) { + if (GC_DELREF(function->op_array.static_variables) == 0) { FREE_HASHTABLE(function->op_array.static_variables); } } diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index d2d943ddbb..a6792aa1ff 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -300,7 +300,7 @@ static void zend_persist_zval(zval *z) zend_hash_persist(Z_ARRVAL_P(z), zend_persist_zval); /* make immutable array */ Z_TYPE_FLAGS_P(z) = IS_TYPE_COPYABLE; - GC_REFCOUNT(Z_COUNTED_P(z)) = 2; + GC_SET_REFCOUNT(Z_COUNTED_P(z), 2); GC_FLAGS(Z_COUNTED_P(z)) |= IS_ARRAY_IMMUTABLE; Z_ARRVAL_P(z)->u.flags |= HASH_FLAG_STATIC_KEYS; } @@ -325,7 +325,7 @@ static void zend_persist_zval(zval *z) Z_ARR_P(z) = zend_accel_memdup(Z_AST_P(z), sizeof(zend_ast_ref)); zend_persist_ast(GC_AST(old_ref)); Z_TYPE_FLAGS_P(z) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); - GC_REFCOUNT(Z_COUNTED_P(z)) = 2; + GC_SET_REFCOUNT(Z_COUNTED_P(z), 2); efree(old_ref); } break; @@ -370,7 +370,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc zend_hash_persist(op_array->static_variables, zend_persist_zval); zend_accel_store(op_array->static_variables, sizeof(HashTable)); /* make immutable array */ - GC_REFCOUNT(op_array->static_variables) = 2; + GC_SET_REFCOUNT(op_array->static_variables, 2); GC_TYPE_INFO(op_array->static_variables) = IS_ARRAY | (IS_ARRAY_IMMUTABLE << 8); op_array->static_variables->u.flags |= HASH_FLAG_STATIC_KEYS; } diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index bb47f3965a..c7fe1730e9 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -2291,7 +2291,7 @@ static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_ if (xparam->outputs.client) { xparam->outputs.client->ctx = stream->ctx; if (stream->ctx) { - GC_REFCOUNT(stream->ctx)++; + GC_ADDREF(stream->ctx); } } diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index afca2d1cfb..be5f1e363f 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -367,7 +367,7 @@ static PHP_METHOD(PDO, dbh_constructor) le.type = php_pdo_list_entry(); le.ptr = dbh; - GC_REFCOUNT(&le) = 1; + GC_SET_REFCOUNT(&le, 1); if ((zend_hash_str_update_mem(&EG(persistent_list), (char*)dbh->persistent_id, dbh->persistent_id_len, &le, sizeof(le))) == NULL) { diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 246ea19a8d..fcb5ae664a 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -246,8 +246,8 @@ static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */ zend_object_std_init(&row->std, pdo_row_ce); ZVAL_OBJ(&stmt->lazy_object_ref, &row->std); row->std.handlers = &pdo_row_object_handlers; - GC_REFCOUNT(&stmt->std)++; - GC_REFCOUNT(&row->std)--; + GC_ADDREF(&stmt->std); + GC_DELREF(&row->std); } ZVAL_COPY(return_value, &stmt->lazy_object_ref); } diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c index 306713bac3..2d64e242aa 100644 --- a/ext/pdo_oci/oci_statement.c +++ b/ext/pdo_oci/oci_statement.c @@ -691,7 +691,7 @@ static int oci_blob_close(php_stream *stream, int close_handle) OCILobClose(self->E->svc, self->E->err, self->lob); zval_ptr_dtor(&self->dbh); - GC_REFCOUNT(obj)--; + GC_DELREF(obj); efree(self->E); efree(self); } @@ -751,7 +751,7 @@ static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLoca zend_object *obj; obj = &stmt->std; Z_ADDREF(self->dbh); - GC_REFCOUNT(obj)++; + GC_ADDREF(obj); return stm; } diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index 1b4fecae81..e0627c1e32 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -346,7 +346,7 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, ZVAL_NULL(&zargs[0]); } else { if (Z_ISUNDEF(agg_context->val)) { - GC_REFCOUNT(agg_context) = 1; + GC_SET_REFCOUNT(agg_context, 1); GC_TYPE_INFO(agg_context) = IS_REFERENCE; ZVAL_NULL(&agg_context->val); } diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d9cb3ec301..f1bc779cfe 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -923,7 +923,7 @@ static inline char * _php_pgsql_trim_result(PGconn * pgsql, char **buf) */ static void php_pgsql_set_default_link(zend_resource *res) { - GC_REFCOUNT(res)++; + GC_ADDREF(res); if (PGG(default_link) != NULL) { zend_list_delete(PGG(default_link)); @@ -1451,7 +1451,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) link = (zend_resource *)index_ptr->ptr; if (link->ptr && (link->type == le_link || link->type == le_plink)) { php_pgsql_set_default_link(link); - GC_REFCOUNT(link)++; + GC_ADDREF(link); RETVAL_RES(link); goto cleanup; } else { diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index f8073e9186..9b91a5a1c3 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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(¤t->std); + GC_ADDREF(¤t->std); ZVAL_OBJ(return_value, (zend_object *) current); } diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index d8d8f95f2b..5315a3e0be 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -519,7 +519,7 @@ try_again: if (stream) { php_stream_auto_cleanup(stream); add_property_resource(this_ptr, "httpsocket", stream->res); - GC_REFCOUNT(stream->res)++; + GC_ADDREF(stream->res); add_property_long(this_ptr, "_use_proxy", use_proxy); } else { php_url_free(phpurl); @@ -539,7 +539,7 @@ try_again: zend_resource *ret = zend_register_resource(phpurl, le_url); add_property_resource(this_ptr, "httpurl", ret); - GC_REFCOUNT(ret)++; + GC_ADDREF(ret); /*zend_list_addref(ret);*/ if (context && @@ -1014,7 +1014,7 @@ try_again: } if (!zend_hash_index_exists(Z_ARRVAL(zcookie), 2)) { add_index_str(&zcookie, 2, phpurl->host); - GC_REFCOUNT(phpurl->host)++; + GC_ADDREF(phpurl->host); } zend_symtable_update(Z_ARRVAL_P(cookies), name.s, &zcookie); diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 672f40e469..f1c49f4db4 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -100,7 +100,7 @@ static inline HashTable **spl_array_get_hash_table_ptr(spl_array_object* intern) rebuild_object_properties(obj); } else if (GC_REFCOUNT(obj->properties) > 1) { if (EXPECTED(!(GC_FLAGS(obj->properties) & IS_ARRAY_IMMUTABLE))) { - GC_REFCOUNT(obj->properties)--; + GC_DELREF(obj->properties); } obj->properties = zend_array_dup(obj->properties); } @@ -1473,7 +1473,7 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam ZVAL_NEW_EMPTY_REF(¶ms[0]); ZVAL_ARR(Z_REFVAL(params[0]), aht); - GC_REFCOUNT(aht)++; + GC_ADDREF(aht); if (!use_arg) { intern->nApplyCount++; @@ -1507,7 +1507,7 @@ exit: if (aht != new_ht) { spl_array_replace_hash_table(intern, new_ht); } else { - GC_REFCOUNT(aht)--; + GC_DELREF(aht); } efree(Z_REF(params[0])); zend_string_free(Z_STR(function_name)); diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 64b80b6e02..41597e5f6b 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1583,7 +1583,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z Z_ADDREF(cfi->fci.function_name); } cfi->object = cfi->fcc.object; - if (cfi->object) GC_REFCOUNT(cfi->object)++; + if (cfi->object) GC_ADDREF(cfi->object); intern->u.cbfilter = cfi; break; } diff --git a/ext/standard/array.c b/ext/standard/array.c index 2a0053ee8b..61c6837586 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2567,7 +2567,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu if (zend_string_equals_literal(Z_STR_P(entry), "this")) { zend_object *object = zend_get_this_object(EG(current_execute_data)); if (object) { - GC_REFCOUNT(object)++; + GC_ADDREF(object); ZVAL_OBJ(&data, object); zend_hash_update(Z_ARRVAL_P(return_value), Z_STR_P(entry), &data); } @@ -2659,7 +2659,7 @@ PHP_FUNCTION(array_fill) Z_ARRVAL_P(return_value)->nNextFreeElement = (zend_long)(start_key + num); if (Z_REFCOUNTED_P(val)) { - GC_REFCOUNT(Z_COUNTED_P(val)) += (uint32_t)num; + GC_ADDREF_EX(Z_COUNTED_P(val), (uint32_t)num); } p = Z_ARRVAL_P(return_value)->arData; @@ -2680,7 +2680,7 @@ PHP_FUNCTION(array_fill) array_init_size(return_value, (uint32_t)num); zend_hash_real_init(Z_ARRVAL_P(return_value), 0); if (Z_REFCOUNTED_P(val)) { - GC_REFCOUNT(Z_COUNTED_P(val)) += (uint32_t)num; + GC_ADDREF_EX(Z_COUNTED_P(val), (uint32_t)num); } zend_hash_index_add_new(Z_ARRVAL_P(return_value), start_key, val); while (--num) { @@ -4311,7 +4311,7 @@ PHP_FUNCTION(array_pad) num_pads = pad_size_abs - input_size; if (Z_REFCOUNTED_P(pad_value)) { - GC_REFCOUNT(Z_COUNTED_P(pad_value)) += num_pads; + GC_ADDREF_EX(Z_COUNTED_P(pad_value), num_pads); } array_init_size(return_value, pad_size_abs); diff --git a/ext/standard/dir.c b/ext/standard/dir.c index cc5c6d44ae..797ea1f701 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -113,7 +113,7 @@ static void php_set_default_dir(zend_resource *res) } if (res) { - GC_REFCOUNT(res)++; + GC_ADDREF(res); } DIRG(default_dir) = res; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 78131fbcc5..6e02743a5b 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -447,7 +447,7 @@ finish: if (ZSTR_IS_INTERNED(tmp)) { tmp = zend_string_init(ZSTR_VAL(tmp), ZSTR_LEN(tmp), 0); } else if (GC_REFCOUNT(tmp) > 1) { - GC_REFCOUNT(tmp)--; + GC_DELREF(tmp); tmp = zend_string_init(ZSTR_VAL(tmp), ZSTR_LEN(tmp), 0); } diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 539d2c5b69..90fa48b012 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -185,7 +185,7 @@ static void proc_open_rsrc_dtor(zend_resource *rsrc) /* Close all handles to avoid a deadlock */ for (i = 0; i < proc->npipes; i++) { if (proc->pipes[i] != 0) { - GC_REFCOUNT(proc->pipes[i])--; + GC_DELREF(proc->pipes[i]); zend_list_close(proc->pipes[i]); proc->pipes[i] = 0; } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index b8d189d47d..3cb23b7165 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -208,7 +208,7 @@ PHP_FUNCTION(stream_socket_server) context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); if (context) { - GC_REFCOUNT(context->res)++; + GC_ADDREF(context->res); } if (zerrno) { @@ -1229,7 +1229,7 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS) if (filter) { filter->res = zend_register_resource(filter, php_file_le_stream_filter()); - GC_REFCOUNT(filter->res)++; + GC_ADDREF(filter->res); RETURN_RES(filter->res); } else { RETURN_FALSE; diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 88f52519d0..cb727da38c 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -279,9 +279,9 @@ static void destroy_server_data(xmlrpc_server_data *server) static void xmlrpc_server_destructor(zend_resource *rsrc) { if (rsrc && rsrc->ptr) { - rsrc->gc.refcount++; + GC_ADDREF(rsrc); destroy_server_data((xmlrpc_server_data*) rsrc->ptr); - rsrc->gc.refcount--; + GC_DELREF(rsrc); } } diff --git a/main/main.c b/main/main.c index 2443eac1dc..ef619a76fa 100644 --- a/main/main.c +++ b/main/main.c @@ -1596,6 +1596,10 @@ int php_request_startup(void) { int retval = SUCCESS; +#if ZEND_RC_DEBUG + zend_rc_debug = 1; +#endif + zend_interned_strings_activate(); #ifdef HAVE_DTRACE @@ -1805,6 +1809,10 @@ void php_request_shutdown(void *dummy) #ifdef HAVE_DTRACE DTRACE_REQUEST_SHUTDOWN(SAFE_FILENAME(SG(request_info).path_translated), SAFE_FILENAME(SG(request_info).request_uri), (char *)SAFE_FILENAME(SG(request_info).request_method)); #endif /* HAVE_DTRACE */ + +#if ZEND_RC_DEBUG + zend_rc_debug = 0; +#endif } /* }}} */ diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index 924a20ae09..f21deafdb8 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -38,7 +38,7 @@ typedef void (*php_stream_notification_func)(php_stream_context *context, FG(default_context) ? FG(default_context) : \ (FG(default_context) = php_stream_context_alloc()) ) -#define php_stream_context_to_zval(context, zval) { ZVAL_RES(zval, (context)->res); GC_REFCOUNT((context)->res)++; } +#define php_stream_context_to_zval(context, zval) { ZVAL_RES(zval, (context)->res); GC_ADDREF((context)->res); } typedef struct _php_stream_notifier php_stream_notifier; diff --git a/main/streams/streams.c b/main/streams/streams.c index e768d0f533..c46bf8328b 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -120,12 +120,12 @@ PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream * *stream = (php_stream*)le->ptr; ZEND_HASH_FOREACH_PTR(&EG(regular_list), regentry) { if (regentry->ptr == le->ptr) { - GC_REFCOUNT(regentry)++; + GC_ADDREF(regentry); (*stream)->res = regentry; return PHP_STREAM_PERSISTENT_SUCCESS; } } ZEND_HASH_FOREACH_END(); - GC_REFCOUNT(le)++; + GC_ADDREF(le); (*stream)->res = zend_register_resource(*stream, le_pstream); } return PHP_STREAM_PERSISTENT_SUCCESS; @@ -2127,7 +2127,7 @@ PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream if (context) { stream->ctx = context->res; - GC_REFCOUNT(context->res)++; + GC_ADDREF(context->res); } else { stream->ctx = NULL; } diff --git a/main/streams/userspace.c b/main/streams/userspace.c index b5061514f4..2b838c6ddc 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -293,7 +293,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php if (context) { add_property_resource(object, "context", context->res); - GC_REFCOUNT(context->res)++; + GC_ADDREF(context->res); } else { add_property_null(object, "context"); } diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 8efc4cdbc3..57e2f22fba 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -835,7 +835,7 @@ static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t if (xparam->outputs.client) { xparam->outputs.client->ctx = stream->ctx; if (stream->ctx) { - GC_REFCOUNT(stream->ctx)++; + GC_ADDREF(stream->ctx); } } } diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 5ef6b59d64..b212679ab9 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -580,10 +580,10 @@ static PHP_FUNCTION(phpdbg_get_executable) zend_hash_add_empty_element(files, zval_get_string(filename)); } ZEND_HASH_FOREACH_END(); } else { - GC_REFCOUNT(files)++; + GC_ADDREF(files); } } else { - GC_REFCOUNT(files)++; + GC_ADDREF(files); } array_init(return_value); @@ -632,7 +632,7 @@ static PHP_FUNCTION(phpdbg_get_executable) } } ZEND_HASH_FOREACH_END(); - if (!--GC_REFCOUNT(files)) { + if (!GC_DELREF(files)) { zend_hash_destroy(files); } } diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 88b0dad0b0..b6cd50179d 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1692,7 +1692,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */ backup_opline = EG(current_execute_data)->opline; \ } \ before_ex = EG(opline_before_exception); \ - ++GC_REFCOUNT(exception); \ + GC_ADDREF(exception); \ zend_clear_exception(); \ } \ if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \ |