Cleanup CompilerTask

make a number of fields private

Change-Id: Ib44aa3459e5d286004de7cb08e07039dc115894a
Reviewed-on: https://dart-review.googlesource.com/c/85645
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart
index 4fdef87..f54520a 100644
--- a/pkg/compiler/lib/src/apiimpl.dart
+++ b/pkg/compiler/lib/src/apiimpl.dart
@@ -82,7 +82,7 @@
   }
 
   Future<bool> run(Uri uri) {
-    Duration setupDuration = measurer.wallClock.elapsed;
+    Duration setupDuration = measurer.elapsedWallClock;
     return selfTask.measureSubtask("impl.run", () {
       return setupSdk().then((_) {
         return super.run(uri);
@@ -103,8 +103,8 @@
 
   void computeTimings(Duration setupDuration, StringBuffer timings) {
     timings.writeln("Timings:");
-    Duration totalDuration = measurer.wallClock.elapsed;
-    Duration asyncDuration = measurer.asyncWallClock.elapsed;
+    Duration totalDuration = measurer.elapsedWallClock;
+    Duration asyncDuration = measurer.elapsedAsyncWallClock;
     Duration cumulatedDuration = Duration.zero;
     List<_TimingData> timingData = [];
     for (final task in tasks) {
diff --git a/pkg/compiler/lib/src/common/tasks.dart b/pkg/compiler/lib/src/common/tasks.dart
index f617999..83a1e0d 100644
--- a/pkg/compiler/lib/src/common/tasks.dart
+++ b/pkg/compiler/lib/src/common/tasks.dart
@@ -14,20 +14,19 @@
 /// introduced by using [measureSubtask].
 // TODO(sigmund): rename to MeasurableTask
 abstract class CompilerTask {
-  final Measurer measurer;
+  final Measurer _measurer;
   final Stopwatch _watch;
   final Map<String, GenericTask> _subtasks = <String, GenericTask>{};
 
-  int asyncCount = 0;
+  int _asyncCount = 0;
 
   // Each task has a fixed, lazily computed, ZoneSpecification and zoneValues
   // for [_measureZoned].
   ZoneSpecification _zoneSpecification;
   Map _zoneValues;
 
-  CompilerTask(Measurer measurer)
-      : measurer = measurer,
-        _watch = measurer.enableTaskMeasurements ? new Stopwatch() : null;
+  CompilerTask(this._measurer)
+      : _watch = _measurer.enableTaskMeasurements ? new Stopwatch() : null;
 
   /// Whether measurement is disabled. The functions [measure] and [measureIo]
   /// only measure time if measurements are enabled.
@@ -66,12 +65,12 @@
   /// make this task the currently measured task.
   CompilerTask _start() {
     if (_isDisabled) return null;
-    CompilerTask previous = measurer.currentTask;
-    measurer.currentTask = this;
+    CompilerTask previous = _measurer._currentTask;
+    _measurer._currentTask = this;
     if (previous != null) previous._watch.stop();
     // Regardless of whether [previous] is `null` we've returned from the
     // eventloop.
-    measurer.stopAsyncWallClock();
+    _measurer.stopAsyncWallClock();
     _watch.start();
     return previous;
   }
@@ -86,9 +85,9 @@
     } else {
       // If there's no previous task, we're about to return control to the
       // event loop. Start counting that as waiting asynchronous I/O.
-      measurer.startAsyncWallClock();
+      _measurer.startAsyncWallClock();
     }
-    measurer.currentTask = previous;
+    _measurer._currentTask = previous;
   }
 
   T _measureZoned<T>(T action()) {
@@ -100,10 +99,10 @@
     assert(_watch != null);
 
     // The current zone is already measuring `this` task.
-    if (Zone.current[measurer] == this) return action();
+    if (Zone.current[_measurer] == this) return action();
 
     return runZoned(action,
-        zoneValues: _zoneValues ??= {measurer: this},
+        zoneValues: _zoneValues ??= {_measurer: this},
         zoneSpecification: _zoneSpecification ??= new ZoneSpecification(
             run: _run, runUnary: _runUnary, runBinary: _runBinary));
   }
@@ -113,10 +112,10 @@
   /// 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
+  /// chain. Consequently, we use a zone value keyed by [_measurer] to see if
   /// we should measure or not when delegating.
   R _run<R>(Zone self, ZoneDelegate parent, Zone zone, R f()) {
-    if (zone[measurer] != this) return parent.run(zone, f);
+    if (zone[_measurer] != this) return parent.run(zone, f);
     CompilerTask previous = _start();
     try {
       return parent.run(zone, f);
@@ -128,7 +127,7 @@
   /// Same as [run] except that [f] takes one argument, [arg].
   R _runUnary<R, T>(
       Zone self, ZoneDelegate parent, Zone zone, R f(T arg), T arg) {
-    if (zone[measurer] != this) return parent.runUnary(zone, f, arg);
+    if (zone[_measurer] != this) return parent.runUnary(zone, f, arg);
     CompilerTask previous = _start();
     try {
       return parent.runUnary(zone, f, arg);
@@ -140,7 +139,7 @@
   /// Same as [run] except that [f] takes two arguments ([a1] and [a2]).
   R _runBinary<R, T1, T2>(Zone self, ZoneDelegate parent, Zone zone,
       R f(T1 a1, T2 a2), T1 a1, T2 a2) {
-    if (zone[measurer] != this) return parent.runBinary(zone, f, a1, a2);
+    if (zone[_measurer] != this) return parent.runBinary(zone, f, a1, a2);
     CompilerTask previous = _start();
     try {
       return parent.runBinary(zone, f, a1, a2);
@@ -159,16 +158,16 @@
   Future<T> measureIo<T>(Future<T> action()) {
     if (_isDisabled) return action();
 
-    if (measurer.currentAsyncTask == null) {
-      measurer.currentAsyncTask = this;
-    } else if (measurer.currentAsyncTask != this) {
+    if (_measurer._currentAsyncTask == null) {
+      _measurer._currentAsyncTask = this;
+    } else if (_measurer._currentAsyncTask != this) {
       throw "Can't track async task '$name' because"
-          " '${measurer.currentAsyncTask.name}' is already being tracked.";
+          " '${_measurer._currentAsyncTask.name}' is already being tracked.";
     }
-    asyncCount++;
+    _asyncCount++;
     return measure(action).whenComplete(() {
-      asyncCount--;
-      if (asyncCount == 0) measurer.currentAsyncTask = null;
+      _asyncCount--;
+      if (_asyncCount == 0) _measurer._currentAsyncTask = null;
     });
   }
 
@@ -180,7 +179,7 @@
     // Use a nested CompilerTask for the measurement to ensure nested [measure]
     // calls work correctly. The subtasks will never themselves have nested
     // subtasks because they are not accessible outside.
-    GenericTask subtask = _subtasks[name] ??= new GenericTask(name, measurer);
+    GenericTask subtask = _subtasks[name] ??= new GenericTask(name, _measurer);
     return subtask.measure(action);
   }
 
@@ -197,7 +196,7 @@
     // Use a nested CompilerTask for the measurement to ensure nested [measure]
     // calls work correctly. The subtasks will never themselves have nested
     // subtasks because they are not accessible outside.
-    GenericTask subtask = _subtasks[name] ??= new GenericTask(name, measurer);
+    GenericTask subtask = _subtasks[name] ??= new GenericTask(name, _measurer);
     return subtask.measureIo(action);
   }
 
@@ -218,10 +217,14 @@
   ///
   /// Note: MUST be the first field of this class to ensure [wallclock] is
   /// started before other computations.
-  final Stopwatch wallClock = new Stopwatch()..start();
+  final Stopwatch _wallClock = new Stopwatch()..start();
+
+  Duration get elapsedWallClock => _wallClock.elapsed;
 
   /// Measures gaps between zoned closures due to asynchronicity.
-  final Stopwatch asyncWallClock = new Stopwatch();
+  final Stopwatch _asyncWallClock = new Stopwatch();
+
+  Duration get elapsedAsyncWallClock => _asyncWallClock.elapsed;
 
   /// Whether measurement of tasks is enabled.
   final bool enableTaskMeasurements;
@@ -233,35 +236,35 @@
 
   /// The currently running task, that is, the task whose [Stopwatch] is
   /// currently running.
-  CompilerTask currentTask;
+  CompilerTask _currentTask;
 
   /// The current task which should be charged for asynchronous gaps.
-  CompilerTask currentAsyncTask;
+  CompilerTask _currentAsyncTask;
 
   /// Start counting the total elapsed time since the compiler started.
   void startWallClock() {
-    wallClock.start();
+    _wallClock.start();
   }
 
   /// Start counting the total elapsed time since the compiler started.
   void stopWallClock() {
-    wallClock.stop();
+    _wallClock.stop();
   }
 
   /// Call this before returning to the eventloop.
   void startAsyncWallClock() {
-    if (currentAsyncTask != null) {
-      currentAsyncTask._watch.start();
+    if (_currentAsyncTask != null) {
+      _currentAsyncTask._watch.start();
     } else {
-      asyncWallClock.start();
+      _asyncWallClock.start();
     }
   }
 
   /// Call this when the eventloop returns control to us.
   void stopAsyncWallClock() {
-    if (currentAsyncTask != null) {
-      currentAsyncTask._watch.stop();
+    if (_currentAsyncTask != null) {
+      _currentAsyncTask._watch.stop();
     }
-    asyncWallClock.stop();
+    _asyncWallClock.stop();
   }
 }
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index 7c14077..afa2952 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -612,7 +612,7 @@
         dart2jsVersion:
             compiler.options.hasBuildId ? compiler.options.buildId : null,
         compilationMoment: new DateTime.now(),
-        compilationDuration: compiler.measurer.wallClock.elapsed,
+        compilationDuration: compiler.measurer.elapsedWallClock,
         toJsonDuration:
             new Duration(milliseconds: stopwatch.elapsedMilliseconds),
         dumpInfoDuration: new Duration(milliseconds: this.timing),