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:
parent
fb63aeae4d
commit
a00d154522
7 changed files with 62 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue