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

@ -13,6 +13,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ByteLengthQueuingStrategy);
// https://streams.spec.whatwg.org/#blqs-constructor
WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> ByteLengthQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
{

View file

@ -17,6 +17,7 @@ namespace Web::Streams {
// https://streams.spec.whatwg.org/#bytelengthqueuingstrategy
class ByteLengthQueuingStrategy final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ByteLengthQueuingStrategy, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ByteLengthQueuingStrategy);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ByteLengthQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);

View file

@ -13,6 +13,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(CountQueuingStrategy);
// https://streams.spec.whatwg.org/#blqs-constructor
WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
{

View file

@ -17,6 +17,7 @@ namespace Web::Streams {
// https://streams.spec.whatwg.org/#countqueuingstrategy
class CountQueuingStrategy final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CountQueuingStrategy, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CountQueuingStrategy);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);

View file

@ -11,6 +11,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableByteStreamController);
// https://streams.spec.whatwg.org/#rbs-controller-desired-size
Optional<double> ReadableByteStreamController::desired_size() const
{

View file

@ -72,6 +72,7 @@ struct ReadableByteStreamQueueEntry {
// https://streams.spec.whatwg.org/#readablebytestreamcontroller
class ReadableByteStreamController : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ReadableByteStreamController, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ReadableByteStreamController);
public:
virtual ~ReadableByteStreamController() override = default;

View file

@ -18,6 +18,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableStream);
// https://streams.spec.whatwg.org/#rs-constructor
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> const& underlying_source_object, QueuingStrategy const& strategy)
{

View file

@ -29,6 +29,7 @@ struct ReadableStreamGetReaderOptions {
// https://streams.spec.whatwg.org/#readablestream
class ReadableStream final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ReadableStream, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ReadableStream);
public:
enum class State {

View file

@ -15,6 +15,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableStreamBYOBReader);
ReadableStreamBYOBReader::ReadableStreamBYOBReader(JS::Realm& realm)
: Bindings::PlatformObject(realm)
, ReadableStreamGenericReaderMixin(realm)

View file

@ -38,6 +38,7 @@ class ReadableStreamBYOBReader final
: public Bindings::PlatformObject
, public ReadableStreamGenericReaderMixin {
WEB_PLATFORM_OBJECT(ReadableStreamBYOBReader, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ReadableStreamBYOBReader);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamBYOBReader>> construct_impl(JS::Realm&, JS::NonnullGCPtr<ReadableStream>);

View file

@ -9,6 +9,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableStreamBYOBRequest);
// https://streams.spec.whatwg.org/#rs-byob-request-view
JS::GCPtr<JS::TypedArrayBase> ReadableStreamBYOBRequest::view()
{

View file

@ -16,6 +16,7 @@ namespace Web::Streams {
// https://streams.spec.whatwg.org/#readablestreambyobrequest
class ReadableStreamBYOBRequest : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ReadableStreamBYOBRequest, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ReadableStreamBYOBRequest);
public:
virtual ~ReadableStreamBYOBRequest() override = default;

View file

@ -16,6 +16,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableStreamDefaultController);
ReadableStreamDefaultController::ReadableStreamDefaultController(JS::Realm& realm)
: Bindings::PlatformObject(realm)
{

View file

@ -20,6 +20,7 @@ namespace Web::Streams {
// https://streams.spec.whatwg.org/#readablestreamdefaultcontroller
class ReadableStreamDefaultController : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ReadableStreamDefaultController, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ReadableStreamDefaultController);
public:
explicit ReadableStreamDefaultController(JS::Realm&);

View file

@ -23,6 +23,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(ReadableStreamDefaultReader);
void ReadLoopReadRequest::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);

View file

@ -65,6 +65,7 @@ class ReadableStreamDefaultReader final
: public Bindings::PlatformObject
, public ReadableStreamGenericReaderMixin {
WEB_PLATFORM_OBJECT(ReadableStreamDefaultReader, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ReadableStreamDefaultReader);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> construct_impl(JS::Realm&, JS::NonnullGCPtr<ReadableStream>);

View file

@ -15,6 +15,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(TransformStream);
// https://streams.spec.whatwg.org/#ts-construct
WebIDL::ExceptionOr<JS::NonnullGCPtr<TransformStream>> TransformStream::construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> transformer_object, QueuingStrategy const& writable_strategy, QueuingStrategy const& readable_strategy)
{

View file

@ -16,6 +16,7 @@ namespace Web::Streams {
class TransformStream final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(TransformStream, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(TransformStream);
public:
virtual ~TransformStream() override;

View file

@ -10,6 +10,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(TransformStreamDefaultController);
TransformStreamDefaultController::TransformStreamDefaultController(JS::Realm& realm)
: Bindings::PlatformObject(realm)
{

View file

@ -13,6 +13,7 @@ namespace Web::Streams {
class TransformStreamDefaultController : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(TransformStreamDefaultController, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(TransformStreamDefaultController);
public:
explicit TransformStreamDefaultController(JS::Realm&);

View file

@ -16,6 +16,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(WritableStream);
// https://streams.spec.whatwg.org/#ws-constructor
WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStream>> WritableStream::construct_impl(JS::Realm& realm, Optional<JS::Handle<JS::Object>> const& underlying_sink_object, QueuingStrategy const& strategy)
{

View file

@ -34,6 +34,7 @@ struct PendingAbortRequest {
// https://streams.spec.whatwg.org/#writablestream
class WritableStream final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(WritableStream, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(WritableStream);
public:
enum class State {

View file

@ -10,6 +10,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(WritableStreamDefaultController);
void WritableStreamDefaultController::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);

View file

@ -15,6 +15,7 @@ namespace Web::Streams {
// https://streams.spec.whatwg.org/#writablestreamdefaultcontroller
class WritableStreamDefaultController final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(WritableStreamDefaultController, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(WritableStreamDefaultController);
public:
virtual ~WritableStreamDefaultController() override = default;

View file

@ -14,6 +14,8 @@
namespace Web::Streams {
JS_DEFINE_ALLOCATOR(WritableStreamDefaultWriter);
WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStreamDefaultWriter>> WritableStreamDefaultWriter::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<WritableStream> stream)
{
auto writer = realm.heap().allocate<WritableStreamDefaultWriter>(realm, realm);

View file

@ -18,6 +18,7 @@ namespace Web::Streams {
// https://streams.spec.whatwg.org/#writablestreamdefaultwriter
class WritableStreamDefaultWriter final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(WritableStreamDefaultWriter, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(WritableStreamDefaultWriter);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WritableStreamDefaultWriter>> construct_impl(JS::Realm&, JS::NonnullGCPtr<WritableStream>);