ladybird/Userland/Libraries/LibWeb/HTML/Scripting
Andreas Kling b0b022507b LibJS: Reduce AST memory usage by shrink-wrapping source range info
Before this change, each AST node had a 64-byte SourceRange member.
This SourceRange had the following layout:

    filename:       StringView (16 bytes)
    start:          Position (24 bytes)
    end:            Position (24 bytes)

The Position structs have { line, column, offset }, all members size_t.

To reduce memory consumption, AST nodes now only store the following:

    source_code:    NonnullRefPtr<SourceCode> (8 bytes)
    start_offset:   u32 (4 bytes)
    end_offset:     u32 (4 bytes)

SourceCode is a new ref-counted data structure that keeps the filename
and original parsed source code in a single location, and all AST nodes
have a pointer to it.

The start_offset and end_offset can be turned into (line, column) when
necessary by calling SourceCode::range_from_offsets(). This will walk
the source code string and compute line/column numbers on the fly, so
it's not necessarily fast, but it should be rare since this information
is primarily used for diagnostics and exception stack traces.

With this, ASTNode shrinks from 80 bytes to 32 bytes. This gives us a
~23% reduction in memory usage when loading twitter.com/awesomekling
(330 MiB before, 253 MiB after!) :^)
2022-11-22 21:13:35 +01:00
..
ClassicScript.cpp LibWeb: Remove accidentally commited dbglns 2022-11-15 21:48:19 +00:00
ClassicScript.h LibWeb: Allow all Script types to be used as [[HostDefined]] values 2022-10-06 16:41:36 +02:00
Environments.cpp LibJS+LibWeb: Make JS::ExecutionContext protect its Web::HTML::ESO owner 2022-11-21 19:22:09 +00:00
Environments.h LibWeb: Support parsing a URL relative to environment settings object 2022-11-15 21:48:19 +00:00
ExceptionReporter.cpp LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
ExceptionReporter.h WebContent+LibWeb+LibJS: Report exceptions to the JS console 2022-10-15 01:25:12 +02:00
Fetching.cpp LibWeb: Implement recent changes to module script fetching 2022-10-24 23:06:56 +01:00
Fetching.h LibWeb: Implement recent changes to module script fetching 2022-10-24 23:06:56 +01:00
ImportMap.h LibWeb: Add the ImportMap struct 2022-10-24 23:06:56 +01:00
ModuleMap.cpp LibWeb: Implement ModuleMap and expose it on EnvironmentSettingsObject 2022-10-06 16:41:36 +02:00
ModuleMap.h LibWeb: Implement ModuleMap and expose it on EnvironmentSettingsObject 2022-10-06 16:41:36 +02:00
ModuleScript.cpp LibWeb: Implement recent changes to module script fetching 2022-10-24 23:06:56 +01:00
ModuleScript.h LibWeb: Implement ModuleScript and JavaScriptModuleScript 2022-10-06 16:41:36 +02:00
Script.cpp LibWeb: Allow all Script types to be used as [[HostDefined]] values 2022-10-06 16:41:36 +02:00
Script.h LibWeb: Allow all Script types to be used as [[HostDefined]] values 2022-10-06 16:41:36 +02:00
WindowEnvironmentSettingsObject.cpp LibWeb: Add policy container to {Window,Worker}EnvironmentSettingsObject 2022-10-24 22:58:37 +01:00
WindowEnvironmentSettingsObject.h LibWeb: Add policy container to {Window,Worker}EnvironmentSettingsObject 2022-10-24 22:58:37 +01:00
WorkerEnvironmentSettingsObject.h LibWeb: Add policy container to {Window,Worker}EnvironmentSettingsObject 2022-10-24 22:58:37 +01:00