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

dart2js: consider canonicalization of tear-off closures #583

Closed
rakudrama opened this issue Nov 23, 2011 · 11 comments
Closed

dart2js: consider canonicalization of tear-off closures #583

rakudrama opened this issue Nov 23, 2011 · 11 comments
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug web-dart2js

Comments

@rakudrama
Copy link
Member

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)

@jmesserly
Copy link

Removed Type-Defect label.
Added Type-Enhancement label.

@anders-sandholm
Copy link
Contributor

Removed Area-Frog label.
Added Area-Dart2JS, FromAreaFrog labels.

@kasperl
Copy link

kasperl commented Jun 12, 2012

This might make sense for dart2js.


Removed FromAreaFrog label.
Changed the title to: "Consider canonicalization of tear-off closures".

@kasperl
Copy link

kasperl commented Sep 3, 2012

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented Oct 17, 2012

Removed this from the Later milestone.

@kasperl
Copy link

kasperl commented Oct 17, 2012

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented May 23, 2013

Added TriageForM5 label.

@kasperl
Copy link

kasperl commented May 28, 2013

Removed TriageForM5 label.
Changed the title to: "dart2js: consider canonicalization of tear-off closures".

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@floitschG
Copy link
Contributor

I think we decided not to canonicalize tear-off closures.
(Note that the proposed approach would also change the hidden class of the object).


Added NotPlanned label.

@rakudrama rakudrama added Type-Enhancement web-dart2js closed-not-planned Closed as we don't intend to take action on the reported issue labels Aug 14, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
nex3 pushed a commit that referenced this issue Aug 31, 2016
fixes #584, works around analyzer message #583

R=leafp@google.com

Review URL: https://codereview.chromium.org/2048463002 .
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug web-dart2js
Projects
None yet
Development

No branches or pull requests

6 participants