mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +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:
committed by
Linus Groh
parent
fb63aeae4d
commit
a00d154522
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user