Remove CodegenEnqueuer.compiler

R=het@google.com

Review-Url: https://codereview.chromium.org/2564823002 .
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index d441137..523186c 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -419,9 +419,11 @@
   }
 
   final Map<Element, Set<Element>> _dependencies = {};
-  void registerDependency(Element source, Element target) {
+  void registerDependency(Element target) {
     if (compiler.options.dumpInfo) {
-      _dependencies.putIfAbsent(source, () => new Set()).add(target);
+      _dependencies
+          .putIfAbsent(compiler.currentElement, () => new Set())
+          .add(target);
     }
   }
 
diff --git a/pkg/compiler/lib/src/enqueue.dart b/pkg/compiler/lib/src/enqueue.dart
index 7ea6d84..30c5aef 100644
--- a/pkg/compiler/lib/src/enqueue.dart
+++ b/pkg/compiler/lib/src/enqueue.dart
@@ -135,7 +135,7 @@
   final native.NativeEnqueuer nativeEnqueuer;
 
   final EnqueuerStrategy strategy;
-  Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>();
+  final Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>();
   final ResolutionWorldBuilderImpl _universe;
 
   bool queueIsClosed = false;
@@ -307,7 +307,7 @@
   }
 
   void _registerIsCheck(DartType type) {
-    type = _universe.registerIsCheck(type, _resolution);
+    type = _universe.registerIsCheck(type);
     // Even in checked mode, type annotations for return type and argument
     // types do not imply type checks, so there should never be a check
     // against the type variable of a typedef.
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 780901c..8b5e052 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -1428,8 +1428,8 @@
   CodegenEnqueuer get codegenEnqueuer => compiler.enqueuer.codegen;
 
   CodegenEnqueuer createCodegenEnqueuer(CompilerTask task, Compiler compiler) {
-    return new CodegenEnqueuer(
-        task, compiler, const TreeShakingEnqueuerStrategy());
+    return new CodegenEnqueuer(task, compiler.cacheStrategy, this,
+        compiler.options, const TreeShakingEnqueuerStrategy());
   }
 
   WorldImpact codegen(CodegenWorkItem work) {
diff --git a/pkg/compiler/lib/src/js_backend/enqueuer.dart b/pkg/compiler/lib/src/js_backend/enqueuer.dart
index d5ade52..4784df0 100644
--- a/pkg/compiler/lib/src/js_backend/enqueuer.dart
+++ b/pkg/compiler/lib/src/js_backend/enqueuer.dart
@@ -6,6 +6,7 @@
 
 import 'dart:collection' show Queue;
 
+import '../cache_strategy.dart' show CacheStrategy;
 import '../common/backend_api.dart' show Backend;
 import '../common/codegen.dart' show CodegenWorkItem;
 import '../common/names.dart' show Identifiers;
@@ -14,6 +15,7 @@
 import '../common.dart';
 import '../compiler.dart' show Compiler;
 import '../dart_types.dart' show DartType, InterfaceType;
+import '../dump_info.dart';
 import '../elements/elements.dart'
     show
         ClassElement,
@@ -41,8 +43,6 @@
 /// [Enqueuer] which is specific to code generation.
 class CodegenEnqueuer extends EnqueuerImpl {
   final String name;
-  @deprecated
-  final Compiler _compiler; // TODO(ahe): Remove this dependency.
   final EnqueuerStrategy strategy;
   final Map<String, Set<Element>> _instanceMembersByName =
       new Map<String, Set<Element>>();
@@ -56,10 +56,12 @@
   bool queueIsClosed = false;
   final CompilerTask task;
   final native.NativeEnqueuer nativeEnqueuer;
+  final Backend _backend;
+  final CompilerOptions _options;
 
   WorldImpactVisitor _impactVisitor;
 
-  final Queue<WorkItem> queue = new Queue<WorkItem>();
+  final Queue<WorkItem> _queue = new Queue<WorkItem>();
   final Map<Element, js.Expression> generatedCode = <Element, js.Expression>{};
 
   final Set<Element> newlyEnqueuedElements;
@@ -71,24 +73,23 @@
   static const ImpactUseCase IMPACT_USE =
       const ImpactUseCase('CodegenEnqueuer');
 
-  CodegenEnqueuer(this.task, Compiler compiler, this.strategy)
-      : newlyEnqueuedElements = compiler.cacheStrategy.newSet(),
-        newlySeenSelectors = compiler.cacheStrategy.newSet(),
-        nativeEnqueuer = compiler.backend.nativeCodegenEnqueuer(),
-        this.name = 'codegen enqueuer',
-        this._compiler = compiler {
+  CodegenEnqueuer(this.task, CacheStrategy cacheStrategy, Backend backend,
+      this._options, this.strategy)
+      : newlyEnqueuedElements = cacheStrategy.newSet(),
+        newlySeenSelectors = cacheStrategy.newSet(),
+        nativeEnqueuer = backend.nativeCodegenEnqueuer(),
+        this._backend = backend,
+        this.name = 'codegen enqueuer' {
     _impactVisitor = new EnqueuerImplImpactVisitor(this);
   }
 
   CodegenWorldBuilder get universe => _universe;
 
-  Backend get _backend => _compiler.backend;
+  // TODO(johnniwinther): Remove these hacks:
+  ClosedWorld get _world => _backend.compiler.closedWorld;
+  DumpInfoTask get _dumpInfoTask => _backend.compiler.dumpInfoTask;
 
-  CompilerOptions get _options => _compiler.options;
-
-  ClosedWorld get _world => _compiler.closedWorld;
-
-  bool get queueIsEmpty => queue.isEmpty;
+  bool get queueIsEmpty => _queue.isEmpty;
 
   /// Returns [:true:] if this enqueuer is the resolution enqueuer.
   bool get isResolutionQueue => false;
@@ -120,11 +121,10 @@
       throw new SpannableAssertionFailure(
           element, "Codegen work list is closed. Trying to add $element");
     }
-    queue.add(new CodegenWorkItem(_backend, element));
+    _queue.add(new CodegenWorkItem(_backend, element));
     // TODO(sigmund): add other missing dependencies (internals, selectors
     // enqueued after allocations).
-    _compiler.dumpInfoTask
-        .registerDependency(_compiler.currentElement, element);
+    _dumpInfoTask.registerDependency(element);
   }
 
   void applyImpact(WorldImpact worldImpact, {Element impactSource}) {
@@ -408,7 +408,7 @@
   }
 
   void _registerIsCheck(DartType type) {
-    type = _universe.registerIsCheck(type, _compiler.resolution);
+    type = _universe.registerIsCheck(type);
     // Even in checked mode, type annotations for return type and argument
     // types do not imply type checks, so there should never be a check
     // against the type variable of a typedef.
@@ -431,9 +431,9 @@
 
   void forEach(void f(WorkItem work)) {
     do {
-      while (queue.isNotEmpty) {
+      while (_queue.isNotEmpty) {
         // TODO(johnniwinther): Find an optimal process order.
-        WorkItem work = queue.removeLast();
+        WorkItem work = _queue.removeLast();
         if (!isProcessed(work.element)) {
           strategy.processWorkItem(f, work);
           // TODO(johnniwinther): Register the processed element here. This
@@ -443,7 +443,7 @@
       List recents = _recentClasses.toList(growable: false);
       _recentClasses.clear();
       if (!_onQueueEmpty(recents)) _recentClasses.addAll(recents);
-    } while (queue.isNotEmpty || _recentClasses.isNotEmpty);
+    } while (_queue.isNotEmpty || _recentClasses.isNotEmpty);
   }
 
   /// [_onQueueEmpty] is called whenever the queue is drained. [recentClasses]
@@ -476,7 +476,7 @@
   }
 
   void forgetEntity(Element element, Compiler compiler) {
-    _universe.forgetElement(element, _compiler);
+    _universe.forgetElement(element, compiler);
     _processedClasses.remove(element);
     _instanceMembersByName[element.name]?.remove(element);
     _instanceFunctionsByName[element.name]?.remove(element);
diff --git a/pkg/compiler/lib/src/js_backend/runtime_types.dart b/pkg/compiler/lib/src/js_backend/runtime_types.dart
index 23740b3..590e99f 100644
--- a/pkg/compiler/lib/src/js_backend/runtime_types.dart
+++ b/pkg/compiler/lib/src/js_backend/runtime_types.dart
@@ -181,7 +181,7 @@
         InterfaceType interface = type;
         do {
           for (DartType argument in interface.typeArguments) {
-            universe.registerIsCheck(argument, compiler.resolution);
+            universe.registerIsCheck(argument);
           }
           interface = interface.element.supertype;
         } while (interface != null && !instantiatedTypes.contains(interface));
@@ -204,7 +204,7 @@
             InterfaceType instance = current.asInstanceOf(cls);
             if (instance == null) break;
             for (DartType argument in instance.typeArguments) {
-              universe.registerIsCheck(argument, compiler.resolution);
+              universe.registerIsCheck(argument);
             }
             current = current.element.supertype;
           } while (current != null && !instantiatedTypes.contains(current));
diff --git a/pkg/compiler/lib/src/universe/world_builder.dart b/pkg/compiler/lib/src/universe/world_builder.dart
index f6992cd..23855be 100644
--- a/pkg/compiler/lib/src/universe/world_builder.dart
+++ b/pkg/compiler/lib/src/universe/world_builder.dart
@@ -125,7 +125,7 @@
 
   /// Registers that [type] is checked in this universe. The unaliased type is
   /// returned.
-  DartType registerIsCheck(DartType type, Resolution resolution);
+  DartType registerIsCheck(DartType type);
 
   /// All directly instantiated types, that is, the types of the directly
   /// instantiated classes.
@@ -677,8 +677,8 @@
     return constraints.addReceiverConstraint(mask);
   }
 
-  DartType registerIsCheck(DartType type, Resolution resolution) {
-    type.computeUnaliased(resolution);
+  DartType registerIsCheck(DartType type) {
+    type.computeUnaliased(_resolution);
     type = type.unaliased;
     // Even in checked mode, type annotations for return type and argument
     // types do not imply type checks, so there should never be a check
@@ -1118,7 +1118,7 @@
     _invokedSetters.forEach(f);
   }
 
-  DartType registerIsCheck(DartType type, Resolution resolution) {
+  DartType registerIsCheck(DartType type) {
     type = type.unaliased;
     // Even in checked mode, type annotations for return type and argument
     // types do not imply type checks, so there should never be a check