Skip to content

Commit 7518b7b

Browse files
rerobikazherczeg
authored andcommitted
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 [email protected]
1 parent f0e432c commit 7518b7b

File tree

1 file changed

+4
-53
lines changed

1 file changed

+4
-53
lines changed

jerry-core/ecma/base/ecma-property-hashmap.c

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828

2929
#if ENABLED (JERRY_PROPRETY_HASHMAP)
3030

31-
/**
32-
* Maximum number of properties that can be stored in a hashmap directly
33-
*/
34-
#define ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT (UINT16_MAX + 1)
35-
3631
/**
3732
* Compute the total size of the property hashmap.
3833
*/
@@ -134,7 +129,6 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
134129
memset (hashmap_p, 0, total_size);
135130

136131
hashmap_p->header.types[0] = ECMA_PROPERTY_TYPE_HASHMAP;
137-
hashmap_p->header.types[1] = 0;
138132
hashmap_p->header.next_property_cp = object_p->u1.property_list_cp;
139133
hashmap_p->max_property_count = max_property_count;
140134
hashmap_p->null_count = max_property_count - named_property_count;
@@ -144,16 +138,6 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
144138
uint8_t *bits_p = (uint8_t *) (pair_list_p + max_property_count);
145139
uint32_t mask = max_property_count - 1;
146140

147-
uint8_t shift_counter = 0;
148-
149-
while (max_property_count > ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT)
150-
{
151-
shift_counter++;
152-
max_property_count >>= 1;
153-
}
154-
155-
hashmap_p->header.types[1] = shift_counter;
156-
157141
prop_iter_cp = object_p->u1.property_list_cp;
158142
ECMA_SET_NON_NULL_POINTER (object_p->u1.property_list_cp, hashmap_p);
159143

@@ -175,16 +159,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
175159
property_pair_p->names_cp[i]);
176160
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
177161

178-
if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT)
179-
{
180-
entry_index &= mask;
181-
}
182-
else
183-
{
184-
entry_index <<= shift_counter;
185-
JERRY_ASSERT (entry_index <= mask);
186-
}
187-
162+
entry_index &= mask;
188163
#ifndef JERRY_NDEBUG
189164
/* Because max_property_count (power of 2) and step (a prime
190165
* number) are relative primes, all entries of the hasmap are
@@ -268,15 +243,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
268243
uint32_t entry_index = ecma_string_hash (name_p);
269244
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
270245
uint32_t mask = hashmap_p->max_property_count - 1;
246+
entry_index &= mask;
271247

272-
if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT)
273-
{
274-
entry_index &= mask;
275-
}
276-
else
277-
{
278-
entry_index <<= hashmap_p->header.types[1];
279-
}
280248

281249
#ifndef JERRY_NDEBUG
282250
/* 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 */
351319
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
352320
uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count);
353321

354-
if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT)
355-
{
356-
entry_index &= mask;
357-
}
358-
else
359-
{
360-
entry_index <<= hashmap_p->header.types[1];
361-
JERRY_ASSERT (entry_index <= mask);
362-
}
322+
entry_index &= mask;
363323

364324
#ifndef JERRY_NDEBUG
365325
/* 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 */
453413
uint32_t mask = hashmap_p->max_property_count - 1;
454414
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
455415
uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count);
456-
457-
if (mask < ECMA_PROPERTY_HASHMAP_SHIFT_LIMIT)
458-
{
459-
entry_index &= mask;
460-
}
461-
else
462-
{
463-
entry_index <<= hashmap_p->header.types[1];
464-
JERRY_ASSERT (entry_index <= mask);
465-
}
416+
entry_index &= mask;
466417

467418
#ifndef JERRY_NDEBUG
468419
/* See the comment for this variable in ecma_property_hashmap_create. */

0 commit comments

Comments
 (0)