diff options
-rw-r--r-- | ext/opcache/zend_persist.c | 28 | ||||
-rw-r--r-- | ext/opcache/zend_persist_calc.c | 4 |
2 files changed, 18 insertions, 14 deletions
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index dec68b7cd7..8e37e6247b 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -94,13 +94,15 @@ static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement /* compact table */ void *old_data = HT_GET_DATA_ADDR(ht); Bucket *old_buckets = ht->arData; - int32_t hash_size = -(int32_t)ht->nTableMask; + int32_t hash_size; - while (hash_size >> 1 > ht->nNumUsed) { - hash_size >>= 1; - } - if (hash_size < -HT_MIN_MASK) { - hash_size = -HT_MIN_MASK; + if (ht->nNumUsed <= HT_MIN_SIZE) { + hash_size = HT_MIN_SIZE; + } else { + hash_size = -(int32_t)ht->nTableMask; + while (hash_size >> 1 > ht->nNumUsed) { + hash_size >>= 1; + } } ht->nTableMask = -hash_size; ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */ @@ -174,13 +176,15 @@ static void zend_hash_persist_immutable(HashTable *ht) /* compact table */ void *old_data = HT_GET_DATA_ADDR(ht); Bucket *old_buckets = ht->arData; - int32_t hash_size = -(int32_t)ht->nTableMask; + int32_t hash_size; - while (hash_size >> 1 > ht->nNumUsed) { - hash_size >>= 1; - } - if (hash_size < -HT_MIN_MASK) { - hash_size = -HT_MIN_MASK; + if (ht->nNumUsed <= HT_MIN_SIZE) { + hash_size = HT_MIN_SIZE; + } else { + hash_size = -(int32_t)ht->nTableMask; + while (hash_size >> 1 > ht->nNumUsed) { + hash_size >>= 1; + } } ht->nTableMask = -hash_size; ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */ diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 5217c2ca9e..bad7d70cc8 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -65,8 +65,8 @@ static void zend_hash_persist_calc(HashTable *ht, void (*pPersistElement)(zval * while (hash_size >> 1 > ht->nNumUsed) { hash_size >>= 1; } - if (hash_size < -HT_MIN_MASK) { - hash_size = -HT_MIN_MASK; + if (hash_size < HT_MIN_SIZE) { + hash_size = HT_MIN_SIZE; } ADD_SIZE(hash_size * sizeof(uint32_t) + ht->nNumUsed * sizeof(Bucket)); } else { |