From 98d2b66e40974fbc2a9361d67d8543794695398d Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Fri, 3 Jun 2016 00:07:03 -0700 Subject: [PATCH] Reduce the default LCache size by half. From 4Kbyte to 2Kbyte. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/ecma/base/ecma-lcache.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jerry-core/ecma/base/ecma-lcache.c b/jerry-core/ecma/base/ecma-lcache.c index 34fab5009..1178e33c2 100644 --- a/jerry-core/ecma/base/ecma-lcache.c +++ b/jerry-core/ecma/base/ecma-lcache.c @@ -46,13 +46,19 @@ typedef struct /** * Number of rows in LCache's hash table */ -#define ECMA_LCACHE_HASH_ROWS_COUNT 256 +#define ECMA_LCACHE_HASH_ROWS_COUNT 128 /** * Number of entries in a row of LCache's hash table */ #define ECMA_LCACHE_HASH_ROW_LENGTH 2 + +/** + * Mask for hash bits + */ +#define ECMA_LCACHE_HASH_MASK (ECMA_LCACHE_HASH_ROWS_COUNT - 1) + /** * LCache's hash table */ @@ -97,7 +103,7 @@ ecma_lcache_row_idx (jmem_cpointer_t object_cp, /**< compressed pointer to objec { /* Randomize the hash of the property name with the object pointer using a xor operation, * so properties of different objects with the same name can be cached effectively. */ - return (size_t) ((ecma_string_hash (prop_name_p) ^ object_cp) & (ECMA_LCACHE_HASH_ROWS_COUNT - 1)); + return (size_t) ((ecma_string_hash (prop_name_p) ^ object_cp) & ECMA_LCACHE_HASH_MASK); } /* ecma_lcache_row_idx */ #endif /* !CONFIG_ECMA_LCACHE_DISABLE */ @@ -181,7 +187,7 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */ ecma_string_t *entry_prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, entry_p->prop_name_cp); - JERRY_ASSERT (prop_name_p->hash == entry_prop_name_p->hash); + JERRY_ASSERT ((prop_name_p->hash & ECMA_LCACHE_HASH_MASK) == (entry_prop_name_p->hash & ECMA_LCACHE_HASH_MASK)); if (ECMA_STRING_GET_CONTAINER (prop_name_p) == ECMA_STRING_GET_CONTAINER (entry_prop_name_p) && prop_name_p->u.common_field == entry_prop_name_p->u.common_field)