-
-
Notifications
You must be signed in to change notification settings - Fork 401
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 boxed JavaScript Value #1373
Comments
I ended up reading through the links and can see the benefit in doing NaN boxing, however, what is the memory footprint of the fat enum being used currently? Not totally sure how or whether Rust does any sort of padding or whatnot on fat enums. |
Currently the size of |
If you're looking for impl of NaN boxing in Rust Starlight has two different implementations of them for handling JS values: https://github.com/Starlight-JS/starlight/blob/dev/crates/starlight/src/vm/value.rs :) |
Awesome! thanks, for the suggestion. I have implemented NaN boxing locally, but the problem is refactoring the existing |
What about having |
Yup. thought about this as a possible solution and it's probably the best solution, since refactoring will be a nightmare otherwise. |
@HalidOdat any news on this? |
Sorry for not replying I have been very busy, but plan to start to do more contributions in the future. I'll start working on this again. had a semi-working implementation of this that needs a rebase (it's pretty old). Hopefully I can get it working by this weekend :) |
Will try to do some investigation on how to reduce the size of JsObject. |
Would be nice to revisit this as part of our performance focus, I’m happy to team up with @jedel1043 if at some point you wanted to take another look at this |
Currently a JavaScript value in Boa is defined as a fat enum. With NaN boxing we can reduce this to
8
bytes having all the variants of a JS value fit inu64
/f64
. With this we can reduce the memory footprint of Boa, also a JS value will be able to be put into a 64bit register.Many JS engines use this, like spidermonkey, JavaScriptCore, etc.
For more information:
- https://anniecherkaev.com/the-secret-life-of-nan
- https://leonardschuetz.ch/blog/nan-boxing/
- https://github.com/mozilla/gecko-dev/blob/master/js/public/Value.h
The text was updated successfully, but these errors were encountered: