Commit graph

11604 commits

Author SHA1 Message Date
Ömer Sinan Ağacan 39276e9bd4 [dart2wasm] Simplify libraries.yaml setup:
Move common libraries of wasm and wasm_js_compatibility to wasm_common,
remove wasm_base.

Change-Id: I0293cfd11b58be3d921413fdb2fff7171f0b3d4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-24 08:04:58 +00:00
Ömer Sinan Ağacan bae278ec40 Minor tweaks in Finalizer documentation:
- Fix typos in "Get finalizer callback" -> "Call finalizer callback"
  in documentation of an `attach` call.

- Make it clear that the `detach` parameter of `attach` is not used by
  the finalizer.

- Make it clear what "the same value" means in the `detach` parameter
  documentation.

CoreLibraryReviewExempt: Documentation only
Change-Id: I8c1dc9e5fd6926e5c594c26a50228a044e892974
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364100
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-23 13:36:57 +00:00
Tess Strickland 1774314a04 [vm/test] Fix flakiness of vm/dart/use_dwarf_stack_traces_flag_test.
Previously, Internal_randomInstructionsOffsetInsideAllocateObjectStub
assumed the entry point is at the start of the instructions payload when
choosing a random offset into the instructions payload.  However, most
of our architectures have non-zero entry point offsets.

Instead, replace it with two methods, one that returns the start
(inclusive) and one that returns the end (exclusive) of the
AllocateObject stub instructions payload and have the test choose
points inside and outside of that range to test.

TEST=vm/dart/use_dwarf_stack_traces_flag_test

Fixes: https://github.com/dart-lang/sdk/issues/50286
Cq-Include-Trybots: luci.dart.try:vm-aot-dwarf-linux-product-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try
Change-Id: Ia8965c72fbc6f6d2c178778a32f8083923a8b243
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363080
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-04-23 09:45:21 +00:00
Moritz 8bc935cdb3 Fix documentation for sublist of typed_data
Change-Id: I90ece50be57a7a57cc8bc2ef27402d63bfaa71bd
CoreLibraryReviewExempt: Documentation fixes only.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363704
Commit-Queue: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-04-22 08:54:02 +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
Ömer Sinan Ağacan 637f3b216a [dart2wasm,dart2js] Fix setTimeout and setInterval impls in d8 scripts
HTML spec says the timeout argument in `setInterval` and `setTimeout`
will be 0 when negative [1], update our mocked versions in the d8 script
to implement this.

Fixes tests on dart2wasm-linux-d8:

- co19/LibTest/async/Timer/Timer.periodic_A02_t01
- co19/LibTest/async/Timer/Timer_A02_t01

These tests already pass on Firefox and Chrome.

Fixes #54598.

[1]: https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval-dev
in "Timer initialization steps" step 4: "If timeout is less than 0, then
set timeout to 0."

Change-Id: I716f5942b5dff0fbd5a45c2bb6e0ef2732a5ea67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362260
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-04-19 07:39:55 +00:00
Nicholas Shahan 061004f83f [ddc] Cleanup old setBaseClass()
With the new type system type arguments appearing in extends are
no longer represented by a class definition and do not need to
trigger any lazy logic.

Change-Id: I3f80f9f972bec69c678909c12d25a604a8fe2c59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353205
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-04-18 23:21:07 +00:00
Nate Biggs 215323ad51 Fix broken links in dart:html package.
Fixes: https://github.com/dart-lang/sdk/issues/50247
Change-Id: Ia43cef267fa9f82702892c3a27cbaa81d71386c7
CoreLibraryReviewExempt: Doc update
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363440
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-04-18 18:10:45 +00:00
Ömer Sinan Ağacan a2e3063250 [dart2wasm] Remove redundant allocation in JSStringImpl.toString
Also removes a redundant variable.

