1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2026-01-14 16:11:00 +00:00
serenity/Userland/Applications/Spreadsheet
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
..
CellType LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19] 2022-08-23 13:58:30 +01:00
Readers Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
Tests Spreadsheet: Throw if lookup value doesn't exist and no default is given 2022-06-26 22:21:17 +01:00
Writers Everywhere: Replace single-char StringView op. arguments with chars 2022-07-12 23:11:35 +02:00
Cell.cpp Everywhere: Replace single-char StringView op. arguments with chars 2022-07-12 23:11:35 +02:00
Cell.h Spreadsheet: Display a detailed view of a cell error on hover 2022-06-26 22:21:17 +01:00
CellSyntaxHighlighter.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
CellSyntaxHighlighter.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
CellTypeDialog.cpp Spreadsheet: Make conditional-formatting condition-list scrollable 2022-06-30 11:53:50 +02:00
CellTypeDialog.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
CMakeLists.txt Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
CondFormatting.gml Spreadsheet: Make conditional-formatting condition-list scrollable 2022-06-30 11:53:50 +02:00
ConditionalFormatting.h Spreadsheet: Add toolbar actions to change the cell style 2022-09-27 13:38:11 +03:30
CondView.gml Spreadsheet: Use new layout system 2022-06-30 11:51:25 +02:00
csv_export.gml Userland: Replace empty GUI::Widgets in GML with GUI::Layout::Spacer 2022-09-29 08:31:15 -04:00
csv_import.gml Userland: Replace empty GUI::Widgets in GML with GUI::Layout::Spacer 2022-09-29 08:31:15 -04:00
ExportDialog.cpp Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
ExportDialog.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Forward.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
HelpWindow.cpp AK+Everywhere: Replace "protocol" with "scheme" url helpers 2022-09-29 09:39:04 +01:00
HelpWindow.h LibWebView: Move OutOfProcessWebView to a new LibWebView library 2022-05-15 12:17:36 +02:00
ImportDialog.cpp Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
ImportDialog.h Spreadsheet: Use FileSystemAccessClient for the reading of files 2022-01-15 22:20:15 +03:30
JSIntegration.cpp LibJS: Turn initialize_global_object() into a regular initialize() 2022-08-28 16:36:56 +01:00
JSIntegration.h LibJS: Turn initialize_global_object() into a regular initialize() 2022-08-28 16:36:56 +01:00
main.cpp Applications: Use new global variables at /sys/kernel/ directory 2022-10-25 15:33:34 -06:00
Position.h Everywhere: Remove redundant inequality comparison operators 2022-11-06 10:25:08 -07:00
select_format_page.gml Userland: Replace empty GUI::Widgets in GML with GUI::Layout::Spacer 2022-09-29 08:31:15 -04:00
Spreadsheet.cpp LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
Spreadsheet.h Spreadsheet: Implement undo functionality where missing 2022-04-13 09:26:44 +04:30
SpreadsheetModel.cpp LibJS: Reduce AST memory usage by shrink-wrapping source range info 2022-11-22 21:13:35 +01:00
SpreadsheetModel.h Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
SpreadsheetView.cpp Everywhere: Clean up "the the" comment typos 2022-11-03 17:38:32 +00:00
SpreadsheetView.h Spreadsheet: Display a detailed view of a cell error on hover 2022-06-26 22:21:17 +01:00
SpreadsheetWidget.cpp Userland: Let applications make use of make_command_palette_action() 2022-10-25 10:21:18 +01:00
SpreadsheetWidget.h Userland: Let applications make use of make_command_palette_action() 2022-10-25 10:21:18 +01:00
Workbook.cpp LibJS: Remove {Bytecode::,}Interpreter::global_object() 2022-08-23 13:58:30 +01:00
Workbook.h Spreadsheet: Allow importing sheets into an existing workbook 2022-06-26 22:21:17 +01:00