From: Dmitry Stogov Date: Tue, 27 Feb 2018 23:36:50 +0000 (+0300) Subject: Simplify GC_FLAGS cand CG_INFO checks X-Git-Tag: php-7.3.0alpha1~287 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1d5168a7414e996957efa298013caa47579a046;p=php Simplify GC_FLAGS cand CG_INFO checks --- diff --git a/Zend/zend_gc.h b/Zend/zend_gc.h index f5c7b63ffd..cf327e2d06 100644 --- a/Zend/zend_gc.h +++ b/Zend/zend_gc.h @@ -39,7 +39,7 @@ END_EXTERN_C() #define GC_REMOVE_FROM_BUFFER(p) do { \ zend_refcounted *_p = (zend_refcounted*)(p); \ - if (GC_INFO(_p)) { \ + if (GC_TYPE_INFO(_p) & GC_INFO_MASK) { \ gc_remove_from_buffer(_p); \ } \ } while (0) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index af185ad276..b0a1ce589d 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -443,14 +443,14 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define GC_TYPE_MASK 0x0000000f #define GC_FLAGS_MASK 0x000003f0 #define GC_INFO_MASK 0xfffffc00 -#define GC_FLAGS_SHIFT 4 +#define GC_FLAGS_SHIFT 0 #define GC_INFO_SHIFT 10 static zend_always_inline zend_uchar zval_gc_type(uint32_t gc_type_info) { return (gc_type_info & GC_TYPE_MASK); } -static zend_always_inline zend_uchar zval_gc_flags(uint32_t gc_type_info) { +static zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info) { return (gc_type_info >> GC_FLAGS_SHIFT) & (GC_FLAGS_MASK >> GC_FLAGS_SHIFT); } @@ -482,11 +482,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { #define Z_GC_TYPE_INFO_P(zval_p) Z_GC_TYPE_INFO(*(zval_p)) /* zval.value->gc.u.v.flags (common flags) */ -#define GC_COLLECTABLE (1<<0) -#define GC_PROTECTED (1<<1) /* used for recursion detection */ -#define GC_IMMUTABLE (1<<2) /* can't be canged in place */ -#define GC_PERSISTENT (1<<3) /* allocated using malloc */ -#define GC_PERSISTENT_LOCAL (1<<4) /* persistent, but thread-local */ +#define GC_COLLECTABLE (1<<4) +#define GC_PROTECTED (1<<5) /* used for recursion detection */ +#define GC_IMMUTABLE (1<<6) /* can't be canged in place */ +#define GC_PERSISTENT (1<<7) /* allocated using malloc */ +#define GC_PERSISTENT_LOCAL (1<<8) /* persistent, but thread-local */ #define GC_ARRAY (IS_ARRAY | (GC_COLLECTABLE << GC_FLAGS_SHIFT)) #define GC_OBJECT (IS_OBJECT | (GC_COLLECTABLE << GC_FLAGS_SHIFT)) @@ -515,15 +515,15 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { /* string flags (zval.value->gc.u.flags) */ #define IS_STR_INTERNED GC_IMMUTABLE /* interned string */ #define IS_STR_PERSISTENT GC_PERSISTENT /* allocated using malloc */ -#define IS_STR_PERMANENT (1<<5) /* relives request boundary */ +#define IS_STR_PERMANENT (1<<8) /* relives request boundary */ /* array flags */ #define IS_ARRAY_IMMUTABLE GC_IMMUTABLE #define IS_ARRAY_PERSISTENT GC_PERSISTENT /* object flags (zval.value->gc.u.flags) */ -#define IS_OBJ_DESTRUCTOR_CALLED (1<<4) -#define IS_OBJ_FREE_CALLED (1<<5) +#define IS_OBJ_DESTRUCTOR_CALLED (1<<8) +#define IS_OBJ_FREE_CALLED (1<<9) #define OBJ_FLAGS(obj) GC_FLAGS(obj)