Remove CompilerOptions.useKernel

Change-Id: I9ea69addeb18e061280329c233a110fe2d8ca763
Reviewed-on: https://dart-review.googlesource.com/54240
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart
index 8ff3879..1ad4fc81 100644
--- a/pkg/compiler/lib/src/apiimpl.dart
+++ b/pkg/compiler/lib/src/apiimpl.dart
@@ -382,12 +382,7 @@
     // TODO(sigmund): use libraries.json instead of .platform files, then simply
     // use the `supported` bit.
     if (libraryUri != null && libraryUri.scheme != "unsupported") {
-      // Dart2js always "supports" importing 'dart:mirrors' but will abort
-      // the compilation at a later point if the backend doesn't support
-      // mirrors. In this case 'mirrors' should not be in the environment.
-      if (libraryName == 'mirrors') {
-        return compiler.backend.supportsReflection ? "true" : null;
-      }
+      if (libraryName == 'mirrors') return null;
       if (libraryName == 'isolate') return null;
       return "true";
     }
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 7bc310e..dde70dd 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -39,7 +39,6 @@
 import 'io/source_information.dart' show SourceInformation;
 import 'io/source_file.dart' show Binary;
 import 'js_backend/backend.dart' show JavaScriptBackend;
-import 'js_backend/element_strategy.dart' show ElementBackendStrategy;
 import 'kernel/kernel_backend_strategy.dart';
 import 'kernel/kernel_strategy.dart';
 import 'library_loader.dart'
@@ -192,20 +191,12 @@
     } else {
       _reporter = new CompilerDiagnosticReporter(this, options);
     }
-    if (options.useKernel) {
-      kernelFrontEndTask = new GenericTask('Front end', measurer);
-      frontendStrategy = new KernelFrontEndStrategy(kernelFrontEndTask, options,
-          reporter, environment, options.kernelInitializedCompilerState);
-      backendStrategy = new KernelBackendStrategy(this);
-      _impactCache = <Entity, WorldImpact>{};
-      _impactCacheDeleter = new _MapImpactCacheDeleter(_impactCache);
-    } else {
-      frontendStrategy = new ResolutionFrontEndStrategy(this);
-      backendStrategy = new ElementBackendStrategy(this);
-      _resolution = createResolution();
-      _impactCache = _resolution._worldImpactCache;
-      _impactCacheDeleter = _resolution;
-    }
+    kernelFrontEndTask = new GenericTask('Front end', measurer);
+    frontendStrategy = new KernelFrontEndStrategy(kernelFrontEndTask, options,
+        reporter, environment, options.kernelInitializedCompilerState);
+    backendStrategy = new KernelBackendStrategy(this);
+    _impactCache = <Entity, WorldImpact>{};
+    _impactCacheDeleter = new _MapImpactCacheDeleter(_impactCache);
 
     if (options.verbose) {
       progress = new ProgressImpl(_reporter);
@@ -241,7 +232,7 @@
       dumpInfoTask = new DumpInfoTask(this),
       selfTask,
     ];
-    if (options.useKernel) tasks.add(kernelFrontEndTask);
+    tasks.add(kernelFrontEndTask);
 
     _parsingContext =
         new ParsingContext(reporter, parser, scanner, patchParser, backend);
@@ -385,47 +376,9 @@
     // front end for the Kernel path since Kernel doesn't have the notion of
     // imports (everything has already been resolved). (See
     // https://github.com/dart-lang/sdk/issues/29368)
-    if (!options.useKernel) {
-      for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) {
-        if (loadedLibraries.containsLibrary(uri)) {
-          Set<String> importChains =
-              computeImportChainsFor(loadedLibraries, uri);
-          reporter.reportInfo(
-              NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, {
-            'uri': uri,
-            'importChain': importChains
-                .join(MessageTemplate.DISALLOWED_LIBRARY_IMPORT_PADDING)
-          });
-        }
-      }
-
-      if (loadedLibraries.containsLibrary(Uris.dart_core)) {
-        bool importsMirrorsLibrary =
-            loadedLibraries.containsLibrary(Uris.dart_mirrors);
-        if (importsMirrorsLibrary && !backend.supportsReflection) {
-          Set<String> importChains =
-              computeImportChainsFor(loadedLibraries, Uris.dart_mirrors);
-          reporter.reportErrorMessage(NO_LOCATION_SPANNABLE,
-              MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND, {
-            'importChain': importChains
-                .join(MessageTemplate.MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING)
-          });
-        } else if (importsMirrorsLibrary &&
-            !options.enableExperimentalMirrors) {
-          Set<String> importChains =
-              computeImportChainsFor(loadedLibraries, Uris.dart_mirrors);
-          reporter.reportWarningMessage(
-              NO_LOCATION_SPANNABLE, MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, {
-            'importChain': importChains
-                .join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)
-          });
-        }
-      }
-    } else {
-      if (loadedLibraries.containsLibrary(Uris.dart_mirrors)) {
-        reporter.reportWarningMessage(NO_LOCATION_SPANNABLE,
-            MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_WITH_CFE);
-      }
+    if (loadedLibraries.containsLibrary(Uris.dart_mirrors)) {
+      reporter.reportWarningMessage(NO_LOCATION_SPANNABLE,
+          MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_WITH_CFE);
     }
     backend.onLibrariesLoaded(frontendStrategy.commonElements, loadedLibraries);
     return loadedLibraries;
@@ -529,11 +482,6 @@
         FunctionEntity mainFunction =
             frontendStrategy.computeMain(rootLibrary, mainImpact);
 
-        if (!options.useKernel) {
-          // TODO(johnniwinther): Support mirrors usages analysis from dill.
-          mirrorUsageAnalyzerTask.analyzeUsage(rootLibrary);
-        }
-
         // In order to see if a library is deferred, we must compute the
         // compile-time constants that are metadata.  This means adding
         // something to the resolution queue.  So we cannot wait with
@@ -562,11 +510,6 @@
             }
           }
         }
-        if (frontendStrategy.commonElements.mirrorsLibrary != null &&
-            !options.useKernel) {
-          // TODO(johnniwinther): Support mirrors from dill.
-          resolveLibraryMetadata();
-        }
         reporter.log('Resolving...');
 
         processQueue(frontendStrategy.elementEnvironment, resolutionEnqueuer,
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index 1e56455..430c1bf 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -97,9 +97,6 @@
   /// Will be `true` if the program contains deferred libraries.
   bool isProgramSplit = false;
 
-  /// Whether mirrors have been used in the program.
-  bool _isMirrorsUsed = false;
-
   static const ImpactUseCase IMPACT_USE = const ImpactUseCase('Deferred load');
 
   /// A mapping from the name of a defer import to all the output units it
@@ -224,10 +221,6 @@
       collectConstantsInBody(analyzableElement, constants);
     }
 
-    if (_isMirrorsUsed) {
-      collectConstantsFromMetadata(element, constants);
-    }
-
     if (element is FunctionEntity) {
       _collectTypeDependencies(
           elementEnvironment.getFunctionType(element), elements);
@@ -686,8 +679,6 @@
 
     work() {
       var queue = new WorkQueue(this.importSets);
-      _isMirrorsUsed =
-          closedWorld.backendUsage.isMirrorsUsed && !compiler.options.useKernel;
 
       // Add `main` and their recursive dependencies to the main output unit.
       // We do this upfront to avoid wasting time visiting these elements when
@@ -708,9 +699,6 @@
         element = element is ClassElement ? element.implementation : element;
         queue.addElement(element, importSets.mainSet);
       }
-      if (_isMirrorsUsed) {
-        addMirrorElementsForLibrary(queue, main.library, importSets.mainSet);
-      }
 
       void emptyQueue() {
         while (queue.isNotEmpty) {
@@ -729,10 +717,6 @@
       }
 
       emptyQueue();
-      if (_isMirrorsUsed) {
-        addDeferredMirrorElements(queue);
-        emptyQueue();
-      }
     }
 
     reporter.withCurrentElement(main.library, () => measure(work));
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index c83d813..50f882d 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -324,10 +324,6 @@
 
   FrontendStrategy get frontendStrategy => compiler.frontendStrategy;
 
-  /// Returns true if the backend supports reflection and this isn't Dart 2.
-  bool get supportsReflection =>
-      emitter.supportsReflection && !compiler.options.useKernel;
-
   FunctionCompiler functionCompiler;
 
   CodeEmitterTask emitter;
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index cf43c6c..eb81c27 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -141,54 +141,30 @@
         } else {
           staticUses.add(_commonElements.asyncHelperStart);
         }
