From 592c8a0426d070d4ff9031695d238452248fa6c3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 11 Jun 2014 02:46:50 +0400 Subject: [PATCH] Improved conditions order --- Zend/zend.h | 45 ++++++++++++++++++++++----------------------- Zend/zend_compile.c | 1 + 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Zend/zend.h b/Zend/zend.h index c346c023c1..ea2c8f7a33 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -379,7 +379,7 @@ void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((nore #include "zend_string.h" static zend_always_inline zend_uint zval_refcount_p(zval* pz) { - ZEND_ASSERT(Z_REFCOUNTED_P(pz)); + ZEND_ASSERT(Z_REFCOUNTED_P(pz) || Z_IMMUTABLE_P(pz)); return GC_REFCOUNT(Z_COUNTED_P(pz)); } @@ -734,10 +734,10 @@ END_EXTERN_C() #define SEPARATE_ARRAY(zv) do { \ zval *_zv = (zv); \ - if (Z_IMMUTABLE_P(_zv)) { \ - zval_copy_ctor_func(_zv); \ - } else if (Z_REFCOUNT_P(_zv) > 1) { \ - Z_DELREF_P(_zv); \ + if (Z_REFCOUNT_P(_zv) > 1) { \ + if (!Z_IMMUTABLE_P(_zv)) { \ + Z_DELREF_P(_zv); \ + } \ zval_copy_ctor_func(_zv); \ } \ } while (0) @@ -746,10 +746,10 @@ END_EXTERN_C() zval *_zv = (zv); \ if (Z_COPYABLE_P(_zv) || \ Z_IMMUTABLE_P(_zv)) { \ - if (Z_IMMUTABLE_P(_zv)) { \ - zval_copy_ctor_func(_zv); \ - } else if (Z_REFCOUNT_P(_zv) > 1) { \ - Z_DELREF_P(_zv); \ + if (Z_REFCOUNT_P(_zv) > 1) { \ + if (!Z_IMMUTABLE_P(_zv)) { \ + Z_DELREF_P(_zv); \ + } \ zval_copy_ctor_func(_zv); \ } \ } \ @@ -759,15 +759,16 @@ END_EXTERN_C() zval *_zv = (zv); \ if (Z_REFCOUNTED_P(_zv) || \ Z_IMMUTABLE_P(_zv)) { \ - if (Z_IMMUTABLE_P(_zv)) { \ - zval_copy_ctor_func(_zv); \ - } else if (Z_REFCOUNT_P(_zv) > 1) { \ - if (Z_ISREF_P(_zv)) { \ + if (Z_REFCOUNT_P(_zv) > 1) { \ + if (Z_COPYABLE_P(_zv) || \ + Z_IMMUTABLE_P(_zv)) { \ + if (!Z_IMMUTABLE_P(_zv)) { \ + Z_DELREF_P(_zv); \ + } \ + zval_copy_ctor_func(_zv); \ + } else if (Z_ISREF_P(_zv)) { \ Z_DELREF_P(_zv); \ ZVAL_DUP(_zv, Z_REFVAL_P(_zv)); \ - } else if (Z_COPYABLE_P(_zv)) { \ - Z_DELREF_P(_zv); \ - zval_copy_ctor_func(_zv); \ } \ } \ } \ @@ -775,15 +776,13 @@ END_EXTERN_C() #define SEPARATE_ZVAL_IF_NOT_REF(zv) do { \ zval *_zv = (zv); \ - if (!Z_ISREF_P(_zv)) { \ - if (Z_COPYABLE_P(_zv) || \ - Z_IMMUTABLE_P(_zv)) { \ - if (Z_IMMUTABLE_P(_zv)) { \ - zval_copy_ctor_func(_zv); \ - } else if (Z_REFCOUNT_P(_zv) > 1) { \ + if (Z_COPYABLE_P(_zv) || \ + Z_IMMUTABLE_P(_zv)) { \ + if (Z_REFCOUNT_P(_zv) > 1) { \ + if (!Z_IMMUTABLE_P(_zv)) { \ Z_DELREF_P(_zv); \ - zval_copy_ctor_func(_zv); \ } \ + zval_copy_ctor_func(_zv); \ } \ } \ } while (0) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index de45b5a683..ada6c873a1 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7501,6 +7501,7 @@ ZEND_API void zend_make_immutable_array(zval *zv TSRMLS_DC) /* {{{ */ } Z_TYPE_FLAGS_P(zv) = IS_TYPE_IMMUTABLE; + GC_REFCOUNT(Z_COUNTED_P(zv)) = 2; Z_ARRVAL_P(zv)->u.flags &= ~HASH_FLAG_APPLY_PROTECTION; /* store as an anonymous constant */ -- 2.40.0