Change-Id: I6ff36f2a007f4248b9ec4b3c1fc3fe78a2bb6e85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363560
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-04-18 09:07:54 +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
asiva 0165643fa7 Reland "[SDK] - Ensure we only build an AOT snapshot for the frontend-server"
This is a reland of commit e6c9eaaf6b

Original change's description:
> [SDK] - Ensure we only build an AOT snapshot for the frontend-server
>
> Currently we seem to build both the JIT and AOT snapshots of the
> frontend-server, ensure we only build the AOT snapshot on all
> architectures except IA32
>
> Change-Id: Ie79dc6d88fd9fa680267571e5d65081ca57609c6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359100
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: Id9a695f33e4e808463b4f65bdb3cd0e546a695d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363480
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-04-17 20:42:51 +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
Alexander Markov ad95bb6f89 Reland "[vm] Implement typed data view GetIndexed in flow graph builder"
This is a reland of commit a7e2dce0cc

Fixes the crash during code generation when typed data view
LoadIndexed was used on an internal typed data array
(in the unreachable code path) without loading its payload.

TEST=runtime/tests/vm/dart/regress_b_334128316_test.dart
TEST=manually verified repro from b/334128316

Original change's description:
> [vm] Implement typed data view GetIndexed in flow graph builder
>
> Typed data view 'operator []' is now implemented in the flow
> graph builder. This unifies all typed data GetIndexed operations
> and removes unnecessary address calculations.
>
> TEST=ci
>
> Change-Id: I8d2ca6e7c7bf18b2590536a643f92cad5beb6d95
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361283
> Reviewed-by: Tess Strickland <sstrickl@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>

Change-Id: I3786fa17e971f8ba6cd01a57f1a68504bf24bc47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362821
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-04-16 14:39:48 +00:00
Ömer Sinan Ağacan 95d871084e [dart2wasm] Cache hash codes in JSStringImpl
Change-Id: I41980461f9e6a4818458aa17471bd868b70ad354
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362781
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-16 13:42:48 +00:00
Ömer Ağacan a02859c7b1 Revert "[dart2wasm] Fix trim methods of JS strings"
This reverts commit 102f6c7f33.

Reason for revert: Instead of using VM's implementation we will
refactor and fix the old implementation that calls JS `trim`.

Since the original CL fixed some tests, revert will break them again.

Original change's description:
> [dart2wasm] Fix trim methods of JS strings
>
> We can't use JS `String.p.trim` (and the left/right trims) as we need to
> return the original argument when itd oesn't have any whitespace to
> remove.
>
> They also don't handle the NEL character as expected by Dart.
>
> Instead use the VM's trim implementations.
>
> Fix extracted from https://dart-review.googlesource.com/c/sdk/+/361362
> to keep the CL small.
>
> Change-Id: I5cd6cc2d4349f7b55544257666faff3bbeb00b8c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362388
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Ömer Ağacan <omersa@google.com>

Change-Id: I9c4a3402213f5ace0da55584e737bf62bb51924b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362802
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-04-16 07:20:28 +00:00
Ömer Sinan Ağacan 102f6c7f33 [dart2wasm] Fix trim methods of JS strings
We can't use JS `String.p.trim` (and the left/right trims) as we need to
return the original argument when itd oesn't have any whitespace to
remove.

They also don't handle the NEL character as expected by Dart.

Instead use the VM's trim implementations.

Fix extracted from https://dart-review.googlesource.com/c/sdk/+/361362
to keep the CL small.

Change-Id: I5cd6cc2d4349f7b55544257666faff3bbeb00b8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362388
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-15 09:51:57 +00:00
Ömer Sinan Ağacan 7f275c01b6 [dart2wasm] Escape replacement patterns when calling JS replace
When calling `String.p.replace` we need to escape `$` characters in
replacement argument as `$$` as Dart doesn't have the `$` replacement
syntax.

Fix extracted from https://dart-review.googlesource.com/c/sdk/+/361362
to keep the CL small.

Change-Id: I23a26dda48ed0d5ccb7fea5353f16350a2b046f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362387
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-04-15 08:46:58 +00:00
Ömer Sinan Ağacan 0703566101 [dart2wasm] Fix int-to-js-string conversion
Converting the int to JS `double` fails with large integers. Pass the
`int` as Wasm `i64`, which will implicitly convert it to `BigInt`, and
then use `BigInt.p.toString`.

Fix extracted from https://dart-review.googlesource.com/c/sdk/+/361362
to keep the CL small.

Change-Id: Ia5723632d11fd8544789cf453bb5c0e36ac8f6bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362461
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-15 08:36:22 +00:00
Alexander Markov 8a4c626086 Revert "[vm] Implement typed data view GetIndexed in flow graph builder"
This reverts commit a7e2dce0cc.

Reason for revert: VM crash (b/334128316)

Original change's description:
> [vm] Implement typed data view GetIndexed in flow graph builder
>
> Typed data view 'operator []' is now implemented in the flow
> graph builder. This unifies all typed data GetIndexed operations
> and removes unnecessary address calculations.
>
> TEST=ci
>
> Change-Id: I8d2ca6e7c7bf18b2590536a643f92cad5beb6d95
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361283
> Reviewed-by: Tess Strickland <sstrickl@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>

TEST=ci

Change-Id: I4c5b2e16d1218b92b717c4d0e8eea548d3113eab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362620
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-04-12 19:46:56 +00:00
Alexander Aprelev 62ef193d1a [vm/asserts] Keep asserts lines and source snippets in AOT.
TEST=vm/dart/asserts_test
Fixes https://github.com/dart-lang/sdk/issues/34110

Change-Id: I9f186e7833a30b98739ed7fde6064cc47d14d5c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362198
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-04-12 19:42:15 +00:00
Alexander Markov a7e2dce0cc [vm] Implement typed data view GetIndexed in flow graph builder
Typed data view 'operator []' is now implemented in the flow
graph builder. This unifies all typed data GetIndexed operations
and removes unnecessary address calculations.

TEST=ci

Change-Id: I8d2ca6e7c7bf18b2590536a643f92cad5beb6d95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361283
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-04-12 15:48:22 +00:00
Alexander Aprelev 8af6f94b61 [vm/datetime] Fix construction of '1 microsecond before epoch' DateTime.
TEST=corelib/date_time_extremes_test
Fixes https://github.com/dart-lang/sdk/issues/55438

Change-Id: I87f5c01450089a76703ae6a3326fc188f2b90903
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362301
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-04-11 22:01:29 +00:00
Alexander Markov 6511af1095 [vm] Unsound mode cleanup: remove --null-assertions
Vm flag --null-assertions only makes sense without sound null safety.
Now that VM no longer supports unsound mode, the flag is obsolete and
can be removed.

TEST=ci

Change-Id: I69eb2012ac483f082fd43ecc9743076e0e1928c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362181
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-04-10 18:00:09 +00:00
William Hesse cd2c566bcf 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>
2024-04-09 18:10:57 +00:00
Lasse R.H. Nielsen ff5f391c0a 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>
2024-04-09 14:49:17 +00:00
Parker Lougheed f9bdb11899 [sdk/async] Add since info to new ParallelWaitError parameters
These were added in 1436635d27.

CoreLibraryReviewExempt: No functional change. Only adding since version metadata.
Change-Id: Ifc20265df2694d8ce410025f1d1f6a65f5da81d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361500
Commit-Queue: Marya Belanger <mbelanger@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-04-08 19:40:25 +00:00
Ömer Sinan Ağacan 377d61b625 [dart2wasm] Remove an unnecessary unsafeCast in JSCM string patch
Change-Id: I31e4d4db5cd0fdb9e9bb0f507b4eb521e0fcf3d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361380
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-08 08:24:18 +00:00
Nicholas Shahan cd4070bad8 [ddc] Update _isBrowserType() for use on d8
Before testing values first check if the type being used in the
`instanceOf` exists in the global scope.

Issue: https://github.com/dart-lang/sdk/issues/55378
Change-Id: I1a4759c660aee32071cf7869611f7af85574e04d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361131
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-04-05 23:32:47 +00:00
Siva Annamalai c394f20e82 Revert "[SDK] - Ensure we only build an AOT snapshot for the frontend-server"
This reverts commit e6c9eaaf6b.

Reason for revert: We seem to have issues rolling Dart into Flutter frame works because code outside of the Dart SDK seems to rely on the existence of this snapshot.

Original change's description:
> [SDK] - Ensure we only build an AOT snapshot for the frontend-server
>
> Currently we seem to build both the JIT and AOT snapshots of the
> frontend-server, ensure we only build the AOT snapshot on all
> architectures except IA32
>
> Change-Id: Ie79dc6d88fd9fa680267571e5d65081ca57609c6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359100
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: I0e79cc688aaec7dc5428ccbbaff7f1dbea11a962
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361285
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-04-05 19:47:17 +00:00
Ben Konyi e82ff48027 [ CLI ] Add dart development-service command
The `dart development-service` command will be used by tooling to launch
DDS from the SDK instead of shipping DDS via package:dds.

TEST=Existing service test suite

Change-Id: Ib928aa5b8961caf87d7074884c3d226b5c096ccd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361180
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-04-05 16:30:11 +00:00
Flop 4fd5d783c1 Update Symbol constructor documentation
R=iinozemtsev@google.com

CoreLibraryReviewExempt: Documentation change
Change-Id: I3354f7d4a0c9e5a7281ea8764431139deeac1014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361220
Auto-Submit: 枯枯坐 <kukuzuo@gmail.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-04-05 12:06:39 +00:00
Nicholas Shahan 2379cdc080 [ddc] Enforce more null safety on js interop
- Add a runtime flag to enable checks on non-nullable APIs that
  return values from non-static JavaScript interop.
- Call a new helper method at the call site when these APIs are
  detected to perform the null check.
- Add test file for the cases we can detect and enforce.

NOTE: This does not make non-static JavaScript interop sound.
This only adds more checks to enforce soundness with respect
to nullability in some cases. There are still holes that will
never be closed due to the permissive nature of this form of
JavaScript interop.

Change-Id: I2f88d1543a683fdc84d764e2b0eaafeb0ca73107
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358581
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-04-03 23:20:15 +00:00
asiva e6c9eaaf6b [SDK] - Ensure we only build an AOT snapshot for the frontend-server
Currently we seem to build both the JIT and AOT snapshots of the
frontend-server, ensure we only build the AOT snapshot on all
architectures except IA32

Change-Id: Ie79dc6d88fd9fa680267571e5d65081ca57609c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359100
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-04-03 18:27:39 +00:00
Ömer Sinan Ağacan beecfbcdac [dart2wasm] Remove redundant imports in int_patch.dart
Change-Id: Idab8e7823512898b614de0f944af4de720dced7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360860
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-04-03 17:33:52 +00:00
Ben Konyi d4c20e285c [ Service ] Include drive letter in path when launching DDS snapshot
The previous logic for building the path to dds.dart.snapshot would result
in the Windows drive letter being dropped from the path:

\path\to\dart-sdk\bin\dds.dart.snapshot

This works most of the time since a leading slash is treated as a reference
to the current drive, which often contains the Dart SDK. However, if the SDK
is on a different drive than the current (e.g., in a container with two drives),
the VM will fail to find the snapshot.

This change uses the File(...) APIs from dart:io to build the path rather than
trying to use the Uri class to manually hack together a path.

TEST=N/A, not reproducible without a second Windows drive

Change-Id: I78e9f2980ac583f3784d0c7a5333ec2d235cc113
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360920
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-04-03 17:30:42 +00:00
Jackson Gardner c87367f315 [dart2wasm] typeof process should be compared to a string.
Change-Id: I5e9f144e786c03dca8c63775f15529a9b4fe7d89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360565
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2024-04-03 15:22:38 +00:00
Jackson Gardner d0061b65fc [dart2wasm] Include file, line, and condition text in assertion's toString()
This fixes https://github.com/dart-lang/sdk/issues/55317

