| commit | 90162cc1f616ec22fc6751fba478cda9d59d4e35 | [log] [tgz] |
|---|---|---|
| author | Nate Biggs <natebiggs@google.com> | Tue Jul 30 03:13:58 2024 +0000 |
| committer | Commit Queue <dart-scoped@luci-project-accounts.iam.gserviceaccount.com> | Tue Jul 30 03:13:58 2024 +0000 |
| tree | 94967b1c905a49a7b0578497d23d0d23a82285be | |
| parent | 961bc9236e7715655d97e6c832ed83fb34658bda [diff] |
[ddc] Fixes for DDC async lowering. --- Super fix --- When the arguments to a call contain an async gap (an await in this case), the new lowering will save the receiver to a temp variable so it can be accessed on re-entry to the function body. This is skipped for literals as the literal does not need to be stored in a variable, it can simply be used as-is. However, the DDC JS AST did not treat "this" or "super" as literals so we ended up with invalid JS like "let temp = super; // do await; temp.foo(...);". In this case "let temp = super;" is invalid, "super" cannot be used as a bare expression. --- Function scope change --- The original approach of using TemporaryIds for all the hoisted variables had a large flaw in that it didn't account for scopes captured by closures within async code. Hoisted variables were lifted out of their attached scope and so closures captured the single hoisted declaration and all modified the same variable. See async_scope_capture_test.dart for an example of this breaking. To fix this we need to box any captured variables into a JS object. We then wrap any closures in an IIFE and pass the correct scope objects in as arguments to "capture" them. This is similar to dart2js's approach of boxing variables for closures. The approach is a little less fine-grained though and we simply box every variable. This makes the logic simpler and provides a better debug experience as users will just be able to look at the available "asyncScope" variables and see all the declarations in the original source code. --- Add async callback --- After further study, none of the other backends add implicit calls to 'async_helper.asyncStart' or 'async_helper.asyncEnd'. All the tests (with the exception of the hot_restart_timer_test updated below) are all set up to call asyncStart if they need it. As such we can simply remove and calls in the runtime/sdk to 'addAsyncCallback' (which is then calling 'async_helper.asyncStart'). Ditto with their remove/end counterparts. Change-Id: Iac9a3774cc43fc2270e3bb2e992893358042e604 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376020 Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Mark Zhou <markzipan@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
Dart is:
Approachable: Develop with a strongly typed programming language that is consistent, concise, and offers modern language features like null safety and patterns.
Portable: Compile to ARM, x64, or RISC-V machine code for mobile, desktop, and backend. Compile to JavaScript or WebAssembly for the web.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app. Diagnose app issues using DevTools.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents in our repo at docs.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.
Future plans for Dart are included in the combined Dart and Flutter roadmap on the Flutter wiki.