Commit Graph

23381 Commits

Author SHA1 Message Date
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
Ömer Sinan Ağacan d7a39788d4 [dart2wasm] Box Pointer values obtained from FFI calls
Currently `Pointer` argument and return types of `FfiNative` functions
are translated to Wasm as `i32`.

This causes problems when we need to box those `i32` values as we don't
track which Dart types Wasm types come from when converting a Dart type
like `Pointer` to a Wasm type like `i32`.

Currently this works somewhat accidentally. All `i32`s are boxed as
`BoxedBool`, including `i32`s that represent `Pointer`s.

This breaks when we need to get the type parameter of a `Pointer` (e.g.
in a `is` or `as` check), but more importantly it means that we can't
cache boxed `true` and `false` values and return those cached values
when converting an `i32` to a boxed type as we don't know whether the
`i32` represents a bool or pointer.

Ideally we would have some kind of intermediate layer between
`wasm_builder` and dart2wasm that allows types like "a Wasm i32
representing an unboxed T" (for some T).

Alternatively we could attach extra information to `ValueType`s, for
example using expandos or maybe by adding a `dynamic` field to the base
class.

However it's unclear whether it's worth doing a major refactoring, when
a simpler alternative exist: we box `Pointer` values obtained from an
import in the Dart wrapper for the imported function.

VM already boxes `Pointer`s, so the performance should be acceptable.

This CL implements this simpler alternative of boxing `Pointer` values.

Tested: web/wasm/ffi/ffi_native_test updated.
Change-Id: I02e5c07fdb021a7b51ed5db2a44123b1608c9aad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383325
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-05 11:24:10 +00:00
Martin Kustermann 0e620b27a0 [dart2wasm] Align test outcomes of dart2wasm across configurations
Aligns exit codes of

  * `dart compile wasm` and
  * `pkg/dart2wasm/tool/compile_benchmark`

Also make them use exit codes recognized by the test runner to
distinguish CFE crashes, CFE compile-time-errors and other failures.

Also update status file entries to from D8 specific entries
to JS commandline shell entries

=> Step towards aligning D8 & JSC test results

Change-Id: I1acb8803f5db7c732ad546d5989b1c555583e7c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383660
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-09-05 11:22:18 +00:00
Rutvik Tak 1fb6869585 Adds a static from method on JSArray which helps a create a JSArray from a given JS iterable or array-like object. (Resolves #56069)
R=brianwilkerson@google.com, nshahan@google.com

Change-Id: I4b913107f5789f48af521b90052052d87453951d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382080
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Auto-Submit: Rutvik Tak <takrutvik@gmail.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-04 23:27:18 +00:00
Nate Biggs c936c0fdd2 [dart2wasm] Add deferred loading support to dart2wasm (11/X).
This is the final CL for deferred loading. It wires up the library-module analysis logic to the compiler. With all the Translator module predicates implemented, code should now be generated in separate modules (assuming the flag is enabled).

This also handles the module naming scheme. For an invocation of dart2wasm like `dart2wasm main.dart out.wasm` this will produce files like `out.mjs, out.wasm, out_module1.wasm, out_module2.wasm, ...`. `out.wasm` is the main module that gets loaded on initialization. When the flag is disabled this will always be the only output.

If the flag is disabled then the `_importMapping` in `deferred.dart` will be empty and we will default to the same behavior as today which will be to just return an empty `Future`. When enabled, `loadLibrary` will fetch and instantiate the new module(s) before proceeding.

Change-Id: I0dd136c0af61b916be2a24b3d79052ff1b786b52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380440
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-04 21:58:12 +00:00
Kallen Tu c6ae757c62 [wildcard-variables] Add tests for const behaviour.
Missing a few cases for interactions between wildcard variables and const.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: I4ae1ca0041b5b8ca3c24ab866bd9d8e19832ef2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382963
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-09-04 17:10:06 +00:00
Nicholas Shahan 3037c3aa4a [dart2js,ddc] Skip tests on Firefox and Safari
All of these tests call the TouchEvent constructor which is not exposed
in FireFox or Safari like it is in Chrome.
https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent#browser_compatibility

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: I6404163f085795d86278831d3cdf62b5f5501a05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383450
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-09-04 15:39:29 +00:00
Alexander Markov a17bc048b4 [dart2bytecode, vm/interpreter] Late final fields and variables
* Also, add implicitly overridden _Enum._enumToString to dynamic
  interface.

TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: I9d9d368715d0837d8b1039a46451152e03be7eec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383024
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-04 14:18:09 +00:00
Alexander Markov 52304b29d0 [vm/interpreter] Fix type checks and async stack traces
TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: Ia8d5dff98ef1b1afa97108a40f1835545e08790f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382962
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2024-09-04 08:14:18 +00:00