diff --git a/CHANGELOG.md b/CHANGELOG.md index 693080f29da..186a341de28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,11 @@ ### Tool Changes +#### dart2js + +* `async` functions now start synchronously. This will be the default behavior + across all tools. To temporarily opt-out, use the `--no-sync-async` flag. + #### Pub * Fix another bug where the version solver could crash when resolving a conflict diff --git a/pkg/compiler/lib/src/commandline_options.dart b/pkg/compiler/lib/src/commandline_options.dart index 9673775eabf..152ac6c5a10 100644 --- a/pkg/compiler/lib/src/commandline_options.dart +++ b/pkg/compiler/lib/src/commandline_options.dart @@ -95,11 +95,19 @@ class Flags { // https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c. static const String genericMethodSyntax = '--generic-method-syntax'; - // Starts `async` functions synchronously. + // Deprecated. This flag is no longer in use for dart2js, but we are keeping + // it around for a while longer until all other tools deprecate the same flag. // - // This is the Dart 2.0 behavior. This flag is only used during the migration. + // It was used to start `async` functions synchronously, but now dart2js + // switched on this behavior by default. + // TODO(sigmund): delete once this is on by default on all of our tools. static const String syncAsync = '--sync-async'; + // Starts `async` functions asynchronously. + // + // This is the old Dart 1.0 behavior. Only used during the migration. + static const String noSyncAsync = '--no-sync-async'; + // Initializing-formal access is enabled by default and cannot be disabled. // For backward compatibility the option is still accepted, but it is ignored. static const String initializingFormalAccess = '--initializing-formal-access'; diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart index 8da68d43ba5..de738410a8a 100644 --- a/pkg/compiler/lib/src/dart2js.dart +++ b/pkg/compiler/lib/src/dart2js.dart @@ -317,7 +317,8 @@ Future compile(List argv, new OptionHandler(Flags.allowMockCompilation, ignoreOption), new OptionHandler(Flags.fastStartup, passThrough), new OptionHandler(Flags.genericMethodSyntax, ignoreOption), - new OptionHandler(Flags.syncAsync, passThrough), + new OptionHandler(Flags.syncAsync, ignoreOption), + new OptionHandler(Flags.noSyncAsync, passThrough), new OptionHandler(Flags.initializingFormalAccess, ignoreOption), new OptionHandler(Flags.minify, passThrough), new OptionHandler(Flags.preserveUris, ignoreOption), diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart index 6d474b288c0..01e4689c06d 100644 --- a/pkg/compiler/lib/src/options.dart +++ b/pkg/compiler/lib/src/options.dart @@ -348,7 +348,7 @@ class CompilerOptions implements DiagnosticOptions { ..useMultiSourceInfo = _hasOption(options, Flags.useMultiSourceInfo) ..useNewSourceInfo = _hasOption(options, Flags.useNewSourceInfo) ..useStartupEmitter = _hasOption(options, Flags.fastStartup) - ..startAsyncSynchronously = _hasOption(options, Flags.syncAsync) + ..startAsyncSynchronously = !_hasOption(options, Flags.noSyncAsync) ..verbose = _hasOption(options, Flags.verbose); } diff --git a/runtime/observatory/tests/observatory_ui/mocks/repositories/flag.dart b/runtime/observatory/tests/observatory_ui/mocks/repositories/flag.dart index c6755e65934..578c034086a 100644 --- a/runtime/observatory/tests/observatory_ui/mocks/repositories/flag.dart +++ b/runtime/observatory/tests/observatory_ui/mocks/repositories/flag.dart @@ -9,6 +9,7 @@ class FlagsRepositoryMock implements M.FlagsRepository { bool isListInvoked = false; Future> list() async { + await null; isListInvoked = true; return _list; } diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status index ffb0f77ffc7..f451f72f54b 100644 --- a/tests/co19/co19-dart2js.status +++ b/tests/co19/co19-dart2js.status @@ -17,6 +17,7 @@ Language/Expressions/Function_Invocation/async_cleanup_t06: Skip # https://githu Language/Expressions/Function_Invocation/async_cleanup_t08: Skip # https://github.com/dart-lang/sdk/issues/28873 Language/Expressions/Function_Invocation/async_generator_invokation_t08: Skip # Issue 25967 Language/Expressions/Function_Invocation/async_generator_invokation_t10: Skip # Issue 25967 +Language/Expressions/Function_Invocation/async_invokation_t02: RuntimeError # sync-async is on by default. Language/Expressions/Function_Invocation/async_invokation_t04: RuntimeError, Pass # co19 issue 57 Language/Expressions/Instance_Creation/New/evaluation_t19: RuntimeError # Please triage this failure Language/Expressions/Instance_Creation/New/evaluation_t20: RuntimeError # Please triage this failure diff --git a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_async.dart b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_async.dart index b1cc65d73d8..7ca81d38d61 100644 --- a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_async.dart +++ b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_async.dart @@ -11,5 +11,6 @@ main() { @NoInline() test() async { + await null; /*1:test*/ throw '>ExceptionMarker<'; } diff --git a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_awaited_async.dart b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_awaited_async.dart index 47d2c2d0de9..522bcf7c700 100644 --- a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_awaited_async.dart +++ b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_awaited_async.dart @@ -16,5 +16,6 @@ test1() async { @NoInline() test2() async { + await null; /*1:test2*/ throw '>ExceptionMarker<'; } diff --git a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_constructor_from_async.dart b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_constructor_from_async.dart index 05db172f37e..0120aa3ab7b 100644 --- a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_constructor_from_async.dart +++ b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_constructor_from_async.dart @@ -10,6 +10,7 @@ main() { } test() async { + await null; // ignore: UNUSED_LOCAL_VARIABLE var c = new /*1:test*/ Class(); } diff --git a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_top_level_method_from_async.dart b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_top_level_method_from_async.dart index af5ea174987..c172214961d 100644 --- a/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_top_level_method_from_async.dart +++ b/tests/compiler/dart2js/sourcemaps/stacktrace/throw_in_top_level_method_from_async.dart @@ -10,6 +10,7 @@ main() { @NoInline() test1() async { + await null; /*1:test1*/ test2(); } diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status index 05f819e0d50..9a7255e8120 100644 --- a/tests/language/language_dart2js.status +++ b/tests/language/language_dart2js.status @@ -5,8 +5,11 @@ [ $compiler != dart2analyzer ] switch_case_warn_test: Skip # Analyzer only, see language_analyzer2.status -# VM specific tests that should not be run by dart2js. [ $compiler == dart2js ] +async_await_test: RuntimeError # sync-async is on by default +asyncstar_throw_in_catch_test: RuntimeError # sync-async is on by default +await_nonfuture_test: RuntimeError # sync-async is on by default +await_not_started_immediately_test: RuntimeError # sync-async is on by default full_stacktrace1_test: Pass, RuntimeError # Issue 12698 full_stacktrace2_test: Pass, RuntimeError # Issue 12698 full_stacktrace3_test: Pass, RuntimeError # Issue 12698 diff --git a/tests/lib/lib.status b/tests/lib/lib.status index 45b680a1750..7a7c744e280 100644 --- a/tests/lib/lib.status +++ b/tests/lib/lib.status @@ -15,6 +15,7 @@ mirrors/*: Skip # Issue 27929: Triage *: Skip [ $compiler == dart2js ] +async/async_await_sync_completer_test: RuntimeError # sync-async is on by default. async/schedule_microtask6_test: RuntimeError # global error handling is not supported. Issue 5958 convert/base64_test/01: Fail, OK # Uses bit-wise operations to detect invalid values. Some large invalid values accepted by dart2js. convert/chunked_conversion_utf88_test: Slow, Pass