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

@ -15,6 +15,8 @@
namespace Web::XHR {
JS_DEFINE_ALLOCATOR(FormData);
// https://xhr.spec.whatwg.org/#dom-formdata
WebIDL::ExceptionOr<JS::NonnullGCPtr<FormData>> FormData::construct_impl(JS::Realm& realm, Optional<JS::NonnullGCPtr<HTML::HTMLFormElement>> form)
{

View file

@ -18,6 +18,7 @@ namespace Web::XHR {
// https://xhr.spec.whatwg.org/#interface-formdata
class FormData : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(FormData, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(FormData);
public:
virtual ~FormData() override;

View file

@ -23,6 +23,8 @@ void Intrinsics::create_web_prototype_and_constructor<FormDataIteratorPrototype>
namespace Web::XHR {
JS_DEFINE_ALLOCATOR(FormDataIterator);
JS::NonnullGCPtr<FormDataIterator> FormDataIterator::create(FormData const& form_data, JS::Object::PropertyKind iterator_kind)
{
return form_data.heap().allocate<FormDataIterator>(form_data.realm(), form_data, iterator_kind);

View file

@ -13,6 +13,7 @@ namespace Web::XHR {
class FormDataIterator : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(FormDataIterator, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(FormDataIterator);
public:
[[nodiscard]] static JS::NonnullGCPtr<FormDataIterator> create(FormData const&, JS::Object::PropertyKind iterator_kind);

View file

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

View file

@ -22,6 +22,7 @@ struct ProgressEventInit : public DOM::EventInit {
class ProgressEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(ProgressEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(ProgressEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<ProgressEvent> create(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);

View file

@ -53,6 +53,8 @@
namespace Web::XHR {
JS_DEFINE_ALLOCATOR(XMLHttpRequest);
WebIDL::ExceptionOr<JS::NonnullGCPtr<XMLHttpRequest>> XMLHttpRequest::construct_impl(JS::Realm& realm)
{
auto upload_object = realm.heap().allocate<XMLHttpRequestUpload>(realm, realm);

View file

@ -30,6 +30,7 @@ using DocumentOrXMLHttpRequestBodyInit = Variant<JS::Handle<Web::DOM::Document>,
class XMLHttpRequest final : public XMLHttpRequestEventTarget {
WEB_PLATFORM_OBJECT(XMLHttpRequest, XMLHttpRequestEventTarget);
JS_DECLARE_ALLOCATOR(XMLHttpRequest);
public:
enum class State : u16 {

View file

@ -10,6 +10,8 @@
namespace Web::XHR {
JS_DEFINE_ALLOCATOR(XMLHttpRequestUpload);
XMLHttpRequestUpload::XMLHttpRequestUpload(JS::Realm& realm)
: XMLHttpRequestEventTarget(realm)
{

View file

@ -12,6 +12,7 @@ namespace Web::XHR {
class XMLHttpRequestUpload : public XMLHttpRequestEventTarget {
WEB_PLATFORM_OBJECT(XMLHttpRequestUpload, XMLHttpRequestEventTarget);
JS_DECLARE_ALLOCATOR(XMLHttpRequestUpload);
public:
virtual ~XMLHttpRequestUpload() override;