Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart

Issue 1508543003: Initialize the deferred global for every fragment. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index 07ba88b0ec5d0a469be545d06ccab254ecb35f8a..7abae77453072725cfc516457b948ff3321a62a8 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -1371,6 +1371,16 @@ class Emitter implements js_emitter.Emitter {
assembleTypedefs(program);
}
+ jsAst.Statement buildDeferredHeader() {
+ /// For deferred loading we communicate the initializers via this global
+ /// variable. The deferred hunks will add their initialization to this.
+ /// The semicolon is important in minified mode, without it the
+ /// following parenthesis looks like a call to the object literal.
+ return js.statement('self.#deferredInitializers = '
+ 'self.#deferredInitializers || Object.create(null);',
+ {'deferredInitializers': deferredInitializers});
+ }
+
jsAst.Program buildOutputAstForMain(Program program,
Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) {
MainFragment mainFragment = program.mainFragment;
@@ -1383,14 +1393,7 @@ class Emitter implements js_emitter.Emitter {
..add(js.comment(HOOKS_API_USAGE));
if (isProgramSplit) {
- /// For deferred loading we communicate the initializers via this global
- /// variable. The deferred hunks will add their initialization to this.
- /// The semicolon is important in minified mode, without it the
- /// following parenthesis looks like a call to the object literal.
- statements.add(
- js.statement('self.#deferredInitializers = '
- 'self.#deferredInitializers || Object.create(null);',
- {'deferredInitializers': deferredInitializers}));
+ statements.add(buildDeferredHeader());
}
// Collect the AST for the decriptors
@@ -1999,6 +2002,7 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) {
statements
..add(buildGeneratedBy())
+ ..add(buildDeferredHeader())
..add(js.statement('${deferredInitializers}.current = '
"""function (#, ${namer.staticStateHolder}) {
#
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698