1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:47:34 +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:
Andreas Kling 2023-11-19 19:47:52 +01:00
parent 536596632b
commit bfd354492e
599 changed files with 933 additions and 3 deletions

View file

@ -17,6 +17,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(Animation);
// https://www.w3.org/TR/web-animations-1/#dom-animation-animation
JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, JS::GCPtr<AnimationTimeline> timeline)
{

View file

@ -15,6 +15,7 @@ namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#the-animation-interface
class Animation : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Animation, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(Animation);
public:
static JS::NonnullGCPtr<Animation> create(JS::Realm&, JS::GCPtr<AnimationEffect>, JS::GCPtr<AnimationTimeline>);

View file

@ -12,6 +12,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationEffect);
JS::NonnullGCPtr<AnimationEffect> AnimationEffect::create(JS::Realm& realm)
{
return realm.heap().allocate<AnimationEffect>(realm, realm);

View file

@ -58,6 +58,7 @@ enum class AnimationDirection {
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
class AnimationEffect : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AnimationEffect);
public:
static JS::NonnullGCPtr<AnimationEffect> create(JS::Realm&);

View file

@ -9,6 +9,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationPlaybackEvent);
JS::NonnullGCPtr<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& event_name, AnimationPlaybackEventInit const& event_init)
{
return realm.heap().allocate<AnimationPlaybackEvent>(realm, realm, event_name, event_init);

View file

@ -20,6 +20,7 @@ struct AnimationPlaybackEventInit : public DOM::EventInit {
// https://www.w3.org/TR/web-animations-1/#animationplaybackevent
class AnimationPlaybackEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(AnimationPlaybackEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& event_name, AnimationPlaybackEventInit const& event_init = {});

View file

@ -10,6 +10,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationTimeline);
WebIDL::ExceptionOr<void> AnimationTimeline::set_current_time(Optional<double> value)
{
if (value == m_current_time)

View file

@ -13,6 +13,7 @@ namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#animationtimeline
class AnimationTimeline : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AnimationTimeline, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AnimationTimeline);
public:
Optional<double> current_time() const { return m_current_time; }

View file

@ -13,6 +13,8 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(DocumentTimeline);
JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
{
return realm.heap().allocate<DocumentTimeline>(realm, realm, document, origin_time);

View file

@ -20,6 +20,7 @@ struct DocumentTimelineOptions {
// https://www.w3.org/TR/web-animations-1/#the-documenttimeline-interface
class DocumentTimeline : public AnimationTimeline {
WEB_PLATFORM_OBJECT(DocumentTimeline, AnimationTimeline);
JS_DECLARE_ALLOCATOR(DocumentTimeline);
public:
static JS::NonnullGCPtr<DocumentTimeline> create(JS::Realm&, DOM::Document&, HighResolutionTime::DOMHighResTimeStamp origin_time);

View file

@ -39,6 +39,7 @@ struct BaseKeyframe {
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffect-interface
class KeyframeEffect : public AnimationEffect {
WEB_PLATFORM_OBJECT(KeyframeEffect, AnimationEffect);
JS_DECLARE_ALLOCATOR(KeyframeEffect);
public:
static JS::NonnullGCPtr<KeyframeEffect> create(JS::Realm&);