Skip to content
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

Automatic Boxing and Unboxing of Primitive Values #29

Closed
jasonwilliams opened this issue Jun 23, 2019 · 2 comments
Closed

Automatic Boxing and Unboxing of Primitive Values #29

jasonwilliams opened this issue Jun 23, 2019 · 2 comments
Assignees

Comments

@jasonwilliams
Copy link
Member

jasonwilliams commented Jun 23, 2019

As spotted in jasonwilliams#13 (comment) string methods on string literals won't work because automatic Boxing and Unboxing is not supported in Boa yet. This is something we'll need to think about adding, it could be worth seeing how spidermonkey or V8 do this

@jasonwilliams
Copy link
Member Author

jasonwilliams commented Jun 24, 2019

V8 representation of primitive values:
https://cs.chromium.org/chromium/src/v8/src/objects/js-objects.h?rcl=fe77d58a6a3cd9385454aa0bc29330ec668e293a&l=1236-1252

Unboxing in Spidermonkey:
https://searchfox.org/mozilla-central/source/js/src/vm/JSObject.cpp#4198-4220

ChakraCore:
https://github.com/microsoft/ChakraCore/blob/4565a28e899322e364ee1a204f1e1a6c17aa5269/lib/Runtime/Language/JavascriptConversion.cpp#L221-L265


SpiderMonkey js::getProperty()
https://searchfox.org/mozilla-central/rev/928742d3ea30e0eb4a8622d260041564d81a8468/js/src/vm/Interpreter.cpp#4438-4493
Spidermonkey have a js::getProperty method which checks if a JSValue is a primitive, if it is it will get the proto of its object equivalent and use that.

They also cache this value so it can be used again, but the cache never gets cleared.
https://searchfox.org/mozilla-central/source/js/src/vm/GlobalObject.h#207-211

This is quite a different approach from V8 who create wrapper objects and use them

@jasonwilliams jasonwilliams changed the title Boxing and Unboxing of Primitive Values Automatic Boxing and Unboxing of Primitive Values Jun 25, 2019
@jasonwilliams jasonwilliams self-assigned this Jul 3, 2019
@jasonwilliams
Copy link
Member Author

Fixed by jasonwilliams#86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant