1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2026-01-12 23:01:01 +00:00
serenity/Userland
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
..
Applets Base: Launch AudioServer at session start-up 2022-08-14 21:52:35 +01:00
Applications LibJS: Use NaN boxing to decrease the memory size of Values 2022-08-15 17:11:25 +02:00
Demos Everywhere: Replace hardcoded anon's uid in unveil path with %uid 2022-08-14 21:52:35 +01:00
DevTools Base: Launch LanguageServers at session start-up 2022-08-14 21:52:35 +01:00
DynamicLoader LibPthread: Implement named semaphores 2022-07-21 16:39:22 +02:00
Games Base: Launch FileSystemAccessServer at session start-up 2022-08-14 21:52:35 +01:00
Libraries LibJS: Use NaN boxing to decrease the memory size of Values 2022-08-15 17:11:25 +02:00
Services Base: Launch InspectorServer at session start-up 2022-08-14 21:52:35 +01:00
Shell Shell: Avoid StringView OOB access in Formatter ctor 2022-08-11 14:12:55 +00:00
Utilities Base: Launch AudioServer at session start-up 2022-08-14 21:52:35 +01:00
CMakeLists.txt Meta+Userland: Add ENABLE_USERSPACE_COVERAGE_COLLECTION CMake option 2022-05-02 01:46:18 +02:00