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] Too many call-through stubs for fields named call. #51827

Open
rakudrama opened this issue Mar 23, 2023 · 0 comments
Open

[dart2js] Too many call-through stubs for fields named call. #51827

rakudrama opened this issue Mar 23, 2023 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-optimization web-dart2js

Comments

@rakudrama
Copy link
Member

Consider the following program that has a field named call and some closure calls:

class Foo {
  final String call;
  Foo(this.call);
}

Object f2(Object Function(Object, Object) f, Object a1, Object a2) {
  return f(a1, a2);
}

Object f3(Object Function(Object, Object, Object) f, Object a1, Object a2,
    Object a3) {
  return f(a1, a2, a3);
}

void main() {
  print(Foo('hello'));
  print(f2((a, b) => [a, b], 1, 2));
  print(f3((a, b, c) => [a, b, c], 1, 2, 3));
}

The output contains call-through stubs on Foo

  A.Foo.prototype = {
    call$3(arg0, arg1, arg2) {
      return this.$call.call$3(arg0, arg1, arg2);
    },
    call$2(arg0, arg1) {
      return this.$call.call$2(arg0, arg1);
    }
  };

These happen because Foo escapes and the properly-typed closure calls are treated as dynamic closure calls.

In a real large app, there were ~800 such call-through stubs (b/274670138).

Fixes:

  • dart2js should better distinguish closure calls from dynamic calls and not generate call-through stubs for closure calls.
  • the field type is not callable, so the call-through stubs could be eliminated on those grounds too.
@rakudrama rakudrama added web-dart2js dart2js-optimization area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-optimization web-dart2js
Projects
None yet
Development

No branches or pull requests

1 participant