-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Extracted __proto__
from internal slots
#580
Conversation
Codecov Report
@@ Coverage Diff @@
## master #580 +/- ##
==========================================
- Coverage 70.40% 70.34% -0.06%
==========================================
Files 175 175
Lines 11162 11160 -2
==========================================
- Hits 7859 7851 -8
- Misses 3303 3309 +6
Continue to review full report at Codecov.
|
Benchmark for ba450bcClick to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good, this is a much needed change and benchmarks are looking great! Maybe we could extend this to other things in the future too :)
Check my comments, I have a couple of suggestions that might improve it.
boa/src/builtins/array/mod.rs
Outdated
.get_binding_value("Array") | ||
.expect("Array was not initialized") | ||
.borrow() | ||
.get_field(PROTOTYPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have a prototype()
getter here, and the get_field()
use that function if the passed string is the correct one. I think this would make it faster most of the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could store the builtin objects like Array
, String
, Number
etc, in the interpreter or Realm as fields as a GcObject
this will eliminate the Object lookup an we could do something like:
interperter.realm().array_object().prototype()
So we would cache the them, this will probably be easier after #577
boa/src/builtins/object/mod.rs
Outdated
@@ -130,6 +133,7 @@ impl Object { | |||
internal_slots: FxHashMap::default(), | |||
properties: FxHashMap::default(), | |||
symbol_properties: FxHashMap::default(), | |||
prototype: Value::null(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I see many fields here have the default value. Can't we use the ..Self::default()
notation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the ..Self::default() notation but, eventually we will have to remove them they are not spec compliant.
boa/src/exec/mod.rs
Outdated
|
||
new_func.prototype = function_prototype.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I see we create a function and then assign it a prototype. I would do this with a set_prototype()
setter as I explained before, but if we are using this a lot, we could maybe have a constructor that accepts a prototype too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably better for the constructor to take it, function objects should always have a prototype instance.
Yes. I planing to deprecate the |
eaf586d
to
875b291
Compare
Benchmark for e07b64cClick to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect :)
This Pull Request fixes/closes #578 .