Change-Id: I2371423a9715059b8a4c4ede2ef567a4b6293287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360460
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2024-04-03 14:14:08 +00:00
Daco Harkes 410291fc0f [ffi] AbiSpecificIntegerArray explicit type argument
This makes it explicit on the call site what the integer is,
simplifying follow up CLs.

TEST=tests/ffi

CoreLibraryReviewExempt: implementation change only.
Bug: https://github.com/dart-lang/sdk/issues/54739
Change-Id: Ib5bc09f4194e9103cf42eb3851b2308553fd8990
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360640
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2024-04-03 06:11:31 +00:00
Alexander Markov 0af6dde79d Reland "[vm] Replace array GetIndexed graph intrinsics with flow graph builder implementation"
This is a reland of commit d24b5d1f5e

On top of the original change, the following is fixed and improved:

1) Flow graph builder (FGB) body is now also applied to
   dynamic invocation forwarders (similarly to graph
   intrinsics).

2) Frame can be omitted for functions which have a
   call on a shared slow path. This is needed to make
   FGB implementation of GetIndexed frameless, as it has
   GenericCheckBound which calls on shared slow path.
   (Graph intrinsics are frameless).

3) Range analysis is enabled for force-optimized functions,
   so more efficient code can be generated for boxing
   instructions. Range analysis is fixed to avoid crashes
   and correctly intersect ranges with constant boundaries
   (needed for some force-optimized FFI functions).

4) EliminateStackOverflowChecks pass is enabled for
   force-optimized functions so CheckStackOverflow can be
   eliminated.

Original change's description:
> [vm] Replace array GetIndexed graph intrinsics with flow graph builder implementation
>
> _Array, _GrowableList, internal and external typed data 'operator []'
> are now implemented in the flow graph builder.
>
> Unlike graph intrinsics, flow graph created in the flow graph builder
> can be used by the inliner. Corresponding graph intrinsics and native
> methods are removed.
>
> Also, this change adds missing external typed data indexing operations.
>
> TEST=ci
>
> Change-Id: Ic19784481feadf54c096a587413e67b4e18353dc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359940
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TEST=ci

Change-Id: I04ef008a04238d432683d7543cd047e35bad17c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360560
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-04-02 20:41:19 +00:00
Brian Quinlan 9b2b0ac848 [docs,io] Clarify that isDirectory is not meaningful for FileSystemDeleteEvent.
Bug: https://github.com/dart-lang/sdk/issues/55130
Change-Id: I43c95218cd9f6b87ab242affa8cc2b9d42df7d96
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357663
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-03-30 01:03:08 +00:00
Nate Biggs 50360c51ce [dart2js] Add retry to dart2js deferred loading multi loader hook.
In some cases the code downloaded through this hook is corrupted and one or more part files don't get registered correctly. The implementer of this hook just gets a 'download success' event and calls the success callback. It's not until dart2js itself checks if the part file as registered that we know it failed. In this case we should retry the load request with only the failed part files.

This matches the retry logic from the non-multi deferred load hook.

Change-Id: I655acd9f519cba1837d5cb367365a7be7254df03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360380
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-03-29 23:47:13 +00:00
Alexander Markov a33270dc0a Revert "[vm] Replace array GetIndexed graph intrinsics with flow graph builder implementation"
This reverts commit d24b5d1f5e.

