1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:47:35 +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

@ -12,6 +12,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMMatrix);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrix::construct_impl(JS::Realm& realm, Optional<Variant<String, Vector<double>>> const& init)
{
auto& vm = realm.vm();

View file

@ -14,6 +14,7 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#dommatrix
class DOMMatrix : public DOMMatrixReadOnly {
WEB_PLATFORM_OBJECT(DOMMatrix, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMMatrix);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> construct_impl(JS::Realm&, Optional<Variant<String, Vector<double>>> const& init);

View file

@ -10,6 +10,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMPoint);
JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
{
return realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w);

View file

@ -14,6 +14,7 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#DOMPoint
class DOMPoint final : public DOMPointReadOnly {
WEB_PLATFORM_OBJECT(DOMPoint, DOMPointReadOnly);
JS_DECLARE_ALLOCATOR(DOMPoint);
public:
static JS::NonnullGCPtr<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);

View file

@ -12,6 +12,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMPointReadOnly);
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
{
return realm.heap().allocate<DOMPointReadOnly>(realm, realm, x, y, z, w);

View file

@ -23,6 +23,7 @@ struct DOMPointInit {
// https://drafts.fxtf.org/geometry/#dompointreadonly
class DOMPointReadOnly : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMPointReadOnly);
public:
static JS::NonnullGCPtr<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);

View file

@ -9,6 +9,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMQuad);
JS::NonnullGCPtr<DOMQuad> DOMQuad::construct_impl(JS::Realm& realm, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4)
{
return realm.heap().allocate<DOMQuad>(realm, realm, p1, p2, p3, p4);

View file

@ -24,6 +24,7 @@ struct DOMQuadInit {
// https://drafts.fxtf.org/geometry/#domquad
class DOMQuad : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMQuad, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMQuad);
public:
static JS::NonnullGCPtr<DOMQuad> construct_impl(JS::Realm&, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4);

View file

@ -10,6 +10,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMRect);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
{
return create(realm, Gfx::FloatRect { x, y, width, height });

View file

@ -13,6 +13,7 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#DOMRect
class DOMRect final : public DOMRectReadOnly {
WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly);
JS_DECLARE_ALLOCATOR(DOMRect);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);

View file

@ -12,6 +12,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMRectList);
JS::NonnullGCPtr<DOMRectList> DOMRectList::create(JS::Realm& realm, Vector<JS::Handle<DOMRect>> rect_handles)
{
Vector<JS::NonnullGCPtr<DOMRect>> rects;

View file

@ -16,6 +16,7 @@ namespace Web::Geometry {
// https://drafts.fxtf.org/geometry-1/#DOMRectList
class DOMRectList final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(DOMRectList, Bindings::LegacyPlatformObject);
JS_DECLARE_ALLOCATOR(DOMRectList);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMRectList> create(JS::Realm&, Vector<JS::Handle<DOMRect>>);

View file

@ -10,6 +10,8 @@
namespace Web::Geometry {
JS_DEFINE_ALLOCATOR(DOMRectReadOnly);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
{
return realm.heap().allocate<DOMRectReadOnly>(realm, realm, x, y, width, height);

View file

@ -23,6 +23,7 @@ struct DOMRectInit {
// https://drafts.fxtf.org/geometry/#domrectreadonly
class DOMRectReadOnly : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMRectReadOnly, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMRectReadOnly);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);