mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Let Backend determine support for deferred loading.
BUG= R=ajohnsen@google.com Review URL: https://codereview.chromium.org//1149303006
This commit is contained in:
parent
7230007d52
commit
c03bbb79f9
5 changed files with 21 additions and 11 deletions
|
@ -314,6 +314,10 @@ abstract class Backend {
|
|||
bool classNeedsRti(ClassElement cls);
|
||||
bool methodNeedsRti(FunctionElement function);
|
||||
|
||||
/// Register deferred loading. Returns `true` if the backend supports deferred
|
||||
/// loading.
|
||||
bool registerDeferredLoading(Spannable node, Registry registry);
|
||||
|
||||
/// Called during codegen when [constant] has been used.
|
||||
void registerCompileTimeConstant(ConstantValue constant, Registry registry) {}
|
||||
|
||||
|
|
|
@ -312,6 +312,13 @@ class DartBackend extends Backend {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
bool registerDeferredLoading(Spannable node, Registry registry) {
|
||||
// TODO(sigurdm): Implement deferred loading for dart2dart.
|
||||
compiler.reportWarning(node, MessageKind.DEFERRED_LIBRARY_DART_2_DART);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class DartResolutionCallbacks extends ResolutionCallbacks {
|
||||
|
|
|
@ -770,16 +770,9 @@ class DeferredLoadTask extends CompilerTask {
|
|||
}
|
||||
});
|
||||
}
|
||||
Backend backend = compiler.backend;
|
||||
if (isProgramSplit && backend is JavaScriptBackend) {
|
||||
backend.registerCheckDeferredIsLoaded(compiler.globalDependencies);
|
||||
}
|
||||
if (isProgramSplit && backend is DartBackend) {
|
||||
// TODO(sigurdm): Implement deferred loading for dart2dart.
|
||||
compiler.reportWarning(
|
||||
lastDeferred,
|
||||
MessageKind.DEFERRED_LIBRARY_DART_2_DART);
|
||||
isProgramSplit = false;
|
||||
if (isProgramSplit) {
|
||||
isProgramSplit = compiler.backend.registerDeferredLoading(
|
||||
lastDeferred, compiler.globalDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2669,6 +2669,12 @@ class JavaScriptBackend extends Backend {
|
|||
enqueue(enqueuer, getStreamIteratorConstructor(), registry);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool registerDeferredLoading(Spannable node, Registry registry) {
|
||||
registerCheckDeferredIsLoaded(registry);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Handling of special annotations for tests.
|
||||
|
|
|
@ -1364,7 +1364,7 @@ main() => A.A = 1;
|
|||
|
||||
static const MessageKind DEFERRED_LIBRARY_DART_2_DART =
|
||||
const MessageKind(
|
||||
"Deferred loading is not supported by the dart backend yet."
|
||||
"Deferred loading is not supported by the dart backend yet. "
|
||||
"The output will not be split.");
|
||||
|
||||
static const MessageKind DEFERRED_LIBRARY_WITHOUT_PREFIX =
|
||||
|
|
Loading…
Reference in a new issue