-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
[Merged by Bors] - Refactor mapped Arguments
object
#1849
Conversation
Test262 conformance changesVM implementation
|
Codecov Report
@@ Coverage Diff @@
## main #1849 +/- ##
==========================================
- Coverage 55.57% 55.55% -0.03%
==========================================
Files 199 199
Lines 17756 17768 +12
==========================================
+ Hits 9868 9871 +3
- Misses 7888 7897 +9
Continue to review full report at Codecov.
|
Benchmark for 507f73eClick 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 good to me :) I think it could use some better documentation in some functions, though.
} | ||
|
||
impl ParameterMap { | ||
pub(crate) fn delete(&mut self, index: usize) { |
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.
pub(crate) fn delete(&mut self, index: usize) { | |
/// Deletes the binding with the given index from the parameter map. | |
pub(crate) fn delete(&mut self, index: usize) { |
// 10.4.4.7.1 MakeArgGetter ( name, env ) | ||
// https://tc39.es/ecma262/#sec-makearggetter |
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.
Could we use documentation comments here?
// 10.4.4.7.2 MakeArgSetter ( name, env ) | ||
// https://tc39.es/ecma262/#sec-makeargsetter |
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 also, we should use documentation comments, and add a bit of explanation.
Benchmark for 7ee330eClick 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.
Benchmarks look good! Especially the Fibonacci benchmark with a 30+% reduction in runtime. That's probably because the engine doesn't need to slowly create the mapped arguments object on each recursive call, right?
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 good to me :)
bors r+ |
This refactors the representation of the `[[ParameterMap]]` internal slot on the `Arguments` exotic object to be faster at runtime. Previously `[[ParameterMap]]` was a `JsObject` like the spec describes. This can be pretty slow a runtime, because the argument getters and setters must be represented as function objects on the `[[ParameterMap]]` object. In addition to the time spend on creation and calling of those functions, every getter/setter needs a cloned gc reference to the function environment to access the bindings. This adds to the gc overhead. The spec states that the `[[ParameterMap]]` internal slot doesn't have to be a `JsObject`. See NOTE 3 here: https://tc39.es/ecma262/#sec-arguments-exotic-objects Leveraging this freedom, we can use a more optimized representation, that avoids any `JsObject` usage and only needs one clone of the function environment.
Pull request successfully merged into main. Build succeeded: |
Arguments
objectArguments
object
This refactors the representation of the `[[ParameterMap]]` internal slot on the `Arguments` exotic object to be faster at runtime. Previously `[[ParameterMap]]` was a `JsObject` like the spec describes. This can be pretty slow a runtime, because the argument getters and setters must be represented as function objects on the `[[ParameterMap]]` object. In addition to the time spend on creation and calling of those functions, every getter/setter needs a cloned gc reference to the function environment to access the bindings. This adds to the gc overhead. The spec states that the `[[ParameterMap]]` internal slot doesn't have to be a `JsObject`. See NOTE 3 here: https://tc39.es/ecma262/#sec-arguments-exotic-objects Leveraging this freedom, we can use a more optimized representation, that avoids any `JsObject` usage and only needs one clone of the function environment.
This refactors the representation of the
[[ParameterMap]]
internal slot on theArguments
exotic object to be faster at runtime.Previously
[[ParameterMap]]
was aJsObject
like the spec describes. This can be pretty slow a runtime, because the argument getters and setters must be represented as function objects on the[[ParameterMap]]
object. In addition to the time spend on creation and calling of those functions, every getter/setter needs a cloned gc reference to the function environment to access the bindings. This adds to the gc overhead.The spec states that the
[[ParameterMap]]
internal slot doesn't have to be aJsObject
. See NOTE 3 here: https://tc39.es/ecma262/#sec-arguments-exotic-objectsLeveraging this freedom, we can use a more optimized representation, that avoids any
JsObject
usage and only needs one clone of the function environment.