Commit graph

23203 commits

Author SHA1 Message Date
Ryan Macnak 1a9acb9171 [vm, ffi] Make callbacks profiler-safe.
Delay changing Thread::vm_tag on callback entry and restore the tag early on callback return so that the profiler doesn't see the "running Dart" tag unless it can also see the fake return address marking the entry frame.

TEST=ffi/async_void_function_callbacks, ffi/function_callbacks_subtype, ffi/function_callbacks, ffi/isolate_local_function_callbacks
Bug: https://github.com/dart-lang/sdk/issues/52814
Change-Id: I40d80ec7c44063d078db0e211565e2d127c6b81e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367460
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-05-28 21:16:41 +00:00
Ömer Sinan Ağacan a0f1bd5a4b Update test for #45060
Equal types should have the same hash, but they are not necessarily
identical.

Update the test to remove the identity check between a constant type and
a type constructed in runtime.

Change-Id: I0d6c6395c587391d3087c26b00fff36d645b33dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368340
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-05-28 07:10:39 +00:00
Martin Kustermann 827a7c4e95 [dart2wasm] Only perform compile-time lookup in constant list if index is in-bounds
We have an optimization that will do list lookups at compile time when
the receiver is a constant list and the index is a constant integer.

=> We should only perform this optimization if index is in-bounds.
=> If it's out-of-bounds it should be a [RangeError] thrown at runtime
   (if that code is ever executed)

Closes https://github.com/dart-lang/sdk/issues/55817

Change-Id: I3e99cdd96c79e7ff3f490babb2d52131cbd83a88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368302
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-05-27 11:52:48 +00:00
Ivan Inozemtsev 72b2883c6f Revert "[js_runtime, js_dev_runtime] Implement microsecond field of DataTime"
This reverts commit fb057ea4e0.

Reason for revert: b/342552853

Original change's description:
> [js_runtime, js_dev_runtime] Implement `microsecond` field of `DataTime`
>
> - Move DateTime implementation for dart2js and DDC into a shared place to reduce duplication.
>
> - Add a _microsecond field to the web DateTime to track microseconds outside of the JavaScript Date.
>
> - The cute dart2js optimization whereby `DateTime.now().millisecondsSinceEpoch` is compiled to `Date.now()` still works.
>
> - Both implementations report better errors.
>
> - Fixed VM bug with in-range sentinel.
>
>
> Change-Id: I9156255bdb6ecc195500ae9bc88f91fb315b6297
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366963
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Stephen Adams <sra@google.com>

Change-Id: I58572256a7710df4589bb5e41c7afee295c2388b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368103
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-05-27 07:54:14 +00:00
Kallen Tu 70b9b4637b [wildcard-variables] Add async rethrow test and wildcard patterns.
Fix follow up comments with an async rethrow test.
Tests that wildcard patterns still work while mixed with wildcard variables.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: If6ab4de68ff27ad51215427a7183f1aed7229947
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367501
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-05-24 18:40:47 +00:00
Simon Binder 6b71aa1f3e [dart2wasm]: Add compile-time define identifying tool
Knowing whether Dart code is running in a WebAssembly context is useful
to potentially select different code paths exploiting differences in
JavaScript and WASM behavior or simply to report the information to
users (e.g. for crash reports).

Without such a constant, one has to rely on implementation differences
such as `identical(0, 0.0)` or check the available `dart:` libraries.
Both are error-prone, so having a reliable constant as an alternative
makes this easier.

Closes https://github.com/dart-lang/sdk/issues/55694

Change-Id: Ia969641e4b78223c394cbf251805cf77a30cb0fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365822
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-05-23 10:51:50 +00:00
Sam Rawlins c386ca52d7 Clean up ex-multitest: number/identifier_test
I convert the `noSuchMethod` tests to (imho) simpler tests of what
property access of `e` or `d` or `D` would look like on an int, via
extension getters.

The noSuchMethod test as it was written cannot be executed at runtime,
because (as of Dart 2, I think, maybe earlier), property access on
expressions is a compile-time consideration. And I think as a compile-
time error test, it's hard to see what it's testing.

Change-Id: I5c0ca728e6e812b8f35adb80b288be351c4b076a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367461
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2024-05-23 01:19:59 +00:00
Paul Berry 14c15d936a Fix detection of record field name mismatch in subtype matching.
Fixes #55802.

