mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:17:46 +00:00
LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and LibWeb in a normal WebContent instance. This gives us a minimum heap size of 4.7 MiB in the scenario where we only have one cell allocated per type. Of course, in practice there will be many more of each type, so the effective overhead is quite a bit smaller than that in practice. I left a few types unconverted to this mechanism because I got tired of doing this. :^)
This commit is contained in:
parent
536596632b
commit
bfd354492e
599 changed files with 933 additions and 3 deletions
|
@ -14,6 +14,7 @@ namespace Web::CSS {
|
|||
|
||||
class CSSFontFaceRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSFontFaceRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, FontFace&&);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(AK::URL url, DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
|
|
|
@ -20,6 +20,7 @@ class CSSImportRule final
|
|||
: public CSSRule
|
||||
, public ResourceClient {
|
||||
WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSImportRule> create(AK::URL, DOM::Document&);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSKeyframeRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations)
|
||||
{
|
||||
return realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/css-animations/#interface-csskeyframerule
|
||||
class CSSKeyframeRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSKeyframeRule);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, CSSStyleDeclaration&);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSKeyframesRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, FlyString name, JS::MarkedVector<JS::NonnullGCPtr<CSSKeyframeRule>> keyframes)
|
||||
{
|
||||
return realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(keyframes));
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/css-animations/#interface-csskeyframesrule
|
||||
class CSSKeyframesRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSKeyframesRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSKeyframesRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSKeyframesRule> create(JS::Realm&, FlyString name, JS::MarkedVector<JS::NonnullGCPtr<CSSKeyframeRule>>);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSMediaRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSMediaRule> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||
{
|
||||
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules);
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/css-conditional-3/#the-cssmediarule-interface
|
||||
class CSSMediaRule final : public CSSConditionRule {
|
||||
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSMediaRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSMediaRule> create(JS::Realm&, MediaList& media_queries, CSSRuleList&);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSNamespaceRule);
|
||||
|
||||
CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional<DeprecatedString> prefix, StringView namespace_uri)
|
||||
: CSSRule(realm)
|
||||
, m_namespace_uri(namespace_uri)
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Web::CSS {
|
|||
|
||||
class CSSNamespaceRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSNamespaceRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSNamespaceRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSNamespaceRule> create(JS::Realm&, Optional<DeprecatedString> prefix, StringView namespace_uri);
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSRuleList);
|
||||
|
||||
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
|
||||
{
|
||||
auto rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/cssom/#the-cssrulelist-interface
|
||||
class CSSRuleList : public Bindings::LegacyPlatformObject {
|
||||
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(CSSRuleList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSRuleList> create(JS::Realm&, JS::MarkedVector<CSSRule*> const&);
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleDeclaration);
|
||||
JS_DEFINE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
|
||||
JS_DEFINE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
|
||||
|
||||
CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Web::CSS {
|
|||
|
||||
class CSSStyleDeclaration : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
virtual ~CSSStyleDeclaration() = default;
|
||||
|
@ -50,6 +51,8 @@ protected:
|
|||
|
||||
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||
WEB_PLATFORM_OBJECT(PropertyOwningCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
JS_DECLARE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
|
||||
|
||||
friend class ElementInlineCSSStyleDeclaration;
|
||||
|
||||
public:
|
||||
|
@ -93,6 +96,7 @@ private:
|
|||
|
||||
class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDeclaration {
|
||||
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
||||
JS_DECLARE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element&, Vector<StyleProperty>, HashMap<FlyString, StyleProperty> custom_properties);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, Vector<NonnullRefPtr<Web::CSS::Selector>>&& selectors, CSSStyleDeclaration& declaration)
|
||||
{
|
||||
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration);
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Web::CSS {
|
|||
|
||||
class CSSStyleRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleRule> create(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, CSSStyleDeclaration&);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleSheet);
|
||||
|
||||
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
|
||||
{
|
||||
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location));
|
||||
|
|
|
@ -21,6 +21,7 @@ class CSSStyleSheet final
|
|||
: public StyleSheet
|
||||
, public Weakable<CSSStyleSheet> {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleSheet);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSSupportsRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSSupportsRule> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
{
|
||||
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules);
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/css-conditional-3/#the-csssupportsrule-interface
|
||||
class CSSSupportsRule final : public CSSConditionRule {
|
||||
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSSupportsRule);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSSupportsRule> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MediaList);
|
||||
|
||||
JS::NonnullGCPtr<MediaList> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
{
|
||||
return realm.heap().allocate<MediaList>(realm, realm, move(media));
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/cssom-1/#the-medialist-interface
|
||||
class MediaList final : public Bindings::LegacyPlatformObject {
|
||||
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(MediaList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MediaQueryList);
|
||||
|
||||
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
{
|
||||
return document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Web::CSS {
|
|||
// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface
|
||||
class MediaQueryList final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(MediaQueryList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryList> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MediaQueryListEvent);
|
||||
|
||||
JS::NonnullGCPtr<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);
|
||||
|
|
|
@ -18,6 +18,7 @@ struct MediaQueryListEventInit : public DOM::EventInit {
|
|||
|
||||
class MediaQueryListEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
JS_DECLARE_ALLOCATOR(MediaQueryListEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ResolvedCSSStyleDeclaration);
|
||||
|
||||
JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
||||
{
|
||||
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element);
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Web::CSS {
|
|||
|
||||
class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
|
||||
WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
JS_DECLARE_ALLOCATOR(ResolvedCSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> create(DOM::Element&);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Screen);
|
||||
|
||||
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
|
||||
{
|
||||
return window.heap().allocate<Screen>(window.realm(), window);
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Web::CSS {
|
|||
|
||||
class Screen final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(Screen);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Screen> create(HTML::Window&);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(StyleSheetList);
|
||||
|
||||
void StyleSheetList::add_sheet(CSSStyleSheet& sheet)
|
||||
{
|
||||
sheet.set_style_sheet_list({}, this);
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
class StyleSheetList : public Bindings::LegacyPlatformObject {
|
||||
class StyleSheetList final : public Bindings::LegacyPlatformObject {
|
||||
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(StyleSheetList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(DOM::Document&);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(VisualViewport);
|
||||
|
||||
JS::NonnullGCPtr<VisualViewport> VisualViewport::create(DOM::Document& document)
|
||||
{
|
||||
return document.heap().allocate<VisualViewport>(document.realm(), document);
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/cssom-view/#visualviewport
|
||||
class VisualViewport final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(VisualViewport, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(VisualViewport);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<VisualViewport> create(DOM::Document&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue