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: Make BoundClosures work with dummy receiver optimization #15933

Open
rakudrama opened this issue Jan 7, 2014 · 1 comment
Open

dart2js: Make BoundClosures work with dummy receiver optimization #15933

rakudrama opened this issue Jan 7, 2014 · 1 comment
Labels
area-web Issues related to Dart Web. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug web-dart2js

Comments

@rakudrama
Copy link
Member

BoundClosure type tests fail with the dummy-receiver optimization because the type test looks into the closure to find the receiver, but finds the dummy receiver instead of the true receiver.

The dummy receiver optimization was reverted to enable the metadata-generated tear-off closures to be committed:
https://code.google.com/p/dart/source/detail?r=31414

A better fix for the incompatibility would have been to disable the dummy receiver optimization only for getters. I will do this.

Another way to fix the incompatibility is to make BoundClosures work properly when the dummy receiver optimization is in use.

There are three flavors of bound closure.

  1. Plain 'Dart' bound closures that have no interceptor
  2. 'native' and 'primitive' bound closures that have an interceptor and a receiver (two different values)
  3. Plain dart bound closures for methods that use the interceptor calling convention but are 'self-intercepting'. These should pass the same value to the target function's 'self' and 'receiver' arguments.

­2 and #­3 are currently folded together.

They can be made to work with the dummy receiver optimization in one of two ways:

(a) Have separate classes and don't store separate (and inconsistent) 'self' and 'receiver' values. Ensure that generated methods that pass the one value in both positions.

(b) Use one class as current, but canonicalize the closure on construction to have the same value for 'self' and 'receiver', in effect replacing the dummy receiver with the true receiver.

Care needs to be taken with mixins. A mixin is a regular class but may be mixed into a native class, requiring a separate receiver/interceptor.

@sethladd
Copy link
Contributor

sethladd commented Jan 7, 2014

Removed Type-Defect label.
Added Type-Enhancement, Triaged labels.

@rakudrama rakudrama added Type-Enhancement P3 A lower priority bug or feature request web-dart2js labels Jan 7, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@vsmenon vsmenon added the area-web Issues related to Dart Web. label Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Issues related to Dart Web. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants