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

Unified Diff: pkg/dev_compiler/lib/js/legacy/dart_library.js

Issue 2634463002: Make ddc legacy loader more defensive (Closed)
Patch Set: Created 3 years, 11 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/js/legacy/dart_library.js
diff --git a/pkg/dev_compiler/lib/js/legacy/dart_library.js b/pkg/dev_compiler/lib/js/legacy/dart_library.js
index f72cf9e089cfc8e274db9f22ca12ab9eaf64bd40..d4f8e8cb64f1076ae26eb639890309644ce4b1bd 100644
--- a/pkg/dev_compiler/lib/js/legacy/dart_library.js
+++ b/pkg/dev_compiler/lib/js/legacy/dart_library.js
@@ -4,8 +4,9 @@
/* This file defines the module loader for the dart runtime.
*/
-
-var dart_library =
+var dart_library;
+if (!dart_library) {
+dart_library =
typeof module != "undefined" && module.exports || {};
(function (dart_library) {
@@ -93,7 +94,12 @@ var dart_library =
};
function library(name, defaultValue, imports, loader) {
- let result = new LibraryLoader(name, defaultValue, imports, loader);
+ let result = libraries.get(name);
+ if (result) {
+ console.warn('Already loaded ' + name);
+ return result;
+ }
+ result = new LibraryLoader(name, defaultValue, imports, loader);
libraries.set(name, result);
return result;
}
@@ -109,11 +115,20 @@ var dart_library =
}
dart_library.import = import_;
+ var _currentIsolate = false;
+
function start(moduleName, libraryName) {
if (libraryName == null) libraryName = moduleName;
let library = import_(moduleName)[libraryName];
let dart_sdk = import_('dart_sdk');
- dart_sdk._isolate_helper.startRootIsolate(library.main, []);
+ if (!_currentIsolate) {
+ // Create isolate and run main
+ _currentIsolate = true;
+ dart_sdk._isolate_helper.startRootIsolate(library.main, []);
+ } else {
Jacob 2017/01/13 00:48:17 missing periods at the end of comments.
vsm 2017/01/13 16:02:20 Done.
+ // Main isolate is already initialized - just run main
+ library.main();
+ }
}
dart_library.start = start;
@@ -179,3 +194,4 @@ var dart_library =
}
})(dart_library);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698