Bug: https://github.com/dart-lang/sdk/issues/55802
Change-Id: I9f9488cb09243679965ee891c45bee293af5056a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367462
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-05-22 14:22:00 +00:00
Stephen Adams fb057ea4e0 [js_runtime, js_dev_runtime] Implement microsecond field of DataTime
- Move DateTime implementation for dart2js and DDC into a shared place to reduce duplication.

- Add a _microsecond field to the web DateTime to track microseconds outside of the JavaScript Date.

- The cute dart2js optimization whereby `DateTime.now().millisecondsSinceEpoch` is compiled to `Date.now()` still works.

- Both implementations report better errors.

- Fixed VM bug with in-range sentinel.


Change-Id: I9156255bdb6ecc195500ae9bc88f91fb315b6297
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366963
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-05-22 05:18:52 +00:00
Kallen Tu bd8f87d477 [wildcard-variables] Test non-binding behaviour with top-level declarations.
Added a little section for late wildcard variables too.

This CL tests mixing top-level wildcard declarations with local wildcard declarations and the non-shadowing, non-binding behaviour.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: I72e7cfb1b2d80a3934af355579c36252881cf3fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367241
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-05-21 22:15:11 +00:00
Kallen Tu 03ea9eb524 [wildcard-variables] Basic language tests for non-binding locals.
Making language tests in small batches. These are very basic ones to test that you can have multiple local declarations named `_` in the same namespace without a collision error.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: I4d00e9072ba745b363d68db72505c599953c41ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366022
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-05-17 17:25:41 +00:00
Martin Kustermann 8fa0675a6d [dart2wasm] Make optimized builders run with --use-sdk (and therefore dart compile wasm)
This gives some more coverage for `dart compile wasm`

Change-Id: I62e7f9c6ecbdf80a1445c35d1733a7f89e6bcf54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366623
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-05-17 13:08:31 +00:00
Martin Kustermann e6e9b4e595 [dart2wasm] Only share type parameter fields if nullability allows
Closes https://github.com/dart-lang/sdk/issues/55741

Change-Id: I1e542041496d07714431ed40871031a117030736
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366940
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-05-17 12:07:56 +00:00
Devon Carew 2837647bea [wiki] move the https://github.com/dart-lang/sdk/wiki to the docs/ dir
Change-Id: I28db796fadcc111d97d3589bf3988ea0bbb8e18a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366682
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-05-16 18:19:40 +00:00
Paul Berry c734d583c1 Prevent .call tearoff on expressions whose type is a nullable type variable.
Note that this is not a breaking change, since the CFE already
correctly flags the error condition.

Fixes #55734.

Bug: https://github.com/dart-lang/sdk/issues/55734
Change-Id: I5570e0840ce20c2a761d88f698b9876f7543bd8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-05-16 16:44:29 +00:00
Stephen Adams 762ca98456 [corelib] Update date_time_far_away_dates_test
Bug: #37442
Change-Id: I0c04136bc4fdbf2908154a608f09311c5c511da5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366720
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-05-16 14:19:18 +00:00
Lasse R.H. Nielsen b06a34fc5a Don't allow completing a _Future with itself.
This never worked. It was silently accepted, at least if the future had no listeners, then any later attempt to use the future would cause a stack overflow or other impossible results.

Moves some `_Future._complete` call out of try-catch.
The `_complete` shouldn't throw (but before this fix it could).
Moving them out of the `try`/`catch` makes such errors be reported
as unhandled, instead of catching them and trying to complete the same
future again with an error, when it's possibly in an inconsistent state.

Fixes #43662.
Based on https://github.com/dart-lang/sdk/issues/43662#issuecomment-2058870247

CoreLibraryReviewExempt: No response.
Bug: http://dartbug.com/43662
Change-Id: I96a4f01bcd5b6cee93bba267299852569a9b905c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363060
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-05-14 15:44:07 +00:00
Martin Kustermann 3dfee274cc [dart2wasm] Use TFA-inferred types also for static fields
Currently the type of a static field is only based on the dart type, not
inferred types. This can mean that the type of such field is e.g.
`dynamic`.

Though the return type of the initializer function used the unboxing
information.

=> There was an invariant that if we use `null` to signal uninitialized
in the global, then calling the initializer will also result in a
non-nullable reference type.

=> This was invariant was broken by recent changes to dart2wasm that
take advantage of TFA-inferred unboxing information.

=> We fix this inconsistency by ensuring the wasm global's type is the
same as the initializer function's return type.

Change-Id: I9c27c0b28d2f81f888b4c9afc59dad42af2229ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365825
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-05-14 07:29:53 +00:00
Paul Berry 5b020f2ee6 [cfe] Make type inference for if-null expressions consistent with analyzer.
Fixes https://github.com/dart-lang/language/issues/3650.
Fixes https://github.com/dart-lang/sdk/issues/55436.

Bug: https://github.com/dart-lang/language/issues/3650
Change-Id: I30b39221c85713aab10f2edc35625f38e34cae5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362100
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-05-08 20:05:18 +00:00
Paul Berry 497d6105df [cfe] Make the context for await expressions consistent with analyzer.
Fixes https://github.com/dart-lang/language/issues/3649.
Fixes https://github.com/dart-lang/sdk/issues/55418.

Bug: https://github.com/dart-lang/language/issues/3649
Change-Id: Ifb2fe47bb343a357e2338843775f140c01bd8a88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361302
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-05-08 17:10:52 +00:00
Martin Kustermann bb044733cd [vm]/[dart2wasm] Fix list factory specialization code
The list factory specialization code can only know constant values
passed to `growable: <xxx>` if the variables are local and not
parameters.

TEST=corelib/list_factory_specialization_regression_test

Change-Id: I2c425108fd266fea6b443a7adee86c5a2b33a4d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365584
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-05-08 08:59:01 +00:00
Lasse R.H. Nielsen 281241ea71 Retire inference-update-3 experiment introduced in Dart 3.4.
The expriment is now retired in Dart 3.5, and the flag
stops being valid.

Change-Id: I1ecb087d45b90e98a7f0d3c15a6c8038a1c6982e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365260
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-05-03 12:26:59 +00:00
Martin Kustermann 74fbb380e2 [dart2wasm] Use concrete classes for wasm type representation selection
For example code that uses `Completer` in parameters/fields/...
used to be represented as `Object` in wasm type system, which we
can now represent instead as `_Completer`.

Change-Id: I35b2d8cb45717e58a813756dfa6278804552fbcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365020
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-05-02 12:28:48 +00:00
MarkZ 842c0981b2 [reload_test] Adding several new reload tests.
Change-Id: Ia654e827d7758d44ece6e52f4d8a15aae4f90e97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365122
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-05-01 20:01:19 +00:00
Paul Berry b026068313 Flow analysis: fix handling of list pattern type promotion.
When analyzing the type test implied by a pattern, flow analysis uses
three variables to control promotion behavior:

- `matchFailsIfWrongType`, which indicates whether flow analysis needs
  to account for the possible control flow path resulting from the
  type test failing. (This is `false` for cast patterns, because in
  the case where a cast pattern fails, an exception is thrown).

- `matchMayFailEvenIfCorrectType`, which indicates whether flow
  analysis needs to account for the possible control flow path
  resulting from the type test succeeding, but some other check
  causing the match to fail. (This is `true` for most list patterns,
  because the list pattern will fail to match if the list has the
  wrong length).

  (Note that `matchMayFailEvenIfCorrectType` doesn't account for the
  fact that a pattern match might fail due to failure in a subpattern
  match; this is automatically handled by the fact that flow analysis
  walks through the complete pattern in the order in which it
  executes.)

- `coversMatchedType`, which indicates whether the type test is
  guaranteed to succeed due to a subtype relationship between the
  matched value type and the type being tested (e.g. a `num x` pattern
  is guaranteed to succeed if the matched value type is `int`).

In the case where `matchFailsIfWrongType` is `true`,
`matchMayFailEvenIfCorrectType` is `true`, and `coversMatchedType` is
`false`, flow analysis must account for the fact that there are two
ways that the pattern match might fail: the type test might fail, or
the type test might succeed but then the pattern match might fail for
some other reason.

Before this change, this was done incorrectly, and flow analysis only
accounted for the possibility of the type test failing.

