Commit graph

1512 commits

Author SHA1 Message Date
Martin Kustermann 8d802dd78a [vm] Avoid embedding sources in CFE compilations if we AppJit
Creation of AppJit snapshot will not include the source of [Script]
objects (see `UntaggedScript::snapshot_to`). As a result there's no
point in letting the CFE embed the sources into the kernel if we
only use it to create an AppJit snapshot.

This is also in line with build rules for our dart-sdk, where we do the
kernel compilation separately, see utils/application_snapshot.gni:

```
  template("application_snapshot") {
    ...
    # Build the kernel file using the prebuilt VM to speed up the
    # debug and simulator builds.
    prebuilt_dart_action(target_name + "_dill") {
      ...

      args = [
        ...
        "--no-embed-sources",
        ...
      ]
      [[[
    }
    ...
  }
```

TEST=ci

Change-Id: I4e17e49dc21af6102d62c2278dbd6ebbe387f7e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313560
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-14 09:47:38 +00:00
Martin Kustermann 81df36216f Make utf8.encode() have Uint8List return type
Right now `utf8.encode()` has a static return type of `List<int>`
due to extending `Encoding` (which extends `Codec<String, List<int>>`).

We cannot easily change `Encoding` to extend `Codec<String, Uint8List>`
because that would also change `utf8.decode()` to require `Uint8List`
which would be a breaking change.

So instead we override `utf8.encode()` to have more precise return type.

Some parts of our SDK are run using the checked-in SDK, so it cannot
rely on the changed return type yet (until checked-in SDK is rolled).

So we use `const Utf8Encoder().convert()` as a temporary change, as
that already has `Uint8List` return type.

Issue https://github.com/dart-lang/sdk/issues/52801

TEST=ci

CoreLibraryReviewExempt: More precise return type for existing API
Change-Id: I2861d1f0eb3d292d8e3ec8437c0d441a2d2bd193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254903
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-07-11 08:54:33 +00:00
Daco Harkes e1c12b3ab2 [cfe/ffi] Fix Finalizable non-nullable variables
TEST=pkg/vm/test/transformations/ffi_test.dart
TEST=pkg/vm/testcases/transformations/ffi/regress_52596.dart
Contains
`throw "Attempt to execute code removed by Dart AOT compiler (TFA)";`
without the fix.

Closes:https://github.com/dart-lang/sdk/issues/52596
Change-Id: I5de819afcf6f70be037b60432ea016bc281b742e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312909
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-07-11 07:53:47 +00:00
Tess Strickland ac2533e705 [pkg/vm] Instantiate the ffi Pointer class to bounds when needed.
Previously, the FFI transformer could produce is checks where the
type to check against was Pointer<dynamic>. However, given that
the Pointer class is defined as:

abstract class Pointer<X extends NativeType> ...

the instantiated to bounds version of its type is Pointer<NativeType>.
Pointer<dynamic> is not a subtype of Pointer<NativeType>, and thus is an
invalid instantiation, but the only place this type could occur was as
the right hand side of an is check.

Before 7cc005ea1, Class::RareType() returned the class instantiated with
the null (all-dynamic) type arguments vector. Among other things, this
"rare" type was compared to the right-hand side of is checks and, if it
matched, performed a simple (cid-only) check of the instance type
arguments in unoptimized code.

Afterwards, Class::RareType() returns the class instantiated with a type
arguments vector where each type parameter is instantiated to bounds, so
now the "rare" type check fails and it falls back to the full check of
the instance type arguments, which causes a ~25% regression in some
unoptimized benchmarks.

This CL fixes the generation of those is checks in the FFI transformer
to use the instantiated to bounds version of the Pointer type instead.

TEST=pkg/front_end/test

Issue: https://github.com/dart-lang/sdk/issues/52843
Issue: https://github.com/dart-lang/sdk/issues/52848
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-debug-x64-try,vm-linux-debug-x64-try
Change-Id: Ic9ac6d75ba2743e233065444fad13ab098094349
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312400
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-05 14:24:56 +00:00
Liam Appelbe 13ec07415b [vm] Async FFI callbacks
More details about the design:
https://docs.google.com/document/d/1QDjyY_6wOTOgURwpeYMKU9qEz0gKxx2MUrdruC6Kp6c/edit?usp=sharing

Change-Id: Ie3985d86dca7f5010044ca46c33ca177588c0f69
Bug: #37022
CoreLibraryReviewExempt: Reviewed by vm and api groups. web and wasm groups not affected because FFI isn't on those platforms.
TEST=async_void_function_callbacks_test.dart, ffi_callback_metadata_test.cc, other front end tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305900
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-28 01:00:18 +00:00
Alexander Markov 57863dc64b [vm/aot/tfa] Tree-shake unused libraries
On a large app (which apparently has too many unused dependencies),
size of the AOT kernel file:
before: 464 MB
after: 108 MB

TEST=pkg/vm/testcases/transformations/type_flow/transformer/libraries.dart
Bug: b/287638965
Change-Id: I79a26305c00741babb6a69a18919983b398109e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310772
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-23 20:14:08 +00:00
Aske Simon Christensen 5838562040 [dart2wasm] Add option and target for stringref.
This adds basic infrastructure for a stringref implementation in
dart2wasm:

- A `--[no-]stringref` option to the compiler
- An option in the `WasmTarget`, controlling the name of the target
- Separate sets of patch files for the two targets
- Separate platform dill files for the two targets

For now, the patch file contents are the same, and the compiler flag
is not used by the backend (only by the `dart2wasm` script to select
the appropriate platform dill file). Both of these will change as the
implementation progresses.

Tested: ci + manual check that the option selects the correct dill
Change-Id: I2c9bb95ba06fd3de3f7007703ef545e3f0c728ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310621
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-06-21 14:25:38 +00:00
Martin Kustermann ddc236ba64 [vm] Add @pragma('vm:keep-name') annotation
This allows us to keep symbol names for classes/methods/fields - even if
obfuscation is enabled, but has no other effect on tree shaker / ...

For go/dart-ama

TEST=vm/dart/keep_name_pragma_test

Change-Id: I66c0fc32217d9180f821658bae463f2c1d7fb1af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309740
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
2023-06-16 10:22:23 +00:00
Johnni Winther 545b7c02f7 [cfe] Support redirecting factories in inline classes
Closes #52525

TEST=inline_class/issue52525

Change-Id: Ia2f6e3aa92ddd053f5736150713d9267b89f401c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308621
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-14 10:31:42 +00:00
Johnni Winther 7226c7245e [kernel] Remove RedirectingFactory node
Closes #28421
Closes #29169

TEST=existing

Change-Id: Iee7d84fadc10981648cb327589fd7aa15b9b3e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308140
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-14 06:38:32 +00:00
Johnni Winther 90d5a99c15 [cfe] Remove redirecting factory field
TEST=existing

Change-Id: Ic9f51693d0cc75cbe745dcaa0f4feb26d7005a9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307941
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-13 09:24:28 +00:00
Alexander Markov 4a222e0924 [vm/aot/tfa] Cache types
Hide constructors of types objects and avoid creating extra instances of
types, caching them as necessary.

TEST=existing

Change-Id: I2897888649dd1c4338d6e4000ab0c481d9da3c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308242
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-06-09 14:15:48 +00:00
Tess Strickland c4b6fd687b [pkg/vm] Update test/transformations/type_flow/transformer_test expects.
These changes are needed after the recent changes in c308c932
"[cfe] Ensure Member.isInlineClassMember is set".

TEST=pkg/vm/test/transformations/type_flow/transformer_test

Change-Id: Ibf2c3ee7198175c6cd46f5a423f35619476c8f85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308321
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-09 10:19:28 +00:00
Johnni Winther c308c9327d [cfe] Ensure Member.isInlineClassMember is set
TEST=existing

Change-Id: I16fbeb0bbe431e3f85ed11c21e0506e6aa4abf58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302206
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-06-08 15:02:03 +00:00
Johnni Winther 7cfbb9ee96 [vm] Update test expectations
Expectation output changed by https://dart-review.googlesource.com/c/sdk/+/307121

TEST=existing

Change-Id: I7267d6c09a3a41d4a428cdf3b4507a57049459c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307862
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-08 09:11:27 +00:00
Johnni Winther 82e3a751a9 [cfe] Remove unnecessary_null_comparison code
The frontend is now run with sound null safety so these are no longer needed.

TEST=existing

Change-Id: I6c1776845854695ff34e310a3bb5bc9d86715f06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307901
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-08 08:46:47 +00:00
Johnni Winther 36641368bb [cfe] Treat NonNullableByDefault as default in ast-to-text
This changes ast-to-text to mark legacy libraries instead of
non-nullable-by-default libraries.

TEST=existing

Change-Id: Ib01147e4ef48c2c5b2ffc6b23547998344dfdf2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307121
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-08 06:28:50 +00:00
Alexander Markov 5b6512f54e [vm/aot] Disable signature shaking for 'this' of inline class members
Specification of inline classes has the following rule for
closurization (tear-off creation) of inline class members:

> The operator == of the closurization returns true if and only if
> the operand is the same object.

This means that each time tear-off is taken, a new closure should be
created which compares equal only to itself. This is true iff that
closure has a non-empty context which captures 'this'.

Signature shaking can remove 'this' parameter if it is not used
and this affects equality of the tear-offs of inline class members.
This change prevents that by marking 'this' parameter of inline
class members as checked.

TEST=co19/LanguageFeatures/Inline-classes/dynamic_semantics_member_invocation_A02_t03
TEST=co19/LanguageFeatures/Inline-classes/dynamic_semantics_member_invocation_A03_t03

Issue: https://github.com/dart-lang/sdk/issues/49737
Change-Id: I4cf4f5afdb6c83a1b1eccf587cafcf9a9ca5178a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307665
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-07 16:02:13 +00:00
Alexander Markov c82672780a [vm/aot/tfa] Tree-shaking of inline classes
TEST=pkg/vm/testcases/transformations/type_flow/transformer/inline_class.dart

