-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.cfe-encodingsEncoding related CFE issues.Encoding related CFE issues.
Description
One may have code like this:
import 'foo.dart' deferred as foo;
main() {
...
print(foo.topLevelConst);
}It seems currently this gets lowered into something like this
let
_ = StaticInvocation(_checkLibraryIsLoaded(...)) // <-- this is modular dart2wasm lowering of `CheckLibraryIsLoaded()` AST node
in
ConstantExpresion(<constant>)
Now when one visits the AST and hits a ConstantExpression the code generator may want to do something different.
-
Normally the code generator has to assume the constant is needed by the main module and has to bundle related data/code in the main module.
-
If it knows the constant access is guaranteed to happen after the deferred library was loaded, it can move the constant related data/code into the deferred library.
Right now one needs to match this particular lowering pattern to detect this guarantee, it would be nice if it was more readily available on ConstantExpression.
/cc @johnniwinther
Metadata
Metadata
Assignees
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.cfe-encodingsEncoding related CFE issues.Encoding related CFE issues.