Fixes #55543.

Bug: https://github.com/dart-lang/sdk/issues/55543
Change-Id: I86603ec5f940402313f32177212b7960878db97f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364942
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-05-01 17:12:00 +00:00
Konstantin Shcheglov 33f0388776 Test. Support for optinal 'deferred as' to find URIs.
Change-Id: I923b65931de5d7ac56bea0b356474113ebb9a778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364627
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-01 15:45:58 +00:00
Martin Kustermann 24370b42b0 [dart2wasm] Represent ffi compounds as actual Dart objects (they are views on the actual memory)
This fixes issues where structs are accessed dynamically
or simply accessed in a nullable fashion, e.g. with `MyStruct? foo`

dart2wasm does not yet support using structs-by-value as arguments
or return values when calling linear-memory wasm functions.

dart2wasm also doesn't support structs-by-value created in dart
that are backed by WasmGC memory (e.g. arrays).

Change-Id: I9b9c60002d2d32db3f235f1cec25fe3b35fcc17b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365140
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-05-01 10:33:20 +00:00
Ryan Macnak d42a4b7219 [test] Run FFI tests on Fuchsia ARM64.
- Compile tests to kernel and use that instead of source for the Fuchsia test package.
 - Skip multitests instead of the running them and approving the failures.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38752
Change-Id: Idd9bef0f6026c6d882712eb1083e88433bb53b13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333121
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-04-30 17:37:45 +00:00
Ryan Macnak 1ff4f72ebc Mark file system event tests as slow.
Restore timeout for windows-arm64, which did not get faster.

Change-Id: I9f032c25fc69454929348f0589d35200a4728142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364625
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-04-26 23:46:17 +00:00
MarkZ 6357371c0a [reload_test] Adding diffs to existing tests.
Change-Id: Icf7135ae46159ca834a54849c72405eec83f9b4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364384
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-04-26 23:05:10 +00:00
Ryan Macnak f02007839d [test_runner] Reduce timeouts.
We've roughly doubled bot speeds; half timeouts to provide pressure against this simply getting filled with slower tests.

Change-Id: I812da7adc6c08e6d484732c2558e0d3f63b2694a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364385
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-04-26 21:39:34 +00:00
Srujan Gaddam 307d739158 [dart:js_interop] Fix lowerings of ExternalDartReferences
Closes https://github.com/dart-lang/sdk/issues/55549
Closes https://github.com/dart-lang/sdk/issues/55340

Fixes several issues around using ExternalDartReferences:
- Better inlining of interop methods is enabled when this
type is used. This also indirectly improves inlining when
using JSAny.
- Adding some missed inlining for setting properties in
general.
- Allows opaque references of Dart functions to be passed
to JS
- Allows type parameters that extend ExternalDartReference
to be used in interop methods.
- Fixes up parent pointers of nodes in transforms.

Change-Id: I8cbd163ee3c1b98e733c35a61e6e83a0787d334c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364580
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-04-26 19:08:13 +00:00
Lasse R.H. Nielsen b464fc9037 Reland "Tweak expect.dart library."
This reverts commit cd2c566bcf.

Reason for revert: Updating to not remove field used by Flutter engine.