Reason for revert: performance regression
(Graph intrinsics are applied to dynamic invocation forwarders,
but flow graph builder implementation isn't.)

Original change's description:
> [vm] Replace array GetIndexed graph intrinsics with flow graph builder implementation
>
> _Array, _GrowableList, internal and external typed data 'operator []'
> are now implemented in the flow graph builder.
>
> Unlike graph intrinsics, flow graph created in the flow graph builder
> can be used by the inliner. Corresponding graph intrinsics and native
> methods are removed.
>
> Also, this change adds missing external typed data indexing operations.
>
> TEST=ci
>
> Change-Id: Ic19784481feadf54c096a587413e67b4e18353dc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359940
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

Change-Id: I2b31b06edaa4b8a09d256f25f923d4489e28518b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360305
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-03-29 17:27:50 +00:00
Alexander Markov d24b5d1f5e [vm] Replace array GetIndexed graph intrinsics with flow graph builder implementation
_Array, _GrowableList, internal and external typed data 'operator []'
are now implemented in the flow graph builder.

Unlike graph intrinsics, flow graph created in the flow graph builder
can be used by the inliner. Corresponding graph intrinsics and native
methods are removed.

Also, this change adds missing external typed data indexing operations.

TEST=ci

Change-Id: Ic19784481feadf54c096a587413e67b4e18353dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359940
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-03-28 20:43:59 +00:00
Daco Harkes eb50c2683c [vm/ffi] Throw on attaching NativeFinalizer to deeply immutable object
This CL

* adds a `kind` to `CheckWritableInstr`,
* starts using `CheckWritableInstr` in JIT mode, and
* adds support for `CheckWritableInstr` ia32.

TEST=tests/ffi/vmspecific_native_finalizer_deeply_immutable_test.dart

Closes: https://github.com/dart-lang/sdk/issues/55067
Change-Id: I0b397daba12cfc8b885401169889f7cd7c040166
Cq-Include-Trybots: dart-internal/g3.dart-internal.try:g3-cbuild-try
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-arm-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/+/359223
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-03-28 11:24:36 +00:00
Konstantin Shcheglov 36c0788137 add package:_macros (SDK vendored) and package:macros (pub published)
add sdk_packages.yaml file (describes SDK vendored package locations)

delete old macro code in _fe_analyzer_shared, move tests/benchmarks

adds a top level `pkg` directory to the Dart SDK, which is where vendored packages live

BUG: https://github.com/dart-lang/sdk/issues/54976
Change-Id: Ib3503a27fb5644fa8a39ab5a3e5b568df330cfd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359040
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2024-03-26 18:40:00 +00:00
Daco Harkes 0bcb0c934d [vm/ffi] Add _Compound _offsetInBytes field
This CL changes compounds (structs, unions, and arrays) to be backed
by a TypedDataBase and an int offset.

Before this CL, the compounds where only backed by a TypedDataBase.
This leads to the following issues:

1. Access to nested structs required code for allocating new typed data
   views or pointers, which the optimizer then had to prevent from
   being allocated after inlining.
2. Runtime branching on whether the TypedDataBase was a Pointer or
   TypedData increased code size and prevented inlining.
   https://github.com/dart-lang/sdk/issues/54892
   This could not be properly optimized if in AOT both typed
   data and pointer were flowing into the same compound.
3. Constructing TypedData views required calculating the length of the
   view.

After this CL, accessing nested compounds will lead to accesses on the
original TypedDataBase with an extra offset.

This removes the polymorphism on TypedData vs Pointer, because the
final int/float/Pointer accesses in nested compounds operate on
TypedDataBase.

Also, it simplifies creating an `offsetBy` accessor, because it will
no longer have to be polymorphic in typed data vs pointer, nor will it
have to calculate the length of the field.

Implementation details:

* The changes in the CFE and patch files are straightforward.
* VM: Struct-by-value returns (or callback params) are initialized
  with an offsetInBytes of 0.
* VM: Struct-by-value arguments (and callback return) need to read out
  the offsetInBytes. Before this CL we were passing in the TypedData
  as tagged value. With this CL we are passing the TypedData as tagged
  value and the offset as unboxed int, from 1 IL input to 2 IL
  inputs. (The alternative would have been to take the compound as
  a tagged value, but that would have prevented optimizations from not
  allocating the compound object in the optimizer.
  The FfiCallInstr is updated to have two definitions for the case
  where we were passing in the TypedData previously.
  The NativeReturnInstr is refactored to be able to take two inputs
  instead of 1. (Note that we don't have VariadicInstr only
  VariadicDefinition in the code base. So the instruction is _not_
  implemented as variadic, rather as having a fixed length of 2.)
* dart2wasm does no longer support nested compounds due to the
  compound implementation only storing a pointer address.
  https://github.com/dart-lang/sdk/issues/55083

Intending to land this after
https://dart-review.googlesource.com/c/sdk/+/353101.

TEST=test/ffi

CoreLibraryReviewExempt: VM and WASM-only implementation change.
Closes: https://github.com/dart-lang/sdk/issues/54892
Bug: https://github.com/dart-lang/sdk/issues/44589
Change-Id: I8749e21094bf8fa2d5ff1e48b6b002c375232eb5
Cq-Include-Trybots: dart-internal/g3.dart-internal.try:g3-cbuild-try
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-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/+/354226
Reviewed-by: Tess Strickland <sstrickl@google.com>
2024-03-26 17:14:13 +00:00
Srujan Gaddam 1232260158 [dart:js_interop] Add ExternalDartReference
Closes https://github.com/dart-lang/sdk/issues/55187

Adds a faster way for users to pass opaque Dart values to
JS without the need for boxing like in JSBoxedDartObject.
This does mean, however, that this new type can't be a JS type,
and therefore cannot have interop members declared on it.
Refactors existing code to handle that distinction.

CoreLibraryReviewExempt: Backend-specific library that's been reviewed by both dart2wasm and JS compiler teams.
Change-Id: Ia86f1fe3476512fc0e5f382e05739713b687f092
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358224
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-03-26 15:43:19 +00:00
Brian Quinlan 97d8445e5f Revert "[io] Fix a bug where Process.stdin.add exceptions could not be caught"
This reverts commit 9967075787.

Reason for revert: Ignoring `done` is asymmetrical with other IOSinks.

Original change's description:
> [io] Fix a bug where Process.stdin.add exceptions could not be caught
>
> Change-Id: I2383a74bfa6950ab8f8934087fb68218f06dd681
> Bug:https://github.com/dart-lang/sdk/issues/48501
> Tested: Unit test
> CoreLibraryReviewExempt: dart:io only
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351380
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Brian Quinlan <bquinlan@google.com>

Bug: https://github.com/dart-lang/sdk/issues/48501
Change-Id: Ib5356c640d4dddc30e561b9d60d93f794a935103
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359680
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-03-25 21:03:12 +00:00
Alexander Markov b771c6f45d [vm/corelib] Remove intermediate _getIndexed/_setIndexed methods from typed data
This change aligns all typed data implementations with Int8 typed data
and allows compiler to recognized and replace typed data access
operations earlier, before method inlining. Consequently, this increases
chances for [] and []= to be inlined. In JIT, this also prevents
non-inlined calls to _getIndexed/_setIndexed as [] and []= are graph
intrinsics which bypass calls to _getIndexed/_setIndexed.

TEST=ci

Change-Id: I95a85963da07fd1c04c06e0af09f76eb15f93353
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359520
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-03-25 20:06:40 +00:00
Srujan Gaddam 47f08fb143 [dart:js_interop] Change several operators back to JSBoolean
Related issues:
https://github.com/dart-lang/sdk/issues/55024
https://github.com/dart-lang/sdk/issues/55267

These operators were initially broken in 3.3 and were exposed
as returning JSBoolean but implemented as returning bool. They
were fixed to return bool in the public API, but we should
prefer to have them return JS types as they're likely to be used
in cases where implicit conversions are not useful.

CoreLibraryReviewExempt: Fixing type mismatch in backend-specific library.
Change-Id: I3b0e60550dcac78918f8399d11238dcfa34982cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359180
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-03-25 17:05:36 +00:00