1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2026-01-12 22:50:59 +00:00
serenity/Userland
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
..
Applets LibGUI+Taskbar+Applets+Applications: Set various windows as Popups 2022-11-19 16:04:42 +01:00
Applications LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
Demos Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
DevTools Userland: Accept drag_enter events for widgets supporting file drops 2022-11-13 16:13:03 -07:00
DynamicLoader LibC: Properly implement stack protectors 2022-11-01 14:49:09 +00:00
Games 2048: Call event.ignore() correctly in 2048's BoardView keydown handler 2022-11-14 16:08:11 +00:00
Libraries LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
Services WebContent: Implement WebDriver's implicit timeout for finding elements 2022-11-21 18:54:22 +00:00
Shell Shell: Re-block SIGTT{IN,OU} on start 2022-11-03 00:01:42 +03:30
Utilities cksum: Manually count file size instead of using stat() 2022-11-19 17:00:10 +00:00
CMakeLists.txt Meta+Userland: Add ENABLE_USERSPACE_COVERAGE_COLLECTION CMake option 2022-05-02 01:46:18 +02:00