-        if (!_options.useKernel) {
-          if (_options.startAsyncSynchronously) {
-            staticUses.add(_commonElements.asyncAwaitCompleterFactory);
-          } else {
-            staticUses.add(_commonElements.syncCompleterFactory);
-          }
-        }
         return new BackendImpact(staticUses: staticUses);
       }();
 
   BackendImpact _syncStarBody;
 
   BackendImpact get syncStarBody {
-    return _syncStarBody ??= _options.useKernel
-        ? new BackendImpact(staticUses: [
-            _commonElements.endOfIteration,
-            _commonElements.yieldStar,
-            _commonElements.syncStarUncaughtError,
-          ])
-        : new BackendImpact(staticUses: [
-            _commonElements.endOfIteration,
-            _commonElements.yieldStar,
-            _commonElements.syncStarUncaughtError,
-            _commonElements.syncStarIterableFactory,
-          ]);
+    return _syncStarBody ??= new BackendImpact(staticUses: [
+      _commonElements.endOfIteration,
+      _commonElements.yieldStar,
+      _commonElements.syncStarUncaughtError,
+    ]);
   }
 
   BackendImpact _asyncStarBody;
 
   BackendImpact get asyncStarBody {
-    return _asyncStarBody ??= _options.useKernel
-        ? new BackendImpact(staticUses: [
-            _commonElements.asyncStarHelper,
-            _commonElements.streamOfController,
-            _commonElements.yieldSingle,
-            _commonElements.yieldStar,
-            _commonElements.streamIteratorConstructor,
-            _commonElements.wrapBody,
-          ])
-        : new BackendImpact(staticUses: [
-            _commonElements.asyncStarHelper,
-            _commonElements.streamOfController,
-            _commonElements.yieldSingle,
-            _commonElements.yieldStar,
-            _commonElements.streamIteratorConstructor,
-            _commonElements.wrapBody,
-            _commonElements.asyncStarStreamControllerFactory,
-          ]);
+    return _asyncStarBody ??= new BackendImpact(staticUses: [
+      _commonElements.asyncStarHelper,
+      _commonElements.streamOfController,
+      _commonElements.yieldSingle,
+      _commonElements.yieldStar,
+      _commonElements.streamIteratorConstructor,
+      _commonElements.wrapBody,
+    ]);
   }
 
   BackendImpact _typeVariableBoundCheck;
