-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaN-boxing of SOM values #37
base: master
Are you sure you want to change the base?
Conversation
The bytecode interpreter is fully working and passing tests except for 6 failures in The CI is unable to show this due to the AST interpreter not being able to build successfully right now. Also, currently, both the enum-based |
The primitives have now been all revisited to stop using the old Previously, all primitives were bare function pointers, had the same prototype ( Now, primitives can declare their expected arguments directly in their argument list, trait-based dispatch will take care of extracting them from the interpreter stack and converting them automatically (using a new This significantly simplified the function bodies of the primitives, clearing them free of most conversions and interpreter stack management. I think the ergonomics can be improved even further, through the use of procedural macros (like a |
Here are the benchmark results for AST interpreter
Bytecode interpreter
|
SOM-RS Benchmarker? :) building your own GitHub tooling? Very interesting! |
Yeah, it is just a little thing I built to have these benchmarks summary tables without running them manually and managing all the I am not even sure if it will stay, given that it is a bit redundant with ReBenchDB, but maybe having the results inline in the PRs can make the results a bit easier to access. I have also updated my ReBenchDB instance and noticed a new compare page, but it seems to have an issue right now displaying the results (like in this page), so I'll investigate that. Also, it seems that ReBenchDB has a feature to post GitHub comments automatically which could replace my little setup.
Thank you, altough it's advancing slower than I would like (like the GC who hasn't really improved in a while). |
It's something I always wanted for ReBenchDB ;)
Hmm. So, yeah, that could be a bug, or somehow the configuration between runs changed in ways that are not expected? It's all reimplemented in TypeScript, and the R is removed from the project.
Yes, there's a "feature", but it is broken at least on my setup, and I haven't had a time to debug that since upgrading rebench.dev...
Is Rust getting in your way? :) |
feat: more trait impls for `Gc<T>`
feat: trait-based declaration of primitive implementations
refactor: renamed `Value` to `ValueEnum`
Here are the benchmark results for AST interpreter
Bytecode interpreter
|
This PR reduces the size of SOM values from 16 bytes (as an enum) to just 8 bytes using a technique called NaN-boxing.
NaN-boxing is a technique where we take advantage of the fact that just 12 bits are enough to signal an
NaN
in 64-bit floating point numbers, so we hijack the 52 remaining bits to encode custom payloads.This technique is notably used within the LuaJIT project and LibJS from the SerenityOS project.
This PR is built on top of the custom GC (
som-gc
) branch and the NaN-boxing is only implemented for the bytecode interpreter right now (so the AST one is currently broken).This change means multiple things:
This change also makes the code a bit less portable due to us relying on the fact that pointers on most 64-bit systems actually only use the lowest 48 bits out of the 64 available to make them embeddable in the NaNs.
While this is valid for x86-64, I am not currently aware of which architecture are now broken by this assumption.
Depends on #33.