diff options
author | Yiduo (David) Wang <davidw@php.net> | 2007-10-07 05:22:07 +0000 |
---|---|---|
committer | Yiduo (David) Wang <davidw@php.net> | 2007-10-07 05:22:07 +0000 |
commit | 4b4d634cb956de1efc13c8ed9b243fe1a85f783b (patch) | |
tree | eaa8d691de244aff3ee68fd3c23f769f02fa4446 /Zend | |
parent | ca4c55ad3a673257925bd9b458683c4f0e60e755 (diff) | |
download | php-git-4b4d634cb956de1efc13c8ed9b243fe1a85f783b.tar.gz |
MFH: Added macros for managing zval refcounts and is_ref statuses
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend.c | 6 | ||||
-rw-r--r-- | Zend/zend.h | 110 | ||||
-rw-r--r-- | Zend/zend_API.c | 74 | ||||
-rw-r--r-- | Zend/zend_API.h | 18 | ||||
-rw-r--r-- | Zend/zend_builtin_functions.c | 18 | ||||
-rw-r--r-- | Zend/zend_compile.c | 12 | ||||
-rw-r--r-- | Zend/zend_constants.c | 8 | ||||
-rw-r--r-- | Zend/zend_exceptions.c | 4 | ||||
-rw-r--r-- | Zend/zend_execute.c | 138 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 64 | ||||
-rwxr-xr-x | Zend/zend_interfaces.c | 2 | ||||
-rw-r--r-- | Zend/zend_language_scanner.l | 4 | ||||
-rw-r--r-- | Zend/zend_modules.h | 2 | ||||
-rw-r--r-- | Zend/zend_object_handlers.c | 32 | ||||
-rw-r--r-- | Zend/zend_objects.c | 2 | ||||
-rw-r--r-- | Zend/zend_objects_API.c | 4 | ||||
-rw-r--r-- | Zend/zend_opcode.c | 8 | ||||
-rw-r--r-- | Zend/zend_operators.c | 2 | ||||
-rw-r--r-- | Zend/zend_operators.h | 2 | ||||
-rw-r--r-- | Zend/zend_variables.c | 2 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 130 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 684 | ||||
-rw-r--r-- | Zend/zend_vm_execute.skl | 4 |
23 files changed, 695 insertions, 635 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index 1af881614e..1921b07a3f 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -236,7 +236,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop if (!Z_OBJ_HANDLER_P(expr, cast_object) && Z_OBJ_HANDLER_P(expr, get)) { zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); - z->refcount++; + Z_ADDREF_P(z); if(Z_TYPE_P(z) != IS_OBJECT) { zend_make_printable_zval(z, expr_copy, use_copy); if (*use_copy) { @@ -629,8 +629,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i /* This zval can be used to initialize allocate zval's to an uninit'ed value */ - zval_used_for_init.is_ref = 0; - zval_used_for_init.refcount = 1; + Z_UNSET_ISREF(zval_used_for_init); + Z_SET_REFCOUNT(zval_used_for_init, 1); zval_used_for_init.type = IS_NULL; #ifdef ZTS diff --git a/Zend/zend.h b/Zend/zend.h index 7246462fe7..d2d54a36d5 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -295,12 +295,77 @@ typedef union _zvalue_value { struct _zval_struct { /* Variable information */ zvalue_value value; /* value */ - zend_uint refcount; + zend_uint refcount__gc; zend_uchar type; /* active type */ - zend_uchar is_ref; + zend_uchar is_ref__gc; zend_uchar idx_type; /* type of element's index in constant array */ }; +#define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz)) +#define Z_SET_REFCOUNT_PP(ppz, rc) Z_SET_REFCOUNT_P(*(ppz), rc) +#define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz)) +#define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz)) +#define Z_ISREF_PP(ppz) Z_ISREF_P(*(ppz)) +#define Z_SET_ISREF_PP(ppz) Z_SET_ISREF_P(*(ppz)) +#define Z_UNSET_ISREF_PP(ppz) Z_UNSET_ISREF_P(*(ppz)) +#define Z_SET_ISREF_TO_PP(ppz, isref) Z_SET_ISREF_TO_P(*(ppz), isref) + +#define Z_REFCOUNT_P(pz) zval_refcount_p(pz) +#define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc) +#define Z_ADDREF_P(pz) zval_addref_p(pz) +#define Z_DELREF_P(pz) zval_delref_p(pz) +#define Z_ISREF_P(pz) zval_isref_p(pz) +#define Z_SET_ISREF_P(pz) zval_set_isref_p(pz) +#define Z_UNSET_ISREF_P(pz) zval_unset_isref_p(pz) +#define Z_SET_ISREF_TO_P(pz, isref) zval_set_isref_to_p(pz, isref) + +#define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z)) +#define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc) +#define Z_ADDREF(z) Z_ADDREF_P(&(z)) +#define Z_DELREF(z) Z_DELREF_P(&(z)) +#define Z_ISREF(z) Z_ISREF_P(&(z)) +#define Z_SET_ISREF(z) Z_SET_ISREF_P(&(z)) +#define Z_UNSET_ISREF(z) Z_UNSET_ISREF_P(&(z)) +#define Z_SET_ISREF_TO(z, isref) Z_SET_ISREF_TO_P(&(z), isref) + +#if defined(__GNUC__) +#define always_inline inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define always_inline __forceinline +#else +#define always_inline inline +#endif + +static always_inline zend_uint zval_refcount_p(zval* pz) { + return pz->refcount__gc; +} + +static always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) { + return pz->refcount__gc = rc; +} + +static always_inline zend_uint zval_addref_p(zval* pz) { + return ++pz->refcount__gc; +} + +static always_inline zend_uint zval_delref_p(zval* pz) { + return --pz->refcount__gc; +} + +static always_inline zend_bool zval_isref_p(zval* pz) { + return pz->is_ref__gc; +} + +static always_inline zend_bool zval_set_isref_p(zval* pz) { + return pz->is_ref__gc = 1; +} + +static always_inline zend_bool zval_unset_isref_p(zval* pz) { + return pz->is_ref__gc = 0; +} +static always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isref) { + return pz->is_ref__gc = isref; +} /* excpt.h on Digital Unix 4.0 defines function_table */ #undef function_table @@ -561,14 +626,9 @@ END_EXTERN_C() #define ZMSG_LOG_SCRIPT_NAME 6L #define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L - -#define ZVAL_ADDREF(pz) (++(pz)->refcount) -#define ZVAL_DELREF(pz) (--(pz)->refcount) -#define ZVAL_REFCOUNT(pz) ((pz)->refcount) - #define INIT_PZVAL(z) \ - (z)->refcount = 1; \ - (z)->is_ref = 0; + (z)->refcount__gc = 1; \ + (z)->is_ref__gc = 0; #define INIT_ZVAL(z) z = zval_used_for_init; @@ -580,19 +640,19 @@ END_EXTERN_C() ALLOC_ZVAL(zv); \ INIT_PZVAL(zv); -#define PZVAL_IS_REF(z) ((z)->is_ref) +#define PZVAL_IS_REF(z) Z_ISREF_P(z) #define SEPARATE_ZVAL(ppzv) \ { \ zval *orig_ptr = *(ppzv); \ \ - if (orig_ptr->refcount>1) { \ - orig_ptr->refcount--; \ + if (Z_REFCOUNT_P(orig_ptr)>1) { \ + Z_DELREF_P(orig_ptr); \ ALLOC_ZVAL(*(ppzv)); \ **(ppzv) = *orig_ptr; \ zval_copy_ctor(*(ppzv)); \ - (*(ppzv))->refcount=1; \ - (*(ppzv))->is_ref = 0; \ + Z_SET_REFCOUNT_PP(ppzv, 1); \ + Z_UNSET_ISREF_PP(ppzv); \ } \ } @@ -604,14 +664,14 @@ END_EXTERN_C() #define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \ if (!PZVAL_IS_REF(*ppzv)) { \ SEPARATE_ZVAL(ppzv); \ - (*(ppzv))->is_ref = 1; \ + Z_SET_ISREF_PP(ppzv); \ } #define COPY_PZVAL_TO_ZVAL(zv, pzv) \ (zv) = *(pzv); \ - if ((pzv)->refcount>1) { \ + if (Z_REFCOUNT_P(pzv)>1) { \ zval_copy_ctor(&(zv)); \ - (pzv)->refcount--; \ + Z_DELREF_P(pzv); \ } else { \ FREE_ZVAL(pzv); \ } \ @@ -621,15 +681,15 @@ END_EXTERN_C() int is_ref, refcount; \ \ SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \ - is_ref = (*ppzv_dest)->is_ref; \ - refcount = (*ppzv_dest)->refcount; \ + is_ref = Z_ISREF_PP(ppzv_dest); \ + refcount = Z_REFCOUNT_PP(ppzv_dest); \ zval_dtor(*ppzv_dest); \ **ppzv_dest = *pzv_src; \ if (copy) { \ zval_copy_ctor(*ppzv_dest); \ } \ - (*ppzv_dest)->is_ref = is_ref; \ - (*ppzv_dest)->refcount = refcount; \ + Z_SET_ISREF_TO_PP(ppzv_dest, is_ref); \ + Z_SET_REFCOUNT_PP(ppzv_dest, refcount); \ } #define SEPARATE_ARG_IF_REF(varptr) \ @@ -638,15 +698,15 @@ END_EXTERN_C() ALLOC_ZVAL(varptr); \ varptr->value = original_var->value; \ varptr->type = original_var->type; \ - varptr->is_ref = 0; \ - varptr->refcount = 1; \ + Z_UNSET_ISREF_P(varptr); \ + Z_SET_REFCOUNT_P(varptr, 1); \ zval_copy_ctor(varptr); \ } else { \ - varptr->refcount++; \ + Z_ADDREF_P(varptr); \ } #define READY_TO_DESTROY(zv) \ - ((zv)->refcount == 1 && \ + (Z_REFCOUNT_P(zv) == 1 && \ (Z_TYPE_P(zv) != IS_OBJECT || \ zend_objects_store_get_refcount(zv TSRMLS_CC) == 1)) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index c65cc8aec5..2bc48cd3d0 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -55,7 +55,7 @@ ZEND_API int zend_get_parameters(int ht, int param_count, ...) while (param_count-->0) { param = va_arg(ptr, zval **); param_ptr = *(p-arg_count); - if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) { + if (!PZVAL_IS_REF(param_ptr) && Z_REFCOUNT_P(param_ptr)>1) { zval *new_tmp; ALLOC_ZVAL(new_tmp); @@ -63,7 +63,7 @@ ZEND_API int zend_get_parameters(int ht, int param_count, ...) zval_copy_ctor(new_tmp); INIT_PZVAL(new_tmp); param_ptr = new_tmp; - ((zval *) *(p-arg_count))->refcount--; + Z_DELREF_P((zval *) *(p-arg_count)); *(p-arg_count) = param_ptr; } *param = param_ptr; @@ -90,7 +90,7 @@ ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument while (param_count-->0) { param_ptr = *(p-arg_count); - if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) { + if (!PZVAL_IS_REF(param_ptr) && Z_REFCOUNT_P(param_ptr)>1) { zval *new_tmp; ALLOC_ZVAL(new_tmp); @@ -98,7 +98,7 @@ ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument zval_copy_ctor(new_tmp); INIT_PZVAL(new_tmp); param_ptr = new_tmp; - ((zval *) *(p-arg_count))->refcount--; + Z_DELREF_P((zval *) *(p-arg_count)); *(p-arg_count) = param_ptr; } *(argument_array++) = param_ptr; @@ -156,7 +156,7 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_arr if (EG(ze1_compatibility_mode) && Z_TYPE_PP(value) == IS_OBJECT && - !(*value)->is_ref) { + !Z_ISREF_PP(value)) { zval *value_ptr; char *class_name; zend_uint class_name_len; @@ -291,7 +291,7 @@ static int parse_arg_object_to_string(zval **arg, char **p, int *pl, int type TS if (!Z_OBJ_HANDLER_PP(arg, cast_object) && Z_OBJ_HANDLER_PP(arg, get)) { int use_copy; zval *z = Z_OBJ_HANDLER_PP(arg, get)(*arg TSRMLS_CC); - z->refcount++; + Z_ADDREF_P(z); if(Z_TYPE_P(z) != IS_OBJECT) { zval_dtor(*arg); Z_TYPE_P(*arg) = IS_NULL; @@ -894,13 +894,13 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC zval **q; zend_hash_get_current_key_ex(&class_type->default_static_members, &str_index, &str_length, &num_index, 0, &pos); - if ((*p)->is_ref && + if (Z_ISREF_PP(p) && class_type->parent && zend_hash_find(&class_type->parent->default_static_members, str_index, str_length, (void**)&q) == SUCCESS && *p == *q && zend_hash_find(CE_STATIC_MEMBERS(class_type->parent), str_index, str_length, (void**)&q) == SUCCESS) { - (*q)->refcount++; - (*q)->is_ref = 1; + Z_ADDREF_PP(q); + Z_SET_ISREF_PP(q); zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)q, sizeof(zval*), NULL); } else { zval *q; @@ -2082,7 +2082,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length, if (num_symbol_tables <= 0) return FAILURE; - symbol->is_ref = is_ref; + Z_SET_ISREF_TO_P(symbol, is_ref); va_start(symbol_table_list, num_symbol_tables); while (num_symbol_tables-- > 0) { @@ -2507,7 +2507,7 @@ ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) &arg, &pos) == SUCCESS) { *params++ = arg; - (*arg)->refcount++; + Z_ADDREF_PP(arg); zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos); } return SUCCESS; @@ -2826,8 +2826,8 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_NULL(tmp); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); } @@ -2837,8 +2837,8 @@ ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, c zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_BOOL(tmp, value); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); } @@ -2848,8 +2848,8 @@ ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, c zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_LONG(tmp, value); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); } @@ -2859,8 +2859,8 @@ ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_DOUBLE(tmp, value); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); } @@ -2870,8 +2870,8 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_STRING(tmp, value, 1); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); } @@ -2881,8 +2881,8 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_STRINGL(tmp, value, value_len, 1); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); } @@ -2903,13 +2903,13 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, in zval_dtor(*property); Z_TYPE_PP(property) = Z_TYPE_P(value); (*property)->value = value->value; - if (value->refcount > 0) { + if (Z_REFCOUNT_P(value) > 0) { zval_copy_ctor(*property); } } else { zval *garbage = *property; - value->refcount++; + Z_ADDREF_P(value); if (PZVAL_IS_REF(value)) { SEPARATE_ZVAL(&value); } @@ -2926,8 +2926,8 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, char *nam zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_NULL(tmp); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } @@ -2937,8 +2937,8 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *nam zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_BOOL(tmp, value); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } @@ -2948,8 +2948,8 @@ ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *nam zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_LONG(tmp, value); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } @@ -2959,8 +2959,8 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *n zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_DOUBLE(tmp, value); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } @@ -2970,8 +2970,8 @@ ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *n zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_STRING(tmp, value, 1); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } @@ -2981,8 +2981,8 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char * zval *tmp; ALLOC_ZVAL(tmp); - tmp->is_ref = 0; - tmp->refcount = 0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); ZVAL_STRINGL(tmp, value, value_len, 1); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index f44b6fdf47..c0db612c10 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -485,8 +485,8 @@ END_EXTERN_C() #define ZVAL_ZVAL(z, zv, copy, dtor) { \ int is_ref, refcount; \ - is_ref = (z)->is_ref; \ - refcount = (z)->refcount; \ + is_ref = Z_ISREF_P(z); \ + refcount = Z_REFCOUNT_P(z); \ *(z) = *(zv); \ if (copy) { \ zval_copy_ctor(z); \ @@ -497,8 +497,8 @@ END_EXTERN_C() } \ zval_ptr_dtor(&zv); \ } \ - (z)->is_ref = is_ref; \ - (z)->refcount = refcount; \ + Z_SET_ISREF_TO_P(z, is_ref); \ + Z_SET_REFCOUNT_P(z, refcount); \ } #define ZVAL_FALSE(z) ZVAL_BOOL(z, 0) @@ -578,19 +578,19 @@ END_EXTERN_C() \ if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS \ && PZVAL_IS_REF(*orig_var)) { \ - (var)->refcount = (*orig_var)->refcount; \ - (var)->is_ref = 1; \ + Z_SET_REFCOUNT_P(var, Z_REFCOUNT_PP(orig_var)); \ + Z_SET_ISREF_P(var); \ \ if (_refcount) { \ - (var)->refcount += _refcount-1; \ + Z_SET_REFCOUNT_P(var, Z_REFCOUNT_P(var) + _refcount-1); \ } \ zval_dtor(*orig_var); \ **orig_var = *(var); \ FREE_ZVAL(var); \ } else { \ - (var)->is_ref = _is_ref; \ + Z_SET_ISREF_TO_P(var, _is_ref); \ if (_refcount) { \ - (var)->refcount = _refcount; \ + Z_SET_REFCOUNT_P(var, _refcount); \ } \ zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL); \ } \ diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 6e97b100ae..27559f59f4 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -395,18 +395,18 @@ ZEND_FUNCTION(each) entry = *entry_ptr; /* add value elements */ - if (entry->is_ref) { + if (Z_ISREF_P(entry)) { ALLOC_ZVAL(tmp); *tmp = *entry; zval_copy_ctor(tmp); - tmp->is_ref=0; - tmp->refcount=0; + Z_UNSET_ISREF_P(tmp); + Z_SET_REFCOUNT_P(tmp, 0); entry=tmp; } zend_hash_index_update(return_value->value.ht, 1, &entry, sizeof(zval *), NULL); - entry->refcount++; + Z_ADDREF_P(entry); zend_hash_update(return_value->value.ht, "value", sizeof("value"), &entry, sizeof(zval *), NULL); - entry->refcount++; + Z_ADDREF_P(entry); /* add the key elements */ switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 1, NULL)) { @@ -418,7 +418,7 @@ ZEND_FUNCTION(each) break; } zend_hash_update(return_value->value.ht, "key", sizeof("key"), inserted_pointer, sizeof(zval *), NULL); - (*inserted_pointer)->refcount++; + Z_ADDREF_PP(inserted_pointer); zend_hash_move_forward(target_hash); } /* }}} */ @@ -841,7 +841,7 @@ ZEND_FUNCTION(get_object_vars) if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) { zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); /* Not separating references */ - (*value)->refcount++; + Z_ADDREF_PP(value); add_assoc_zval_ex(return_value, prop_name, strlen(prop_name)+1, *value); } } @@ -1700,7 +1700,7 @@ static zval *debug_backtrace_get_args(void ***curpos TSRMLS_DC) if (Z_TYPE_PP(arg) != IS_OBJECT) { SEPARATE_ZVAL_TO_MAKE_IS_REF(arg); } - (*arg)->refcount++; + Z_ADDREF_PP(arg); add_next_index_zval(arg_array, *arg); } else { add_next_index_null(arg_array); @@ -2038,7 +2038,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int } if (provide_object) { add_assoc_zval_ex(stack_frame, "object", sizeof("object"), ptr->object); - ptr->object->refcount++; + Z_ADDREF_P(ptr->object); } add_assoc_string_ex(stack_frame, "type", sizeof("type"), "->", 1); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ab86ce463f..1fee2fe4d9 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -94,7 +94,7 @@ static void build_runtime_defined_function_key(zval *result, char *name, int nam zend_spprintf(&result->value.str.val, 0, "%c%s%s%s", '\0', name, filename, char_pos_buf); #endif /* ZEND_MULTIBYTE */ result->type = IS_STRING; - result->refcount = 1; + Z_SET_REFCOUNT_P(result, 1); } @@ -1197,7 +1197,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n opline->op2.u.constant.type = IS_STRING; opline->op2.u.constant.value.str.val = lcname; opline->op2.u.constant.value.str.len = name_len; - opline->op2.u.constant.refcount = 1; + Z_SET_REFCOUNT(opline->op2.u.constant, 1); opline->extended_value = ZEND_DECLARE_FUNCTION; zend_hash_update(CG(function_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)); } @@ -2316,7 +2316,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro zval **pvalue; if (zend_hash_quick_find(&parent_ce->default_properties, parent_info->name, parent_info->name_length+1, parent_info->h, (void **) &pvalue) == SUCCESS) { - (*pvalue)->refcount++; + Z_ADDREF_PP(pvalue); zend_hash_del(&ce->default_properties, child_info->name, child_info->name_length+1); zend_hash_quick_update(&ce->default_properties, parent_info->name, parent_info->name_length+1, parent_info->h, pvalue, sizeof(zval *), NULL); } @@ -2350,7 +2350,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro parent_ce->name, prop_name, ce->name); } } - (*prop)->refcount++; + Z_ADDREF_PP(prop); zend_hash_update(&ce->default_static_members, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL); zend_hash_del(&ce->default_static_members, prot_name, prot_name_length+1); } @@ -2421,7 +2421,7 @@ static int inherit_static_prop(zval **p, int num_args, va_list args, zend_hash_k if (!zend_hash_quick_exists(target, key->arKey, key->nKeyLength, key->h)) { SEPARATE_ZVAL_TO_MAKE_IS_REF(p); if (zend_hash_quick_add(target, key->arKey, key->nKeyLength, key->h, p, sizeof(zval*), NULL) == SUCCESS) { - (*p)->refcount++; + Z_ADDREF_PP(p); } } return ZEND_HASH_APPLY_KEEP; @@ -3031,7 +3031,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod opline->op2.op_type = IS_CONST; opline->op2.u.constant.type = IS_STRING; - opline->op2.u.constant.refcount = 1; + Z_SET_REFCOUNT(opline->op2.u.constant, 1); if (doing_inheritance) { opline->extended_value = parent_class_name->u.var; diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index fd1caba4f5..95c62cf1f3 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -257,8 +257,8 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC if (retval) { *result = c->value; zval_copy_ctor(result); - result->refcount = 1; - result->is_ref = 0; + Z_SET_REFCOUNT_P(result, 1); + Z_UNSET_ISREF_P(result); } return retval; @@ -349,8 +349,8 @@ ZEND_API int zend_get_constant_ex(char *name, uint name_len, zval *result, zend_ *result = c->value; zval_update_constant_ex(&result, (void*)1, NULL TSRMLS_CC); zval_copy_ctor(result); - result->refcount = 1; - result->is_ref = 0; + Z_SET_REFCOUNT_P(result, 1); + Z_UNSET_ISREF_P(result); return 1; } efree(lcname); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 38185819cb..e2cae139fe 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -87,8 +87,8 @@ static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_t zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); ALLOC_ZVAL(trace); - trace->is_ref = 0; - trace->refcount = 0; + Z_UNSET_ISREF_P(trace); + Z_SET_REFCOUNT_P(trace, 0); zend_fetch_debug_backtrace(trace, skip_top_traces, 0 TSRMLS_CC); zend_update_property_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index cb76a16c17..2150e73314 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -66,22 +66,22 @@ static void zend_extension_fcall_end_handler(zend_extension *extension, zend_op_ static inline void zend_pzval_unlock_func(zval *z, zend_free_op *should_free, int unref) { - if (!--z->refcount) { - z->refcount = 1; - z->is_ref = 0; + if (!Z_DELREF_P(z)) { + Z_SET_REFCOUNT_P(z, 1); + Z_UNSET_ISREF_P(z); should_free->var = z; /* should_free->is_var = 1; */ } else { should_free->var = 0; - if (unref && z->is_ref && z->refcount == 1) { - z->is_ref = 0; + if (unref && Z_ISREF_P(z) && Z_REFCOUNT_P(z) == 1) { + Z_UNSET_ISREF_P(z); } } } static inline void zend_pzval_unlock_free_func(zval *z) { - if (!--z->refcount) { + if (!Z_DELREF_P(z)) { zval_dtor(z); safe_free_zval_ptr(z); } @@ -90,7 +90,7 @@ static inline void zend_pzval_unlock_free_func(zval *z) #define PZVAL_UNLOCK(z, f) zend_pzval_unlock_func(z, f, 1) #define PZVAL_UNLOCK_EX(z, f, u) zend_pzval_unlock_func(z, f, u) #define PZVAL_UNLOCK_FREE(z) zend_pzval_unlock_free_func(z) -#define PZVAL_LOCK(z) (z)->refcount++ +#define PZVAL_LOCK(z) Z_ADDREF_P((z)) #define RETURN_VALUE_UNUSED(pzn) (((pzn)->u.EA.type & EXT_TYPE_UNUSED)) #define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!RETURN_VALUE_UNUSED(pzn)) { PZVAL_LOCK(pzv); } @@ -128,8 +128,8 @@ static inline void zend_pzval_unlock_free_func(zval *z) #define INIT_PZVAL_COPY(z,v) \ (z)->value = (v)->value; \ Z_TYPE_P(z) = Z_TYPE_P(v); \ - (z)->refcount = 1; \ - (z)->is_ref = 0; + Z_SET_REFCOUNT_P(z, 1); \ + Z_UNSET_ISREF_P(z); #define MAKE_REAL_ZVAL_PTR(val) \ do { \ @@ -137,8 +137,8 @@ static inline void zend_pzval_unlock_free_func(zval *z) ALLOC_ZVAL(_tmp); \ _tmp->value = (val)->value; \ Z_TYPE_P(_tmp) = Z_TYPE_P(val); \ - _tmp->refcount = 1; \ - _tmp->is_ref = 0; \ + Z_SET_REFCOUNT_P(_tmp, 1); \ + Z_UNSET_ISREF_P(_tmp); \ val = _tmp; \ } while (0) @@ -167,7 +167,7 @@ static inline void zend_get_cv_address(zend_compiled_variable *cv, zval ***ptr, { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_quick_update(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, &new_zval, sizeof(zval *), (void **)ptr); } @@ -204,8 +204,8 @@ static inline zval *_get_zval_ptr_var(znode *node, temp_variable *Ts, zend_free_ ptr->value.str.len = 1; } PZVAL_UNLOCK_FREE(str); - ptr->refcount=1; - ptr->is_ref=1; + Z_SET_REFCOUNT_P(ptr, 1); + Z_SET_ISREF_P(ptr); ptr->type = IS_STRING; return ptr; } @@ -409,35 +409,35 @@ static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **va } else if (variable_ptr != value_ptr) { if (!PZVAL_IS_REF(value_ptr)) { /* break it away */ - value_ptr->refcount--; - if (value_ptr->refcount>0) { + Z_DELREF_P(value_ptr); + if (Z_REFCOUNT_P(value_ptr)>0) { ALLOC_ZVAL(*value_ptr_ptr); **value_ptr_ptr = *value_ptr; value_ptr = *value_ptr_ptr; zendi_zval_copy_ctor(*value_ptr); } - value_ptr->refcount = 1; - value_ptr->is_ref = 1; + Z_SET_REFCOUNT_P(value_ptr, 1); + Z_SET_ISREF_P(value_ptr); } *variable_ptr_ptr = value_ptr; - value_ptr->refcount++; + Z_ADDREF_P(value_ptr); zval_ptr_dtor(&variable_ptr); - } else if (!variable_ptr->is_ref) { + } else if (!Z_ISREF_P(variable_ptr)) { if (variable_ptr_ptr == value_ptr_ptr) { SEPARATE_ZVAL(variable_ptr_ptr); } else if (variable_ptr==EG(uninitialized_zval_ptr) - || variable_ptr->refcount>2) { + || Z_REFCOUNT_P(variable_ptr)>2) { /* we need to separate */ - variable_ptr->refcount -= 2; + Z_SET_REFCOUNT_P(variable_ptr, Z_REFCOUNT_P(variable_ptr) - 2); ALLOC_ZVAL(*variable_ptr_ptr); **variable_ptr_ptr = *variable_ptr; zval_copy_ctor(*variable_ptr_ptr); *value_ptr_ptr = *variable_ptr_ptr; - (*variable_ptr_ptr)->refcount = 2; + Z_SET_REFCOUNT_PP(variable_ptr_ptr, 2); } - (*variable_ptr_ptr)->is_ref = 1; + Z_SET_ISREF_PP(variable_ptr_ptr); } } @@ -579,8 +579,8 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode ALLOC_ZVAL(value); *value = *orig_value; - value->is_ref = 0; - value->refcount = 0; + Z_UNSET_ISREF_P(value); + Z_SET_REFCOUNT_P(value, 0); dup = zend_get_object_classname(orig_value, &class_name, &class_name_len TSRMLS_CC); if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name); @@ -595,20 +595,20 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode ALLOC_ZVAL(value); *value = *orig_value; - value->is_ref = 0; - value->refcount = 0; + Z_UNSET_ISREF_P(value); + Z_SET_REFCOUNT_P(value, 0); } else if (value_op->op_type == IS_CONST) { zval *orig_value = value; ALLOC_ZVAL(value); *value = *orig_value; - value->is_ref = 0; - value->refcount = 0; + Z_UNSET_ISREF_P(value); + Z_SET_REFCOUNT_P(value, 0); zval_copy_ctor(value); } - value->refcount++; + Z_ADDREF_P(value); if (opcode == ZEND_ASSIGN_OBJ) { if (IS_TMP_FREE(free_op2)) { MAKE_REAL_ZVAL_PTR(property_name); @@ -744,28 +744,28 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2 zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name); } else if (PZVAL_IS_REF(variable_ptr)) { if (variable_ptr != value) { - zend_uint refcount = variable_ptr->refcount; + zend_uint refcount = Z_REFCOUNT_P(variable_ptr); zval garbage; if (type != IS_TMP_VAR) { - value->refcount++; + Z_ADDREF_P(value); } garbage = *variable_ptr; *variable_ptr = *value; - variable_ptr->refcount = refcount; - variable_ptr->is_ref = 1; + Z_SET_REFCOUNT_P(variable_ptr, refcount); + Z_SET_ISREF_P(variable_ptr); zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name); variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC); if (type != IS_TMP_VAR) { - value->refcount--; + Z_DELREF_P(value); } zendi_zval_dtor(garbage); } } else { if (variable_ptr != value) { - value->refcount++; - variable_ptr->refcount--; - if (variable_ptr->refcount == 0) { + Z_ADDREF_P(value); + Z_DELREF_P(variable_ptr); + if (Z_REFCOUNT_P(variable_ptr) == 0) { zendi_zval_dtor(*variable_ptr); } else { ALLOC_ZVAL(variable_ptr); @@ -783,42 +783,42 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2 } } else if (PZVAL_IS_REF(variable_ptr)) { if (variable_ptr!=value) { - zend_uint refcount = variable_ptr->refcount; + zend_uint refcount = Z_REFCOUNT_P(variable_ptr); zval garbage; if (type!=IS_TMP_VAR) { - value->refcount++; + Z_ADDREF_P(value); } garbage = *variable_ptr; *variable_ptr = *value; - variable_ptr->refcount = refcount; - variable_ptr->is_ref = 1; + Z_SET_REFCOUNT_P(variable_ptr, refcount); + Z_SET_ISREF_P(variable_ptr); if (type!=IS_TMP_VAR) { zendi_zval_copy_ctor(*variable_ptr); - value->refcount--; + Z_DELREF_P(value); } zendi_zval_dtor(garbage); } } else { - variable_ptr->refcount--; - if (variable_ptr->refcount==0) { + Z_DELREF_P(variable_ptr); + if (Z_REFCOUNT_P(variable_ptr)==0) { switch (type) { case IS_CV: case IS_VAR: /* break missing intentionally */ case IS_CONST: if (variable_ptr==value) { - variable_ptr->refcount++; + Z_ADDREF_P(variable_ptr); } else if (PZVAL_IS_REF(value)) { zval tmp; tmp = *value; zval_copy_ctor(&tmp); - tmp.refcount=1; + Z_SET_REFCOUNT(tmp, 1); zendi_zval_dtor(*variable_ptr); *variable_ptr = tmp; } else { - value->refcount++; + Z_ADDREF_P(value); zendi_zval_dtor(*variable_ptr); safe_free_zval_ptr(variable_ptr); *variable_ptr_ptr = value; @@ -826,7 +826,7 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2 break; case IS_TMP_VAR: zendi_zval_dtor(*variable_ptr); - value->refcount=1; + Z_SET_REFCOUNT_P(value, 1); *variable_ptr = *value; break; EMPTY_SWITCH_DEFAULT_CASE() @@ -837,26 +837,26 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2 case IS_VAR: /* break missing intentionally */ case IS_CONST: - if (PZVAL_IS_REF(value) && value->refcount > 0) { + if (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) { ALLOC_ZVAL(variable_ptr); *variable_ptr_ptr = variable_ptr; *variable_ptr = *value; zval_copy_ctor(variable_ptr); - variable_ptr->refcount=1; + Z_SET_REFCOUNT_P(variable_ptr, 1); break; } *variable_ptr_ptr = value; - value->refcount++; + Z_ADDREF_P(value); break; case IS_TMP_VAR: ALLOC_ZVAL(*variable_ptr_ptr); - value->refcount=1; + Z_SET_REFCOUNT_P(value, 1); **variable_ptr_ptr = *value; break; EMPTY_SWITCH_DEFAULT_CASE() } } - (*variable_ptr_ptr)->is_ref=0; + Z_UNSET_ISREF_PP(variable_ptr_ptr); } done_setting_var: @@ -883,7 +883,7 @@ static inline void zend_receive(zval **variable_ptr_ptr, zval *value TSRMLS_DC) if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", class_name); } else { - variable_ptr->refcount--; + Z_DELREF_P(variable_ptr); ALLOC_ZVAL(variable_ptr); *variable_ptr_ptr = variable_ptr; *variable_ptr = *value; @@ -895,9 +895,9 @@ static inline void zend_receive(zval **variable_ptr_ptr, zval *value TSRMLS_DC) efree(class_name); } } else { - variable_ptr->refcount--; + Z_DELREF_P(variable_ptr); *variable_ptr_ptr = value; - value->refcount++; + Z_ADDREF_P(value); } } @@ -981,7 +981,7 @@ fetch_string_dim: case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_symtable_update(ht, offset_key, offset_key_length+1, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -1016,7 +1016,7 @@ fetch_string_dim: case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_index_update(ht, index, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -1082,18 +1082,18 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container zval **retval; case IS_ARRAY: - if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) { + if ((type==BP_VAR_W || type==BP_VAR_RW) && Z_REFCOUNT_P(container)>1 && !PZVAL_IS_REF(container)) { SEPARATE_ZVAL(container_ptr); container = *container_ptr; } if (dim == NULL) { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); if (zend_hash_next_index_insert(Z_ARRVAL_P(container), &new_zval, sizeof(zval *), (void **) &retval) == FAILURE) { zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied"); retval = &EG(error_zval_ptr); - new_zval->refcount--; + Z_DELREF_P(new_zval); } } else { retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, type TSRMLS_CC); @@ -1177,16 +1177,16 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC); if (overloaded_result) { - if (!overloaded_result->is_ref && + if (!Z_ISREF_P(overloaded_result) && (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET)) { - if (overloaded_result->refcount > 0) { + if (Z_REFCOUNT_P(overloaded_result) > 0) { zval *tmp = overloaded_result; ALLOC_ZVAL(overloaded_result); *overloaded_result = *tmp; zval_copy_ctor(overloaded_result); - overloaded_result->is_ref = 0; - overloaded_result->refcount = 0; + Z_UNSET_ISREF_P(overloaded_result); + Z_SET_REFCOUNT_P(overloaded_result, 0); } if (Z_TYPE_P(overloaded_result) != IS_OBJECT) { zend_class_entry *ce = Z_OBJCE_P(container); @@ -1201,9 +1201,9 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container result->var.ptr_ptr = retval; AI_USE_PTR(result->var); PZVAL_LOCK(*result->var.ptr_ptr); - } else if ((*retval)->refcount == 0) { + } else if (Z_REFCOUNT_PP(retval) == 0) { /* Destroy unused result from offsetGet() magic method */ - (*retval)->refcount = 1; + Z_SET_REFCOUNT_PP(retval, 1); zval_ptr_dtor(retval); } if (dim_is_tmp_var) { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 28e1d79245..5bddc4dcc5 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -123,7 +123,7 @@ void init_executor(TSRMLS_D) { INIT_ZVAL(EG(uninitialized_zval)); /* trick to make uninitialized_zval never be modified, passed by ref, etc. */ - EG(uninitialized_zval).refcount++; + Z_ADDREF(EG(uninitialized_zval)); INIT_ZVAL(EG(error_zval)); EG(uninitialized_zval_ptr)=&EG(uninitialized_zval); EG(error_zval_ptr)=&EG(error_zval); @@ -153,8 +153,8 @@ void init_executor(TSRMLS_D) zval *globals; ALLOC_ZVAL(globals); - globals->refcount=1; - globals->is_ref=1; + Z_SET_REFCOUNT_P(globals, 1); + Z_SET_ISREF_P(globals); Z_TYPE_P(globals) = IS_ARRAY; Z_ARRVAL_P(globals) = &EG(symbol_table); zend_hash_update(&EG(symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL); @@ -197,7 +197,7 @@ void init_executor(TSRMLS_D) static int zval_call_destructor(zval **zv TSRMLS_DC) { - if (Z_TYPE_PP(zv) == IS_OBJECT && (*zv)->refcount == 1) { + if (Z_TYPE_PP(zv) == IS_OBJECT && Z_REFCOUNT_PP(zv) == 1) { return ZEND_HASH_APPLY_REMOVE; } else { return ZEND_HASH_APPLY_KEEP; @@ -408,13 +408,13 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) { #if DEBUG_ZEND>=2 - printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1); + printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr)-1); #endif - (*zval_ptr)->refcount--; - if ((*zval_ptr)->refcount==0) { + Z_DELREF_PP(zval_ptr); + if (Z_REFCOUNT_PP(zval_ptr)==0) { zval_dtor(*zval_ptr); safe_free_zval_ptr_rel(*zval_ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC); - } else if ((*zval_ptr)->refcount == 1) { + } else if (Z_REFCOUNT_PP(zval_ptr) == 1) { if ((*zval_ptr)->type == IS_OBJECT) { TSRMLS_FETCH(); @@ -422,7 +422,7 @@ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) return; } } - (*zval_ptr)->is_ref = 0; + Z_UNSET_ISREF_PP(zval_ptr); } } @@ -430,14 +430,14 @@ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) ZEND_API void _zval_internal_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) { #if DEBUG_ZEND>=2 - printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1); + printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr)-1); #endif - (*zval_ptr)->refcount--; - if ((*zval_ptr)->refcount==0) { + Z_DELREF_PP(zval_ptr); + if (Z_REFCOUNT_PP(zval_ptr)==0) { zval_internal_dtor(*zval_ptr); free(*zval_ptr); - } else if ((*zval_ptr)->refcount == 1) { - (*zval_ptr)->is_ref = 0; + } else if (Z_REFCOUNT_PP(zval_ptr) == 1) { + Z_UNSET_ISREF_PP(zval_ptr); } } @@ -472,8 +472,8 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco MARK_CONSTANT_VISITED(p); - refcount = p->refcount; - is_ref = p->is_ref; + refcount = Z_REFCOUNT_P(p); + is_ref = Z_ISREF_P(p); if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) { if ((colon = memchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p))) && colon[1] == ':') { @@ -493,8 +493,8 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco *p = const_value; } - p->refcount = refcount; - p->is_ref = is_ref; + Z_SET_REFCOUNT_P(p, refcount); + Z_SET_ISREF_TO_P(p, is_ref); } else if (Z_TYPE_P(p) == IS_CONSTANT_ARRAY) { zval **element, *new_val; char *str_index; @@ -537,8 +537,8 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco ALLOC_ZVAL(new_val); *new_val = **element; zval_copy_ctor(new_val); - new_val->refcount = 1; - new_val->is_ref = 0; + Z_SET_REFCOUNT_P(new_val, 1); + Z_UNSET_ISREF_P(new_val); /* preserve this bit for inheritance */ Z_TYPE_PP(element) |= IS_CONSTANT_INDEX; @@ -686,7 +686,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS fci->function_name = *tmp_real_function_name; SEPARATE_ZVAL_IF_NOT_REF(tmp_object_ptr); fci->object_pp = tmp_object_ptr; - (*fci->object_pp)->is_ref = 1; + Z_SET_ISREF_PP(fci->object_pp); } if (fci->object_pp && !*fci->object_pp) { @@ -904,7 +904,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i+1) && !PZVAL_IS_REF(*fci->params[i])) { - if ((*fci->params[i])->refcount>1) { + if (Z_REFCOUNT_PP(fci->params[i])>1) { zval *new_zval; if (fci->no_separation) { @@ -923,15 +923,15 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS ALLOC_ZVAL(new_zval); *new_zval = **fci->params[i]; zval_copy_ctor(new_zval); - new_zval->refcount = 1; - (*fci->params[i])->refcount--; + Z_SET_REFCOUNT_P(new_zval, 1); + Z_DELREF_PP(fci->params[i]); *fci->params[i] = new_zval; } - (*fci->params[i])->refcount++; - (*fci->params[i])->is_ref = 1; + Z_ADDREF_PP(fci->params[i]); + Z_SET_ISREF_PP(fci->params[i]); param = *fci->params[i]; } else if (*fci->params[i] != &EG(uninitialized_zval)) { - (*fci->params[i])->refcount++; + Z_ADDREF_PP(fci->params[i]); param = *fci->params[i]; } else { ALLOC_ZVAL(param); @@ -975,7 +975,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EG(This) = *fci->object_pp; if (!PZVAL_IS_REF(EG(This))) { - EG(This)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EG(This)); /* For $this pointer */ } else { zval *this_ptr; @@ -1278,12 +1278,12 @@ void execute_new_code(TSRMLS_D) while (opline<end) { if (opline->op1.op_type==IS_CONST) { - opline->op1.u.constant.is_ref = 1; - opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */ + Z_SET_ISREF(opline->op1.u.constant); + Z_SET_REFCOUNT(opline->op1.u.constant, 2); /* Make sure is_ref won't be reset */ } if (opline->op2.op_type==IS_CONST) { - opline->op2.u.constant.is_ref = 1; - opline->op2.u.constant.refcount = 2; + Z_SET_ISREF(opline->op2.u.constant); + Z_SET_REFCOUNT(opline->op2.u.constant, 2); } switch (opline->opcode) { case ZEND_JMP: diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 40c63ed967..d92cf92fe4 100755 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -274,7 +274,7 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva iterator = emalloc(sizeof(zend_user_iterator)); - object->refcount++; + Z_ADDREF_P(object); iterator->it.data = (void*)object; iterator->it.funcs = ce->iterator_funcs.funcs; iterator->ce = Z_OBJCE_P(object); diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index f05ab62394..6f43145819 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -378,8 +378,8 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR retval_znode.op_type = IS_CONST; retval_znode.u.constant.type = IS_LONG; retval_znode.u.constant.value.lval = 1; - retval_znode.u.constant.is_ref = 0; - retval_znode.u.constant.refcount = 1; + Z_UNSET_ISREF(retval_znode.u.constant); + Z_SET_REFCOUNT(retval_znode.u.constant, 1); zend_save_lexical_state(&original_lex_state TSRMLS_CC); diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index 8eec12cd03..1b03a097dd 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -39,7 +39,7 @@ extern const struct _zend_arg_info fourth_arg_force_ref[5]; extern const struct _zend_arg_info fifth_arg_force_ref[6]; extern const struct _zend_arg_info all_args_by_ref[1]; -#define ZEND_MODULE_API_NO 20070929 +#define ZEND_MODULE_API_NO 20071006 #ifdef ZTS #define USING_ZTS 1 #else diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 5e741a0737..e0260c1a65 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -74,7 +74,7 @@ static zval *zend_std_call_getter(zval *object, zval *member TSRMLS_DC) zval_ptr_dtor(&member); if (retval) { - retval->refcount--; + Z_DELREF_P(retval); } return retval; @@ -87,7 +87,7 @@ static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_D zend_class_entry *ce = Z_OBJCE_P(object); SEPARATE_ARG_IF_REF(member); - value->refcount++; + Z_ADDREF_P(value); /* __set handler is called with two arguments: property name @@ -334,16 +334,16 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC) if (rv) { retval = &rv; - if (!rv->is_ref && + if (!Z_ISREF_P(rv) && (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET)) { - if (rv->refcount > 0) { + if (Z_REFCOUNT_P(rv) > 0) { zval *tmp = rv; ALLOC_ZVAL(rv); *rv = *tmp; zval_copy_ctor(rv); - rv->is_ref = 0; - rv->refcount = 0; + Z_UNSET_ISREF_P(rv); + Z_SET_REFCOUNT_P(rv, 0); } if (Z_TYPE_P(rv) != IS_OBJECT) { zend_error(E_NOTICE, "Indirect modification of overloaded property %s::$%s has no effect", zobj->ce->name, Z_STRVAL_P(member)); @@ -360,9 +360,9 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC) } } if (tmp_member) { - (*retval)->refcount++; + Z_ADDREF_PP(retval); zval_ptr_dtor(&tmp_member); - (*retval)->refcount--; + Z_DELREF_PP(retval); } return *retval; } @@ -399,7 +399,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM /* To check: can't *variable_ptr be some system variable like error_zval here? */ (*variable_ptr)->type = value->type; (*variable_ptr)->value = value->value; - if (value->refcount>0) { + if (Z_REFCOUNT_P(value)>0) { zval_copy_ctor(*variable_ptr); } zval_dtor(&garbage); @@ -407,7 +407,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM zval *garbage = *variable_ptr; /* if we assign referenced variable, we should separate it */ - value->refcount++; + Z_ADDREF_P(value); if (PZVAL_IS_REF(value)) { SEPARATE_ZVAL(&value); } @@ -433,7 +433,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM zval **foo; /* if we assign referenced variable, we should separate it */ - value->refcount++; + Z_ADDREF_P(value); if (PZVAL_IS_REF(value)) { SEPARATE_ZVAL(&value); } @@ -470,7 +470,7 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) } /* Undo PZVAL_LOCK() */ - retval->refcount--; + Z_DELREF_P(retval); return retval; } else { @@ -562,7 +562,7 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC new_zval = &EG(uninitialized_zval); /* zend_error(E_NOTICE, "Undefined property: %s", Z_STRVAL_P(member)); */ - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_quick_update(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, &new_zval, sizeof(zval *), (void **) &retval); } else { /* we do have getter - fail and let it try again with usual get/set */ @@ -657,7 +657,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) zend_call_method_with_2_params(&this_ptr, ce, &ce->__call, ZEND_CALL_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr); if (method_result_ptr) { - if (method_result_ptr->is_ref || method_result_ptr->refcount > 1) { + if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) { RETVAL_ZVAL(method_result_ptr, 1, 1); } else { RETVAL_ZVAL(method_result_ptr, 0, 1); @@ -852,7 +852,7 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ zend_call_method_with_2_params(NULL, ce, &ce->__callstatic, ZEND_CALLSTATIC_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr); if (method_result_ptr) { - if (method_result_ptr->is_ref || method_result_ptr->refcount > 1) { + if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) { RETVAL_ZVAL(method_result_ptr, 1, 1); } else { RETVAL_ZVAL(method_result_ptr, 0, 1); @@ -1064,7 +1064,7 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists rv = zend_std_call_getter(object, member TSRMLS_CC); guard->in_get = 0; if (rv) { - rv->refcount++; + Z_ADDREF_P(rv); result = i_zend_is_true(rv); zval_ptr_dtor(&rv); } diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 1c7d61e850..08ecc9641e 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -156,7 +156,7 @@ static void zval_add_ref_or_clone(zval **p) (*p)->value.obj = Z_OBJ_HT_PP(p)->clone_obj(orig TSRMLS_CC); } } else { - (*p)->refcount++; + Z_ADDREF_PP(p); } } diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index d2d4ff0ace..c3c3d3c14e 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -164,9 +164,9 @@ ZEND_API void zend_objects_store_del_ref(zval *zobject TSRMLS_DC) handle = Z_OBJ_HANDLE_P(zobject); - zobject->refcount++; + Z_ADDREF_P(zobject); zend_objects_store_del_ref_by_handle(handle TSRMLS_CC); - zobject->refcount--; + Z_DELREF_P(zobject); } /* diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 973d3f3b65..c883cf45d3 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -378,12 +378,12 @@ int pass_two(zend_op_array *op_array TSRMLS_DC) end = opline + op_array->last; while (opline < end) { if (opline->op1.op_type == IS_CONST) { - opline->op1.u.constant.is_ref = 1; - opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */ + Z_SET_ISREF(opline->op1.u.constant); + Z_SET_REFCOUNT(opline->op1.u.constant, 2); /* Make sure is_ref won't be reset */ } if (opline->op2.op_type == IS_CONST) { - opline->op2.u.constant.is_ref = 1; - opline->op2.u.constant.refcount = 2; + Z_SET_ISREF(opline->op2.u.constant); + Z_SET_REFCOUNT(opline->op2.u.constant, 2); } switch (opline->opcode) { case ZEND_JMP: diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index b37e44f026..4f0936192d 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1306,7 +1306,7 @@ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_ static inline void zend_free_obj_get_result(zval *op) { if (op) { - if (op->refcount == 0) { + if (Z_REFCOUNT_P(op) == 0) { zval_dtor(op); FREE_ZVAL(op); } else { diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 342ecc4d01..c20c57088c 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -367,7 +367,7 @@ END_EXTERN_C() #define convert_scalar_to_number_ex(ppzv) \ if (Z_TYPE_PP(ppzv)!=IS_LONG && Z_TYPE_PP(ppzv)!=IS_DOUBLE) { \ - if (!(*ppzv)->is_ref) { \ + if (!Z_ISREF_PP(ppzv)) { \ SEPARATE_ZVAL(ppzv); \ } \ convert_scalar_to_number(*ppzv TSRMLS_CC); \ diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index fecaf7811c..8664145c6d 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -97,7 +97,7 @@ ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC) ZEND_API void zval_add_ref(zval **p) { - (*p)->refcount++; + Z_ADDREF_PP(p); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 8d706d49d9..54af310f5a 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -348,13 +348,13 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -409,7 +409,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); if (object_ptr && OP1_TYPE != IS_CV && !OP1_FREE) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -456,7 +456,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -586,13 +586,13 @@ ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR| if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -676,7 +676,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -689,7 +689,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -743,7 +743,7 @@ ZEND_VM_HANDLER(34, ZEND_PRE_INC, VAR|CV, ANY) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -786,7 +786,7 @@ ZEND_VM_HANDLER(35, ZEND_PRE_DEC, VAR|CV, ANY) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -830,7 +830,7 @@ ZEND_VM_HANDLER(36, ZEND_POST_INC, VAR|CV, ANY) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -868,7 +868,7 @@ ZEND_VM_HANDLER(37, ZEND_POST_DEC, VAR|CV, ANY) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -949,7 +949,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, ANY, int type case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -1201,7 +1201,7 @@ ZEND_VM_HELPER_EX(zend_fetch_property_address_read_helper, VAR|UNUSED|CV, CONST| /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -1443,7 +1443,7 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV) if (OP2_TYPE == IS_VAR && value_ptr_ptr && - !(*value_ptr_ptr)->is_ref && + !Z_ISREF_PP(value_ptr_ptr) && opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op2.u.var).var.fcall_returned_reference) { if (free_op2.var == NULL) { @@ -1583,9 +1583,9 @@ ZEND_VM_HANDLER(53, ZEND_INIT_STRING, ANY, ANY) tmp->value.str.val = emalloc(1); tmp->value.str.val[0] = 0; tmp->value.str.len = 0; - tmp->refcount = 1; + Z_SET_REFCOUNT_P(tmp, 1); tmp->type = IS_STRING; - tmp->is_ref = 0; + Z_UNSET_ISREF_P(tmp); ZEND_VM_NEXT_OPCODE(); } @@ -1716,7 +1716,7 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -1813,7 +1813,7 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -1967,8 +1967,8 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) { - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; + Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); } */ if (!return_value_used) { @@ -2035,8 +2035,8 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) if (!return_value_used) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } else { - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; + Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); EX_T(opline->result.u.var).var.fcall_returned_reference = 0; } } @@ -2044,9 +2044,9 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) if (EG(This)) { if (EG(exception) && IS_CTOR_CALL(EX(called_scope))) { if (IS_CTOR_USED(EX(called_scope))) { - EG(This)->refcount--; + Z_DELREF_P(EG(This)); } - if (EG(This)->refcount == 1) { + if (Z_REFCOUNT_P(EG(This)) == 1) { zend_object_store_ctor_failed(EG(This) TSRMLS_CC); } } @@ -2123,7 +2123,7 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY) zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } - if (OP1_TYPE == IS_VAR && !(*retval_ptr_ptr)->is_ref) { + if (OP1_TYPE == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) { if (opline->extended_value == ZEND_RETURNS_FUNCTION && EX_T(opline->op1.u.var).var.fcall_returned_reference) { } else if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr) { @@ -2136,7 +2136,7 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY) } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; + Z_ADDREF_PP(retval_ptr_ptr); (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { @@ -2164,7 +2164,7 @@ ZEND_VM_C_LABEL(return_by_value): } } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */ if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || - (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { + (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; ALLOC_ZVAL(ret); @@ -2173,7 +2173,7 @@ ZEND_VM_C_LABEL(return_by_value): *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; + Z_ADDREF_P(retval_ptr); } } else { zval *ret; @@ -2274,17 +2274,17 @@ ZEND_VM_HELPER(zend_send_by_var_helper, VAR|CV, ANY) if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); INIT_ZVAL(*varptr); - varptr->refcount = 0; + Z_SET_REFCOUNT_P(varptr, 0); } else if (PZVAL_IS_REF(varptr)) { zval *original_var = varptr; ALLOC_ZVAL(varptr); *varptr = *original_var; - varptr->is_ref = 0; - varptr->refcount = 0; + Z_UNSET_ISREF_P(varptr); + Z_SET_REFCOUNT_P(varptr, 0); zval_copy_ctor(varptr); } - varptr->refcount++; + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1(); /* for string offsets */ @@ -2318,9 +2318,9 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY) EX_T(opline->op1.u.var).var.fcall_returned_reference) && varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || - (varptr->refcount == 1 && (OP1_TYPE == IS_CV || free_op1.var)))) { - varptr->is_ref = 1; - varptr->refcount++; + (Z_REFCOUNT_P(varptr) == 1 && (OP1_TYPE == IS_CV || free_op1.var)))) { + Z_SET_ISREF_P(varptr); + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); } else { zval *valptr; @@ -2351,7 +2351,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY) SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); varptr = *varptr_ptr; - varptr->refcount++; + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1_VAR_PTR(); @@ -2421,10 +2421,10 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST) if (Z_TYPE(opline->op2.u.constant)==IS_CONSTANT_ARRAY) { zval_copy_ctor(default_value); } - default_value->refcount=1; + Z_SET_REFCOUNT_P(default_value, 1); zval_update_constant(&default_value, 0 TSRMLS_CC); - default_value->refcount=0; - default_value->is_ref=0; + Z_SET_REFCOUNT_P(default_value, 0); + Z_UNSET_ISREF_P(default_value); param = &default_value; assignment_value = default_value; } else { @@ -2496,7 +2496,7 @@ ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -2581,7 +2581,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY) if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error_noreturn(E_ERROR, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } @@ -2596,7 +2596,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY) zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object"); } EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); } if (ce && clone) { @@ -2620,8 +2620,8 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY) ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC); Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); + Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr); if (!RETURN_VALUE_USED(opline) || EG(exception)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } @@ -2729,7 +2729,7 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUS if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -2740,7 +2740,7 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUS expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -2992,7 +2992,7 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, ANY) convert_to_string(&tmp); varname = &tmp; } else if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) { - varname->refcount++; + Z_ADDREF_P(varname); } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -3059,7 +3059,7 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV) break; case IS_STRING: if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -3179,18 +3179,18 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; + Z_ADDREF_PP(array_ptr_ptr); } array_ptr = *array_ptr_ptr; } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - (*array_ptr_ptr)->is_ref = 1; + Z_SET_ISREF_PP(array_ptr_ptr); } } array_ptr = *array_ptr_ptr; - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); @@ -3203,12 +3203,12 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); if (!ce || !ce->get_iterator) { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && - !array_ptr->is_ref && - array_ptr->refcount > 1) { + !Z_ISREF_P(array_ptr) && + Z_REFCOUNT_P(array_ptr) > 1) { zval *tmp; ALLOC_ZVAL(tmp); @@ -3216,7 +3216,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) zval_copy_ctor(tmp); array_ptr = tmp; } else { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } } @@ -3249,7 +3249,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { FREE_OP1_VAR_PTR(); @@ -3261,7 +3261,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) } is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS; if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { FREE_OP1_VAR_PTR(); @@ -3379,7 +3379,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter TSRMLS_CC); if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -3388,7 +3388,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) { /* reached end of iteration */ if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -3396,7 +3396,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) } iter->funcs->get_current_data(iter, &value TSRMLS_CC); if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -3408,7 +3408,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) if (iter->funcs->get_current_key) { key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -3422,9 +3422,9 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) if (opline->extended_value & ZEND_FE_FETCH_BYREF) { SEPARATE_ZVAL_IF_NOT_REF(value); - (*value)->is_ref = 1; + Z_SET_ISREF_PP(value); EX_T(opline->result.u.var).var.ptr_ptr = value; - (*value)->refcount++; + Z_ADDREF_PP(value); } else { EX_T(opline->result.u.var).var.ptr_ptr = value; PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); @@ -3855,7 +3855,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack)); if (EX(object)) { if (IS_CTOR_USED(EX(called_scope))) { - EX(object)->refcount--; + Z_DELREF_P(EX(object)); } zval_ptr_dtor(&EX(object)); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 1c941bc173..5cd25157e6 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -66,9 +66,9 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) } if (op_array->uses_this && EG(This)) { - EG(This)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EG(This)); /* For $this pointer */ if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL)==FAILURE) { - EG(This)->refcount--; + Z_DELREF_P(EG(This)); } } @@ -111,9 +111,9 @@ static int ZEND_INIT_STRING_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) tmp->value.str.val = emalloc(1); tmp->value.str.val[0] = 0; tmp->value.str.len = 0; - tmp->refcount = 1; + Z_SET_REFCOUNT_P(tmp, 1); tmp->type = IS_STRING; - tmp->is_ref = 0; + Z_UNSET_ISREF_P(tmp); ZEND_VM_NEXT_OPCODE(); } @@ -201,8 +201,8 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) { - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; + Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); } */ if (!return_value_used) { @@ -269,8 +269,8 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) if (!return_value_used) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } else { - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; + Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); EX_T(opline->result.u.var).var.fcall_returned_reference = 0; } } @@ -278,9 +278,9 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) if (EG(This)) { if (EG(exception) && IS_CTOR_CALL(EX(called_scope))) { if (IS_CTOR_USED(EX(called_scope))) { - EG(This)->refcount--; + Z_DELREF_P(EG(This)); } - if (EG(This)->refcount == 1) { + if (Z_REFCOUNT_P(EG(This)) == 1) { zend_object_store_ctor_failed(EG(This) TSRMLS_CC); } } @@ -554,7 +554,7 @@ static int ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack)); if (EX(object)) { if (IS_CTOR_USED(EX(called_scope))) { - EX(object)->refcount--; + Z_DELREF_P(EX(object)); } zval_ptr_dtor(&EX(object)); } @@ -731,10 +731,10 @@ static int ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (Z_TYPE(opline->op2.u.constant)==IS_CONSTANT_ARRAY) { zval_copy_ctor(default_value); } - default_value->refcount=1; + Z_SET_REFCOUNT_P(default_value, 1); zval_update_constant(&default_value, 0 TSRMLS_CC); - default_value->refcount=0; - default_value->is_ref=0; + Z_SET_REFCOUNT_P(default_value, 0); + Z_UNSET_ISREF_P(default_value); param = &default_value; assignment_value = default_value; } else { @@ -1248,7 +1248,7 @@ static int zend_fetch_var_address_helper_SPEC_CONST(int type, ZEND_OPCODE_HANDLE case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -1455,7 +1455,7 @@ static int ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } - if (IS_CONST == IS_VAR && !(*retval_ptr_ptr)->is_ref) { + if (IS_CONST == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) { if (opline->extended_value == ZEND_RETURNS_FUNCTION && EX_T(opline->op1.u.var).var.fcall_returned_reference) { } else if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr) { @@ -1468,7 +1468,7 @@ static int ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; + Z_ADDREF_PP(retval_ptr_ptr); (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { @@ -1496,7 +1496,7 @@ return_by_value: } } else if (!0) { /* Not a temp var */ if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || - (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { + (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; ALLOC_ZVAL(ret); @@ -1505,7 +1505,7 @@ return_by_value: *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; + Z_ADDREF_P(retval_ptr); } } else { zval *ret; @@ -1592,7 +1592,7 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error_noreturn(E_ERROR, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); ZEND_VM_NEXT_OPCODE(); } @@ -1607,7 +1607,7 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object"); } EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); } if (ce && clone) { @@ -1631,8 +1631,8 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC); Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); + Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr); if (!RETURN_VALUE_USED(opline) || EG(exception)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } @@ -1843,7 +1843,7 @@ static int ZEND_UNSET_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) convert_to_string(&tmp); varname = &tmp; } else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { - varname->refcount++; + Z_ADDREF_P(varname); } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -1904,18 +1904,18 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; + Z_ADDREF_PP(array_ptr_ptr); } array_ptr = *array_ptr_ptr; } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - (*array_ptr_ptr)->is_ref = 1; + Z_SET_ISREF_PP(array_ptr_ptr); } } array_ptr = *array_ptr_ptr; - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { array_ptr = &opline->op1.u.constant; @@ -1928,12 +1928,12 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); if (!ce || !ce->get_iterator) { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) && - !array_ptr->is_ref && - array_ptr->refcount > 1) { + !Z_ISREF_P(array_ptr) && + Z_REFCOUNT_P(array_ptr) > 1) { zval *tmp; ALLOC_ZVAL(tmp); @@ -1941,7 +1941,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval_copy_ctor(tmp); array_ptr = tmp; } else { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } } @@ -1974,7 +1974,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -1986,7 +1986,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS; if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -2473,7 +2473,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HAN } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -2492,7 +2492,7 @@ static int ZEND_CASE_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -2611,7 +2611,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_A if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -2622,7 +2622,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_A expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -3021,7 +3021,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -3040,7 +3040,7 @@ static int ZEND_CASE_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -3093,7 +3093,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -3104,7 +3104,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -3469,7 +3469,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -3488,7 +3488,7 @@ static int ZEND_CASE_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -3541,7 +3541,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -3552,7 +3552,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -3683,7 +3683,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HA } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -3723,7 +3723,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -3734,7 +3734,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -4099,7 +4099,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLE } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -4118,7 +4118,7 @@ static int ZEND_CASE_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -4170,7 +4170,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -4181,7 +4181,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -4322,7 +4322,7 @@ static int zend_fetch_var_address_helper_SPEC_TMP(int type, ZEND_OPCODE_HANDLER_ case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -4524,7 +4524,7 @@ static int ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } - if (IS_TMP_VAR == IS_VAR && !(*retval_ptr_ptr)->is_ref) { + if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) { if (opline->extended_value == ZEND_RETURNS_FUNCTION && EX_T(opline->op1.u.var).var.fcall_returned_reference) { } else if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr) { @@ -4537,7 +4537,7 @@ static int ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; + Z_ADDREF_PP(retval_ptr_ptr); (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { @@ -4565,7 +4565,7 @@ return_by_value: } } else if (!1) { /* Not a temp var */ if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || - (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { + (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; ALLOC_ZVAL(ret); @@ -4574,7 +4574,7 @@ return_by_value: *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; + Z_ADDREF_P(retval_ptr); } } else { zval *ret; @@ -4668,7 +4668,7 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error_noreturn(E_ERROR, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); ZEND_VM_NEXT_OPCODE(); } @@ -4683,7 +4683,7 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object"); } EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); } if (ce && clone) { @@ -4707,8 +4707,8 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC); Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); + Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr); if (!RETURN_VALUE_USED(opline) || EG(exception)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } @@ -4919,7 +4919,7 @@ static int ZEND_UNSET_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) convert_to_string(&tmp); varname = &tmp; } else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { - varname->refcount++; + Z_ADDREF_P(varname); } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -4980,18 +4980,18 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; + Z_ADDREF_PP(array_ptr_ptr); } array_ptr = *array_ptr_ptr; } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - (*array_ptr_ptr)->is_ref = 1; + Z_SET_ISREF_PP(array_ptr_ptr); } } array_ptr = *array_ptr_ptr; - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { array_ptr = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); @@ -5004,12 +5004,12 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); if (!ce || !ce->get_iterator) { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { if ((IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) && - !array_ptr->is_ref && - array_ptr->refcount > 1) { + !Z_ISREF_P(array_ptr) && + Z_REFCOUNT_P(array_ptr) > 1) { zval *tmp; ALLOC_ZVAL(tmp); @@ -5017,7 +5017,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval_copy_ctor(tmp); array_ptr = tmp; } else { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } } @@ -5050,7 +5050,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -5062,7 +5062,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS; if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -5556,7 +5556,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -5581,7 +5581,7 @@ static int ZEND_CASE_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -5633,7 +5633,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -5644,7 +5644,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -6001,7 +6001,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -6027,7 +6027,7 @@ static int ZEND_CASE_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -6080,7 +6080,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -6091,7 +6091,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -6448,7 +6448,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -6474,7 +6474,7 @@ static int ZEND_CASE_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -6527,7 +6527,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -6538,7 +6538,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -6620,7 +6620,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -6631,7 +6631,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -6987,7 +6987,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -7012,7 +7012,7 @@ static int ZEND_CASE_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -7064,7 +7064,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -7075,7 +7075,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -7172,7 +7172,7 @@ static int ZEND_PRE_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -7215,7 +7215,7 @@ static int ZEND_PRE_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -7259,7 +7259,7 @@ static int ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -7297,7 +7297,7 @@ static int ZEND_POST_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -7378,7 +7378,7 @@ static int zend_fetch_var_address_helper_SPEC_VAR(int type, ZEND_OPCODE_HANDLER_ case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -7574,7 +7574,7 @@ static int ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } - if (IS_VAR == IS_VAR && !(*retval_ptr_ptr)->is_ref) { + if (IS_VAR == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) { if (opline->extended_value == ZEND_RETURNS_FUNCTION && EX_T(opline->op1.u.var).var.fcall_returned_reference) { } else if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr) { @@ -7587,7 +7587,7 @@ static int ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; + Z_ADDREF_PP(retval_ptr_ptr); (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { @@ -7615,7 +7615,7 @@ return_by_value: } } else if (!0) { /* Not a temp var */ if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || - (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { + (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; ALLOC_ZVAL(ret); @@ -7624,7 +7624,7 @@ return_by_value: *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; + Z_ADDREF_P(retval_ptr); } } else { zval *ret; @@ -7697,17 +7697,17 @@ static int zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS) if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); INIT_ZVAL(*varptr); - varptr->refcount = 0; + Z_SET_REFCOUNT_P(varptr, 0); } else if (PZVAL_IS_REF(varptr)) { zval *original_var = varptr; ALLOC_ZVAL(varptr); *varptr = *original_var; - varptr->is_ref = 0; - varptr->refcount = 0; + Z_UNSET_ISREF_P(varptr); + Z_SET_REFCOUNT_P(varptr, 0); zval_copy_ctor(varptr); } - varptr->refcount++; + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; /* for string offsets */ @@ -7741,9 +7741,9 @@ static int ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX_T(opline->op1.u.var).var.fcall_returned_reference) && varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || - (varptr->refcount == 1 && (IS_VAR == IS_CV || free_op1.var)))) { - varptr->is_ref = 1; - varptr->refcount++; + (Z_REFCOUNT_P(varptr) == 1 && (IS_VAR == IS_CV || free_op1.var)))) { + Z_SET_ISREF_P(varptr); + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); } else { zval *valptr; @@ -7774,7 +7774,7 @@ static int ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); varptr = *varptr_ptr; - varptr->refcount++; + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -7823,7 +7823,7 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error_noreturn(E_ERROR, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; ZEND_VM_NEXT_OPCODE(); } @@ -7838,7 +7838,7 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object"); } EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); } if (ce && clone) { @@ -7862,8 +7862,8 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC); Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); + Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr); if (!RETURN_VALUE_USED(opline) || EG(exception)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } @@ -8074,7 +8074,7 @@ static int ZEND_UNSET_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) convert_to_string(&tmp); varname = &tmp; } else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { - varname->refcount++; + Z_ADDREF_P(varname); } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -8135,18 +8135,18 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; + Z_ADDREF_PP(array_ptr_ptr); } array_ptr = *array_ptr_ptr; } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - (*array_ptr_ptr)->is_ref = 1; + Z_SET_ISREF_PP(array_ptr_ptr); } } array_ptr = *array_ptr_ptr; - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { array_ptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); @@ -8159,12 +8159,12 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); if (!ce || !ce->get_iterator) { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && - !array_ptr->is_ref && - array_ptr->refcount > 1) { + !Z_ISREF_P(array_ptr) && + Z_REFCOUNT_P(array_ptr) > 1) { zval *tmp; ALLOC_ZVAL(tmp); @@ -8172,7 +8172,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval_copy_ctor(tmp); array_ptr = tmp; } else { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } } @@ -8205,7 +8205,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -8217,7 +8217,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS; if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -8335,7 +8335,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter TSRMLS_CC); if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -8344,7 +8344,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) { /* reached end of iteration */ if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -8352,7 +8352,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } iter->funcs->get_current_data(iter, &value TSRMLS_CC); if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -8364,7 +8364,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (iter->funcs->get_current_key) { key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); if (EG(exception)) { - array->refcount--; + Z_DELREF_P(array); zval_ptr_dtor(&array); ZEND_VM_NEXT_OPCODE(); } @@ -8378,9 +8378,9 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value & ZEND_FE_FETCH_BYREF) { SEPARATE_ZVAL_IF_NOT_REF(value); - (*value)->is_ref = 1; + Z_SET_ISREF_PP(value); EX_T(opline->result.u.var).var.ptr_ptr = value; - (*value)->refcount++; + Z_ADDREF_PP(value); } else { EX_T(opline->result.u.var).var.ptr_ptr = value; PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); @@ -8819,13 +8819,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(int (*binary_op)(zval if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -8880,7 +8880,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binary_op)(zval *re zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -8927,7 +8927,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binary_op)(zval *re && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -9056,13 +9056,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_CONST(incdec_t incdec_op, ZE if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -9146,7 +9146,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_t incdec_op, Z if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -9159,7 +9159,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_t incdec_op, Z zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -9354,7 +9354,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_CONST(int type, ZEND /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -9603,7 +9603,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -9699,7 +9699,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -9718,7 +9718,7 @@ static int ZEND_CASE_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -9837,7 +9837,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -9848,7 +9848,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -9927,7 +9927,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -10461,13 +10461,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(int (*binary_op)(zval * if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -10522,7 +10522,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_op)(zval *resu zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -10569,7 +10569,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_op)(zval *resu && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -10699,13 +10699,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_TMP(incdec_t incdec_op, ZEND if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -10789,7 +10789,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t incdec_op, ZEN if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -10802,7 +10802,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t incdec_op, ZEN zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -10997,7 +10997,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_TMP(int type, ZEND_O /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -11247,7 +11247,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -11344,7 +11344,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -11363,7 +11363,7 @@ static int ZEND_CASE_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -11416,7 +11416,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -11427,7 +11427,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -11506,7 +11506,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -12040,13 +12040,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(int (*binary_op)(zval * if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -12101,7 +12101,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_op)(zval *resu zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -12148,7 +12148,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_op)(zval *resu && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -12278,13 +12278,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_VAR(incdec_t incdec_op, ZEND if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -12368,7 +12368,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t incdec_op, ZEN if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -12381,7 +12381,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t incdec_op, ZEN zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -12576,7 +12576,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_VAR(int type, ZEND_O /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -12795,7 +12795,7 @@ static int ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (IS_VAR == IS_VAR && value_ptr_ptr && - !(*value_ptr_ptr)->is_ref && + !Z_ISREF_PP(value_ptr_ptr) && opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op2.u.var).var.fcall_returned_reference) { if (free_op2.var == NULL) { @@ -12864,7 +12864,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -12961,7 +12961,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -12980,7 +12980,7 @@ static int ZEND_CASE_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -13033,7 +13033,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -13044,7 +13044,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -13123,7 +13123,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -13423,13 +13423,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(int (*binary_op)(zva if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -13484,7 +13484,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*binary_op)(zval *r zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -13531,7 +13531,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*binary_op)(zval *r && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -13779,7 +13779,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAND } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -13819,7 +13819,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -13830,7 +13830,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -14181,13 +14181,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_CV(int (*binary_op)(zval *r if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -14242,7 +14242,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_op)(zval *resul zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -14289,7 +14289,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_op)(zval *resul && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -14418,13 +14418,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_CV(incdec_t incdec_op, ZEND_ if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -14508,7 +14508,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t incdec_op, ZEND if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -14521,7 +14521,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t incdec_op, ZEND zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -14716,7 +14716,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_CV(int type, ZEND_OP /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -14933,7 +14933,7 @@ static int ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (IS_CV == IS_VAR && value_ptr_ptr && - !(*value_ptr_ptr)->is_ref && + !Z_ISREF_PP(value_ptr_ptr) && opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op2.u.var).var.fcall_returned_reference) { if (free_op2.var == NULL) { @@ -15001,7 +15001,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -15097,7 +15097,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ } if ((EX(object) = EG(This))) { - EX(object)->refcount++; + Z_ADDREF_P(EX(object)); EX(called_scope) = Z_OBJCE_P(EX(object)); } } @@ -15116,7 +15116,7 @@ static int ZEND_CASE_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -15168,7 +15168,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -15179,7 +15179,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -15258,7 +15258,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_CV == IS_CV || IS_CV == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -15503,7 +15503,7 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error_noreturn(E_ERROR, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); ZEND_VM_NEXT_OPCODE(); } @@ -15518,7 +15518,7 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object"); } EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); } if (ce && clone) { @@ -15542,8 +15542,8 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC); Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); + Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr); if (!RETURN_VALUE_USED(opline) || EG(exception)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } @@ -15639,13 +15639,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_CONST(int (*binary_op)(z if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -15699,7 +15699,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CONST(int (*binary_op)(zval zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (object_ptr && IS_UNUSED != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -15746,7 +15746,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CONST(int (*binary_op)(zval && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -15875,13 +15875,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_CONST(incdec_t incdec_op, if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -15965,7 +15965,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CONST(incdec_t incdec_op if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -15978,7 +15978,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CONST(incdec_t incdec_op zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -16048,7 +16048,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_CONST(int type, Z /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -16250,7 +16250,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_A EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -16374,7 +16374,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -16670,13 +16670,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(int (*binary_op)(zva if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -16730,7 +16730,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*binary_op)(zval *r zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (object_ptr && IS_UNUSED != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -16777,7 +16777,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*binary_op)(zval *r && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -16907,13 +16907,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_TMP(incdec_t incdec_op, Z if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -16997,7 +16997,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec_t incdec_op, if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -17010,7 +17010,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec_t incdec_op, zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -17080,7 +17080,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_TMP(int type, ZEN /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -17282,7 +17282,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -17340,7 +17340,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -17636,13 +17636,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(int (*binary_op)(zva if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -17696,7 +17696,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*binary_op)(zval *r zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (object_ptr && IS_UNUSED != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -17743,7 +17743,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*binary_op)(zval *r && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -17873,13 +17873,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_VAR(incdec_t incdec_op, Z if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -17963,7 +17963,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec_t incdec_op, if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -17976,7 +17976,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec_t incdec_op, zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -18046,7 +18046,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_VAR(int type, ZEN /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -18248,7 +18248,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -18306,7 +18306,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -18602,13 +18602,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(int (*binary_op)( if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -18662,7 +18662,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (object_ptr && IS_UNUSED != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -18709,7 +18709,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -18868,13 +18868,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*binary_op)(zval if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -18928,7 +18928,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *re zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (object_ptr && IS_UNUSED != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -18975,7 +18975,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *re && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -19104,13 +19104,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_CV(incdec_t incdec_op, ZE if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -19194,7 +19194,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CV(incdec_t incdec_op, Z if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -19207,7 +19207,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CV(incdec_t incdec_op, Z zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -19277,7 +19277,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_CV(int type, ZEND /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -19479,7 +19479,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -19536,7 +19536,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_CV == IS_CV || IS_CV == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -19812,7 +19812,7 @@ static int ZEND_PRE_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -19854,7 +19854,7 @@ static int ZEND_PRE_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -19897,7 +19897,7 @@ static int ZEND_POST_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -19934,7 +19934,7 @@ static int ZEND_POST_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; + Z_ADDREF_P(val); decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); @@ -20013,7 +20013,7 @@ static int zend_fetch_var_address_helper_SPEC_CV(int type, ZEND_OPCODE_HANDLER_A case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); - new_zval->refcount++; + Z_ADDREF_P(new_zval); zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; @@ -20204,7 +20204,7 @@ static int ZEND_RETURN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } - if (IS_CV == IS_VAR && !(*retval_ptr_ptr)->is_ref) { + if (IS_CV == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) { if (opline->extended_value == ZEND_RETURNS_FUNCTION && EX_T(opline->op1.u.var).var.fcall_returned_reference) { } else if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr) { @@ -20217,7 +20217,7 @@ static int ZEND_RETURN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; + Z_ADDREF_PP(retval_ptr_ptr); (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { @@ -20245,7 +20245,7 @@ return_by_value: } } else if (!0) { /* Not a temp var */ if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || - (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { + (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; ALLOC_ZVAL(ret); @@ -20254,7 +20254,7 @@ return_by_value: *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; + Z_ADDREF_P(retval_ptr); } } else { zval *ret; @@ -20327,17 +20327,17 @@ static int zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS) if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); INIT_ZVAL(*varptr); - varptr->refcount = 0; + Z_SET_REFCOUNT_P(varptr, 0); } else if (PZVAL_IS_REF(varptr)) { zval *original_var = varptr; ALLOC_ZVAL(varptr); *varptr = *original_var; - varptr->is_ref = 0; - varptr->refcount = 0; + Z_UNSET_ISREF_P(varptr); + Z_SET_REFCOUNT_P(varptr, 0); zval_copy_ctor(varptr); } - varptr->refcount++; + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); ; /* for string offsets */ @@ -20371,9 +20371,9 @@ static int ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX_T(opline->op1.u.var).var.fcall_returned_reference) && varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || - (varptr->refcount == 1 && (IS_CV == IS_CV || free_op1.var)))) { - varptr->is_ref = 1; - varptr->refcount++; + (Z_REFCOUNT_P(varptr) == 1 && (IS_CV == IS_CV || free_op1.var)))) { + Z_SET_ISREF_P(varptr); + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); } else { zval *valptr; @@ -20404,7 +20404,7 @@ static int ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); varptr = *varptr_ptr; - varptr->refcount++; + Z_ADDREF_P(varptr); zend_ptr_stack_push(&EG(argument_stack), varptr); ZEND_VM_NEXT_OPCODE(); @@ -20445,7 +20445,7 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error_noreturn(E_ERROR, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); ZEND_VM_NEXT_OPCODE(); } @@ -20460,7 +20460,7 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object"); } EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; + Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr); } if (ce && clone) { @@ -20484,8 +20484,8 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC); Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; + Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); + Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr); if (!RETURN_VALUE_USED(opline) || EG(exception)) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } @@ -20696,7 +20696,7 @@ static int ZEND_UNSET_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) convert_to_string(&tmp); varname = &tmp; } else if (IS_CV == IS_CV || IS_CV == IS_VAR) { - varname->refcount++; + Z_ADDREF_P(varname); } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -20757,18 +20757,18 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; + Z_ADDREF_PP(array_ptr_ptr); } array_ptr = *array_ptr_ptr; } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - (*array_ptr_ptr)->is_ref = 1; + Z_SET_ISREF_PP(array_ptr_ptr); } } array_ptr = *array_ptr_ptr; - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { array_ptr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC); @@ -20781,12 +20781,12 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); if (!ce || !ce->get_iterator) { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } else { if ((IS_CV == IS_CV || IS_CV == IS_VAR) && - !array_ptr->is_ref && - array_ptr->refcount > 1) { + !Z_ISREF_P(array_ptr) && + Z_REFCOUNT_P(array_ptr) > 1) { zval *tmp; ALLOC_ZVAL(tmp); @@ -20794,7 +20794,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval_copy_ctor(tmp); array_ptr = tmp; } else { - array_ptr->refcount++; + Z_ADDREF_P(array_ptr); } } } @@ -20827,7 +20827,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -20839,7 +20839,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS; if (EG(exception)) { - array_ptr->refcount--; + Z_DELREF_P(array_ptr); zval_ptr_dtor(&array_ptr); if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -21293,13 +21293,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_CONST(int (*binary_op)(zval if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -21353,7 +21353,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CONST(int (*binary_op)(zval *res zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC); if (object_ptr && IS_CV != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -21400,7 +21400,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CONST(int (*binary_op)(zval *res && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -21529,13 +21529,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_CONST(incdec_t incdec_op, ZEN if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -21619,7 +21619,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CONST(incdec_t incdec_op, ZE if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -21632,7 +21632,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CONST(incdec_t incdec_op, ZE zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -21827,7 +21827,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_CONST(int type, ZEND_ /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -22074,7 +22074,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -22099,7 +22099,7 @@ static int ZEND_CASE_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -22151,7 +22151,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -22162,7 +22162,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -22241,7 +22241,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -22771,13 +22771,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_TMP(int (*binary_op)(zval *r if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -22831,7 +22831,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_op)(zval *resul zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC); if (object_ptr && IS_CV != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -22878,7 +22878,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_op)(zval *resul && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -23008,13 +23008,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_TMP(incdec_t incdec_op, ZEND_ if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -23098,7 +23098,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t incdec_op, ZEND if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -23111,7 +23111,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t incdec_op, ZEND zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -23306,7 +23306,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_TMP(int type, ZEND_OP /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -23554,7 +23554,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -23580,7 +23580,7 @@ static int ZEND_CASE_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -23633,7 +23633,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -23644,7 +23644,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -23723,7 +23723,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -24253,13 +24253,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_VAR(int (*binary_op)(zval *r if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -24313,7 +24313,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_op)(zval *resul zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC); if (object_ptr && IS_CV != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -24360,7 +24360,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_op)(zval *resul && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -24490,13 +24490,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_VAR(incdec_t incdec_op, ZEND_ if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -24580,7 +24580,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t incdec_op, ZEND if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -24593,7 +24593,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t incdec_op, ZEND zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -24788,7 +24788,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_VAR(int type, ZEND_OP /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -25005,7 +25005,7 @@ static int ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (IS_VAR == IS_VAR && value_ptr_ptr && - !(*value_ptr_ptr)->is_ref && + !Z_ISREF_PP(value_ptr_ptr) && opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op2.u.var).var.fcall_returned_reference) { if (free_op2.var == NULL) { @@ -25073,7 +25073,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -25099,7 +25099,7 @@ static int ZEND_CASE_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -25152,7 +25152,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -25163,7 +25163,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -25242,7 +25242,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { @@ -25538,13 +25538,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_UNUSED(int (*binary_op)(zval if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -25598,7 +25598,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_UNUSED(int (*binary_op)(zval *re zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC); if (object_ptr && IS_CV != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -25645,7 +25645,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_UNUSED(int (*binary_op)(zval *re && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -25844,7 +25844,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARG if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -25855,7 +25855,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARG expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -26206,13 +26206,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_CV(int (*binary_op)(zval *re if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { @@ -26266,7 +26266,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op)(zval *result zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC); if (object_ptr && IS_CV != IS_CV && !0) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ + Z_ADDREF_PP(object_ptr); /* undo the effect of get_obj_zval_ptr_ptr() */ } if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -26313,7 +26313,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op)(zval *result && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; + Z_ADDREF_P(objval); binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); @@ -26442,13 +26442,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_CV(incdec_t incdec_op, ZEND_O if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } - z->refcount++; + Z_ADDREF_P(z); SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; @@ -26532,7 +26532,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CV(incdec_t incdec_op, ZEND_ if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (z->refcount == 0) { + if (Z_REFCOUNT_P(z) == 0) { zval_dtor(z); FREE_ZVAL(z); } @@ -26545,7 +26545,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CV(incdec_t incdec_op, ZEND_ zendi_zval_copy_ctor(*z_copy); INIT_PZVAL(z_copy); incdec_op(z_copy); - z->refcount++; + Z_ADDREF_P(z); Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC); zval_ptr_dtor(&z_copy); zval_ptr_dtor(&z); @@ -26740,7 +26740,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_CV(int type, ZEND_OPC /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { + if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); } else { @@ -26955,7 +26955,7 @@ static int ZEND_ASSIGN_REF_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (IS_CV == IS_VAR && value_ptr_ptr && - !(*value_ptr_ptr)->is_ref && + !Z_ISREF_PP(value_ptr_ptr) && opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op2.u.var).var.fcall_returned_reference) { if (free_op2.var == NULL) { @@ -27022,7 +27022,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EX(object)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); @@ -27047,7 +27047,7 @@ static int ZEND_CASE_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; + Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str); } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -27099,7 +27099,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } else #endif if (PZVAL_IS_REF(expr_ptr)) { @@ -27110,7 +27110,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { - expr_ptr->refcount++; + Z_ADDREF_P(expr_ptr); } } if (offset) { @@ -27189,7 +27189,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) break; case IS_STRING: if (IS_CV == IS_CV || IS_CV == IS_VAR) { - offset->refcount++; + Z_ADDREF_P(offset); } if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS && ht == &EG(symbol_table)) { diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 6858f76351..5fe8d9e6c8 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -37,9 +37,9 @@ ZEND_API void {%EXECUTOR_NAME%}(zend_op_array *op_array TSRMLS_DC) } if (op_array->uses_this && EG(This)) { - EG(This)->refcount++; /* For $this pointer */ + Z_ADDREF_P(EG(This)); /* For $this pointer */ if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL)==FAILURE) { - EG(This)->refcount--; + Z_DELREF_P(EG(This)); } } |