diff --git a/pkg/compiler/lib/src/js_backend/mirrors_data.dart b/pkg/compiler/lib/src/js_backend/mirrors_data.dart
index c128794..fe94bca 100644
--- a/pkg/compiler/lib/src/js_backend/mirrors_data.dart
+++ b/pkg/compiler/lib/src/js_backend/mirrors_data.dart
@@ -542,11 +542,11 @@
   void computeMembersNeededForReflection(
       ResolutionWorldBuilder worldBuilder, ClosedWorld closedWorld) {
     if (_membersNeededForReflection != null) return;
-    if (!closedWorld.backendUsage.isMirrorsUsed ||
-        _compiler.options.useKernel) {
+    if (!closedWorld.backendUsage.isMirrorsUsed || true) {
       createImmutableSets();
       return;
     }
+    // TODO(johnniwinther): Remove this:
     _classesNeededForReflection = new Set<ClassEntity>();
     _typedefsNeededForReflection = new Set<TypedefEntity>();
     _membersNeededForReflection = new Set<MemberEntity>();
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index 6002105..a158ff2 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -1961,12 +1961,11 @@
 
   jsAst.Comment buildGeneratedBy() {
     StringBuffer flavor = new StringBuffer();
-    flavor.write(compiler.options.useKernel ? 'kernel FE' : 'ast FE');
+    flavor.write('full emitter');
     if (compiler.options.strongMode) flavor.write(', strong');
     if (compiler.options.trustPrimitives) flavor.write(', trust primitives');
     if (compiler.options.trustTypeAnnotations) flavor.write(', trust types');
     if (compiler.options.omitImplicitChecks) flavor.write(', omit checks');
-    flavor.write(', full emitter');
     if (compiler.options.useContentSecurityPolicy) flavor.write(', CSP');
     if (_closedWorld.backendUsage.isMirrorsUsed) flavor.write(', mirrors');
     return new jsAst.Comment(generatedBy(compiler, flavor: '$flavor'));
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index 87667ed..5cd561c 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -687,7 +687,6 @@
         _rtiChecks,
         _rtiEncoder,
         _jsInteropAnalysis,
-        _options.useKernel,
         _options.strongMode);
 
     void visitMember(MemberEntity member) {
diff --git a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
index a277091..b483325 100644
--- a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
@@ -106,7 +106,6 @@
   final RuntimeTypesChecks _rtiChecks;
   final RuntimeTypesEncoder _rtiEncoder;
   final JsInteropAnalysis _jsInteropAnalysis;
-  final bool _useKernel;
   final bool _strongMode;
 
   RuntimeTypeGenerator(
@@ -118,7 +117,6 @@
       this._rtiChecks,
       this._rtiEncoder,
       this._jsInteropAnalysis,
-      this._useKernel,
       this._strongMode);
 
   /**
@@ -169,7 +167,7 @@
         if (classFunctionType.signatureFunction != null) {
           // Use precomputed signature function if live.
         } else {
-          assert(!_useKernel || !_strongMode);
+          assert(!_strongMode);
           // Generate the signature on the fly. This is only supported for
           // Dart 1.
 
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
index 5c5933a..869439e 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
@@ -228,12 +228,11 @@
   /// Generates a simple header that provides the compiler's build id.
   js.Comment buildGeneratedBy() {
     StringBuffer flavor = new StringBuffer();
-    flavor.write(compiler.options.useKernel ? 'kernel FE' : 'ast FE');
+    flavor.write('fast startup emitter');
     if (compiler.options.strongMode) flavor.write(', strong');
     if (compiler.options.trustPrimitives) flavor.write(', trust primitives');
     if (compiler.options.trustTypeAnnotations) flavor.write(', trust types');
     if (compiler.options.omitImplicitChecks) flavor.write(', omit checks');
-    flavor.write(', fast startup emitter');
     if (compiler.options.useContentSecurityPolicy) flavor.write(', CSP');
     return new js.Comment(generatedBy(compiler, flavor: '$flavor'));
   }
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index 1e0fe03..dde23a9 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -226,20 +226,7 @@
   /// Whether to generate code compliant with content security policy (CSP).
   bool useContentSecurityPolicy = false;
 
-  /// Preview the unified front-end and compilation from kernel.
-  ///
-  /// When enabled the compiler will use the unified front-end to compile
-  /// sources to kernel, and then continue compilation from the kernel
-  /// representation.
-  ///
-  /// When this flag is on, the compiler also accepts reading .dill files from
-  /// disk. The compiler reads the sources differently depending on the
-  /// extension format.
-  final useKernel = true;
-
   /// Enables strong mode in dart2js.
-  ///
-  /// This is work-in-progress and will only be supported for [useKernel].
   bool strongMode = false;
 
   /// When obfuscating for minification, whether to use the frequency of a name
@@ -369,7 +356,7 @@
     if (packageRoot != null && !packageRoot.path.endsWith("/")) {
       throw new ArgumentError("[packageRoot] must end with a /");
     }
-    if (useKernel && platformBinaries == null) {
+    if (platformBinaries == null) {
       throw new ArgumentError("Missing required ${Flags.platformBinaries}");
     }
   }
@@ -385,7 +372,8 @@
         trustTypeAnnotations = true;
       }
     }
-    if (useKernel) generateCodeWithCompileTimeErrors = false;
+    // TODO(johnniwinther): Should we support this in the future?
+    generateCodeWithCompileTimeErrors = false;
     if (platformConfigUri == null) {
       platformConfigUri = _resolvePlatformConfig(libraryRoot, null, const []);
     }
diff --git a/pkg/compiler/lib/src/ssa/type_builder.dart b/pkg/compiler/lib/src/ssa/type_builder.dart
index ac340805..c9b456e 100644
--- a/pkg/compiler/lib/src/ssa/type_builder.dart
+++ b/pkg/compiler/lib/src/ssa/type_builder.dart
@@ -4,7 +4,6 @@
 
 import 'graph_builder.dart';
 import 'nodes.dart';
-import '../common.dart';
 import '../elements/entities.dart';
 import '../elements/types.dart';
 import '../io/source_information.dart';
@@ -115,9 +114,8 @@
   HInstruction addTypeVariableReference(
       TypeVariableType type, MemberEntity member,
       {SourceInformation sourceInformation}) {
-    assert(assertTypeInContext(type));
     if (type.element.typeDeclaration is! ClassEntity &&
-        (!builder.options.strongMode || !builder.options.useKernel)) {
+        !builder.options.strongMode) {
       // GENERIC_METHODS:  We currently don't reify method type variables.
       return builder.graph.addConstantNull(builder.closedWorld);
     }
@@ -204,25 +202,9 @@
     return representation;
   }
 
-  /// Check that [type] is valid in the context of `localsHandler.contextClass`.
-  /// This should only be called in assertions.
-  bool assertTypeInContext(DartType type, [Spannable spannable]) {
-    if (builder.compiler.options.useKernel) return true;
-    ClassEntity contextClass = DartTypes.getClassContext(type);
-    assert(
-        contextClass == null ||
-            contextClass == builder.localsHandler.instanceType?.element,
-        failedAt(
-            spannable ?? CURRENT_ELEMENT_SPANNABLE,
-            "Type '$type' is not valid context of "
-            "${builder.localsHandler.instanceType?.element}."));
-    return true;
-  }
-
   HInstruction analyzeTypeArgument(
       DartType argument, MemberEntity sourceElement,
       {SourceInformation sourceInformation}) {
-    assert(assertTypeInContext(argument));
     argument = argument.unaliased;
     if (argument.treatAsDynamic) {
       // Represent [dynamic] as [null].
@@ -237,7 +219,7 @@
     List<HInstruction> inputs = <HInstruction>[];
     argument.forEachTypeVariable((TypeVariableType variable) {
       if (variable.element.typeDeclaration is ClassEntity ||
-          (builder.options.strongMode && builder.options.useKernel)) {
+          builder.options.strongMode) {
         // TODO(johnniwinther): Also make this conditional on whether we have
         // calculated we need that particular method signature.
         inputs.add(analyzeTypeArgument(variable, sourceElement));
@@ -280,7 +262,6 @@
       }
     }
     type = type.unaliased;
-    assert(assertTypeInContext(type, original));
     if (type.isInterfaceType && !type.treatAsRaw) {
       InterfaceType interfaceType = type;
       TypeMask subtype =