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

Unified Diff: runtime/bin/builtin.dart

Issue 328923002: Lazy loading of deferred libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/bin/bin.gypi ('k') | runtime/bin/builtin_impl_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
===================================================================
--- runtime/bin/builtin.dart (revision 37317)
+++ runtime/bin/builtin.dart (working copy)
@@ -308,42 +308,85 @@
}
-void _loadScript(String uri, List<int> data) native "Builtin_LoadScript";
+int _numOutstandingLoadRequests = 0;
-void _asyncLoadError(uri, error) native "Builtin_AsyncLoadError";
+void _signalDoneLoading() native "Builtin_DoneLoading";
+void _loadScriptCallback(String uri, List<int> data) native "Builtin_LoadScript";
+void _loadScript(String uri, List<int> data) {
+ // TODO: Currently a compilation error while loading the script is
+ // fatal for the isolate. _loadScriptCallback() does not return and
+ // the _numOutstandingLoadRequests counter remains out of sync.
+ _loadScriptCallback(uri, data);
+ assert(_numOutstandingLoadRequests > 0);
+ _numOutstandingLoadRequests--;
+ _logResolution("native Builtin_LoadScript($uri) completed, "
+ "${_numOutstandingLoadRequests} requests remaining");
+ if (_numOutstandingLoadRequests == 0) {
+ _signalDoneLoading();
+ }
+}
+
+
+void _asyncLoadErrorCallback(uri, error) native "Builtin_AsyncLoadError";
+
+void _asyncLoadError(uri, error) {
+ assert(_numOutstandingLoadRequests > 0);
+ _numOutstandingLoadRequests--;
+ _asyncLoadErrorCallback(uri, error);
+}
+
+
// Asynchronously loads script data (source or snapshot) through
// an http or file uri.
_loadDataAsync(String uri) {
uri = _resolveScriptUri(uri);
Uri sourceUri = Uri.parse(uri);
+ _numOutstandingLoadRequests++;
+ _logResolution("_loadDataAsync($uri), "
+ "${_numOutstandingLoadRequests} requests outstanding");
if (sourceUri.scheme == 'http') {
_httpGet(sourceUri, (data) {
_loadScript(uri, data);
});
} else {
- _loadDataFromFileAsync(uri);
+ var sourceFile = new File(_filePathFromUri(uri));
+ sourceFile.readAsBytes().then((data) {
+ _loadScript(uri, data);
+ },
+ onError: (e) {
+ _asyncLoadError(uri, e);
+ });
}
}
-_loadDataFromFileAsync(String uri) {
- var sourceFile = new File(_filePathFromUri(uri));
- sourceFile.readAsBytes().then((data) {
- _loadScript(uri, data);
- },
- onError: (e) {
- _asyncLoadError(uri, e);
- });
+
+void _loadLibrarySourceCallback(tag, uri, libraryUri, text)
+ native "Builtin_LoadLibrarySource";
+
+void _loadLibrarySource(tag, uri, libraryUri, text) {
+ // TODO: Currently a compilation error while loading the library is
+ // fatal for the isolate. _loadLibraryCallback() does not return and
+ // the _numOutstandingLoadRequests counter remains out of sync.
+ _loadLibrarySourceCallback(tag, uri, libraryUri, text);
+ assert(_numOutstandingLoadRequests > 0);
+ _numOutstandingLoadRequests--;
+ _logResolution("native Builtin_LoadLibrarySource($uri) completed, "
+ "${_numOutstandingLoadRequests} requests remaining");
+ if (_numOutstandingLoadRequests == 0) {
+ _signalDoneLoading();
+ }
}
-void _loadLibrarySource(tag, uri, libraryUri, text)
- native "Builtin_LoadLibrarySource";
-
+// Asynchronously loads source code through an http or file uri.
_loadSourceAsync(int tag, String uri, String libraryUri) {
var filePath = _filePathFromUri(uri);
Uri sourceUri = Uri.parse(filePath);
+ _numOutstandingLoadRequests++;
+ _logResolution("_loadLibrarySource($uri), "
+ "${_numOutstandingLoadRequests} requests outstanding");
if (sourceUri.scheme == 'http') {
_httpGet(sourceUri, (data) {
var text = UTF8.decode(data);
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/builtin_impl_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698