Remove conditional sync async code

Closes #35466

Change-Id: Ic8a7e6ec4814e9f0ebd6086fea8458f3056786c4
Reviewed-on: https://dart-review.googlesource.com/c/87969
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/common_elements.dart b/pkg/compiler/lib/src/common_elements.dart
index e0b0c54..188f52e 100644
--- a/pkg/compiler/lib/src/common_elements.dart
+++ b/pkg/compiler/lib/src/common_elements.dart
@@ -215,7 +215,6 @@
   bool isDefaultNoSuchMethodImplementation(FunctionEntity element);
 
   // From dart:async
-  FunctionEntity get asyncHelperStart;
   FunctionEntity get asyncHelperStartSync;
   FunctionEntity get asyncHelperAwait;
   FunctionEntity get asyncHelperReturn;
@@ -249,8 +248,6 @@
 
   FunctionEntity get asyncAwaitCompleterFactory;
 
-  FunctionEntity get syncCompleterFactory;
-
   FunctionEntity get asyncStarStreamControllerFactory;
 
   ClassEntity get jsInterceptorClass;
@@ -1027,8 +1024,6 @@
   FunctionEntity _findAsyncHelperFunction(String name) =>
       _findLibraryMember(asyncLibrary, name);
 
-  FunctionEntity get asyncHelperStart =>
-      _findAsyncHelperFunction("_asyncStart");
   FunctionEntity get asyncHelperStartSync =>
       _findAsyncHelperFunction("_asyncStartSync");
   FunctionEntity get asyncHelperAwait =>
@@ -1081,10 +1076,6 @@
       _asyncAwaitCompleterFactory ??=
           _findAsyncHelperFunction('_makeAsyncAwaitCompleter');
 
-  FunctionEntity _syncCompleterFactory;
-  FunctionEntity get syncCompleterFactory =>
-      _syncCompleterFactory ??= _findAsyncHelperFunction('_makeSyncCompleter');
-
   FunctionEntity _asyncStarStreamControllerFactory;
   FunctionEntity get asyncStarStreamControllerFactory =>
       _asyncStarStreamControllerFactory ??=
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 09bfcda..81ea82f 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -540,8 +540,7 @@
     NativeBasicData nativeBasicData = compiler.frontendStrategy.nativeBasicData;
     RuntimeTypesNeedBuilder rtiNeedBuilder =
         compiler.frontendStrategy.createRuntimeTypesNeedBuilder();
-    BackendImpacts impacts =
-        new BackendImpacts(compiler.options, commonElements);
+    BackendImpacts impacts = new BackendImpacts(commonElements);
     _nativeResolutionEnqueuer = new NativeResolutionEnqueuer(
         compiler.options,
         elementEnvironment,
@@ -622,8 +621,7 @@
       GlobalTypeInferenceResults globalInferenceResults) {
     ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
     CommonElements commonElements = closedWorld.commonElements;
-    BackendImpacts impacts =
-        new BackendImpacts(compiler.options, commonElements);
+    BackendImpacts impacts = new BackendImpacts(commonElements);
     _customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis(
         constantSystem,
         commonElements,
@@ -774,8 +772,7 @@
     emitter.createEmitter(namer, closedWorld, codegenWorldBuilder, sorter);
     // TODO(johnniwinther): Share the impact object created in
     // createCodegenEnqueuer.
-    BackendImpacts impacts =
-        new BackendImpacts(compiler.options, closedWorld.commonElements);
+    BackendImpacts impacts = new BackendImpacts(closedWorld.commonElements);
     if (compiler.options.disableRtiOptimization) {
       _rtiSubstitutions = new TrivialRuntimeTypesSubstitutions(closedWorld);
       _rtiChecksBuilder =
@@ -895,14 +892,8 @@
       jsAst.Expression code,
       DartType elementType,
       jsAst.Name name) {
-    bool startAsyncSynchronously = compiler.options.startAsyncSynchronously;
-
-    var startFunction = startAsyncSynchronously
-        ? commonElements.asyncHelperStartSync
-        : commonElements.asyncHelperStart;
-    var completerFactory = startAsyncSynchronously
-        ? commonElements.asyncAwaitCompleterFactory
-        : commonElements.syncCompleterFactory;
+    var startFunction = commonElements.asyncHelperStartSync;
+    var completerFactory = commonElements.asyncAwaitCompleterFactory;
 
     List<jsAst.Expression> itemTypeExpression = _fetchItemType(elementType);
 
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index 9f6ca64..f553d9f 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -8,7 +8,6 @@
 import '../common_elements.dart' show CommonElements, ElementEnvironment;
 import '../elements/types.dart' show InterfaceType;
 import '../elements/entities.dart';
-import '../options.dart' show CompilerOptions;
 import '../universe/selector.dart';
 import '../universe/world_impact.dart'
     show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl;
@@ -89,10 +88,9 @@
 
 /// The JavaScript backend dependencies for various features.
 class BackendImpacts {
-  final CompilerOptions _options;
   final CommonElements _commonElements;
 
-  BackendImpacts(this._options, this._commonElements);
+  BackendImpacts(this._commonElements);
 
   BackendImpact _getRuntimeTypeArgument;
 
@@ -128,21 +126,14 @@
 
   BackendImpact _asyncBody;
 
-  BackendImpact get asyncBody => _asyncBody ??= () {
-        var staticUses = [
-          _commonElements.asyncHelperAwait,
-          _commonElements.asyncHelperReturn,
-          _commonElements.asyncHelperRethrow,
-          _commonElements.streamIteratorConstructor,
-          _commonElements.wrapBody
-        ];
-        if (_options.startAsyncSynchronously) {
-          staticUses.add(_commonElements.asyncHelperStartSync);
-        } else {
-          staticUses.add(_commonElements.asyncHelperStart);
-        }
-        return new BackendImpact(staticUses: staticUses);
-      }();
+  BackendImpact get asyncBody => _asyncBody ??= new BackendImpact(staticUses: [
+        _commonElements.asyncHelperAwait,
+        _commonElements.asyncHelperReturn,
+        _commonElements.asyncHelperRethrow,
+        _commonElements.streamIteratorConstructor,
+        _commonElements.wrapBody,
+        _commonElements.asyncHelperStartSync
+      ]);
 
   BackendImpact _syncStarBody;
 
diff --git a/pkg/compiler/lib/src/kernel/kernel_impact.dart b/pkg/compiler/lib/src/kernel/kernel_impact.dart
index ee62aa6..a93e7e7 100644
--- a/pkg/compiler/lib/src/kernel/kernel_impact.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_impact.dart
@@ -144,9 +144,7 @@
 
       case ir.AsyncMarker.Async:
         impactBuilder.registerFeature(Feature.ASYNC);
-        var completerFactory = _options.startAsyncSynchronously
-            ? commonElements.asyncAwaitCompleterFactory
-            : commonElements.syncCompleterFactory;
+        var completerFactory = commonElements.asyncAwaitCompleterFactory;
         impactBuilder.registerStaticUse(new StaticUse.staticInvoke(
             completerFactory,
             const CallStructure.unnamed(0, 1),
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index 733dc02..41c32cc 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -284,16 +284,12 @@
   /// This is an experimental feature.
   String experimentalAllocationsPath;
 
+  /// If specified, a bundle of optimizations to enable (or disable).
+  int optimizationLevel = null;
+
   // -------------------------------------------------
   // Options for deprecated features
   // -------------------------------------------------
-  // TODO(sigmund): delete these as we delete the underlying features
-
-  /// Whether to start `async` functions synchronously.
-  bool startAsyncSynchronously = true;
-
-  /// If specified, a bundle of optimizations to enable (or disable).
-  int optimizationLevel = null;
 
   /// Create an options object by parsing flags from [options].
   static CompilerOptions parse(List<String> options,
@@ -363,7 +359,6 @@
       ..useMultiSourceInfo = _hasOption(options, Flags.useMultiSourceInfo)
       ..useNewSourceInfo = _hasOption(options, Flags.useNewSourceInfo)
       ..useStartupEmitter = _hasOption(options, Flags.fastStartup)
-      ..startAsyncSynchronously = true
       ..verbose = _hasOption(options, Flags.verbose)
       ..showInternalProgress = _hasOption(options, Flags.progress)
       ..readDataUri = _extractUriOption(options, '${Flags.readData}=')
diff --git a/sdk/lib/_internal/js_runtime/lib/async_patch.dart b/sdk/lib/_internal/js_runtime/lib/async_patch.dart
index 09b75af..87fab54 100644
--- a/sdk/lib/_internal/js_runtime/lib/async_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/async_patch.dart
@@ -229,13 +229,6 @@
   return new _AsyncAwaitCompleter<T>();
 }
 
-/// Creates a Completer for an `async` function.
-///
-/// Used as part of the runtime support for the async/await transformation.
-Completer<T> _makeSyncCompleter<T>() {
-  return new Completer<T>.sync();
-}
-
 /// Initiates the computation of an `async` function and starts the body
 /// synchronously.
 ///
@@ -251,19 +244,6 @@
   return completer.future;
 }
 
-/// Initiates the computation of an `async` function.
-///
-/// Used as part of the runtime support for the async/await transformation.
-///
-/// This function sets up the first call into the transformed [bodyFunction].
-/// Independently, it takes the [completer] and returns the future of the
-/// completer for convenience of the transformed code.
-dynamic _asyncStart(_WrappedAsyncBody bodyFunction, Completer completer) {
-  // TODO(sra): Specialize this implementation of `await null`.
-  _awaitOnObject(null, bodyFunction);
-  return completer.future;
-}
-
 /// Performs the `await` operation of an `async` function.
 ///
 /// Used as part of the runtime support for the async/await transformation.