summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2019-07-10 12:27:59 +0300
committerDmitry Stogov <dmitry@zend.com>2019-07-10 12:27:59 +0300
commitd57d74b2719a6142dcc0719cfc1ac1e1df755f9c (patch)
treee66b9c5ea6384305200d0d5591db2bc79f2c37a4
parent2bca35eaccfcded049f61f994c6c9078c6c91208 (diff)
downloadphp-git-d57d74b2719a6142dcc0719cfc1ac1e1df755f9c.tar.gz
Reduce cost for references to strings and resources
-rw-r--r--Zend/zend_gc.h2
-rw-r--r--Zend/zend_types.h10
2 files changed, 9 insertions, 3 deletions
diff --git a/Zend/zend_gc.h b/Zend/zend_gc.h
index e83e874e07..4baca8fe33 100644
--- a/Zend/zend_gc.h
+++ b/Zend/zend_gc.h
@@ -74,7 +74,7 @@ static zend_always_inline void gc_check_possible_root(zend_refcounted *ref)
if (GC_TYPE_INFO(ref) == IS_REFERENCE) {
zval *zv = &((zend_reference*)ref)->val;
- if (!Z_REFCOUNTED_P(zv)) {
+ if (!Z_COLLECTABLE_P(zv)) {
return;
}
ref = Z_COUNTED_P(zv);
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index 3f6e1c1402..a018c43b81 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -555,9 +555,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
/* zval.u1.v.type_flags */
#define IS_TYPE_REFCOUNTED (1<<0)
+#define IS_TYPE_COLLECTABLE (1<<1)
#if 1
/* This optimized version assumes that we have a single "type_flag" */
+/* IS_TYPE_COLLECTABLE may be used only with IS_TYPE_REFCOUNTED */
# define Z_TYPE_INFO_REFCOUNTED(t) (((t) & Z_TYPE_FLAGS_MASK) != 0)
#else
# define Z_TYPE_INFO_REFCOUNTED(t) (((t) & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)
@@ -567,8 +569,8 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
#define IS_INTERNED_STRING_EX IS_STRING
#define IS_STRING_EX (IS_STRING | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT))
-#define IS_ARRAY_EX (IS_ARRAY | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT))
-#define IS_OBJECT_EX (IS_OBJECT | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT))
+#define IS_ARRAY_EX (IS_ARRAY | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT) | (IS_TYPE_COLLECTABLE << Z_TYPE_FLAGS_SHIFT))
+#define IS_OBJECT_EX (IS_OBJECT | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT) | (IS_TYPE_COLLECTABLE << Z_TYPE_FLAGS_SHIFT))
#define IS_RESOURCE_EX (IS_RESOURCE | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT))
#define IS_REFERENCE_EX (IS_REFERENCE | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT))
@@ -624,12 +626,16 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
#if 1
/* This optimized version assumes that we have a single "type_flag" */
+/* IS_TYPE_COLLECTABLE may be used only with IS_TYPE_REFCOUNTED */
#define Z_REFCOUNTED(zval) (Z_TYPE_FLAGS(zval) != 0)
#else
#define Z_REFCOUNTED(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
#endif
#define Z_REFCOUNTED_P(zval_p) Z_REFCOUNTED(*(zval_p))
+#define Z_COLLECTABLE(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_COLLECTABLE) != 0)
+#define Z_COLLECTABLE_P(zval_p) Z_COLLECTABLE(*(zval_p))
+
/* deprecated: (COPYABLE is the same as IS_ARRAY) */
#define Z_COPYABLE(zval) (Z_TYPE(zval) == IS_ARRAY)
#define Z_COPYABLE_P(zval_p) Z_COPYABLE(*(zval_p))