Commit Graph

23389 Commits

Author SHA1 Message Date
Nate Biggs 963c28a114 [dart2wasm] Allow tests to override jscm mode.
This allows tests that would fail in JS compatibility mode (e.g. tests that do a lot of string manipulation) to disable the mode for their own execution.

Also ensure dart2wasm-*-jscm-* builds do a "create_sdk" so that the dart2js platform dill is available for the test.

The alternative I considered was skipping the test but "--js-compatibility" is a dart2wasm-specific flag and the test infra is unaware of it so we can't skip the test via a status file.

Bug: https://github.com/dart-lang/sdk/issues/56858
Change-Id: I60179eaab2e4522acf1fe0b47c7c02ccb1ca957b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388644
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-10-08 13:16:19 +00:00
Chloe Stefantsova b2e282ad31 [analyzer] Implement inference for null-aware elements in Analyzer
This CL implements type inference for null-aware colletion elements
and map entires in the Analyzer. The new functionality is dependent on
the `null-aware-elements` feature flag, since only when the flag is
enable, can the `keyQuestion` and `valueQuestion` properties of the
MapEntryLiteralEntry class be not null and the objects of the
`NullAwareElement` be created.

Part of https://github.com/dart-lang/sdk/issues/56836

Change-Id: I9243b01d5de097ae0d2ca3376807c6209ef0f830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387980
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-10-03 16:09:32 +00:00
Lasse R.H. Nielsen e260cc0330 Reset regexp lastIndex before using it again.
The way JS RegExps handle anchored matches is to have a separate RegExp
with `|()` added at the end, which means it either matches at that point,
or the `()` matches at that point, and that's visible in the captures
as a non-`null` last capture group.

The same RegExp is used to find the number of captures a RegExp has,
by running it on an empty string, and seeing the length of the capture
array, even if it contains nothing but `null` and `""` values.

The RegExp is as JS global regexp, which is what allows it to start matching
at a specific point, which we use for `startsWith(Pattern, start)`.
Every *normal* use of that RegExp remembers to set the `lastIndex` of the
regexp before using it, but the `regExpCaptureCount` used the "anchored
regexp" directly, and forgot to set the `lastIndex`, and since it had just
been used and failed to match at a position *later* than the current input
string's length, the "unfailable" test on the empty string failed, returning
`null` where no `null` was expected.

So now `regExpCaptureCount` sets `lastIndex` to zero before using the RegExp,
like every use of a shared RegExp should.

Fixes #56834

Bug: https://dartbug/com/56834
Change-Id: Ib649b70db5922c277950d7b7cfd4d157788d11cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388002
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-10-03 14:01:41 +00:00
Johnni Winther a101a99ec7 [cfe] Handle assert in unevaluated extension type constructors
Closes #56803

Change-Id: Icea17859c35128db7d965732bb2329c5c10689bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387540
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-10-01 09:10:22 +00:00
Chloe Stefantsova bc8104f3b2 [analyzer][cfe] Implement flow analysis for null-aware map entries
Closes https://github.com/dart-lang/sdk/issues/56786

Change-Id: I738c98b6f4e632cfbbe51221bbc3547edbc718fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386800
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-09-30 09:48:27 +00:00
Erik Ernst fc7b4dda66 Adjust tests and spec_parser to updated grammar
This CL changes the specification parser grammar to support a switch
expression that has zero cases (this is a missing update, the feature
specification already has it). It also changes several language tests
such that they expect a 'syntax error' rather than a 'compile-time
error'. This makes no difference for any tool except the specification
parser, for which it is needed (in general, a test that is expected
to have a compile-time error will parse just fine, so we need a
separate test outcome expectation for syntax errors).

Change-Id: Ifa00c11ce6c57053bd490e11a41d6e8d7b82a2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384600
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-09-27 15:29:03 +00:00
Nate Biggs 68552a56bc [dart2wasm] Fix module stress tests.
After these changes the tests pass 100% of the time on all expected configurations.

- Emit 'unittest-suite-wait-for-done' at the start of tests to allow for async code loading. Tests must therefore emit 'unittest-suite-done' when they complete. Calling `asyncStart` and `asyncEnd` helpers will achieve this.
- Fix test_runner runtime.
- Add file deps on necessary files (dart2js platform dill & flute) to dart2wasm_hostasserts config.
- Mark dart2js compilation test as slow.