Issue: https://github.com/dart-lang/sdk/issues/49737
Change-Id: I48faba0767994d254590b311380245718895173e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307661
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-07 15:31:34 +00:00
Alexander Markov 808b4d5bf6 [vm/aot/tfa] Cleanup _FallthroughDetector
Control-flow dependent condition can be used to track statically
unreachable code and so separate AST visitor _FallthroughDetector
is no longer needed.

TEST=ci

Change-Id: I9cec56e0f0a7ec6c451ac1143f3048d2de12f053
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306060
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-02 18:03:38 +00:00
Alexander Markov 486b3b380e [vm/aot/tfa] Fix building of data flow summary in case of break from try/finally
In case of a non-local jump (via 'break' or 'continue') which crosses
try/finally block, 'finally' block is executed, so outgoing state of
the 'finally' block should be used at the target of the jump,
instead of the state at break/continue.

In addition to fixing this bug, this change also slightly improves
precision when merging states in try/catch and try/finally based on
the conditions.

TEST=pkg/vm/testcases/transformations/type_flow/summary_collector/control_flow.dart

Change-Id: Id0aa9fa43e73afe2b7eee217837c11dc586b6008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306663
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-02 17:05:10 +00:00
Devon Carew 7b3305ebee [deps] rev args, bazel_worker, dartdoc, http, leak_tracker, mockito, native, protobuf, pub_semver, shelf, stack_trace, tools, vector_math, webdev
Revisions updated by `dart tools/rev_sdk_deps.dart`.

args (f0f6cd2..a9543c0):
  a9543c0  2023-05-31  Devon Carew  switch to using package:dart_flutter_team_lints (#247)
  36407ea  2023-05-31  Devon Carew  adjust the validation of mandatory options (#246)

bazel_worker (d9b389f..c14a268):
  c14a268  2023-05-31  Kevin Moore  Bump lints, regenerate proto file, fix script (#74)

dartdoc (950898f..39fe1a8):
  39fe1a8a  2023-05-31  Parker Lougheed  Update highlight.js to 11.8.0 for Dart 3 syntax highlighting (#3416)
  4574e819  2023-05-30  Sam Rawlins  Convert kind to an enum (#3426)

http (18a43a2..8834aec):
  8834aec  2023-05-31  Brian Quinlan  Update readme and prepare for a new release (#954)
  aca7f0e  2023-05-31  dependabot[bot]  Bump futureware-tech/simulator-action from 1 to 2 (#936)
  7a238a9  2023-05-31  dependabot[bot]  Bump actions/labeler from 4.0.2 to 4.0.4 (#952)
  4c0eb48  2023-05-30  Brian Quinlan  Prepare to publish cupertino_http 1.0.0 (#951)

leak_tracker (7f2cab3..cbbdeca):
  cbbdeca  2023-05-31  Polina Cherkasova  Improve getting retaining path. (#69)

mockito (40fe2ca..924f65c):
  924f65c  2023-06-01  Ilya Yanok  Add support for records

native (76bc55e..c851e69):
  c851e69  2023-06-01  dependabot[bot]  Bump nttld/setup-ndk (#57)
  0df0cad  2023-06-01  dependabot[bot]  Bump actions/labeler from 4.0.3 to 4.0.4 (#58)
  c30faa2  2023-05-31  Daco Harkes  [c_compiler] test install_name_tool behavior (#56)
  45ef2e7  2023-05-31  Daco Harkes  [c_compiler] Support setting the install name of dylibs (#55)

protobuf (346a72d..da6953c):
  da6953c  2023-05-31  Kevin Moore  Update to latest lints and Dart SDK (#828)

pub_semver (c034352..3930557):
  3930557  2023-05-31  Kevin Moore  Bump lints, require Dart 3.0 (#89)

shelf (a404b6a..ce379aa):
  ce379aa  2023-06-01  dependabot[bot]  Bump actions/labeler from 4.0.3 to 4.0.4 (#363)

stack_trace (86f7e30..8b2046e):
  8b2046e  2023-05-31  Devon Carew  blast_repo fixes (#134)

tools (d723a55..389925f):
  389925f  2023-06-01  Elias Yishak  Utility function added to check permissions on directory (#95)
  a436fee  2023-05-31  Elias Yishak  Asserts added to check all relevant GA4 limitations (#96)

vector_math (cd87f57..a3aca09):
  a3aca09  2023-05-31  Lukas Klingsbo  fix: Revert negation change for Vector2 (#296)

webdev (d442fa8..f565d7f):
  f565d7f1  2023-05-31  Anna Gringauze  Disable flaky test on windows (#2127)
  6eed300e  2023-05-31  Anna Gringauze  Cleanup expression evalaluation tests (#2125)

Change-Id: Ia568db23bbc923f764cdf323e249175b609d57ee
Tested: affected files are regenerated test goldens
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306903
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-06-01 20:12:43 +00:00
Alexander Markov 8b8d063679 [vm/aot/tfa] Fix handling of 'assert' statement
With conditional data flow TFA should model control flow in
'assert' statements more precisely: message expression is not always
executed; variable values and condition should not be propagated down
from message expression.

TEST=language/assert/message_test
Fixes https://github.com/dart-lang/sdk/issues/52503

Change-Id: Iea3b0bae38ab328bd1ad92cacc6b4c3c99f9753f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305342
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-05-25 14:37:48 +00:00
Chloe Stefantsova 3da16e93a9 [cfe] Ensure mixed in class of the mixin has been transformed
Closes https://github.com/dart-lang/sdk/issues/52302

TEST=covered by existing tests

Change-Id: I8f4a1d5b35c5fa3b9d18aa7473d62c5ff7d6aed2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305320
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-25 07:48:52 +00:00
Ryan Macnak c747a25d66 [vm] Add arch-specific bits for Android RISCV64.
TEST=local AOSP build
Bug: https://github.com/flutter/flutter/issues/117973
CoreLibraryReviewExempt: VM-only
Change-Id: I9417e86f025bebee359d8ba50ee6b5c8589c2744
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303011
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-05-22 16:43:04 +00:00
Alexander Markov 6d466bcb41 [vm/aot/tfa] Conditional data flow
This change improves type flow analysis by adding conditional data
flow. Now each statement in the data flow summary can have an optional
condition. If a condition is present, then the statement is applied
only if its condition is not a 'false' constant. The condition may
become false as a result of whole-program type and constant
propagation (constant value is an optional property of a concrete
type).

Conditions in the data flow summary are populated from conditions in
the 'if' statements and conditional expressions. Conditions are
propagated down the control flow while building the summary.
For example:

  if (x) { return foo(); }
  bar();

Call 'foo()' is guarded by condition 'x' and 'bar()' is guarded by
condition '!x'.

Also, a bunch of unary and binary operations are added in order to
represent logical expressions, comparisons with null, 'is' tests and
conditional moves.

This change makes TFA much more sensitive to the control flow.

In order to offset increase in the compilation time due to the
additional condition and operations in the data flow summary,
the following is done:
* Types corresponding to bool constants are canonicalized; condition
  checking and logical operations are performed using fast identical
  checks.
* Fast identical checks are also added to union and intersection of
  types.
* Added more sophisticated simplifications of Join statements.

Along with reduced analysis due to skipped data flow statements with
false conditions, these improvements result in the slightly reduced
compilation time.

AOT compilation time on large Flutter apps (only AOT step 2 / TFA):
App 1: Before: 65.448s After: 62.893s (-3.9%)
App 2: Before: 55.067s After: 52.192s (-5.2%)

AOT snapshot size of large Flutter apps (Flutter release mode, arm64):
App 1: Before: 32910316 After: 32599936 (-0.9%)
App 2: Before: 34464544 After: 34092907 (-1.0%)
Flutter gallery: -1.9%

Performance on micro-benchmark from https://github.com/dart-lang/sdk/issues/51630 in AOT mode:
Before: 0.405839
After: 0.172886 (2.3x faster than before, still slower than JIT)

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_47509.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_51630.dart

Issue: https://github.com/dart-lang/sdk/issues/51630
Fixes https://github.com/dart-lang/sdk/issues/48154
Fixes https://github.com/dart-lang/sdk/issues/47509

Change-Id: I29baf2933972adf83fd58be5ec25be8c30665c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-05-22 16:20:47 +00:00
Ömer Sinan Ağacan c74387a3a2 [dart2wasm] New async implementation
This CL re-implements the async function compilation without using JSPI
or any other platform features.

This implementation is faster than the JSPI-based one in all benchmarks,
in some cases up to 200x (benchmark results at the end). So we remove
the JSPI-based implementation as there's no point in maintaining a much
slower implementation and supporting two implementations at the same
time (which is tricky because these implementations need different
libraries, all scripts need to support two modes etc.) that also
requires experimental platform features.

# Main changes

- A new pass `AwaitTransformer` transforms `await` expressions to
  top-level statements in form `var <fresh variable> = await <simple
  expr>`, where `<simple expr>` is an expression without `await`.

  After this pass all `await` expressions have the simple continuation
  of "assign the value of the awaited future to this variable and
  continue with the next statement". This simplifies `await`
  compilation.

- A new code generator `AsyncCodeGenerator` (inherits from
  `CodeGenerator`) compiles `async` functions. The `_YieldFinder` class
  is copied from `sync*` code generator but modified to handle `async`
  expressions.

- Mentions to the V8 flag `--experimental-wasm-stack-switching` is
  removed from all scripts and documents.

# Future work

- Control flow handling in `AsyncCodeGenerator` needs to be implemented
  in a similar way in `SyncStarCodeGenerator`. Doing this without
  duplicating a lot of code will require some refactoring.

# New passing tests

- co19/Language/Statements/Yield_and_Yield_Each/Yield/execution_async_A05_t01
- co19/Language/Statements/For/Asynchronous_For_in/execution_A02_t02
- language/regress/regress23996_test
- language/sync_star/dcall_type_test

# Benchmarks

Current implementation:

```
AsyncLiveVars.LiveObj1(RunTime): 1586000.0 us.
AsyncLiveVars.LiveObj2(RunTime): 2114000.0 us.
AsyncLiveVars.LiveObj4(RunTime): 1972500.0 us.
AsyncLiveVars.LiveObj8(RunTime): 2212000.0 us.
AsyncLiveVars.LiveObj16(RunTime): 2238000.0 us.
AsyncLiveVars.LiveInt1(RunTime): 2362000.0 us.
AsyncLiveVars.LiveInt4(RunTime): 2470000.0 us.
AsyncLiveVars.LiveObj2Int2(RunTime): 2575000.0 us.
AsyncLiveVars.LiveObj4Int4(RunTime): 2820000.0 us.
Calls.AwaitAsyncCall(RunTimeRaw): 35676.15658362989 ns.
Calls.AwaitAsyncCallClosureTargetPolymorphic(RunTimeRaw): 38934.108527131786 ns.
Calls.AwaitAsyncCallInstanceTargetPolymorphic(RunTimeRaw): 42617.02127659575 ns.
Calls.AwaitFutureCall(RunTimeRaw): 2832.058906825262 ns.
Calls.AwaitFutureCallClosureTargetPolymorphic(RunTimeRaw): 3665.8125915080527 ns.
Calls.AwaitFutureCallInstanceTargetPolymorphic(RunTimeRaw): 4420.449537241076 ns.
Calls.AwaitFutureOrCall(RunTimeRaw): 3692.7621861152143 ns.
Calls.AwaitFutureOrCallClosureTargetPolymorphic(RunTimeRaw): 4625.346901017576 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphic(RunTimeRaw): 4514.6726862302485 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits(RunTimeRaw): 345172.4137931034 ns.
Calls.AwaitForAsyncStarStreamPolymorphic(RunTimeRaw): 697000.0 ns.
Calls.AwaitForAsyncStarStreamPolymorphicManyYields(RunTimeRaw): 704666.6666666666 ns.
Calls.AwaitForManualStreamPolymorphic(RunTimeRaw): 11010.989010989011 ns.
Calls.SyncCall(RunTimeRaw): 0.40275240996973316 ns.
Calls.SyncCallClosureTarget(RunTimeRaw): 0.3989591156672242 ns.
Calls.SyncCallInstanceTargetPolymorphic(RunTimeRaw): 3.2632549336335526 ns.
Calls.IterableSyncStarIterablePolymorphic(RunTimeRaw): 353.3980582524272 ns.
Calls.IterableManualIterablePolymorphic(RunTimeRaw): 332.1161825726141 ns.
Calls.IterableManualIterablePolymorphicManyYields(RunTimeRaw): 354.28067078552516 ns.
```

New implementation:

```
AsyncLiveVars.LiveObj1(RunTime): 11327.683615819209 us.
AsyncLiveVars.LiveObj2(RunTime): 10923.91304347826 us.
AsyncLiveVars.LiveObj4(RunTime): 10956.284153005465 us.
AsyncLiveVars.LiveObj8(RunTime): 11286.516853932584 us.
AsyncLiveVars.LiveObj16(RunTime): 11445.714285714286 us.
AsyncLiveVars.LiveInt1(RunTime): 11016.483516483517 us.
AsyncLiveVars.LiveInt4(RunTime): 11327.683615819209 us.
AsyncLiveVars.LiveObj2Int2(RunTime): 10918.478260869566 us.
AsyncLiveVars.LiveObj4Int4(RunTime): 10737.967914438503 us.
Calls.AwaitAsyncCall(RunTimeRaw): 1082.2510822510822 ns.
Calls.AwaitAsyncCallClosureTargetPolymorphic(RunTimeRaw): 1056.4124234100993 ns.
Calls.AwaitAsyncCallInstanceTargetPolymorphic(RunTimeRaw): 1134.1726210729273 ns.
Calls.AwaitFutureCall(RunTimeRaw): 865.6509695290858 ns.
Calls.AwaitFutureCallClosureTargetPolymorphic(RunTimeRaw): 841.3967185527977 ns.
Calls.AwaitFutureCallInstanceTargetPolymorphic(RunTimeRaw): 839.066957543212 ns.
Calls.AwaitFutureOrCall(RunTimeRaw): 397.9941096871766 ns.
Calls.AwaitFutureOrCallClosureTargetPolymorphic(RunTimeRaw): 406.17384240454913 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphic(RunTimeRaw): 393.7472929873607 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits(RunTimeRaw): 1095.0503723171266 ns.
Calls.AwaitForAsyncStarStreamPolymorphic(RunTimeRaw): 6643.426294820717 ns.
Calls.AwaitForAsyncStarStreamPolymorphicManyYields(RunTimeRaw): 7178.750897343863 ns.
Calls.AwaitForManualStreamPolymorphic(RunTimeRaw): 1456.23998835008 ns.
Calls.SyncCall(RunTimeRaw): 0.3919935321067202 ns.
Calls.SyncCallClosureTarget(RunTimeRaw): 0.3906669661780074 ns.
Calls.SyncCallInstanceTargetPolymorphic(RunTimeRaw): 3.1676143112814583 ns.
Calls.IterableSyncStarIterablePolymorphic(RunTimeRaw): 104.4932079414838 ns.
Calls.IterableManualIterablePolymorphic(RunTimeRaw): 104.57516339869281 ns.
Calls.IterableManualIterablePolymorphicManyYields(RunTimeRaw): 116.92487576731949 ns.
```

TEST=ci
CoreLibraryReviewExempt: Added entry-point pragmas.
Change-Id: I02fbd08141f51c00fb37b6fa0304dc25d6afdb71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301020
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-05-22 08:32:12 +00:00
Nate Bosch 17c626f8b3 Remove some getters for final fields
These were original getters without any fields. After adding fields
to cache the values instead of rereading them on each access the
forwarding public getters became redundant but were not removed.

Make the fields public, remove the getters, and move the docs from the
getters to the fields.

Change-Id: Ie078f5b85cf85f8f86642ac6fe8d36f4107602ee
CoreLibraryReviewExempt: Only impacts VM platform.
Tested:No behavior changes expected. Confirmed updated fields can be read on VM.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304324
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-05-19 00:52:57 +00:00
Johnni Winther 13c4ad23c5 [kernel] Add SwitchStatement.expressionType
This adds the static type of the switch statement expression to
the AST to better support optimizations based on the possible
runtime values of the switch expression.

TEST=existing

Change-Id: Ief35b687150401100d8c96721a026e9f0911b3b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301063
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-05-08 07:39:02 +00:00
Johnni Winther 009cbfbeac [kernel] Merge front_end and kernel verifiers
This merges the front_end and kernel verifiers into one Target based
kernel verifier. The RedirectingFactoryBody work-around is moved to
package:kernel to support its verification.

TEST=existing

Change-Id: I0adf4d2c22c4009cf439b3b23fa14192253a2846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280161
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-26 14:14:36 +00:00
Stephen Adams 45efccb5e0 Remove left-over patch declarations for List constructor.
This CL replaces https://dart-review.googlesource.com/c/sdk/+/296900

The `List` constructor is removed in Dart 3.0.
Some of the `@patch` implementations were not removed.

This is *high priority*. It seems the left-over `@patch factory List` constructor did not cause any errors, instead it *added* a constructor  to `List` that can be used in web compiled code. Even if `List` doesn't have such a constructor in the SDK code proper.
The VM and analyzer will say the invocation is an error, but dart2js happily compiles it and runs.

(It used to be that patches couldn't add public members, that security seems to have been removed.)

Also removes code which tries to detect "the unnamed List constructor",
which is no longer a thing, and a number of invocations of the constructor, where it's not clear that the test is aware that the constructor no longer exists, and is not marked as `@dart=2.x` with x < 12.

TEST=ci

Change-Id: I4ffaf3ae2c4e75ca06e7ba0bf19187b6376f3888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297100
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-22 00:38:28 +00:00
Daco Harkes fa3a72fa7e [cfe/ffi] Error on compound constructors
TEST=co19/LibTest/ffi/Struct/Struct_A02_t01
TEST=co19/LibTest/ffi/Union/Union_A03_t01
TEST=co19/LibTest/ffi/Union/Union_A03_t02
TEST=co19/LibTest/ffi/Union/Union_A03_t03
TEST=co19/LibTest/ffi/Union/Union_A04_t01

Closes: https://github.com/dart-lang/sdk/issues/46813
Change-Id: I2a057613a62eccc0de81083a6f63f8ba68430fc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293684
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-17 11:03:57 +00:00
Jens Johansen cc40e17fd9 [CFE][ffi] Support FFI Finalizable transformation of redirecting factories
A redirecting factory is normally encoded as something like

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar
    return new self::Foo::•(bar: bar);
```

which the CFE also expects to recreate its internal state when loading
a dill file.

The Finalizable transformation from FFI can change that to something
like:

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar {
    return block {
      final synthesized self::Foo :expressionValueWrappedFinalizable = new self::Foo::•(bar: bar);
      _in::reachabilityFence(bar);
    } =>:expressionValueWrappedFinalizable;
  }
```

though, which the CFE doesn't understand and subsequently crashes as
in https://github.com/flutter/flutter/issues/124369

This CL makes the CFE understand this transformed version,
fixing the crash.

TEST=Existing tests; added incremental compiler test.

Change-Id: I5e7a5fc6201e4419e9ec1ca69d5522d5190f1f83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294761
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-13 07:50:38 +00:00
Lasse R.H. Nielsen 2a38b22aed Add a few more class modifiers.
Mostly interface on classes that can't be extended anyway.
A few `final` implementation classes.

Tested: No new functionality, only restrictions.
CoreLibraryReviewExempt: Just modifiers.
Change-Id: I1f298fe43836892c94c0b23326fda37b1904ec6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293683
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-07 21:54:44 +00:00
Daco Harkes 2d61150905 [cfe/ffi] Fix missing type argument on @Native
TEST=tests/ffi/regress_51913_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51913
Change-Id: I79746f3b3852f34d7e31b32260ce5abcb2d6801a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-04-05 16:24:30 +00:00
Daco Harkes 4b5401bfb2 [cfe/ffi] Fix compiler crash on invalid Array type
And report error on invalid type nested in `Array`.

TEST=co19/LibTest/ffi/Array/Array.multi_A03_t02
TEST=co19/LibTest/ffi/Array/Array.multi_A03_t04
TEST=co19/LibTest/ffi/Array/Array_A03_t02
TEST=co19/LibTest/ffi/Array/Array_A03_t04

Bug: https://github.com/dart-lang/sdk/issues/51958
Change-Id: Ida650f2c7c93ebce8c93a1dc5a5b4b222166438b
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-05 16:00:54 +00:00
Daco Harkes 8765f93404 [cfe/ffi] Error on 0-size array
TEST=co19/LibTest/ffi/Array/Array.multi_A02_t01

Bug: https://github.com/dart-lang/sdk/issues/51958
Closes: https://github.com/dart-lang/sdk/issues/45540
Change-Id: I33f84b829968f7f8496710c6facaa489b741b2fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-04-05 09:17:58 +00:00
Brian Quinlan 9c702bc72e Add Dart 3 class modifiers to dart:io.
Change-Id: Ia6eda18bb4ad6ae9f2705846e262f793f73d1e4f
Tested: class type changes
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291343
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-04-04 19:06:21 +00:00
Lasse R.H. Nielsen 67797ef46f Add more class modifiers to dart:collection.
Pure interfaces made `interface`s
implementation classes which cannot/should not be extended made `final`.

A class like `HasHMap` which provides the `Map` interface,
and no implementation except factory constructors
for internal implementations, is made `final`.

Unified {List,Set,Map}{Base,Mixin} into their `Base` class.
Deprecations are retained in comments for now, to be landed
separately. Search for '// TODO: @Deprecated'.

Tested: No new test, only adding restrictions on use.
CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: Ia83b8a3bb20b5b214546b328d4492de6658253db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288240
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-04 10:39:48 +00:00
Daco Harkes 7a90dd0c4f [cfe/ffi] Remove custom FFI checks covered by class modifiers
Tests are in the following files 3.0 and pre-3.0 respectively.
TEST=tests/ffi/vmspecific_static_checks_test.dart
TEST=tests/ffi_2/vmspecific_static_checks_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: Ib0b27590748ef788c5475929fde585c790f64e63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291064
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-03-27 12:15:22 +00:00
Nate Bosch 4271aaacfd Bump test to cc0598b2c3bf3a7439f10f9542a8d01ff50b69e9
Changes:
```
> git log --format="%C(auto) %h %s" 3ba78f1..cc0598b
 https://dart.googlesource.com/test.git/+/cc0598b2 Move to `expect` from `package:matcher` (1969)
 https://dart.googlesource.com/test.git/+/0e5c028d Only use environment variable for chrome (1970)
 https://dart.googlesource.com/test.git/+/0b08d704 Add a hooks_testing library (1952)
 https://dart.googlesource.com/test.git/+/aacee2c7 Retry filesystem deletes (1965)

```

Diff: https://dart.googlesource.com/test.git/+/3ba78f15538399073d0b5aba4ec19b1378af1625..cc0598b2c3bf3a7439f10f9542a8d01ff50b69e9/
Change-Id: Iddfbc7d804a9864a77268fc0636a2962a2370e49
Tested: updated test expectations for content from the changed packages
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289886
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-03-21 21:37:57 +00:00
Daco Harkes 92e5746494 Reland "[vm/ffi] Add class modifiers"
This is a reland of commit 1755f89092

Can land after (or with) the Flutter PR:
https://github.com/flutter/engine/pull/40434

Original change's description:
> [vm/ffi] Add class modifiers
>
> Adds class modifiers to `dart:ffi`.
>
> Migrates all user-defined subclasses of `Struct`, `Union`, `Opaque`,
> and `AbiSpecificInteger` to be `final class`es.
>
> Does not remove the manual error checking, so some errors will show up
> twice now in language version 3.0. In language version <3.0, only the
> FFI-specific error will show up.
>
> In a follow-up CL, we will try to make the language-errors to show up
> also <3.0 so that we can remove the FFI-specific errors.
>
> Examples of duplicated errors:
> pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart
>
> TEST=pkg/analyzer/test/ (for the analyzer)
> TEST=pkg/front_end/testcases/ (for the CFE)
> TEST=test/ffi/ (for the VM)
>
> CoreLibraryReviewExempt: No need for dart2js to review.
> Bug: https://github.com/dart-lang/sdk/issues/51683
> Change-Id: I2964ceccb7db59fbdaf6be5319f5e4ec2dabe0f3
> Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289223
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Devon Carew <devoncarew@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Jackson Gardner <jacksongardner@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TEST=pkg/analyzer/test/ (for the analyzer)
TEST=pkg/front_end/testcases/ (for the CFE)
TEST=test/ffi/ (for the VM)
CoreLibraryReviewExempt: No need for dart2js to review.
Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: I2ee3f0ac31d4162068a2346a06320029b2263ee2
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289781
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-03-21 15:25:10 +00:00
Ryan Macnak 2cc96bfa0b [vm] Add an ABI for Fuchsia RISC-V.
https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0211_fuchsia_on_risc-v

TEST=./tools/build.py -mrelease -asimriscv64 gen_snapshot_fuchsia gen_snapshot_product_fuchsia
CoreLibraryReviewExempt: VM-only
Change-Id: Ie62addda6c15a5b44e814c49b543319aef4fc5e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281869
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-20 20:46:27 +00:00
Johnni Winther 6d2e6f9452 [cfe] Improve switch encoding
Addresses https://github.com/dart-lang/sdk/issues/51554#issuecomment-1466946211

Closes #51391

TEST=existing

Change-Id: Idec105dcfde4a91d0a21a1907777d6c07e5f01b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289224
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-20 15:21:52 +00:00
Lasse R.H. Nielsen 162ff41b0e Add class modifiers to dart:async.
* Pure interfaces marked `interface`. That's most public classes.
* `Stream` made `mixin class`, as a proper skeleton/base implementation.
* `Zone` classes made all `final`.

Added some `<void>` to raw `Future` types.

CoreLibraryReviewExempt: Aske is away.
Tested: No functionality change, only added restrictions.
Change-Id: I91d09fbcdba7d0dfdff3887bc7c9d54364c88b05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289221
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-03-20 12:12:46 +00:00
Zach Anderson 7471994270 Revert "[vm/ffi] Add class modifiers"
This reverts commit 1755f89092.

Reason for revert: This is a breaking change and is blocking the Dart -> Flutter roll. See https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20Unopt/26896/overview.

Original change's description:
> [vm/ffi] Add class modifiers
>
> Adds class modifiers to `dart:ffi`.
>
> Migrates all user-defined subclasses of `Struct`, `Union`, `Opaque`,
> and `AbiSpecificInteger` to be `final class`es.
>
> Does not remove the manual error checking, so some errors will show up
> twice now in language version 3.0. In language version <3.0, only the
> FFI-specific error will show up.
>
> In a follow-up CL, we will try to make the language-errors to show up
> also <3.0 so that we can remove the FFI-specific errors.
>
> Examples of duplicated errors:
> pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart
>
> TEST=pkg/analyzer/test/ (for the analyzer)
> TEST=pkg/front_end/testcases/ (for the CFE)
> TEST=test/ffi/ (for the VM)
>
> CoreLibraryReviewExempt: No need for dart2js to review.
> Bug: https://github.com/dart-lang/sdk/issues/51683
> Change-Id: I2964ceccb7db59fbdaf6be5319f5e4ec2dabe0f3
> Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289223
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Devon Carew <devoncarew@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Jackson Gardner <jacksongardner@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: Ie5b8a08aea6d64b1991ace4814322b21ffb670c7
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289640
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-03-20 11:15:59 +00:00
Daco Harkes 1755f89092 [vm/ffi] Add class modifiers
Adds class modifiers to `dart:ffi`.

Migrates all user-defined subclasses of `Struct`, `Union`, `Opaque`,
and `AbiSpecificInteger` to be `final class`es.

Does not remove the manual error checking, so some errors will show up
twice now in language version 3.0. In language version <3.0, only the
FFI-specific error will show up.

In a follow-up CL, we will try to make the language-errors to show up
also <3.0 so that we can remove the FFI-specific errors.

Examples of duplicated errors:
pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart

TEST=pkg/analyzer/test/ (for the analyzer)
TEST=pkg/front_end/testcases/ (for the CFE)
TEST=test/ffi/ (for the VM)

CoreLibraryReviewExempt: No need for dart2js to review.
Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: I2964ceccb7db59fbdaf6be5319f5e4ec2dabe0f3
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289223
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-03-17 19:29:41 +00:00
Alexander Markov 295e210975 [vm/aot] Unbox records using inferred record shapes
Unboxing of records in return values is switched to use inferred record
shape instead of a static type. This is more accurate, as
static return type 'Object', 'dynamic' or a type parameter would
not prevent record unboxing.

TEST=runtime/tests/vm/dart/records_return_value_unboxing_il_test.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/unboxed_records.dart

Issue: https://github.com/dart-lang/sdk/issues/49719
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I56528e114bc2de94c4a1ec09c48eb5b9ed3c3d3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288824
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-15 17:34:37 +00:00
Alexander Markov 877245d705 [vm/tests] Update expectations for pkg/vm/test/transformations/type_flow/summary_collector_test
TEST=pkg/vm/test/transformations/type_flow/summary_collector_test
Closes https://github.com/dart-lang/sdk/issues/51692

Change-Id: Ib45863063e1d0f98355b627198ef309ef1672d21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288301
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2023-03-12 09:35:39 +00:00
Johnni Winther 04e6f4c282 [kernel] Add VariableDeclaration.isSynthesized
This adds an [isSynthesized] flag to the [VariableDeclaration] the
signal when the variable doesn't correspond to a variable in the
source code.

The name of a variable can only be `null` if it is synthesized.

Partially in response to
https://github.com/dart-lang/sdk/issues/51554

TEST=existing

Change-Id: I94591971f11da09d210c8b25a2d05e22ca05dc62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286961
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-10 11:13:36 +00:00