1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16: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

@ -9,6 +9,8 @@
namespace Web::UIEvents {
JS_DEFINE_ALLOCATOR(FocusEvent);
WebIDL::ExceptionOr<JS::NonnullGCPtr<FocusEvent>> FocusEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FocusEventInit const& event_init)
{
return realm.heap().allocate<FocusEvent>(realm, realm, event_name, event_init);

View file

@ -17,6 +17,7 @@ struct FocusEventInit : public UIEventInit {
class FocusEvent final : public UIEvent {
WEB_PLATFORM_OBJECT(FocusEvent, UIEvent);
JS_DECLARE_ALLOCATOR(FocusEvent);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<FocusEvent>> construct_impl(JS::Realm&, FlyString const& event_name, FocusEventInit const& event_init);

View file

@ -11,6 +11,8 @@
namespace Web::UIEvents {
JS_DEFINE_ALLOCATOR(KeyboardEvent);
// https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode
static unsigned long determine_key_code(KeyCode platform_key, u32 code_point)
{

View file

@ -34,6 +34,7 @@ enum class DOMKeyLocation {
// https://www.w3.org/TR/uievents/#interface-keyboardevent
class KeyboardEvent final : public UIEvent {
WEB_PLATFORM_OBJECT(KeyboardEvent, UIEvent);
JS_DECLARE_ALLOCATOR(KeyboardEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<KeyboardEvent> create(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& = {});

View file

@ -14,6 +14,8 @@
namespace Web::UIEvents {
JS_DEFINE_ALLOCATOR(MouseEvent);
MouseEvent::MouseEvent(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y, unsigned modifiers)
: UIEvent(realm, event_name, event_init)
, m_screen_x(event_init.screen_x)

View file

@ -26,6 +26,7 @@ struct MouseEventInit : public EventModifierInit {
class MouseEvent : public UIEvent {
WEB_PLATFORM_OBJECT(MouseEvent, UIEvent);
JS_DECLARE_ALLOCATOR(MouseEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<MouseEvent> create(JS::Realm&, FlyString const& event_name, MouseEventInit const& = {}, double page_x = 0, double page_y = 0, double offset_x = 0, double offset_y = 0, unsigned modifiers = 0);

View file

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

View file

@ -19,6 +19,7 @@ struct UIEventInit : public DOM::EventInit {
class UIEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(UIEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(UIEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<UIEvent> create(JS::Realm&, FlyString const& type);

View file

@ -12,6 +12,8 @@
namespace Web::UIEvents {
JS_DEFINE_ALLOCATOR(WheelEvent);
WheelEvent::WheelEvent(JS::Realm& realm, FlyString const& event_name, WheelEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y, unsigned modifiers)
: MouseEvent(realm, event_name, event_init, page_x, page_y, offset_x, offset_y, modifiers)
, m_delta_x(event_init.delta_x)

View file

@ -27,6 +27,7 @@ struct WheelEventInit : public MouseEventInit {
class WheelEvent final : public MouseEvent {
WEB_PLATFORM_OBJECT(WheelEvent, MouseEvent);
JS_DECLARE_ALLOCATOR(WheelEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<WheelEvent> create(JS::Realm&, FlyString const& event_name, WheelEventInit const& event_init = {}, double page_x = 0, double page_y = 0, double offset_x = 0, double offset_y = 0, unsigned modifiers = 0);