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>
This commit is contained in:
Johnni Winther 2019-01-03 19:10:00 +00:00 committed by commit-bot@chromium.org
parent 42702e2c64
commit 5334524f2b
6 changed files with 18 additions and 72 deletions

View file

@ -215,7 +215,6 @@ abstract class CommonElements {
bool isDefaultNoSuchMethodImplementation(FunctionEntity element);
// From dart:async
FunctionEntity get asyncHelperStart;
FunctionEntity get asyncHelperStartSync;
FunctionEntity get asyncHelperAwait;
FunctionEntity get asyncHelperReturn;
@ -249,8 +248,6 @@ abstract class CommonElements {
FunctionEntity get asyncAwaitCompleterFactory;
FunctionEntity get syncCompleterFactory;
FunctionEntity get asyncStarStreamControllerFactory;
ClassEntity get jsInterceptorClass;
@ -1027,8 +1024,6 @@ class CommonElementsImpl
FunctionEntity _findAsyncHelperFunction(String name) =>
_findLibraryMember(asyncLibrary, name);
FunctionEntity get asyncHelperStart =>
_findAsyncHelperFunction("_asyncStart");
FunctionEntity get asyncHelperStartSync =>
_findAsyncHelperFunction("_asyncStartSync");
FunctionEntity get asyncHelperAwait =>
@ -1081,10 +1076,6 @@ class CommonElementsImpl
_asyncAwaitCompleterFactory ??=
_findAsyncHelperFunction('_makeAsyncAwaitCompleter');
FunctionEntity _syncCompleterFactory;
FunctionEntity get syncCompleterFactory =>
_syncCompleterFactory ??= _findAsyncHelperFunction('_makeSyncCompleter');
FunctionEntity _asyncStarStreamControllerFactory;
FunctionEntity get asyncStarStreamControllerFactory =>
_asyncStarStreamControllerFactory ??=

View file

@ -540,8 +540,7 @@ class JavaScriptBackend {
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 @@ class JavaScriptBackend {
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 @@ class JavaScriptBackend {
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 @@ class JavaScriptBackend {
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);

View file

@ -8,7 +8,6 @@ import '../common/names.dart';
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 @@ class BackendImpact {
/// 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 @@ class BackendImpacts {
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;

View file

@ -144,9 +144,7 @@ class KernelImpactBuilder extends StaticTypeVisitor {
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),

View file

@ -284,16 +284,12 @@ class CompilerOptions implements DiagnosticOptions {
/// 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 @@ class CompilerOptions implements DiagnosticOptions {
..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}=')

View file

@ -229,13 +229,6 @@ Completer<T> _makeAsyncAwaitCompleter<T>() {
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 @@ dynamic _asyncStartSync(
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.