Change-Id: Iee993deb3905ccd50068325a5c5fd0bf0512a513
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386980
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-27 15:03:01 +00:00
Chloe Stefantsova 32b00bb42c [language] Add language tests for preserved behavior when the inference-using-bounds flag isn't set
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/386220/comments/75e33432_07105bb3

Change-Id: I26ab50062978e79a2bd113efcac572e68b86e759
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386801
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-09-26 12:56:12 +00:00
Chloe Stefantsova 95056cd8ba [analyzer][cfe] Add tests for constraint generation using bounds
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/364721

Change-Id: I45f7afc410d2265f58c9776aaaeea9058e80ac98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386220
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-09-25 10:59:51 +00:00
MarkZ bbdf1952b4 [reload_test] Enabling all DDC hot reload tests.
Change-Id: I8a6a102f87ff162b1624da0917f3ee8db8f2144c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385120
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-09-24 22:03:24 +00:00
Konstantin Shcheglov b07eb3b325 Parts. Report PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER in parts.
This also moves the target to be the import prefix, not the declaration.
This is how the specification describes it, and scope lookup works.

Change-Id: Ic0f60a6b57bd8760589b1a91be8885fafb5c90c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-09-24 21:45:12 +00:00
Nate Biggs 7ba8957b12 [dart2wasm] Add FluteComplex multi-module stress test.
Change-Id: I2b13649d67d5b68211b6c15c745fd194773b9e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386380
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-24 15:53:30 +00:00
Ömer Sinan Ağacan f80214eb86 [dart2wasm] Fix Uri.base in d8
Currently when the .wasm file path passed to run_wasm.js is a relative
path, `Uri.base` becomes something like `file://test.wasm`, which is not
a valid file URI, so it causes crashes in `Uri.toFilePath`.

When the file path is relative add a omit `file://` prefix.

`Uri.base` values before and after:

- Before, relative .wasm path: `file://test.wasm` (invalid)
- Before, absolute .wasm path: `file:///home/user/test.wasm`

- After, relative .wasm path: `test.wasm` (fixed)
- After, absolute .wasm path: `file:///home/user/test.wasm` (same as before)

Change-Id: I0d1c43716e07a9ee926e7feeeab514c2c66bac16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-24 10:21:52 +00:00
Srujan Gaddam dc3b6af33d Add location rename to locationString in test
The SecurityError was being hidden because of
https://github.com/dart-lang/sdk/issues/56772.
With this, single-stepping through the test succeeds.

Change-Id: I47a768e803598d5f918a4d2bed9aa4391377464f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386401
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-23 22:38:57 +00:00
Nate Biggs 25706745bc [dart2wasm] Fix handling of user-defined _typeArguments members.
The dart2wasm transformer injects a `_typeArguments` into each class.
https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/transformers.dart#L201

This is a synthetic private member that gets handled specially. However, users can have their own private members with the same name so we have to ensure the intrinsic handler is only operating on synthesized members by looking at the library attached to the private name.

Bug: https://github.com/flutter/flutter/issues/154383
Change-Id: I04062bec1f2bcf9ce6420e749c417a65f676505d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386040
Auto-Submit: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 21:15:06 +00:00
Nate Biggs 755db057ff [dart2js] Fix record FieldGet receiver type update.
We should be updating the receiver record's type regardless of whether or not we have a specific record type.

Bug: https://github.com/dart-lang/sdk/issues/56741
Change-Id: I16ce9f1db96c295566be802211c7280917416924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386262
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-23 19:48:07 +00:00
Nate Biggs 1d392255ef [dart2wasm] Add wasm module test mode.
Adds a mode that puts every library (outside of the SDK) into its own wasm module. Each module is then loaded before the program executes.

This allows us to get better coverage on multi-module logic.

I chose to augment the SDK `_invokeMain` entry point because it allows us to push the user-defined main into a second module ensuring we always have at least 2 modules. The SDK alone is then the main module and all user-code is in deferred modules.

The next step is to make a test configuration for this and decide what frequency to execute it with.

Change-Id: I01bf3a5fee4604a890ef376ebd35113281a36a5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384404
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 18:56:24 +00:00
Ömer Sinan Ağacan 09e47b67a7 [dart2wasm] Fix hash code of _RecordType
`_RecordType.operator ==` was overridden, but `hashCode` was not.

Override `_RecordType.hashCode`.

Change-Id: I0ec65bb55dbd1dfad8f9363ff7ffc4847ee48fee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386200
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-23 14:27:53 +00:00
Aravind 8f89bbe1a9 [vm/ffi] Not preventing the transformation for InvalidExpression in ffi
Currently, we just "removed" the actual expression by transforming to
`InvalidExpression('Invalid Type')` if a expression is Invalid. But this  could cascade `.address` position errors (i.e transformer no longer able to walk `.address.abc` if the expression is just replaced with empty expression). So unwrapping actual expression from `InvalidExpression` and trying to transforming that actual expression through a recursive call.

TEST=tests/ffi/static_checks/address_position_cascade_test.dart
Bug: https://github.com/dart-lang/sdk/issues/56613
Change-Id: Ib1ba1d5021797b645c29ac296752d844d0935964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384080
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-13 06:59:39 +00:00
Srujan Gaddam 591b774213 Add tests for cross-origin window and location
Tests that we can use JSAny? as the type without
violating cross-origin policy. This will then be
used in package:web to implement a wrapper.

Change-Id: Ic30557138b61e27e421747ead81ea2fb7f6db240
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381886
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-12 21:30:00 +00:00
Nate Biggs 92727ab977 [dart2wasm] Check laziness of sub-constants for records.
All other constant types include similar logic.

This caused a failure when testing deferred loading logic. Laziness of static tear offs are module sensitive. A record containing a constant static tear off needs to match the inner laziness. Though there are other ways to get lazy subconstants that would also cause this to fail (e.g. very large strings).

Change-Id: Ia55b4f24a15e57b9721383726e7afb5f39557d5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384980
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-12 17:59:36 +00:00
Nate Biggs b8ff81ea0d [dart2wasm] Fix while scoping in async generator.
The new test was resulting in an uninitialized late read of localContext here:
https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/code_generator.dart#L830

The `++i` results in a let expression declaring a new variable within the condition of the while loop.

The code linked above tries to look up the variable within the current context. The `ContextCollector` defines the while scope as including the while's condition:
https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/closures.dart#L1486

However, the AstCodeGenerator doesn't register the while's scope until after processing the condition:
https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/code_generator.dart#L1248

So when processing the condition, the loopkup happens on the scope above the while even though the variable is captured on the while's scope.

