Skip to content

Fine grained selection of 'late' lowering by front end. #43993

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

Closed
rakudrama opened this issue Oct 29, 2020 · 2 comments
Closed

Fine grained selection of 'late' lowering by front end. #43993

rakudrama opened this issue Oct 29, 2020 · 2 comments
Labels
customer-dart2js legacy-area-front-end Legacy: Use area-dart-model instead. type-enhancement A request for a change that isn't a bug

Comments

@rakudrama
Copy link
Member

dart2js would like to lower some late variables and leave others to the front-end.

The number of configurations is large (3×2×2×2 = 24):

{static, instance, local} × {final, non-final} × {initializer, uninitialized} × {nullable, non-nullable}

Where possible, dart2js would like to be able to inspect the initializer and variable type.

@rakudrama rakudrama added the legacy-area-front-end Legacy: Use area-dart-model instead. label Oct 29, 2020
@rakudrama
Copy link
Member Author

/cc @johnniwinther

@johnniwinther johnniwinther added the type-enhancement A request for a change that isn't a bug label Oct 30, 2020
@johnniwinther
Copy link
Member

We could also make the flag in Target a bit mask of requested lowerings:

class Target {
  ...
  int get lateLowerings;
  ...
}

class LateLowering {
  static const int nullableUninitializedNonFinalLocal = 1 << 0;
  static const int nonNullableUninitializedNonFinalLocal = 1 << 1;
  static const int nullableUninitializedFinalLocal = 1 << 2;
  static const int nonNullableUninitializedFinalLocal = 1 << 3;
  static const int nullableInitializedNonFinalLocal = 1 << 4;
  static const int nonNullableInitializedNonFinalLocal = 1 << 5;
  static const int nullableInitializedFinalLocal = 1 << 6;
  static const int nonNullableInitializedFinalLocal = 1 << 7;
  static const int uninitializedNonFinalStaticField = 1 << 8;
  static const int uninitializedFinalStaticField = 1 << 9;
  static const int initializedNonFinalStaticField = 1 << 10;
  static const int initializedFinalStaticField = 1 << 11;
  static const int uninitializedNonFinalInstanceField = 1 << 12;
  static const int uninitializedFinalInstanceField = 1 << 13;
  static const int initializedNonFinalInstanceField = 1 << 14;
  static const int initializedFinalInstanceField = 1 << 15;

  static const int all = (1 << 16) - 1;
}

Here the variants with nullable/non-nullable instance/static fields are excluded. The type of fields rely on top level inference but we set up for lowering of fields when we see their declaration.

This approach would also decouple the decision from the inner workings of the CFE, i.e. knowing how to correctly detect whether a type is nullable or not, or how to detect if an initializer is declared or synthesized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-dart2js legacy-area-front-end Legacy: Use area-dart-model instead. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants