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

Unified Diff: dart/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart

Issue 57393002: Version 0.8.10.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 | « dart/sdk/lib/_internal/lib/isolate_helper.dart ('k') | dart/sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
===================================================================
--- dart/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart (revision 29787)
+++ dart/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart (working copy)
@@ -34,6 +34,16 @@
// TODO(rnystrom): Do something cleaner for this, or eliminate those files.
final entrypoints = new Set<AssetId>();
+ /// If this is non-null, then the transformer is currently being applied, so
+ /// subsequent calls to [apply] will wait for this to finish before
+ /// proceeding.
+ ///
+ /// Dart2js uses lots of memory, so if we try to actually run compiles in
+ /// parallel, it takes down the VM. Instead, the transformer will force
+ /// all applies to be sequential. The tracking bug to do something better
+ /// is here: https://code.google.com/p/dart/issues/detail?id=14730.
+ Future _running;
+
Dart2JSTransformer(this._graph, {bool minify})
: _minify = minify == true ? true : false;
@@ -45,6 +55,18 @@
}
Future apply(Transform transform) {
+ // Wait for any ongoing apply to finish first.
+ // TODO(rnystrom): If there are multiple simultaneous compiles, this will
+ // resume and pause them repeatedly. It still serializes them correctly,
+ // but it might be cleaner to use a real queue.
+ // TODO(rnystrom): Add a test that this is functionality is helpful.
+ if (_running != null) {
+ return _running.then((_) => apply(transform));
+ }
+
+ var completer = new Completer();
+ _running = completer.future;
+
var stopwatch = new Stopwatch();
stopwatch.start();
@@ -96,6 +118,9 @@
if (error is CompilerException) return;
throw error;
});
+ }).whenComplete(() {
+ completer.complete();
+ _running = null;
});
}
}
« no previous file with comments | « dart/sdk/lib/_internal/lib/isolate_helper.dart ('k') | dart/sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698