1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00
ladybird/Userland/Libraries
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
..
LibArchive LibArchive: Make get_field_as_integral error out on non-octal input 2022-11-13 17:37:26 -07:00
LibAudio SoundPlayer: Load cover image from music files 2022-11-13 18:51:18 -07:00
LibC LibC+Tests: Simplify getpwuid_r() and getpwnam_r() and add tests 2022-11-19 11:11:13 +01:00
LibCards Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibChess Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibCodeComprehension Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibCompress Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibConfig Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibCore LibCore: Add a ConfigFile::open() overload for Core::Stream::File 2022-11-19 17:00:10 +00:00
LibCoredump Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibCpp Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibCrypt Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibCrypto AK+LibC+LibCrypto: Move FloatExtractor to AK/FloatingPoint.h 2022-11-03 20:17:09 -06:00
LibDebug Everywhere: Remove redundant inequality comparison operators 2022-11-06 10:25:08 -07:00
LibDesktop Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibDeviceTree Everywhere: Remove redundant inequality comparison operators 2022-11-06 10:25:08 -07:00
LibDiff Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibDNS Userland: Properly define IPC::encode and IPC::decode specializations 2022-11-15 13:25:51 -05:00
LibDSP Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibEDID Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibELF LibELF: Drop the "resolve and map" all-in-one 2022-10-31 19:23:02 +00:00
LibFileSystemAccessClient Userland: Remove workarounds for LibIPC include order sensitivity 2022-11-15 13:25:51 -05:00
LibGemini Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibGfx LibGfx: Add pure virtual fallible clone() for Fonts 2022-11-19 15:41:09 +01:00
LibGL Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibGPU Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibGUI LibGUI: Disallow shortcut propagation in Blocking modals and Popups 2022-11-19 16:04:42 +01:00
LibHTTP LibHTTP: Always send Content-Length header in POST requests 2022-11-07 14:10:41 +01:00
LibIDL Everywhere: Remove unnecessary mutable attributes from lambdas 2022-11-19 14:37:31 +00:00
LibImageDecoderClient Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibIMAP Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibIPC Everywhere: Remove unnecessary mutable attributes from lambdas 2022-11-19 14:37:31 +00:00
LibJS LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
LibKeyboard Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibLine LibVT/LibLine: Delete words when pressing Ctrl+Backspace in Terminal 2022-11-20 03:57:17 +03:30
LibLocale Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibMain Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibMarkdown Everywhere: Clean up "the the" comment typos 2022-11-03 17:38:32 +00:00
LibPartition Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibPCIDB Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibPDF LibPDF: Parse integer numbers with atoi() instead of strtof() 2022-11-19 15:42:08 +01:00
LibProtocol Userland: Remove workarounds for LibIPC include order sensitivity 2022-11-15 13:25:51 -05:00
LibRegex LibRegex: Use spans<4> to avoid allocating small vectors 2022-11-17 20:13:04 +03:30
LibSanitizer LibC: Properly implement stack protectors 2022-11-01 14:49:09 +00:00
LibSoftGPU Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibSQL Everywhere: Remove redundant inequality comparison operators 2022-11-06 10:25:08 -07:00
LibSymbolication Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibSyntax Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibSystem
LibTest LibTest: Fail if the top-level result of running a JS file is an error 2022-11-17 16:05:20 +00:00
LibTextCodec Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibThreading LibThreading: Add thread priority controls to Thread 2022-11-13 19:42:39 +00:00
LibTimeZone LibTimeZone: Resolve /etc/localtime with realpath(), not readlink() 2022-10-17 22:19:50 +02:00
LibTLS Everywhere: Clean up "the the" comment typos 2022-11-03 17:38:32 +00:00
LibUnicode Meta+LibUnicode: Avoid relocations for static unicode data 2022-11-06 17:34:06 +01:00
LibUSBDB Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibVideo VideoPlayer: Make PlaybackManager use OwnPtr 2022-11-14 10:05:56 +00:00
LibVT LibVT/LibLine: Delete words when pressing Ctrl+Backspace in Terminal 2022-11-20 03:57:17 +03:30
LibWasm AK+Everywhere: Replace DistinctNumeric bool parameters with named ones 2022-11-11 17:50:53 +03:30
LibWeb LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
LibWebSocket LibWebSocket: Buffer incoming frame data until whole frame is available 2022-11-09 02:06:33 +01:00
LibWebView LibWebView: Update OOPWV's URL when a page starts/finishes loading 2022-11-19 16:56:02 +00:00
LibX86 Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibXML LibXML+LibWeb: Store the XML document's original source 2022-11-03 14:52:16 +00:00
CMakeLists.txt LibIDL+WrapperGenerator: Move IDL code into a library 2022-09-17 21:27:17 +02:00