Do not mark the unused items of a WeakMap (#4663)

The new method is slower, but correctly release unused objects.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-04-27 09:42:03 +02:00
committed by GitHub
parent ce24edae24
commit 8aaabd8b01
5 changed files with 117 additions and 4 deletions
@@ -870,6 +870,30 @@ ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, /**< map ob
return ECMA_VALUE_TRUE;
} /* ecma_op_container_delete_weak */
/**
* Helper function to get the value from a weak container object
*
* @return value property
*/
ecma_value_t
ecma_op_container_find_weak_value (ecma_object_t *object_p, /**< internal container object */
ecma_value_t key_arg) /**< key */
{
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
JERRY_ASSERT (map_object_p->u.cls.type == ECMA_OBJECT_CLASS_CONTAINER
&& map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL);
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.cls.u3.value);
ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.container_id);
JERRY_ASSERT (entry_p != NULL);
return entry_p[1];
} /* ecma_op_container_find_weak_value */
/**
* Helper function to remove a key/value pair from a weak container object
*/
@@ -879,6 +903,10 @@ ecma_op_container_remove_weak_entry (ecma_object_t *object_p, /**< internal cont
{
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
JERRY_ASSERT (map_object_p->u.cls.type == ECMA_OBJECT_CLASS_CONTAINER
&& (map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKSET_UL
|| map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL));
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.cls.u3.value);