Original change's description:
> Revert "Tweak `expect.dart` library."
>
> This reverts commit ff5f391c0a.
>
> Reason for revert: The expect library is used by Flutter engine, and some of its tests use assertStatementsEnabled. There should be a migration path that doesn't require an atomic change, like adding the replacement api before removing the old one.
>
> Original change's description:
> > Tweak `expect.dart` library.
> >
> > Make API more consistent for a few methods.
> > Reduce the number of language features used in tests:
> > * Never iterating an iterable, always converting it
> >   using `.toList()` first and iterating using indices
> >   (fx `setEquals`).
> >   Also require a `List` in places where an `Iterable`
> >   wasn't necessary.
> > * Avoid doing complicated computations that are also
> >   used for the error message. Do simple check first,
> >   then recompute to get better error messages
> >   (fx `allDistinct`).
> >
> > Renamed some rarely used members for consistency
> > (`stringContainsInOrder`->`containsInOrder`,
> > where other string-contains functions just start
> > with `contains`, and `containsOneOf` -> `containsAny`
> > to match `Iterable.any` phrasing, and also it accepts
> > if containing at least one, not precisely one.)
> >
> > Removed a function that wasn't used anywhere.
> >
> > Moved `assertStatementsEnabled` to `variations.dart` as `asserts`.
> > Removed `typeAssertionsEnabled` and `checkedModeEnabled`. The former used in one place, where it was replaced with `checkedImplicitDowncasts` from `variations.dart`, the latter wasn't used anywhere.
> >
> > Deprecates `package:expect/minitest.dart`. It was never intended
> > to be used for new tests, only as a help to convert existing tests
> > written against `package:unit_test`.
> > All existing imports marked as `// ignore: deprecated_member_use`.
> >
> > Change-Id: I07e21d4c0f3ccf11b82ee34af2668fdbb22264d2
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352360
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Reviewed-by: Ömer Ağacan <omersa@google.com>
> > Reviewed-by: Nate Bosch <nbosch@google.com>
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Commit-Queue: Lasse Nielsen <lrn@google.com>
>
> Change-Id: I360b4347470a0bb2b63c3108e2b83ee2a771bf3f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362020
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Stephen Adams <sra@google.com>
> Reviewed-by: Leaf Petersen <leafp@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: William Hesse <whesse@google.com>

CoreLibraryReviewExempt: Reland
Change-Id: I53db40edc0733842a008839c3913d51c885e39ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362502
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-04-26 15:28:26 +00:00
Johnni Winther dd3fbffac7 [cfe,analyzer] Support new as identifier in metadata
The parser didn't support 'new' as identifier in this context.

The CL also adds the reporting of tear-offs as metadata for the CFE.
This was already handled by the analyzer.

Change-Id: I7ab5868fa83e5f216d0e7be7ae9cec4a2c865e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364480
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-04-26 14:00:04 +00:00
Martin Kustermann 350954ae9d [dart2wasm] Fix this restoration code in sync* handling.
Noticed that the same bug that was fixed in [0] also exists in other
places.

=> Remove duplicated code & share in macro assembler.
=> Make use of this in async & sync* generator.

[0] https://dart-review.googlesource.com/c/sdk/+/364321

Change-Id: Id424ab5e8ed8ab70d19977d10cf80fb8b44b3872
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364441
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-04-25 10:38:35 +00:00
Daco Harkes 4b66657b98 [vm/ffi] address of operator for FFI leaf calls
During FFI leaf calls, the Dart GC will not run. This means that we
can pass pointers into `TypedData` to FFI calls that take `Pointer`
arguments.

After this CL, we have three types of arguments that can flow into
`Pointer` argument in an FFI call:
* `Pointer`.
* `TypedData`: Any typed data including views.
* `_Compound`: A TypedData/Pointer and an offset in bytes.

The is only possible for `@Native external` functions, `asFunction`
does not support passing in `TypedData`. (See related GitHub issues
for discussion. TLDR: FFIgen should generate bindings without config.)

`.address` expressions on `TypedData` and `Array` elements do _not_
introduce bounds checks, even though `TypedData` and `Array` have
bounds information. E.g. `ffiNative(Uint8List(10)[20].address)` does
not throw.

Implementation details:

The CFE analyzes call-sites to `@Native external` functions. If the
arguments are `.address` expressions, it transforms the call site to
pass the compound or `TypedData`. If an additional offset needs to be
applied, the CFE constructs a new `_Compound` with the correct offset
in bytes.

The CFE then also creates a new `@Native external` function which have
`TypedData`s and `_Compound`s parameters. To avoid name clashes, these
functions are postfixed with `#` and `P`, `T`, or `C` for each Pointer
parameter.

TEST=pkg/vm/testcases/transformations/ffi/address_of_*

In the VM, `TypedData` arguments are passed as tagged values, and the
address is loaded inside the `FfiCallInstr`. `_Compound` arguments
turn into two IL definitions, one for the `TypedDataBase` (tagged),
and one for the offset in bytes (unboxed). The address is then loaded
inside the `FfiCallInstr` and the offset in bytes is applied.

Adding the offset in bytes required an extra temp register for ia32.
Also, it uncovered that the temp register in arm32 was conflicting
with the argument registers. However, TMP should suffice instead.

