From 7518b7bfe66c1df5e927d873ad543ba7cf52fdc1 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Wed, 16 Oct 2019 13:59:43 +0200 Subject: [PATCH] Remove ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT (#3217) Ecma-string hash limit has already been increased to UINT32_MAX so all the string hashes can be stored directly in the hashmap. This patch fixes #3216. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu --- jerry-core/ecma/base/ecma-property-hashmap.c | 57 ++------------------ 1 file changed, 4 insertions(+), 53 deletions(-) diff --git a/jerry-core/ecma/base/ecma-property-hashmap.c b/jerry-core/ecma/base/ecma-property-hashmap.c index 1668383bb..a3ab4248f 100644 --- a/jerry-core/ecma/base/ecma-property-hashmap.c +++ b/jerry-core/ecma/base/ecma-property-hashmap.c @@ -28,11 +28,6 @@ #if ENABLED (JERRY_PROPRETY_HASHMAP) -/** - * Maximum number of properties that can be stored in a hashmap directly - */ -#define ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT (UINT16_MAX + 1) - /** * Compute the total size of the property hashmap. */ @@ -134,7 +129,6 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */ memset (hashmap_p, 0, total_size); hashmap_p->header.types[0] = ECMA_PROPERTY_TYPE_HASHMAP; - hashmap_p->header.types[1] = 0; hashmap_p->header.next_property_cp = object_p->u1.property_list_cp; hashmap_p->max_property_count = max_property_count; hashmap_p->null_count = max_property_count - named_property_count; @@ -144,16 +138,6 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */ uint8_t *bits_p = (uint8_t *) (pair_list_p + max_property_count); uint32_t mask = max_property_count - 1; - uint8_t shift_counter = 0; - - while (max_property_count > ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) - { - shift_counter++; - max_property_count >>= 1; - } - - hashmap_p->header.types[1] = shift_counter; - prop_iter_cp = object_p->u1.property_list_cp; ECMA_SET_NON_NULL_POINTER (object_p->u1.property_list_cp, hashmap_p); @@ -175,16 +159,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */ property_pair_p->names_cp[i]); uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)]; - if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) - { - entry_index &= mask; - } - else - { - entry_index <<= shift_counter; - JERRY_ASSERT (entry_index <= mask); - } - + entry_index &= mask; #ifndef JERRY_NDEBUG /* Because max_property_count (power of 2) and step (a prime * number) are relative primes, all entries of the hasmap are @@ -268,15 +243,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */ uint32_t entry_index = ecma_string_hash (name_p); uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)]; uint32_t mask = hashmap_p->max_property_count - 1; + entry_index &= mask; - if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) - { - entry_index &= mask; - } - else - { - entry_index <<= hashmap_p->header.types[1]; - } #ifndef JERRY_NDEBUG /* See the comment for this variable in ecma_property_hashmap_create. */ @@ -351,15 +319,7 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */ jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1); uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count); - if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) - { - entry_index &= mask; - } - else - { - entry_index <<= hashmap_p->header.types[1]; - JERRY_ASSERT (entry_index <= mask); - } + entry_index &= mask; #ifndef JERRY_NDEBUG /* See the comment for this variable in ecma_property_hashmap_create. */ @@ -453,16 +413,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */ uint32_t mask = hashmap_p->max_property_count - 1; jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1); uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count); - - if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) - { - entry_index &= mask; - } - else - { - entry_index <<= hashmap_p->header.types[1]; - JERRY_ASSERT (entry_index <= mask); - } + entry_index &= mask; #ifndef JERRY_NDEBUG /* See the comment for this variable in ecma_property_hashmap_create. */