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

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

Issue 48903020: Run dart2js transformer sequentially. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add TODO. 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart b/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
index 293ac2fc3b9cb53c54cbbde4593dc91ea91e904f..8eca860d05aa9dabc34f2d82aa192bcca11fb2c4 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
@@ -34,6 +34,16 @@ class Dart2JSTransformer extends Transformer {
// 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 @@ class Dart2JSTransformer extends Transformer {
}
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 @@ class Dart2JSTransformer extends Transformer {
if (error is CompilerException) return;
throw error;
});
+ }).whenComplete(() {
+ completer.complete();
+ _running = null;
});
}
}
« 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