Skip to content

Commit 98d2b66

Browse files
committed
Reduce the default LCache size by half. From 4Kbyte to 2Kbyte.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent 6f33ab3 commit 98d2b66

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

jerry-core/ecma/base/ecma-lcache.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ typedef struct
4646
/**
4747
* Number of rows in LCache's hash table
4848
*/
49-
#define ECMA_LCACHE_HASH_ROWS_COUNT 256
49+
#define ECMA_LCACHE_HASH_ROWS_COUNT 128
5050

5151
/**
5252
* Number of entries in a row of LCache's hash table
5353
*/
5454
#define ECMA_LCACHE_HASH_ROW_LENGTH 2
5555

56+
57+
/**
58+
* Mask for hash bits
59+
*/
60+
#define ECMA_LCACHE_HASH_MASK (ECMA_LCACHE_HASH_ROWS_COUNT - 1)
61+
5662
/**
5763
* LCache's hash table
5864
*/
@@ -97,7 +103,7 @@ ecma_lcache_row_idx (jmem_cpointer_t object_cp, /**< compressed pointer to objec
97103
{
98104
/* Randomize the hash of the property name with the object pointer using a xor operation,
99105
* so properties of different objects with the same name can be cached effectively. */
100-
return (size_t) ((ecma_string_hash (prop_name_p) ^ object_cp) & (ECMA_LCACHE_HASH_ROWS_COUNT - 1));
106+
return (size_t) ((ecma_string_hash (prop_name_p) ^ object_cp) & ECMA_LCACHE_HASH_MASK);
101107
} /* ecma_lcache_row_idx */
102108
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
103109

@@ -181,7 +187,7 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
181187
ecma_string_t *entry_prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
182188
entry_p->prop_name_cp);
183189

184-
JERRY_ASSERT (prop_name_p->hash == entry_prop_name_p->hash);
190+
JERRY_ASSERT ((prop_name_p->hash & ECMA_LCACHE_HASH_MASK) == (entry_prop_name_p->hash & ECMA_LCACHE_HASH_MASK));
185191

186192
if (ECMA_STRING_GET_CONTAINER (prop_name_p) == ECMA_STRING_GET_CONTAINER (entry_prop_name_p)
187193
&& prop_name_p->u.common_field == entry_prop_name_p->u.common_field)

0 commit comments

Comments
 (0)