Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a73e86f9a37f81647b8ebd3eab3482e3e7b038ae
https://github.com/WebKit/WebKit/commit/a73e86f9a37f81647b8ebd3eab3482e3e7b038ae
Author: Sosuke Suzuki <[email protected]>
Date: 2026-08-15 (Sat, 15 Aug 2026)
Changed paths:
M Source/JavaScriptCore/runtime/CommonIdentifiers.h
M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
M Source/JavaScriptCore/runtime/JSGlobalObject.h
Log Message:
-----------
[JSC] Do not eagerly create `Set.prototype`, `WeakRef`, and
`FinalizationRegistry` in `JSGlobalObject::init()`
https://bugs.webkit.org/show_bug.cgi?id=321649
Reviewed by Yusuke Suzuki.
JSGlobalObject::init() materializes a few builtins for every global object
even when they are never used:
1. Set is a lazy class structure, but init() installs the
m_setPrimordialPropertiesWatchpointSet watchpoints on Set.prototype.has /
keys via jsSetPrototype(), forcing SetPrototype and all of its functions.
The set starts out IsWatched and is only consulted by
setPrimordialWatchpointIsValid(), which cannot run before SetPrototype
exists, so move the two watchpoints into installSetPrototypeWatchpoint(),
which SetPrototype::finishCreation() already calls.
2. WeakRef and FinalizationRegistry are in
FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR, so their prototype,
constructor and structure are created eagerly. Nothing needs them before
first use, so move them to FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION and
expose the constructors through globalObjectTable like WeakMap / WeakSet.
This saves ~6.6 KB of memory footprint (~3.7 KB of GC heap) per
JSGlobalObject that does not touch these builtins.
* Source/JavaScriptCore/runtime/CommonIdentifiers.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::installSetPrototypeWatchpoint):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
Canonical link: https://commits.webkit.org/319227@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications