From 001af89c8e1b80a62578eb6b751a74dc9117fb1b Mon Sep 17 00:00:00 2001 From: Vijay Menon Date: Mon, 30 Apr 2018 15:04:51 +0000 Subject: [PATCH] Flip DDC to default to sync-async See #32868 Change-Id: I757321632c9f383edea398741c67fc7c3e3815e5 Reviewed-on: https://dart-review.googlesource.com/52900 Commit-Queue: Vijay Menon Reviewed-by: Jenny Messerly Reviewed-by: Sigmund Cherem --- CHANGELOG.md | 6 ++++++ .../stacktrace_testfiles/throw_in_async.dart | 7 +++---- .../stacktrace_testfiles/throw_in_awaited_async.dart | 11 +++++------ .../throw_in_constructor_from_async.dart | 8 ++++---- .../throw_in_top_level_method_from_async.dart | 8 ++++---- .../test/sourcemap/testfiles/hello_async.dart | 8 ++++---- pkg/dev_compiler/tool/ddc | 7 ------- .../input_sdk/private/ddc_runtime/generators.dart | 5 +++-- tools/testing/dart/browser_test.dart | 4 +--- tools/testing/dart/test_suite.dart | 2 +- 10 files changed, 31 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2f0786cbf6..5836325e44a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,12 @@ * Force splitting an empty block as the then body of an if with an else. * Uses the new lowercase Dart 2 constant names. +#### Dart Dev Compiler + +* `async` functions now start synchronously by default. Build tools + (e.g., build_runner) may override the default and/or allow + developers to configure. + #### Pub * The `build` and `serve` commands will now fail and point users to diff --git a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_async.dart b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_async.dart index e6bcb2d26ba..0f6165e7915 100644 --- a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_async.dart +++ b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_async.dart @@ -3,10 +3,9 @@ // BSD-style license that can be found in the LICENSE file. main() { - // This call is no longer on the stack when the error is thrown. - /*:main*/ test(); + /*1:main*/ test(); } -test() async { - /*1:test*/ throw '>ExceptionMarker<'; +test /*ddk.2:test*/ () /*ddc.2:test*/ async { + /*3:test*/ throw '>ExceptionMarker<'; } diff --git a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_awaited_async.dart b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_awaited_async.dart index fbc5eff673e..2801397ded0 100644 --- a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_awaited_async.dart +++ b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_awaited_async.dart @@ -3,14 +3,13 @@ // BSD-style license that can be found in the LICENSE file. main() { - test1(); + /*1:main*/ test1(); } -test1() async { - // This call is no longer on the stack when the error is thrown. - await /*:test1*/ test2(); +test1 /*ddk.2:test1*/ () /*ddc.2:test1*/ async { + await /*3:test1*/ test2(); } -test2() async { - /*1:test2*/ throw '>ExceptionMarker<'; +test2 /*ddk.4:test2*/ () /*ddc.4:test2*/ async { + /*5:test2*/ throw '>ExceptionMarker<'; } diff --git a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_constructor_from_async.dart b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_constructor_from_async.dart index 1eaf256b55a..c3cf4354cae 100644 --- a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_constructor_from_async.dart +++ b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_constructor_from_async.dart @@ -4,17 +4,17 @@ main() { // This call is no longer on the stack when the error is thrown. - /*:main*/ test(); + /*1:main*/ test(); } -test() async { +test /*ddk.2:test*/ () /*ddc.2:test*/ async { // ignore: UNUSED_LOCAL_VARIABLE - var c = new /*1:test*/ Class(); + var c = new /*3:test*/ Class(); } class Class { Class() { // Some comment - /*2:Class.new*/ throw '>ExceptionMarker<'; + /*4:Class.new*/ throw '>ExceptionMarker<'; } } diff --git a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_top_level_method_from_async.dart b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_top_level_method_from_async.dart index 0eeaefe100a..f58dde6c7fe 100644 --- a/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_top_level_method_from_async.dart +++ b/pkg/dev_compiler/test/sourcemap/stacktrace_testfiles/throw_in_top_level_method_from_async.dart @@ -3,13 +3,13 @@ // BSD-style license that can be found in the LICENSE file. main() { - test1(); + /*1:main*/ test1(); } -test1() async { - /*1:test1*/ test2(); +test1 /*ddk.2:test1*/ () /*ddc.2:test1*/ async { + /*3:test1*/ test2(); } test2() { - /*2:test2*/ throw '>ExceptionMarker<'; + /*4:test2*/ throw '>ExceptionMarker<'; } diff --git a/pkg/dev_compiler/test/sourcemap/testfiles/hello_async.dart b/pkg/dev_compiler/test/sourcemap/testfiles/hello_async.dart index a462a3b45d3..6758e460064 100644 --- a/pkg/dev_compiler/test/sourcemap/testfiles/hello_async.dart +++ b/pkg/dev_compiler/test/sourcemap/testfiles/hello_async.dart @@ -5,10 +5,10 @@ main() { /*bl*/ /*s:1*/ foo(); -/*nbb:0:3*/ /*s:3*/ + /*s:4*/ } -foo() async { - /*nbb:0:4*/ /*bc:4*/ print("hello from foo"); -/*s:2*/ +foo() /*sl:2*/ async { + print("hello from foo"); +/*s:3*/ } diff --git a/pkg/dev_compiler/tool/ddc b/pkg/dev_compiler/tool/ddc index 9846cd68481..cc8f4106f71 100755 --- a/pkg/dev_compiler/tool/ddc +++ b/pkg/dev_compiler/tool/ddc @@ -60,12 +60,6 @@ if [ "$1" = "-k" ]; then shift fi -SYNC_ASYNC=false -if [ "$1" = "--sync-async" ]; then - SYNC_ASYNC=true - shift -fi - BASENAME=$( basename "${1%.*}") LIBROOT=$(cd $( dirname "${1%.*}") && pwd) @@ -110,7 +104,6 @@ echo " let sdk = require(\"dart_sdk\"); let main = require(\"./$BASENAME\").$BASENAME.main; sdk.dart.ignoreWhitelistedErrors(false); - if ($SYNC_ASYNC) sdk.dart.setStartAsyncSynchronously(); try { sdk._isolate_helper.startRootIsolate(main, []); } catch(e) { diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart index e6cfecf0ee3..584a6f1efce 100644 --- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart +++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart @@ -11,8 +11,9 @@ /// stepping stone for proposed ES7 async/await, and uses ES6 Promises. part of dart._runtime; -// TODO(vsm): Remove once this flag is the default. -bool startAsyncSynchronously = false; +// TODO(vsm): Remove once this flag we've removed the ability to +// whitelist / fallback on the old behavior. +bool startAsyncSynchronously = true; void setStartAsyncSynchronously([bool value = true]) { startAsyncSynchronously = value; } diff --git a/tools/testing/dart/browser_test.dart b/tools/testing/dart/browser_test.dart index 19b39a73b45..4c2d536eda3 100644 --- a/tools/testing/dart/browser_test.dart +++ b/tools/testing/dart/browser_test.dart @@ -40,8 +40,7 @@ String dart2jsHtml(String title, String scriptPath) { /// The [testName] is the short name of the test without any subdirectory path /// or extension, like "math_test". The [testJSDir] is the relative path to the /// build directory where the dartdevc-generated JS file is stored. -String dartdevcHtml(String testName, String testJSDir, String buildDir, - {bool syncAsync}) { +String dartdevcHtml(String testName, String testJSDir, String buildDir) { var packagePaths = testPackages .map((package) => ' "$package": "/root_dart/$buildDir/gen/utils/' 'dartdevc/pkg/$package",') @@ -87,7 +86,6 @@ window.ddcSettings = { requirejs(["$testName", "dart_sdk", "async_helper"], function($testName, sdk, async_helper) { sdk.dart.ignoreWhitelistedErrors(false); - if ($syncAsync) sdk.dart.setStartAsyncSynchronously(); // TODO(rnystrom): This uses DDC's forked version of async_helper. Unfork // these packages when possible. async_helper.async_helper.asyncTestInitialize(function() {}); diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart index 25e8a791423..479c94f2409 100644 --- a/tools/testing/dart/test_suite.dart +++ b/tools/testing/dart/test_suite.dart @@ -1062,7 +1062,7 @@ class StandardTestSuite extends TestSuite { // Always run with synchronous starts of `async` functions. // If we want to make this dependent on other parameters or flags, // this flag could be become conditional. - content = dartdevcHtml(nameNoExt, jsDir, buildDir, syncAsync: true); + content = dartdevcHtml(nameNoExt, jsDir, buildDir); } }