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

Unified Diff: pkg/compiler/lib/src/common/tasks.dart

Issue 2133913002: dart2js: Reduce overhead of --verbose measurements (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/compiler/lib/src/common/tasks.dart
diff --git a/pkg/compiler/lib/src/common/tasks.dart b/pkg/compiler/lib/src/common/tasks.dart
index f1d342659bd97082c9cbe6a50fc63b2aeae5f658..2c9dd30ee6a9a652968b228a846d511aafaeec29 100644
--- a/pkg/compiler/lib/src/common/tasks.dart
+++ b/pkg/compiler/lib/src/common/tasks.dart
@@ -97,49 +97,51 @@ abstract class CompilerTask {
// The current zone is already measuring `this` task.
if (Zone.current[measurer] == this) return action();
- /// Run [f] in [zone]. Running must be delegated to [parent] to ensure that
- /// various state is set up correctly (in particular that `Zone.current`
- /// has the right value). Since [_measureZoned] can be called recursively
- /// (synchronously), some of the measuring zones we create will be parents
- /// of other measuring zones, but we still need to call through the parent
- /// chain. Consequently, we use a zone value keyed by [measurer] to see if
- /// we should measure or not when delegating.
- run(Zone self, ZoneDelegate parent, Zone zone, f()) {
- if (zone[measurer] != this) return parent.run(zone, f);
- CompilerTask previous = _start();
- try {
- return parent.run(zone, f);
- } finally {
- _stop(previous);
- }
+ return runZoned(action,
+ zoneValues: _zoneValues ??= {measurer: this},
+ zoneSpecification: _zoneSpecification ??= new ZoneSpecification(
+ run: _run, runUnary: _runUnary, runBinary: _runBinary));
+ }
+ Map _zoneValues;
+ ZoneSpecification _zoneSpecification;
ahe 2016/08/04 17:17:33 I would move the fields up with the other fields o
+
+ /// Run [f] in [zone]. Running must be delegated to [parent] to ensure that
+ /// various state is set up correctly (in particular that `Zone.current`
+ /// has the right value). Since [_measureZoned] can be called recursively
+ /// (synchronously), some of the measuring zones we create will be parents
+ /// of other measuring zones, but we still need to call through the parent
+ /// chain. Consequently, we use a zone value keyed by [measurer] to see if
+ /// we should measure or not when delegating.
+ _run(Zone self, ZoneDelegate parent, Zone zone, f()) {
+ if (zone[measurer] != this) return parent.run(zone, f);
+ CompilerTask previous = _start();
+ try {
+ return parent.run(zone, f);
+ } finally {
+ _stop(previous);
}
+ }
- /// Same as [run] except that [f] takes one argument, [arg].
- runUnary(Zone self, ZoneDelegate parent, Zone zone, f(arg), arg) {
- if (zone[measurer] != this) return parent.runUnary(zone, f, arg);
- CompilerTask previous = _start();
- try {
- return parent.runUnary(zone, f, arg);
- } finally {
- _stop(previous);
- }
+ /// Same as [run] except that [f] takes one argument, [arg].
+ _runUnary(Zone self, ZoneDelegate parent, Zone zone, f(arg), arg) {
+ if (zone[measurer] != this) return parent.runUnary(zone, f, arg);
+ CompilerTask previous = _start();
+ try {
+ return parent.runUnary(zone, f, arg);
+ } finally {
+ _stop(previous);
}
+ }
- /// Same as [run] except that [f] takes two arguments ([a1] and [a2]).
- runBinary(Zone self, ZoneDelegate parent, Zone zone, f(a1, a2), a1, a2) {
- if (zone[measurer] != this) return parent.runBinary(zone, f, a1, a2);
- CompilerTask previous = _start();
- try {
- return parent.runBinary(zone, f, a1, a2);
- } finally {
- _stop(previous);
- }
+ /// Same as [run] except that [f] takes two arguments ([a1] and [a2]).
+ _runBinary(Zone self, ZoneDelegate parent, Zone zone, f(a1, a2), a1, a2) {
+ if (zone[measurer] != this) return parent.runBinary(zone, f, a1, a2);
+ CompilerTask previous = _start();
+ try {
+ return parent.runBinary(zone, f, a1, a2);
+ } finally {
+ _stop(previous);
}
-
- return runZoned(action,
- zoneValues: {measurer: this},
- zoneSpecification: new ZoneSpecification(
- run: run, runUnary: runUnary, runBinary: runBinary));
}
/// Asynchronous version of [measure]. Use this when action returns a future
« 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