-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Decouple Object
from Value
#577
Comments
Hey @HalidOdat I found this interesting and am trying to tackle it. Ps: Also, functions like |
@HalidOdat how are you handling boxing, unboxing of primitive values? I think I left set_field and get_field on value so things like |
We store some primitives on the stack (number, boolean, undefined, null) and string, bigint, symbol on the heap with Rcs (since they can't have cycles, less work for the gc) and object with Why would removing |
Ok sounds good.
I think originally the unboxing happened inside of get_field() where the value was checked and upgraded to an object of it was a primitive. I think we refactored quite a few times since this though so you can ignore this. |
Changing We need to the check as described in the spec for when this is not a object for example:
It calls
If it is a helper function then, yes it should. |
Yeah, I started at One thing I was wondering, would the |
It should be If it is referenced it should be |
Start work on boa-dev#577 Value::new_object_from_prototype becomes Object::new_object_from_prototype Introduce some small changes in other files to accommodate for the change in API, I assume once boa-dev#577 is finished everything will be cleaned up
I have created my PR, #712, I'll leave a note here as to how this should also eventually be done since I did it for
|
Hey @HalidOdat any idea on what I should try to change next? I was trying to change |
I think it would be a good idea to wait until #722 lands since it also tackles this issue in a way and will generate a lot of merge conflicts. |
@HalidOdat from my work on #854 it would be good to stack-allocate Values, but as some of them hold RCObjects its not possible. Should there be some pointer which through a method gives back the object? |
There is a problem with objects being stack allocated, many operations (eq, some object methods, object internal methods) require to know the exact location in memory which means we can move the objects once there created (say for example pop two and push one in the case of #854), if we do something will break.
Sorry, could you explain a bit more? |
Hey @HalidOdat I got started on changing the global object to a |
|
No, I was just commenting on the "should set_field panic" part. It shouldn't |
I don't think this will be ready for 0.14, so I'm moving it out. |
This Pull Request is related to #577 . It changes the following: - Remove `JsValue::set_field` - Remove `JsValue::set_property` - Remove almost all uses of `JsValue::get_field` - Use `.get_v()` instead of `get_field` according to spec in `serialize_json_property` - Remove `Array::new_array()` - Remove `Array::add_to_array_object()`
This Pull Request is related to #577 . It changes the following: - Remove `JsValue::set_field` - Remove `JsValue::set_property` - Remove almost all uses of `JsValue::get_field` - Use `.get_v()` instead of `get_field` according to spec in `serialize_json_property` - Remove `Array::new_array()` - Remove `Array::add_to_array_object()`
This PR is also related to #577 Changes: - Implements `IteratorValue` (`IteratorResult::value()`) - Implements `IteratorComplete` (`IteratorResult::complete()`) - Implements `IteratorStep` (`IteratorRecord::step()`) - Makes `IteratorNext` (`IteratorRecord::next()`) spec compliant - Deprecates/removes `JsValue::get_field()`.
Many refactors/changes have been done since this issue was created and they have been resolved. So closing this :) |
What is the problem with the current implementation?
The problem is that we treat
Value
as anObject
which is not always the case. for exampleValue
has a.set_field()
which sets an object field, this does not make sense for a couple of reasons:Value
is not an object should calling.set_field
panic?, should it ignore it? should it return an option or result? or something else? (we ignore non object values which can become a really hard bug to debug), as we can see it does not make sense forValue
to haveObject
behaviourIf we need object behaviour we can call
as_object
method.Changes:
Value
toObject
GcObject
sfunction likedone.to_object
should return aGcObject
notValue
Doing these thing should remove unnecessary checks and make the API more intuitive
Any suggestions on how to improve this?
The text was updated successfully, but these errors were encountered: