From 91e87fe34f7eb9b8dd4fe82f34913d1c8e214f01 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Tue, 3 Sep 2019 17:46:47 +0200 Subject: [PATCH] Fix the limit of the maximum number of directly stored properties in a hashmap (#3032) JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu --- jerry-core/ecma/base/ecma-property-hashmap.c | 15 ++++++++++----- jerry-core/lit/lit-globals.h | 5 ----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jerry-core/ecma/base/ecma-property-hashmap.c b/jerry-core/ecma/base/ecma-property-hashmap.c index 74bfc39fa..1668383bb 100644 --- a/jerry-core/ecma/base/ecma-property-hashmap.c +++ b/jerry-core/ecma/base/ecma-property-hashmap.c @@ -28,6 +28,11 @@ #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. */ @@ -141,7 +146,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */ uint8_t shift_counter = 0; - while (max_property_count > LIT_STRING_HASH_LIMIT) + while (max_property_count > ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) { shift_counter++; max_property_count >>= 1; @@ -170,7 +175,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 < LIT_STRING_HASH_LIMIT) + if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) { entry_index &= mask; } @@ -264,7 +269,7 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */ 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; - if (mask < LIT_STRING_HASH_LIMIT) + if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) { entry_index &= mask; } @@ -346,7 +351,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 < LIT_STRING_HASH_LIMIT) + if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) { entry_index &= mask; } @@ -449,7 +454,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */ 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 < LIT_STRING_HASH_LIMIT) + if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT) { entry_index &= mask; } diff --git a/jerry-core/lit/lit-globals.h b/jerry-core/lit/lit-globals.h index 9edefb224..0582d0a46 100644 --- a/jerry-core/lit/lit-globals.h +++ b/jerry-core/lit/lit-globals.h @@ -123,9 +123,4 @@ typedef uint32_t lit_code_point_t; */ typedef uint32_t lit_string_hash_t; -/** - * Maximum value of ECMA string hash - */ -#define LIT_STRING_HASH_LIMIT UINT32_MAX - #endif /* !LIT_GLOBALS_H */