1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:58:11 +00:00

LibJS: Notify WeakSets when heap cells are sweeped

This is an implementation of the following optional optimization:
https://tc39.es/ecma262/#sec-weakref-execution
This commit is contained in:
Idan Horowitz 2021-06-09 20:10:47 +03:00 committed by Linus Groh
parent fb63aeae4d
commit a00d154522
7 changed files with 62 additions and 3 deletions

View file

@ -32,6 +32,19 @@ TESTJS_GLOBAL_FUNCTION(run_queued_promise_jobs, runQueuedPromiseJobs)
return JS::js_undefined();
}
TESTJS_GLOBAL_FUNCTION(get_weak_set_size, getWeakSetSize)
{
auto* object = vm.argument(0).to_object(global_object);
if (!object)
return {};
if (!is<JS::WeakSet>(object)) {
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "WeakSet");
return {};
}
auto* weak_set = static_cast<JS::WeakSet*>(object);
return JS::Value(weak_set->values().size());
}
TESTJS_RUN_FILE_FUNCTION(const String& test_file, JS::Interpreter&)
{
if (!test262_parser_tests)