Track all NULL values in the property hashmap. (#1534)
There are two types of NULL values in the property hashmap: deleted entries, and never used entries. The current implementation tracks only the never used entries, and never scales back the hashmap. After this patch property delete can also recreate the hashmap, or remove it entirely if there are too few items in the array. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
committed by
Tilmann Scheller
parent
6c708102d3
commit
8b5d645df6
@@ -300,13 +300,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
bits_p += (entry_index >> 3);
|
||||
mask = (uint32_t) (1 << (entry_index & 0x7));
|
||||
|
||||
if (!(*bits_p & mask))
|
||||
{
|
||||
/* Deleted entries also has ECMA_NULL_POINTER
|
||||
* value, but they are not NULL values. */
|
||||
hashmap_p->null_count--;
|
||||
JERRY_ASSERT (hashmap_p->null_count > 0);
|
||||
}
|
||||
hashmap_p->null_count--;
|
||||
JERRY_ASSERT (hashmap_p->null_count > 0);
|
||||
|
||||
if (property_index == 0)
|
||||
{
|
||||
@@ -338,6 +333,22 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
hashmap_p->null_count++;
|
||||
|
||||
/* The NULLs are above 3/4 of the hashmap. */
|
||||
if (hashmap_p->null_count > ((hashmap_p->max_property_count * 3) >> 2))
|
||||
{
|
||||
uint32_t max_property_count = hashmap_p->max_property_count;
|
||||
|
||||
ecma_property_hashmap_free (object_p);
|
||||
|
||||
if (max_property_count >= ECMA_PROPERTY_HASMAP_MINIMUM_SIZE * 2)
|
||||
{
|
||||
ecma_property_hashmap_create (object_p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (*property_p, name_cp);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user