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

[DDC] Don't use CFE constructor tearoff lowering and instead use the same lowering as static method tearoffs #50527

Open
srujzs opened this issue Nov 21, 2022 · 1 comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P3 A lower priority bug or feature request web-dev-compiler

Comments

@srujzs
Copy link
Contributor

srujzs commented Nov 21, 2022

Currently, the CFE lowers tearoffs for constructors as static methods on the relevant class. DDC then forwards a call to this static method in order to fetch the tearoff. While this is useful, this means extra code size for every constructor e.g.

    static ['_#fact#tearOff']() {
      return library_name.ClassName.fact();
    }

and the calling code:

    get C0() {
      return C[0] = dart.fn(library_name.ClassName['_#fact#tearOff'], T$.VoidToClassName());
    },

C0 here is already a tear-off, so we should just leverage that instead of this dual indirection. We already do that with static methods:

    get C3() {
      return C[3] = dart.fn(library_name.ClassName.staticMethod, T$.VoidToString());
    },

So, instead of using the synthetic static methods for constructor tear-offs, we can just return a reference to the constructor instead e.g.

return C[0] = dart.fn(library_name.ClassName.fact, T.VoidToClassName());
@srujzs srujzs added web-dev-compiler area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Nov 21, 2022
@srujzs
Copy link
Contributor Author

srujzs commented Nov 21, 2022

cc @nshahan

@nshahan nshahan added the P3 A lower priority bug or feature request label Dec 3, 2022
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. P3 A lower priority bug or feature request web-dev-compiler
Projects
None yet
Development

No branches or pull requests

2 participants