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

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 795923003: Dart2js, move deferred global vars to the right output unit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 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 | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
index cca4e0e64a94c99369edee4b2654a11f34af6220..9312dc1dea647e8815169460e4ab4597502c6a33 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -3293,15 +3293,17 @@ Future<Null> loadDeferredLibrary(String loadId) {
// The indices into `uris` and `hashes` that we want to load.
List<int> indices = new List.generate(uris.length, (i) => i);
var isHunkLoaded = JS_EMBEDDED_GLOBAL('', IS_HUNK_LOADED);
- return Future.wait(indices
- // Filter away indices for hunks that have already been loaded.
+ // Filter away indices for hunks that have already been loaded.
+ List<int> indicesToLoad = indices
.where((int i) => !JS('bool','#(#)', isHunkLoaded, hashes[i]))
- // Load the rest.
+ .toList();
+ // Load the needed hunks.
+ return Future.wait(indicesToLoad
.map((int i) => _loadHunk(uris[i]))).then((_) {
- // Now all hunks have been loaded, we call all their initializers
- for (String hash in hashes) {
+ // Now all hunks have been loaded, we run the needed initializers.
+ for (int i in indicesToLoad) {
var initializer = JS_EMBEDDED_GLOBAL('', INITIALIZE_LOADED_HUNK);
- JS('void', '#(#)', initializer, hash);
+ JS('void', '#(#)', initializer, hashes[i]);
}
bool updated = _loadedLibraries.add(loadId);
if (updated && deferredLoadHook != null) {
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698