A synthetic let statement is the only way to get a variable declaration within a while's condition. And it wouldn't otherwise be captured (a closure can't reference it) but async function bodies mark all variables as captured.

Change-Id: I5f8fdd69d4875c099a21505cd588b08cacdd86c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384863
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-12 17:59:36 +00:00
Paul Berry a3c696fa58 Properly report unreachable switch cases containing when clauses.
When determining whether a switch statement is exhaustive, it's
important for the exhaustiveness algorithm to ignore cases containing
`when` clauses, since a `when` clause creates the possiblity that the
case won't match.

Previously, the way this was done in the analyzer was for the
`SpaceCreator.createRootSpace` method to create an unknown space for
cases containing `when` clauses. This approach produced the correct
behavior when determining whether the switch statement as a whole was
exhaustive, but since it discarded information about the pattern being
matched, it limited the ability to determine whether an individual
case was reachable, leading to
https://github.com/dart-lang/sdk/issues/56710.

To fix this, `SpaceCreator.createRootSpace` is changed so that it
always produces a space that describes the case pattern, regardless of
whether a `when` clause is present, and instead,
`computeExhaustiveness` is responsible for ensuring that the case is
properly excluded from the determination of whether the switch is
exhaustive. This allows `computeExhaustiveness` to properly computate
whether each individual case is reachable, even for cases that have
`when` clauses.

This change in approach produced some minor differences in the test
cases in `pkg/_fe_analyzer_shared/test/exhaustiveness/data`, but these
differences are not user-observable.

Fixes https://github.com/dart-lang/sdk/issues/56710.

Change-Id: I36629a77c4c1832fb1b8abb6ea7b109e0ca14373
Bug: https://github.com/dart-lang/sdk/issues/56710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384326
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-09-12 16:30:22 +00:00
Vyacheslav Egorov e2efffa005 [vm] Simplify implementation of native ports
This reland commit 5a32d8bc7c with a fix
for thread leak (Issue #56717): when `ThreadPool` is shutting down
asynchronously the last worker should detach itself to prevent
leaking associated low-level data structures, because no thread will
join it.

A hang in service isolate shutdown (caused by an existing bug) was fixed by commit 157a0dc7f9.

This CL turns native ports into a thin abstraction over underlying
thread pool instead of building them as full fledged MessageHandler.

This allows to easily implement a variation of native ports which can
handle messages concurrently with the given degree of concurrency.
This type of port can be used to greatly simplify implementation of
IOService - which previously had to do its own concurrency management
on top of "single threaded" native ports. This capability is exposed
as `Dart_NewConcurrentNativePort` API.

The new implementation is in general much cleaner then the old one
with one exception: `Dart_CloseNativePort` API has unfortunate design
where underlying message handler is destroyed asynchronously and
`Dart_CloseNativePort` returns immediately without waiting for pending
tasks to complete. Implementing this on top of `ThreadPool` requires
some changes to thread pool implementation.

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

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

TEST=ci

Change-Id: Ic68bfb60757685afd75c80a70cdec66cc13c149b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-12 15:16:12 +00:00
Alexander Markov 80b092de04 [dart2bytecode] Throw exception instead of crashing when external member is called
TEST=ci

Change-Id: I60a598dd5f8ac05a4f5f3283d257c2c6a74490e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384820
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-12 14:52:58 +00:00
Ömer Sinan Ağacan c8a7922160 Reland "Reapply "[dart2wasm] Allocate boxed bools once" and "[dart2wasm] Box Pointer values obtained from FFI calls""
This is a reland of commit fca5417d49

- Patchset 1 is the reland.
- Patchset 2 adds a regression test and fixes the bug.

Also tested engine chrome-dart2wasm-html-engine,chrome-dart2wasm-html-html,chrome-dart2wasm-html-ui,chrome-dart2wasm-canvaskit-canvaskit,chrome-dart2wasm-canvaskit-ui,chrome-dart2wasm-skwasm-ui tests manually.

Original change's description:
> Reapply "[dart2wasm] Allocate boxed bools once" and "[dart2wasm] Box `Pointer` values obtained from FFI calls"
>
> This reverts commit a4e9775a99.
>
> - Patchset 1 reverts the revert.
>
> - Patchset 2 adds regression tests. These tests fail.
>
> - Patchset 3 and the rest fixes the bug in `_loadPointer` and
>   `_storePointer` intrinsics. Also adds some inline annotations to
>   reduce the noise in unoptimized builds.
>
> Tested: updated test web/wasm/ffi/ffi_native_test
> Change-Id: I748a8aa8ff7cc663b1980d2bfab0d0da9f369e3b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384760
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Ömer Ağacan <omersa@google.com>

Tested: web/wasm/ffi/ffi_native_test updated. Manual run of engine chrome-dart2wasm-html-engine,chrome-dart2wasm-html-html,chrome-dart2wasm-html-ui,chrome-dart2wasm-canvaskit-canvaskit,chrome-dart2wasm-canvaskit-ui,chrome-dart2wasm-skwasm-ui tests.
Change-Id: Ifcd5156b8a03228119b2146edcfc56db8ac6273b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384843
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-12 09:55:11 +00:00
Slava Egorov 120dac365d Revert "[vm] Simplify implementation of native ports"
This reverts commit 5a32d8bc7c.

Reason for revert: DartIsolateTest.CanCreateServiceIsolate flutter engine unit test hangs on Windows.

Original change's description:
> [vm] Simplify implementation of native ports
>
> This CL turns native ports into a thin abstraction over underlying
> thread pool instead of building them as full fledged MessageHandler.
>
> This allows to easily implement a variation of native ports which can
> handle messages concurrently with the given degree of concurrency.
> This type of port can be used to greatly simplify implementation of
> IOService - which previously had to do its own concurrency management
> on top of "single threaded" native ports. This capability is exposed
> as `Dart_NewConcurrentNativePort` API.
>
> The new implementation is in general much cleaner then the old one
> with one exception: `Dart_CloseNativePort` API has unfortunate design
> where underlying message handler is destroyed asynchronously and
> `Dart_CloseNativePort` returns immediately without waiting for pending
> tasks to complete. Implementing this on top of `ThreadPool` requires
> some changes to thread pool implementation.
>
> Issue https://github.com/dart-lang/sdk/issues/55844
>
> TEST=ci
>
> Change-Id: I062040ff233e93962ae93684e9b044d8facdaffc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382163
> Commit-Queue: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I7de27793a54072e974bf1a9f17a07c12159a202d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384481
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-09-12 08:25:27 +00:00
tguerin e4b505b366 Propagate http status code when http upgrade request failed
R=mosum@google.com

Change-Id: I547d19da251bdea0c259d3896e6e333f9afd0bca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384522
Auto-Submit: Thomas Guerin <thomas.guerin2@gmail.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-09-11 20:02:14 +00:00
Nate Biggs 91f099aa59 [dart2wasm] Fix switch statements containing jumps but no awaits.
This would throw when compiling before because there was no label target recorded for the target case statement.

Change-Id: Id00af345cf2a167a079f6ef8c077fa97cffdb3f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384587
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-11 18:42:23 +00:00
Ömer Ağacan d146083865 Revert "Reapply "[dart2wasm] Allocate boxed bools once" and "[dart2wasm] Box Pointer values obtained from FFI calls""
This reverts commit fca5417d49.

Reason for revert: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Engine%20Drone/2677631/overview

Original change's description:
> Reapply "[dart2wasm] Allocate boxed bools once" and "[dart2wasm] Box `Pointer` values obtained from FFI calls"
>
> This reverts commit a4e9775a99.
>
> - Patchset 1 reverts the revert.
>
> - Patchset 2 adds regression tests. These tests fail.
>
> - Patchset 3 and the rest fixes the bug in `_loadPointer` and
>   `_storePointer` intrinsics. Also adds some inline annotations to
>   reduce the noise in unoptimized builds.
>
> Tested: updated test web/wasm/ffi/ffi_native_test
> Change-Id: I748a8aa8ff7cc663b1980d2bfab0d0da9f369e3b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384760
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Ömer Ağacan <omersa@google.com>

Change-Id: I2cb55b6d2fdf429c5a0634329079e9df7e9e5871
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384841
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-11 17:06:58 +00:00
Paul Berry f7259983d7 Remove redundant test from variable_pattern_switch_test.dart.
This test was out of place (since it doesn't contain any variable
patterns). Also, it was an exact copy of a test in
record_literal_switch_test.dart. There's no point in having the same
test in both locations, so remove it from the location where it
doesn't belong.

Change-Id: I1d3a786caba2b2591255b68c035eff40b2f08237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384565
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-09-11 14:06:42 +00:00
Vyacheslav Egorov 5a32d8bc7c [vm] Simplify implementation of native ports
This CL turns native ports into a thin abstraction over underlying
thread pool instead of building them as full fledged MessageHandler.

This allows to easily implement a variation of native ports which can
handle messages concurrently with the given degree of concurrency.
This type of port can be used to greatly simplify implementation of
IOService - which previously had to do its own concurrency management
on top of "single threaded" native ports. This capability is exposed
as `Dart_NewConcurrentNativePort` API.

The new implementation is in general much cleaner then the old one
with one exception: `Dart_CloseNativePort` API has unfortunate design
where underlying message handler is destroyed asynchronously and
`Dart_CloseNativePort` returns immediately without waiting for pending
tasks to complete. Implementing this on top of `ThreadPool` requires
some changes to thread pool implementation.

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

TEST=ci

Change-Id: I062040ff233e93962ae93684e9b044d8facdaffc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382163
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-11 13:38:24 +00:00
Paul Berry 0a4f390b72 Rename Enum to E in exhaustiveness tests.
In the code review for
https://dart-review.googlesource.com/c/sdk/+/378960, Erik Ernst
pointed out that it's confusing to have enum declarations called
`Enum`, since there's a system library declaration whose name is also
`Enum`.

This CL changes the names to `E`, which is short and simple, and
adequate for testing purposes.

Change-Id: I6a36e1e55279ca6ad95a9f1d5a06292824f1c9d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384720
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-09-11 12:50:37 +00:00
Ömer Sinan Ağacan fca5417d49 Reapply "[dart2wasm] Allocate boxed bools once" and "[dart2wasm] Box Pointer values obtained from FFI calls"
This reverts commit a4e9775a99.

- Patchset 1 reverts the revert.

- Patchset 2 adds regression tests. These tests fail.

- Patchset 3 and the rest fixes the bug in `_loadPointer` and
  `_storePointer` intrinsics. Also adds some inline annotations to
  reduce the noise in unoptimized builds.

Tested: updated test web/wasm/ffi/ffi_native_test
Change-Id: I748a8aa8ff7cc663b1980d2bfab0d0da9f369e3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384760
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-11 11:09:39 +00:00
Martin Kustermann d7cff6c809 [dart2wasm] Make --omit-implicit-checks also omit AsExpression checks inserted by CFE
There are several different kinds of implicit type checks. The most
common ones are the checks on covariant parameters of methods. Those are
not represented in the kernel AST via `AsExpression`s but backend
compilers have to insert them themselves.

Then there's other implicit type checks that users haven't written but
the CFE inserts as synthetic `AsExpression`s. There's several different
kinds.

=> We make --omit-implicit-checks now also not perform those anymore
   (which one would expect given the name of the flag)

Change-Id: Ie61536c0a7269e5c62cd98c62e77d1b6a34e3f1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384740
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-09-11 10:04:28 +00:00
MarkZ 6281f58c58 [ddc] Removing --minimal from reload suite diff logic
This was causing diff discrepancies on Mac vs Linux

Change-Id: I2b67b51d1aab959fa99de916d40d282fc5d19f8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384310
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-09-10 20:47:38 +00:00
Paul Berry cda2815bb1 Add UNREACHABLE_SWITCH_DEFAULT warning to the analyzer.
This warning is similar to the existing `UNREACHABLE_SWITCH_CASE`
warning, except that it warns if the `default` clause of a switch
statement is unreachable due to all the `case` clasuses fully
exhausting the switched type.

To make the implementation easier, I changed the API for the
`reportExhaustiveness` method in `_fe_analyzer_shared` (which is the
primary entry point to the shared exhaustiveness checker). Previously,
this method returned a list of `ExhaustivenessError`, where each list
element was either an `UnreachableCaseError` (indicating that a
certain case was unreachable) or a `NonExhaustiveError` (indicating
that the entire switch statement was not exhaustive). If the caller
passed in `false` for `computeUnreachable`, `UnreachableCaseError`s
would not be returned, so the returned list would either be empty or
contain a single `NonExhaustiveError`.

The new API renames the types for clarity:

- `NonExhaustiveError` becomes `NonExhaustiveness`, to highlight the
  fact that it's not necessarily an error for the switch's cases to be
  non-exhaustive; it's only an error if the scrutinee's static type is
  an "always exhaustive" type and there is no `default` clause.

- `UnreachableCaseError` becomes `CaseUnreachability`, to highlight
  the fact that it's not an error for a case to be unreachable; it's a
  warning.

Also, the new API adds instances of `CaseUnreachability` to an
optional user-provided list instead of returning a newly created list;
this allows callers to communicate that they don't need to see
`CaseUnreachability` information by passing `null`. This frees up the
return type to simply be an instance of `NonExhaustiveness` (if the
cases are not exhaustive) or `null` (if they are exhaustive). This
makes it easier for the analyzer to decide whether to issue the new
warning, because it doesn't have to dig around the list looking for an
instance of `NonExhaustiveness`.

The new warning has an associated quick fix (remove the unreachable
`default` clause). This quick fix uses the same `RemoveDeadCode` logic
in the analysis server that the existing `UNREACHABLE_SWITCH_CASE`
warning uses.

Fixes https://github.com/dart-lang/sdk/issues/54575.

Bug: https://github.com/dart-lang/sdk/issues/54575
Change-Id: I18b6b7c5249d77d28ead7488b4aae4ea65c4b664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-09-10 19:13:12 +00:00
Martin Kustermann bad285fafd [dart2wasm] Make deferred loading embedder call be based on bytes
Change-Id: I56d331028ad08c176fdcbe14655e036a6191d26c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384260
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-09-10 18:17:13 +00:00
Lasse R.H. Nielsen 7e75d881a0 Tweak test_runner.
Clean up and optimize some RegExps, and fix uses of `.group`.
Switch to a newer language version, to be able to use newer features.
Add a little documentation about why some RegExps are as they are.

Add (tentative) warning for multitests.

Change-Id: I59f73b87ce30caaeca1c0e0aa7954af1b97abd1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382620
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-09-10 15:29:28 +00:00
Ömer Sinan Ağacan 0e58775986 [dart2wasm] Small improvements in FFI native tests:
- Document which target needs to be built for the test
  `web/wasm/ffi/ffi_native`.

- Add tests that passes and expects `double` and `float`s.
  (The `sqrt` native function was previous unused)

- Define inputs in `wasm_module` gn template so that the
  `ffi_native_test_wasm_module` target will rebuild the Wasm file when
  `tests/web/wasm/ffi/ffi_native_test_module.c` changes.

Change-Id: Iff642ff2cdee48a617e8f2cf4cca4053122a7e05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384263
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-10 09:51:41 +00:00
Ömer Sinan Ağacan a5baf4e15b [dart2wasm] Improve WasmListBase.{setRange,setAll}
- In `setRange`, use `array.copy` instruction when the iterable argument
  is another Wasm-array-backed list. (instead of only when the iterable
  and `this` are identical)

- In `setRange`, add special case for `SubListIterable`.

- In `setAll`, use unchecked reads from `iterable` when it's a
  Wasm-array-backed list.

Also fix various error checking in `setAll` and `setRange`.

`setAll` and `setRange` tests updated to test handling of different
types of iterable arguments.

CoreLibraryReviewExempt: adds internal method
Change-Id: Ib3ed566018e929950eac4d1f3d41dcd406003f91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383860
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-10 09:03:21 +00:00
Martin Kustermann 7ebc3f7f31 [dart2wasm] Fix bug in --omit-implicit-checks
When `-O3` / `-O4` / `--omit-implicit-checks` are turned on then the
runtime type of tear off functions with covariant parameters was
incorrect.

=> The runtime type of any kind of function or object should always be
the same, irrespective of whether we're dropping some implicit or
explicit `as` checks - as the runtime type can also be observed via e.g.
`is` checks.

The issue was originally introduced in [0].

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

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

Change-Id: I5c64134e4735d73cf228e12b8eb3bd4767616e11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384285
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-09-10 07:55:25 +00:00
Ryan Macnak 214b83c1e4 [vm] Work around C compiler bug with simulation of ARM64 vsub.
TEST=ci, dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/55879
Change-Id: Iadf71b315de3462af6b739c8b49865469368b647
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384443
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-10 01:11:15 +00:00
MarkZ 6db84ef903 [ddc] Adding hot reload test with DDC's new module system.
Change-Id: I55c0b4d3c74654c192b6e664120778b057aa7161
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383820
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-09-09 23:16:48 +00:00
Jason Simmons a4e9775a99 Revert "[dart2wasm] Allocate boxed bools once" and "[dart2wasm] Box Pointer values obtained from FFI calls"
This reverts commit d7a283de26 and commit d7a39788d4

The "[dart2wasm] Box `Pointer` values obtained from FFI calls" change causes a Flutter Web test to hang (https://github.com/flutter/engine/blob/main/lib/web_ui/test/fallbacks/fallbacks_test.dart)

Change-Id: Ia44bcf68cd6edc72697a0c2b05e05b4f8e1408fd
TEST=reproduced the hang locally and confirmed that it does not happen with this revert
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384321
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jason Simmons <jsimmons@google.com>
2024-09-09 20:10:06 +00:00
Nate Biggs b28913c7e1 [dart2js] Make 'load-priority' pragma pass an arbitrary option string.
Change-Id: I4d9fb69dfb4ec040b0e63893e4ace33c6a5dd454
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384360
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-09 19:47:48 +00:00
Nicholas Shahan ec0445ae79 [ddc] Add hot restart to new ddc module format
Add a simple implementation that throws out all libraries and runs the
main method again which triggers all libraries to be initialized with
fresh values.

Move the hot reload tests to the ddc canary test configuration
since that is where the support works at this time.

Update frontend server to use the use the new version of the DDC
LibraryCompiler when the emit library bundle option is true.

Change-Id: I6eba613106672536ef8bfcb0ff0a55749e2fb63c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381902
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-09-09 17:58:56 +00:00
Alexander Markov 1225b45bc7 [dart2bytecode, vm/interpreter] Async exceptions
TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: I9d5bb0f7f2544e41078ec9aeb75bce6224087976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383706
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-09-09 13:44:04 +00:00
Sergey G. Grekhov 36425db14a [co19] Add analyzer-linux-release-try tryjbbot to update.sh
Change-Id: I88099ba8f6835cf157428137021a3fce2d5bc577
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384021
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-09-09 07:40:34 +00:00
Nicholas Shahan 98849d5ae3 [dart2js][ddc] Fix firefox -> ff in .status files
The runtime name is actually expected to be "ff".

Issue: https://github.com/dart-lang/sdk/issues/51666
Issue: https://github.com/dart-lang/sdk/issues/51665
Issue: https://github.com/dart-lang/sdk/issues/51524

Change-Id: Idd0d071343c3908ad8504c55739e767e7ae368c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383704
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-09-05 16:32:47 +00:00