-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
dart2js: consider canonicalization of tear-off closures #583
Comments
Removed Type-Defect label. |
Removed Area-Frog label. |
This might make sense for dart2js. Removed FromAreaFrog label. |
Added this to the Later milestone. |
Removed this from the Later milestone. |
Added this to the Later milestone. |
Added TriageForM5 label. |
Removed TriageForM5 label. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
I think we decided not to canonicalize tear-off closures. Added NotPlanned label. |
fixes #584, works around analyzer message #583 [email protected] Review URL: https://codereview.chromium.org/2048463002 .
The 'tear-off' closure that binds 'this' is slow to create and slow to apply. The following change fixes both issues:
Test.prototype.get$tearOff = function() {
return Test.prototype.tearOff.bind(this);
}
Test.prototype.get$tearOff = function() {
// Caching on object (canonicalizing) make second creation fast.
if (this.get$tearOff$$) return this.get$tearOff$$;
var $this = this;
var f = Test.prototype.tearOff.bind(this); // (Is f ever called directly?)
f.call$0 = function() { $this.tearOff(); }; // Makes calls fast call
this.get$tearOff$$ = f;
return f;
}
This needs to be validated for other browsers, and it should also be validated that single-use tear-offs are not too expensive with all this extra code.
The idea needs to be worked through for named optional arguments and type checking.
See also Issue #551.
Attachments:
bug1o2.dart (774 Bytes)
bug1o3.dart (759 Bytes)
The text was updated successfully, but these errors were encountered: