1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 00:47:36 +00:00
serenity/Userland/Libraries/LibJS
davidot e746360b9a LibJS: Use NaN boxing to decrease the memory size of Values
Using the fact that there are 2^52-2 NaN representations we can
"NaN-box" all the Values possible. This means that Value no longer has
an explicit "Type" but that information is now stored in the bits of a
double. This is done by "tagging" the top two bytes of the double.
For a full explanation see the large comment with asserts at the top of
Value.

We can also use the exact representation of the tags to make checking
properties like nullish, or is_cell quicker. But the largest gains are
in the fact that the size of a Value is now halved.

The SunSpider and other benchmarks have been ran to confirm that there
are no regressions in performance compared to the previous
implementation. The tests never performed worse and in some cases
performed better. But the biggest differences can be seen in memory
usage when large arrays are allocated. A simple test which allocates a
1000 arrays of size 100000 has roughly half the memory usage.

There is also space in the representations for future expansions such as
tuples and records.

To ensure that Values on the stack and registers are not lost during
garbage collection we also have to add a check to the Heap to check for
any of the cell tags and extracting the canonical form of the pointer
if it matches.
2022-08-15 17:11:25 +02:00
..
Bytecode Everywhere: Prefix 'TYPEDEF_DISTINCT_NUMERIC_GENERAL' with 'AK_' 2022-07-22 23:09:43 +01:00
Contrib/Test262 LibJS+LibWeb: Restore type safety of Realm::set_global_object() 2022-08-06 12:02:48 +02:00
Heap LibJS: Use NaN boxing to decrease the memory size of Values 2022-08-15 17:11:25 +02:00
Runtime LibJS: Use NaN boxing to decrease the memory size of Values 2022-08-15 17:11:25 +02:00
Tests LibJS: Add extreme value tests for cos and sin 2022-08-15 17:11:25 +02:00
AST.cpp LibJS: Use NaN boxing to decrease the memory size of Values 2022-08-15 17:11:25 +02:00
AST.h LibJS/Bytecode: Implement break/continue labels 2022-06-13 07:13:03 +04:30
CMakeLists.txt LibJS: Implement a basic Intl mathematical value 2022-07-20 18:21:24 +01:00
Console.cpp Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
Console.h LibJS: Convert Console to use MarkedVector<Value> 2022-05-07 01:22:09 +02:00
CyclicModule.cpp Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
CyclicModule.h LibJS: Remove implicit wrapping/unwrapping of completion records 2022-05-03 01:09:29 +02:00
Forward.h LibJS: Hook up the 'v' (unicodeSets) RegExp flag 2022-07-20 21:25:59 +01:00
Interpreter.cpp LibJS: Make Interpreter::create() call InitializeHostDefinedRealm() 2022-08-05 12:46:39 +02:00
Interpreter.h LibJS+LibWeb: Restore type safety of Realm::set_global_object() 2022-08-06 12:02:48 +02:00
Lexer.cpp Everywhere: Use default StringView constructor over nullptr 2022-07-12 23:11:35 +02:00
Lexer.h Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
MarkupGenerator.cpp Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
MarkupGenerator.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Module.cpp LibJS: Remove implicit wrapping/unwrapping of completion records 2022-05-03 01:09:29 +02:00
Module.h Libraries: Use default constructors/destructors in LibJS 2022-03-16 16:19:40 +00:00
Parser.cpp LibJS: Hook up the 'v' (unicodeSets) RegExp flag 2022-07-20 21:25:59 +01:00
Parser.h Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
Script.cpp LibJS: Rename some variables from "script body" to "script" 2022-05-01 22:47:38 +02:00
Script.h Libraries: Use default constructors/destructors in LibJS 2022-03-16 16:19:40 +00:00
SourceRange.h LibJS: Add missing headers 2021-10-06 23:52:40 +01:00
SourceTextModule.cpp LibJS: Remove implicit wrapping/unwrapping of completion records 2022-05-03 01:09:29 +02:00
SourceTextModule.h LibJS: Remove implicit wrapping/unwrapping of completion records 2022-05-03 01:09:29 +02:00
SyntaxHighlighter.cpp LibJS: Remove a bunch of gratuitous JS namespace qualifiers 2022-04-03 15:19:33 +01:00
SyntaxHighlighter.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
SyntheticModule.cpp LibJS: Mark concrete method calls of Environment Records with ?/! 2022-05-25 00:25:23 +01:00
SyntheticModule.h LibJS: Add support for JSON modules 2022-01-30 17:40:20 +00:00
Token.cpp Everywhere: Add sv suffix to strings relying on StringView(char const*) 2022-07-12 23:11:35 +02:00
Token.h Everywhere: Explicitly specify the size in StringView constructors 2022-07-12 23:11:35 +02:00