From: Dmitry Stogov Date: Mon, 5 Mar 2018 21:00:13 +0000 (+0300) Subject: Set and keep HASH_FLAG_STATIC_KEYS for all HashTables stored in SHM (or file cache). X-Git-Tag: php-7.3.0alpha1~254 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84a0423e055e4150d9b366ae40364d277787e89b;p=php Set and keep HASH_FLAG_STATIC_KEYS for all HashTables stored in SHM (or file cache). --- diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index f37e577f81..f63609417e 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -180,7 +180,7 @@ static void zend_hash_clone_constants(HashTable *ht, HashTable *source) ht->nNumOfElements = source->nNumOfElements; ht->nNextFreeElement = source->nNextFreeElement; ht->pDestructor = NULL; - HT_FLAGS(ht) = (HT_FLAGS(source) & HASH_FLAG_INITIALIZED); + HT_FLAGS(ht) = (HT_FLAGS(source) & (HASH_FLAG_INITIALIZED | HASH_FLAG_STATIC_KEYS)); ht->nInternalPointer = source->nNumOfElements ? 0 : HT_INVALID_IDX; if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { @@ -231,7 +231,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class ht->nNumOfElements = source->nNumOfElements; ht->nNextFreeElement = source->nNextFreeElement; ht->pDestructor = ZEND_FUNCTION_DTOR; - HT_FLAGS(ht) = (HT_FLAGS(source) & HASH_FLAG_INITIALIZED); + HT_FLAGS(ht) = (HT_FLAGS(source) & (HASH_FLAG_INITIALIZED | HASH_FLAG_STATIC_KEYS)); ht->nInternalPointer = source->nNumOfElements ? 0 : HT_INVALID_IDX; if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { @@ -289,7 +289,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla ht->nNumOfElements = source->nNumOfElements; ht->nNextFreeElement = source->nNextFreeElement; ht->pDestructor = NULL; - HT_FLAGS(ht) = (HT_FLAGS(source) & HASH_FLAG_INITIALIZED); + HT_FLAGS(ht) = (HT_FLAGS(source) & (HASH_FLAG_INITIALIZED | HASH_FLAG_STATIC_KEYS)); ht->nInternalPointer = source->nNumOfElements ? 0 : HT_INVALID_IDX; if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index e063f1f4aa..132ecab1d0 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -88,6 +88,8 @@ static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement uint32_t idx, nIndex; Bucket *p; + HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS; + if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { HT_SET_DATA_ADDR(ht, &uninitialized_bucket); return; @@ -172,6 +174,8 @@ static void zend_hash_persist_immutable(HashTable *ht) uint32_t idx, nIndex; Bucket *p; + HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS; + if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { HT_SET_DATA_ADDR(ht, &uninitialized_bucket); return; @@ -304,7 +308,6 @@ static void zend_persist_zval(zval *z) Z_TYPE_FLAGS_P(z) = 0; GC_SET_REFCOUNT(Z_COUNTED_P(z), 2); GC_ADD_FLAGS(Z_COUNTED_P(z), IS_ARRAY_IMMUTABLE); - HT_FLAGS(Z_ARRVAL_P(z)) |= HASH_FLAG_STATIC_KEYS; } } break; @@ -370,7 +373,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc /* make immutable array */ GC_SET_REFCOUNT(op_array->static_variables, 2); GC_TYPE_INFO(op_array->static_variables) = IS_ARRAY | (IS_ARRAY_IMMUTABLE << GC_FLAGS_SHIFT); - HT_FLAGS(op_array->static_variables) |= HASH_FLAG_STATIC_KEYS; } }