Skip to content

Commit 02aea89

Browse files
committed
Use Z_TYPE_INFO_REFCOUNTED() macro
1 parent 285bfb9 commit 02aea89

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ static zend_never_inline void zend_copy_extra_args(EXECUTE_DATA_D)
21422142
ZVAL_UNDEF(src);
21432143
src--;
21442144
} while (--count);
2145-
if (type_flags & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) {
2145+
if (Z_TYPE_INFO_REFCOUNTED(type_flags)) {
21462146
ZEND_ADD_CALL_FLAG(execute_data, ZEND_CALL_FREE_EXTRA_ARGS);
21472147
}
21482148
} else {

Zend/zend_types.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
478478
/* zval.u1.v.type_flags */
479479
#define IS_TYPE_REFCOUNTED (1<<0)
480480

481+
#define Z_TYPE_INFO_REFCOUNTED(t) (((t) & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)
482+
481483
/* extended types */
482484
#define IS_INTERNED_STRING_EX IS_STRING
483485

@@ -549,7 +551,7 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
549551
#define Z_OPT_CONSTANT(zval) (Z_OPT_TYPE(zval) == IS_CONSTANT_AST)
550552
#define Z_OPT_CONSTANT_P(zval_p) Z_OPT_CONSTANT(*(zval_p))
551553

552-
#define Z_OPT_REFCOUNTED(zval) ((Z_TYPE_INFO(zval) & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)
554+
#define Z_OPT_REFCOUNTED(zval) Z_TYPE_INFO_REFCOUNTED(Z_TYPE_INFO(zval))
553555
#define Z_OPT_REFCOUNTED_P(zval_p) Z_OPT_REFCOUNTED(*(zval_p))
554556

555557
/* deprecated: (COPYABLE is the same as IS_ARRAY) */
@@ -999,7 +1001,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
9991001
zend_refcounted *_gc = Z_COUNTED_P(_z2); \
10001002
uint32_t _t = Z_TYPE_INFO_P(_z2); \
10011003
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
1002-
if ((_t & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0) { \
1004+
if (Z_TYPE_INFO_REFCOUNTED(_t)) { \
10031005
GC_ADDREF(_gc); \
10041006
} \
10051007
} while (0)
@@ -1013,7 +1015,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
10131015
if ((_t & Z_TYPE_MASK) == IS_ARRAY) { \
10141016
ZVAL_ARR(_z1, zend_array_dup((zend_array*)_gc));\
10151017
} else { \
1016-
if ((_t & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0) { \
1018+
if (Z_TYPE_INFO_REFCOUNTED(_t)) { \
10171019
GC_ADDREF(_gc); \
10181020
} \
10191021
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
@@ -1031,7 +1033,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
10311033
zend_refcounted *_gc = Z_COUNTED_P(_z2); \
10321034
uint32_t _t = Z_TYPE_INFO_P(_z2); \
10331035
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
1034-
if ((_t & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0) { \
1036+
if (Z_TYPE_INFO_REFCOUNTED(_t)) { \
10351037
if (EXPECTED(!(GC_FLAGS(_gc) & GC_PERSISTENT))) { \
10361038
GC_ADDREF(_gc); \
10371039
} else { \

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6111,7 +6111,7 @@ ZEND_VM_C_LABEL(fe_fetch_r_exit):
61116111
zend_refcounted *gc = Z_COUNTED_P(value);
61126112

61136113
ZVAL_COPY_VALUE_EX(res, value, gc, value_type);
6114-
if (EXPECTED((value_type & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)) {
6114+
if (EXPECTED(Z_TYPE_INFO_REFCOUNTED(value_type))) {
61156115
GC_ADDREF(gc);
61166116
}
61176117
}

Zend/zend_vm_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22428,7 +22428,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_R_SPEC_VAR_HANDLER(ZE
2242822428
zend_refcounted *gc = Z_COUNTED_P(value);
2242922429

2243022430
ZVAL_COPY_VALUE_EX(res, value, gc, value_type);
22431-
if (EXPECTED((value_type & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)) {
22431+
if (EXPECTED(Z_TYPE_INFO_REFCOUNTED(value_type))) {
2243222432
GC_ADDREF(gc);
2243322433
}
2243422434
}

0 commit comments

Comments
 (0)