TEST=tests/ffi/address_of_array_generated_test.dart
TEST=tests/ffi/address_of_struct_generated_test.dart
TEST=tests/ffi/address_of_typeddata_generated_test.dart

Closes: https://github.com/dart-lang/sdk/issues/44589
Closes: https://github.com/dart-lang/sdk/issues/54771

CoreLibraryReviewExempt: VM only, unsupported in dart2wasm
Change-Id: I01fb428cfd6f9096a34689c2819c124a8003cb6b
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360882
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-04-25 10:06:16 +00:00
MarkZ 9d08a13721 [reload_test] Adding support for negative tests in reload suite.
* Extends the frontend server controller to validate/reject compile errors in compiles/recompiles.
* Extends the config to permit an 'expectedError' entry.
* Adds a handful of tests to the suite (adapted from the VM's hot reload tests).

Change-Id: I47d814e375c4c72d0406ebf5bdfee3f1975c64f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363800
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-04-24 12:45:44 +00:00
Martin Kustermann e44bc22ca3 [dart2wasm] Fix bug in restoration of this in async functions.
When entering async functions we read the suspend-state's context and
populate local variables with the context parent chain as well as the
this pointer.

This restoration code assumed that `this` is stored in the outermost
context, which isn't necessarily the case.

In constructors the outermost context can contain the type parameters.

TEST=tests/web/wasm/capture_type_and_this_test.dart

Change-Id: Ie8e3c8732203aea4964d48cb78c97578d0322b2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364321
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-04-24 10:03:00 +00:00
William Hesse c10ecb8fe5 [test] Convert most lib/mirrors multitests to static error tests
Change-Id: I4f3b728a94291bf0a31a5f38af9d8b877a9900af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363702
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2024-04-23 23:33:48 +00:00
William Hesse d6c9c9f8bf [test] Convert syntax_native_test to a static error test
Multitests of compile-time errors should be converted to static
error tests, so they don't run on runtime configurations.
Static error tests also test for all the static errors,
their positions, and error message, in a single test run.

This test is currently failing on the common front end,
and on all runtimes, and passing on the analyzer. The
change keeps the failure on common front end by adding
expectations for an error to be reported at the right places.

Bug: https://github.com/dart-lang/sdk/issues/54153
Change-Id: Ic64961f6e0e575ec60626d4f70a0fdc5d71d024e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363085
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-04-23 23:11:17 +00:00
Alexander Markov 73783847fd [gardening] Fix corelib/weak_reference_test
This test incorrectly expects that WeakReference.target should be
cleared for a weakly reachable object. WeakReference specification
doesn't guarantee that:

a9f684e624/sdk/lib/core/weak.dart (L75-L76)

This change fixes the test to give up after certain number of
iterations instead of hanging forever.

Issue: https://github.com/dart-lang/sdk/issues/55518
Change-Id: Ief0ebe1452c83058a35fc1ba87e5a83924d43919
TEST=corelib/weak_reference_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363960
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2024-04-22 18:00:19 +00:00
Martin Kustermann 149db7eced [dart2wasm] Make commandline JS runner (run_wasm.js) initialize location.href
By initializing `location.href` in the commandline JS runners we allow
programs running in D8 to use `Uri.base` (which depends on
`location.href`).

That in return will allow running some Dart programs in D8 that would
otherwise not run (e.g. code using `package:test/test.dart` - which uses
`Uri.base`)

TEST=tests/web/wasm/location_href_test.dart

Change-Id: Ie219f8d9ece3b92f2442200539557f116d2c84ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363700
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-04-19 12:40:23 +00:00
Martin Kustermann 98808385d0 [dart2wasm] Fix bug in [Finalizer] implementation
The recent rewrite of [0] kept the existing semantics of the finalizer
implementation but migrated to the new interop semantics.

Turns out in that existing semantics there's a bug, namely that it
casted the peer object of to a non-nullable [Object] which is incorrect.

This CL
* fixes the cast to non-nullable [Object]
* moves the (currently) web-specific tests for
  [Finalizer]/[WeakReference] into `corelib` so it runs on all backends
* expands the finalizer tests to check finalizers get invoked
* expands the weak reference test to ensure weak reference is cleared

[0] https://dart-review.googlesource.com/c/sdk/+/363082/

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

Change-Id: Ibd8c186b39100cff9e2f437f1a737034a5364830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363581
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-04-19 11:35:27 +00:00
Sam Rawlins a862d9d745 analyzer: Correct message about const addition operator
Fixes https://github.com/dart-lang/sdk/issues/54578

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Fixed: 54578
Change-Id: Iebc9e04539a172e58024758e33ffd93e48cb1a81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363482
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-04-18 17:21:29 +00:00
Ömer Sinan Ağacan eabb2b3aca [dart2wasm] Catch JS exceptions in async functions
When generating `try` block around a CFG block of an async state
machine, generate `catch_all` if the Dart `catch` blocks wrapping the
CFG block can catch JS exceptions.

`catch_all` bodies are identical to the `catch` bodies we already
generate.

The check for whether to generate `catch_all` is reused from the
non-async code generator without changes.

Fixes #55457.

Change-Id: I9d89593599da592106e12efb77c07d68b6cfce5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-18 08:57:39 +00:00
Martin Kustermann a133b75438 [dart2wasm] Enable weak reference / finalization tests on dart2wasm
This enables the currently dart2js/ddc-only tests for [WeakReference] /
[Finalizer] on dart2wasm.

As part of that we add a polyfill for the two implementations (just like
dart2js/ddc) do, to make the polyfill test pass.

We also migrate the implementation to use static interop.

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

TEST=tests/web/wasm_js_shared/weak_reference_*test.dart

Change-Id: Ic08ae41b6fc78fd9857172ca24695a7f91e06a78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363082
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-04-18 07:55:38 +00:00
Daco Harkes c0b938c228 [vm/ffi] Fix variadic arguments on MacOS Arm64
Non-variadic arguments on the stack on MacOS Arm64 are aligned to
the value size (which can be smaller than word size). However, for
varargs, the arguments on the stack seem to be aligned to the word
size.

This CL introduces an alignment strategy constant for primitives on
the stack in varargs and uses it in the native calling convention
calculation.

TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc with
runtime/vm/compiler/ffi/unit_tests/variadic_less_than_word/arm64_macos.expect

TEST=tests/ffi/function_varargs_generated_native_leaf_test.dart

Closes: https://github.com/dart-lang/sdk/issues/55471
Change-Id: I51d20c3933a2cea9b110954ddec92fb91b9c3ecd
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362762
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2024-04-17 15:42:16 +00:00
Ömer Sinan Ağacan 55f2754d6b [dart2wasm] Fix JSStringImpl trim methods, add tests
Fix trim methods returning a new string (instead of the argument) when
there's nothing to trim.

A second bug fixed in NEL handling in `trim`: the last line should be
`result.substring(...)` instead of `this.substring(...)`. The bug wasn't
caught by any of the tests: NEL needs to be handled specially on the
browser, but mixing NEL with other whitespace wasn't tested in the
existing tests `string_trim_test` and `string_trimlr_test`, so a new
test file added with this case.

Change-Id: Ibf84e185de1b26c9811e3ea58c2ad3f223da8515
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363081
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-04-17 14:41:52 +00:00
Mayank Patke 159906059d [dart2js] Preserve is/as in ConstantTransformer with SNS checks enabled
Also amend SSA type builder to only optimize away casts to *sound* top
types when SNS checks are enabled.

Fixes: b/330884266
Change-Id: Ic619877b7f1e01e1065f4767549880aab2f81106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363162
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-04-16 23:30:10 +00:00
Daco Harkes 51a67b8176 [vm/ffi] Reformat generated tests
`clang-format` has decided to format things slightly differently.
To prevent a huge diff on CLs touching
runtime/bin/ffi_test/ffi_test_functions_generated.cc, run a reformat
eagerly.

The generation script now explicitly uses the the clang-format from
the buildtools/ dir. (It was likely using the one on PATH.)

Also, clean up Dart imports to use single quotes, and generate an
ignore to prevent warnings.

TEST=tests/ffi

Change-Id: I54e24d62fe742770fb041bba73110c5285250fb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362763
Reviewed-by: Hossein Yousefi <yousefi@google.com>
Commit-Queue: Hossein Yousefi <yousefi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2024-04-15 10:55:46 +00:00