Commit graph

14203 commits

Author SHA1 Message Date
Ryan Macnak
6e3ef8b9e6 [standalone] Update tcmalloc to 2.10.
Remove some architecture limitations.

TEST=ci
Change-Id: I9703729d3e871687cd4951ec40d3d09ae579871f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247864
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2022-07-06 17:34:20 +00:00
Vyacheslav Egorov
a2ab7ccea4 [vm] Avoid UB in FinalizeHash(hash)
FinalizeHash(hash) was trying to avoid UB in expression 1 << 32
by casting 1 to uintptr_t. This type however is not wide enough
on 32-bit platforms.

Instead just use explicit comparison hashbits < kBitsPerInt32 to
avoid overflow in left shift.

This bug went unnoticed for a while because it the only place
where we call FinalizeHash(hash) is in the snapshot profile
writer code and it only triggers when gen_snapshot is a
32-bit binary - which is only true on Windows, as Mac and Linux
seem to use simarm_x64 configuration instead.

This UB was explicitly affecting the code behavior because C++
compiler would either optimize out or change behavior of any
code that consumed value produced by FinalizeHash(hash).

Fixes https://github.com/flutter/flutter/issues/97764

TEST=vm/cc/DirectChainedHashMap

Change-Id: I39f2b09e7516c875b765e5a065d1c1331f89fa33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250741
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-07-06 12:48:16 +00:00
方哲源
6b04cac19d [vm] Bug fix in dedup optimization when build deferred components.
Closes https://github.com/dart-lang/sdk/pull/49393

TEST=vm/dart{,_2}/regress_49372

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try
GitOrigin-RevId: c6306f96ae2bafa25c45e5c7a818c71eb72d8d12
Bug: https://github.com/dart-lang/sdk/issues/49372
Change-Id: I7ec4b170819321cb74037e475006890259446744
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250720
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-07-06 11:04:10 +00:00
Johnni Winther
f6846849b9 [cfe] Handle augment super expressions
This adds the generation of access to augmented procedures.

TEST=existing

Change-Id: I5efa9cc541b86c18735bb1f4c51c73976ffa42ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250164
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-07-04 12:37:50 +00:00
Daco Harkes
c48f6fea58 [vm] Small fixes
Some small fixes split off from
https://dart-review.googlesource.com/c/sdk/+/246241.

* Print code comments on disassembly if the code object exists.
* Add Struct to the NativeType API.
* Fix typo.
* Add documentation.

TEST=Only cosmetic changes, build/run CI should be enough.

Change-Id: Ie193243573b034c52e41401b4d384d556c212fdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250165
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-07-04 07:53:39 +00:00
Zach Anderson
d7df61e042 Revert "[vm] Generate event ids for synchronous begin and end events."
This reverts commit 7fe44864d6.

Reason for revert: https://github.com/flutter/flutter/issues/106957

Original change's description:
> [vm] Generate event ids for synchronous begin and end events.
>
> os_signposts needs explicit ids to match begin and end events, whereas all other trace systems do this implicitly.
>
> TEST=Instruments
> Bug: https://github.com/dart-lang/sdk/issues/49178
> Change-Id: Ifeeaa1dfe823a0d5668f48b8c584f8bdeef23212
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249951
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,asiva@google.com

Change-Id: Id86959d08b5352b5446b6f294a8302b88b4fa0c8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/49178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250403
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2022-07-01 16:08:40 +00:00
Liam Appelbe
f7990bc0da Revert "[vm] Forward dynamic events names to os_signposts as arguments."
This reverts commit 90da09e2db.

Reason for revert: Blocking this revert: https://dart-review.googlesource.com/c/sdk/+/250403

Original change's description:
> [vm] Forward dynamic events names to os_signposts as arguments.
>
> TEST=Instruments
> Bug: https://github.com/dart-lang/sdk/issues/49178
> Change-Id: Ice4a83f03dccb6c7dbd54c229f37d4ea7d0d8051
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250111
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,asiva@google.com

Change-Id: I326fb50ead5c298e62666371adadb2b9f40d69c7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/49178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250407
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-07-01 16:07:50 +00:00
Vyacheslav Egorov
ec9a660ccc [vm] Avoid clobbering array length in AllocateArray stub on ARM
It was calling EnsureIsNewOrRemembered on the slow path which
was forgetting to preserve registers around a runtime call.

Fixes https://github.com/flutter/flutter/issues/106510

TEST=vm/dart{,_2}/flutter_regress_106510

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm-try
Change-Id: I621e392304fcd1fd643c009fbcde3f88b6f19b7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250168
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-07-01 12:31:47 +00:00
Alexander Markov
abedfaf62a [vm] Fix soundness issue when awaiting a user-defined Future
TEST=language/async/await_user_defined_future_soundness_test

Issue: https://github.com/dart-lang/sdk/issues/49345
Change-Id: Ieaaa9baace13dad242c770a710d4d459e135af81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250222
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-30 22:53:24 +00:00
Ryan Macnak
7004b1859f [vm] Account for pool entries that are immediate objects.
Cf. 4c82eb5836

TEST=gallery
Bug: https://github.com/flutter/gallery/issues/545
Change-Id: I90935aba3737f7b6873368e5a8ebf1cc48d34a22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250320
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-06-30 20:32:44 +00:00
Ryan Macnak
90da09e2db [vm] Forward dynamic events names to os_signposts as arguments.
TEST=Instruments
Bug: https://github.com/dart-lang/sdk/issues/49178
Change-Id: Ice4a83f03dccb6c7dbd54c229f37d4ea7d0d8051
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250111
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-30 20:16:33 +00:00
Ryan Macnak
7fe44864d6 [vm] Generate event ids for synchronous begin and end events.
os_signposts needs explicit ids to match begin and end events, whereas all other trace systems do this implicitly.

TEST=Instruments
Bug: https://github.com/dart-lang/sdk/issues/49178
Change-Id: Ifeeaa1dfe823a0d5668f48b8c584f8bdeef23212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249951
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-30 16:48:36 +00:00
Ryan Macnak
1c461e06c1 [vm, gc] Make force-growth a thread-local property.
Don't evaluate concurrent marking on new-space page allocation or external allocation under force-growth scopes.

TEST=ci, tsan
Bug: https://github.com/dart-lang/sdk/issues/49344
Bug: https://github.com/dart-lang/sdk/issues/48377
Bug: https://github.com/dart-lang/sdk/issues/48607
Change-Id: Ieff3880bd29228804419ef292a41ba4d502c2c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250223
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-06-30 00:21:36 +00:00
Daco Harkes
a37502c1b8 [misc] Cleanup stale todos
TEST=tests/ffi

Change-Id: Iae97f62b1adb8dbe99ad075dfe750604db0de62c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249301
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-06-28 16:02:53 +00:00
Ryan Macnak
93a4247af3 Reapply "Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units."
Weaken assertion in gen_snapshot requiring all libraries to have a loading unit as there can still be unreachable libraries:
  - Google3 and Fuchsia will compile all the sources in a package to a single dill file, then present multiple input dill files to the AOT compilation. Since the set of libraries was derived from package membership instead of imports, many can be unreachable.
  - When the root library's main comes from an export, the frontend's representation will incorrectly report the library containing main as the root library and the true root library may be unreachable from it.

Instead, assert only that surviving compiled code is assigned a loading unit.

TEST=gallery
Bug: https://github.com/flutter/gallery/issues/545
Bug: https://github.com/dart-lang/sdk/issues/49325
Bug: https://github.com/dart-lang/sdk/issues/41974
Bug: b/237016312
Change-Id: Ia52563a6f517308d041368be11dcc85270f19acc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249724
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-27 18:56:12 +00:00
Alexander Markov
77ea9820aa [vm] New implementation of sync* based on suspend/resume stubs
Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I7f4b6b56d914a617dfd7ac724cd4414532073b4c
TEST=ci
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249141
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-27 18:19:12 +00:00
Ryan Macnak
e7b77987ff [vm, gc] Address TSAN warning on access to PageSpace::phase_.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/49323
Change-Id: I6e98cbd33b69332a01db4fdcceb0b3da164e725e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249760
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-24 23:00:00 +00:00
Emmanuel Pellereau
6c542eca22 Revert "[ VM / Service ] Add abstract flag to Function"
This reverts commit 921476edf3.

Reason for revert: breaks google3 (b/236964692).

Original change's description:
> [ VM / Service ] Add abstract flag to Function
>
> Bug: https://github.com/dart-lang/coverage/issues/398
> Change-Id: I1f6e16483e28fb7a77aebae079fd62abe9d16099
> TEST=Added to get_object_rpc_test.dart
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249421
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

TBR=bkonyi@google.com,liama@google.com

Change-Id: I1733080dadd6f283766dddbdbe1390d821f91f64
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/coverage/issues/398
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249680
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
2022-06-24 07:35:29 +00:00
Emmanuel Pellereau
c13f7b0360 Revert "Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units."
This reverts commit 9c2a91fb72.

Reason for revert: breaks google3 (b/237016312)

Original change's description:
> Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units.
>
> If a library contained an entry point but was not reachable from the root library, it was not assigned to any loading unit and caused a null dereference in gen_snapshot. This is not possible with the standalone embedder, but is possible in Flutter because it passes multiple sources to frontend_server.  E.g., `--source dart_plugin_registrant.dart`.
>
> TEST=gallery
> Bug: https://github.com/flutter/gallery/issues/545
> Change-Id: I9c67f0e39f7509094ee873610d80851a702a0cf2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249640
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com

Change-Id: I3e17bf29b8f29e4797abfca35fa82b9ca3b5a160
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/flutter/gallery/issues/545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249681
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
2022-06-24 07:35:08 +00:00
Ryan Macnak
9c2a91fb72 Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units.
If a library contained an entry point but was not reachable from the root library, it was not assigned to any loading unit and caused a null dereference in gen_snapshot. This is not possible with the standalone embedder, but is possible in Flutter because it passes multiple sources to frontend_server.  E.g., `--source dart_plugin_registrant.dart`.

TEST=gallery
Bug: https://github.com/flutter/gallery/issues/545
Change-Id: I9c67f0e39f7509094ee873610d80851a702a0cf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249640
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-23 23:51:48 +00:00
Ryan Macnak
0a8fda94b6 [vm, compiler] Use RISC-V's compare-and-branch for a shorter write barrier sequence.
dart2js.aot.rv64 25753840 -> 25721032 (-0.13%)
dart2js.aot.rv32 24891160 -> 24858368 (-0.13%)

TEST=ci
Change-Id: I252e0477f11b9198fe043f105a8745bc283aaaa8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249062
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-23 15:58:15 +00:00
Liam Appelbe
921476edf3 [ VM / Service ] Add abstract flag to Function
Bug: https://github.com/dart-lang/coverage/issues/398
Change-Id: I1f6e16483e28fb7a77aebae079fd62abe9d16099
TEST=Added to get_object_rpc_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249421
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-06-23 15:46:05 +00:00
Emmanuel Pellereau
bb104f07fc Revert "Reland "[vm] Remove warnings about non-standard stack traces.""
This reverts commit 6651c29779.

Reason for revert: breaks google3 (b/236928633)

Original change's description:
> Reland "[vm] Remove warnings about non-standard stack traces."
>
> This is a reland of commit cc9d14d822
>
> TEST=vm/dart{,_2}/causal_stacks/async_throws_stack_lazy_non_symbolic_test
>
> Original change's description:
> > [vm] Remove warnings about non-standard stack traces.
> >
> > The language team has clarified in
> > https://github.com/dart-lang/language/issues/1212 that the content of
> > stack traces is not specified in a way that is violated by either
> > obfuscation or non-symbolic stack traces. Thus, we remove the warnings
> > about supposedly standard-violating stack traces.
> >
> > TEST=No change in actual functionality, so tested manually.
> >
> > Bug: https://github.com/dart-lang/sdk/issues/43388
> > Change-Id: I2c7ac44cf2f9afafa85d902b2783e1173e727264
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249185
> > Commit-Queue: Tess Strickland <sstrickl@google.com>
> > Reviewed-by: Daco Harkes <dacoharkes@google.com>
> > Reviewed-by: Martin Kustermann <kustermann@google.com>
>
> Bug: https://github.com/dart-lang/sdk/issues/43388
> Change-Id: Ifa7915b4ba21cca592ed5645cd9ad6cda1575f12
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249192
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>

TBR=kustermann@google.com,dacoharkes@google.com,sstrickl@google.com

Change-Id: I65f3d84caee3ec9ac30f0ce058104bb24ef6ea11
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43388
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249580
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
2022-06-23 09:25:00 +00:00
Alexander Aprelev
413f60a8b6 Reland "Update clang and gn to match Fuchsia."
This reverts commit a99b0f6c09.

To fix culprit for the revert, it no longer rolls zlib, instead adds
an option to ignore clang warnings in zlib source code.

TEST=ci

Change-Id: I9a877ff0c08af961bc49fcacaad5b01f1ed0a743
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249542
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-22 21:54:25 +00:00
Ryan Macnak
2e4107c8ae [vm, gc] Apply incremental marking back-pressure in proportion to internal allocation size.
In particular, do not apply incremental marking back-pressure for external allocations. External allocations do not cause additional marking work. If a mutator thread performs a storm of external allocations, this should not cause it to effectively become a marking thread.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47492
Bug: https://github.com/flutter/flutter/issues/106305
Change-Id: Icace57e73d695143f7e295924b61b9b1c04be121
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249403
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-06-22 15:41:04 +00:00
Tess Strickland
6651c29779 Reland "[vm] Remove warnings about non-standard stack traces."
This is a reland of commit cc9d14d822

TEST=vm/dart{,_2}/causal_stacks/async_throws_stack_lazy_non_symbolic_test

Original change's description:
> [vm] Remove warnings about non-standard stack traces.
>
> The language team has clarified in
> https://github.com/dart-lang/language/issues/1212 that the content of
> stack traces is not specified in a way that is violated by either
> obfuscation or non-symbolic stack traces. Thus, we remove the warnings
> about supposedly standard-violating stack traces.
>
> TEST=No change in actual functionality, so tested manually.
>
> Bug: https://github.com/dart-lang/sdk/issues/43388
> Change-Id: I2c7ac44cf2f9afafa85d902b2783e1173e727264
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249185
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Bug: https://github.com/dart-lang/sdk/issues/43388
Change-Id: Ifa7915b4ba21cca592ed5645cd9ad6cda1575f12
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249192
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-06-22 09:19:37 +00:00
Ryan Macnak
d45dde461e [vm] Fix edge cases in simulating RISC-V's fmin/fmax.
TEST=ci (+ local qemu)
Change-Id: Ia7921c204cf2397fda785196731c93b627dee62a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249082
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-21 20:47:34 +00:00
Ryan Macnak
baa870bfa7 [vm, gc] Prevent multiple threads racing to finalize marking from triggering an extra (synchronous) GC.
TEST=ci
Change-Id: I844f23cbedfc99950b4dfadfb9a339865bea1a6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-21 19:56:34 +00:00
Alexander Aprelev
a99b0f6c09 Revert "Update clang and gn to match Fuchsia."
This reverts commit e9f629f607 as it break flutter build https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20iOS%20Engine/32804/overview

```
[1617/4268] CC obj/third_party/zlib/chrome_zlib.adler32.o

FAILED: obj/third_party/zlib/chrome_zlib.adler32.o
error: unknown warning option '-Wno-deprecated-non-prototype' [-Werror,-Wunknown-warning-option]
[1618/4268] CXX obj/third_party/skia/modules/skunicode/src/skunicode.SkUnicode_icu_builtin.o
[1619/4268] CC obj/third_party/zlib/chrome_zlib.compress.o
FAILED: obj/third_party/zlib/chrome_zlib.compress.o
error: unknown warning option '-Wno-deprecated-non-prototype' [-Werror,-Wunknown-warning-option]
```

TEST=ci

Change-Id: I3c4ce4a9c80be197dc50e70365e668e5b7a4e2fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249240
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-21 17:02:04 +00:00
Tess Strickland
140db2e0f3 Revert "[vm] Remove warnings about non-standard stack traces."
This reverts commit cc9d14d822.

Reason for revert: Broken precomp async stack tests.

Original change's description:
> [vm] Remove warnings about non-standard stack traces.
>
> The language team has clarified in
> https://github.com/dart-lang/language/issues/1212 that the content of
> stack traces is not specified in a way that is violated by either
> obfuscation or non-symbolic stack traces. Thus, we remove the warnings
> about supposedly standard-violating stack traces.
>
> TEST=No change in actual functionality, so tested manually.
>
> Bug: https://github.com/dart-lang/sdk/issues/43388
> Change-Id: I2c7ac44cf2f9afafa85d902b2783e1173e727264
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249185
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,dacoharkes@google.com,sstrickl@google.com

Change-Id: I315ce10074109cf7f7cdbd94402673444b0fd6f3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43388
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249191
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-06-21 11:54:34 +00:00
Tess Strickland
cc9d14d822 [vm] Remove warnings about non-standard stack traces.
The language team has clarified in
https://github.com/dart-lang/language/issues/1212 that the content of
stack traces is not specified in a way that is violated by either
obfuscation or non-symbolic stack traces. Thus, we remove the warnings
about supposedly standard-violating stack traces.

TEST=No change in actual functionality, so tested manually.

Bug: https://github.com/dart-lang/sdk/issues/43388
Change-Id: I2c7ac44cf2f9afafa85d902b2783e1173e727264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249185
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-06-21 08:00:33 +00:00
Alexander Markov
8bc1cda3f7 [vm] Fix --enable-mirrors VM flag to affect environment and conditional imports
This change propagates --enable-mirrors VM flag to CFE via
TargetFlags.supportMirrors. CFE uses that to select conditional
imports and for constant evaluation of bool.fromEnvironment.

TEST=runtime/tests/vm/dart/enable_mirrors_test

Issue: https://github.com/dart-lang/sdk/issues/49266
Change-Id: I9f6b03f1ab224d13cbe9f035fb5b6fa6eb59055c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249020
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-17 17:20:09 +00:00
Ryan Macnak
01a7f207c3 [vm] Speed up the RISC-V simulator.
TEST=ci
Change-Id: I8ddba01117d21fcf915d77bc06765a0d576f55ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248682
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-16 17:56:02 +00:00
Alexander Aprelev
6d923dfd99 Revert "Deprecate outdated errors, drop CastError and NullThrownError."
This reverts commit 0f3dea33f9.

Reason for revert: breaks dart->engine roller as flutter still uses NullThrownError, fails analysis step

Original change's description:
> Deprecate outdated errors, drop `CastError` and `NullThrownError`.
>
> Both `CastError` and `NullThrownError` becomes just (deprecated) aliases for `TypeError`.
>
> `FallThroughError` becomes deprecated. Fall-through was made a compile-time error in Dart 2.0, the error should no longer be used.
>
> `CyclicInitializationError` is deprecated. Null safe Dart doesn't specify which error a late initialization error throws. We use internal errors now.
>
> These errors should not be needed in sound null-safe mode (if they are even needed now), and so should be removed in Dart 3.0.
>
> TEST= No new tests, should not change behavior in a significant way.
>
> Bug: https://github.com/dart-lang/sdk/issues/49141
> Change-Id: I636e9a0d0c32021d40bb819a88a1f57db6efc5a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247384
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Brian Quinlan <bquinlan@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/49141
Change-Id: I1b2802ec69fe654525e683527ff3554ff972f0c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248741
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-16 17:12:19 +00:00
Ryan Macnak
e9f629f607 Update clang and gn to match Fuchsia.
Roll zlib for -Wno-deprecated-non-prototype.

TEST=ci
Bug: https://github.com/flutter/flutter/issues/103568
Change-Id: I969ab107e8917cc35645cfc9916db0d9ab61b203
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248720
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-16 16:06:09 +00:00
Ryan Macnak
068d88b0d0 [vm, compiler] Emit constant-width addresses in IA32 disassembly for the absolute addressing mode.
TEST=ci
Change-Id: I1a3f6a4064ecc6d93e9cb21055d43e9cb698eea5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248721
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-06-16 16:03:19 +00:00
Alexander Aprelev
abeaa03148 [vm/heap/metrics] Remove deprecated isolate-based vm heap statistic messages.
Fixes https://dartbug.com/49211
TEST=ci

Change-Id: Icddbebccf84f226b2ac89acb9153353d84658079
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248680
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-16 15:27:49 +00:00
Tess Strickland
73bc88f957 [vm/compiler] Fix bad check in CompilerType::IsAssignableTo.
In order to know whether a value is assignable to a given type,
we need the fully instantiated type. Thus, return false if the
type given to CompilerType::IsAssignableTo is uninstantiated,
similar to CompilerType::IsInstanceOf.

TEST=vm/dart{,_2}/regress_b_230945329_test.dart

Bug: b/230945329
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I7ff9eb2214debc274f09580d51c80f0921f8f77d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244200
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-06-16 14:03:00 +00:00
Ryan Macnak
1a2dd17712 [vm, compiler] XMM0 is not just a scratch register on IA32.
In particular, it can be live across write-barrier calls.

TEST=ci
Change-Id: I9383cc775315d76d0dc0052fa8f91daa233cb413
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248681
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-15 20:16:58 +00:00
kanghuay
5daf8f21ed [vm] Prevent empty range in coverage output
Closes https://github.com/dart-lang/sdk/pull/49251

GitOrigin-RevId: 4c399e9b8150bbce495b4f88e0546bdd40fff7ed
Change-Id: Ic16843edeeca9678a7caedbe8f675f7d0d20548d
TEST=Added a case to source_report_test.cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248349
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2022-06-15 20:13:28 +00:00
Ryan Macnak
ec54e588fc [vm, compiler] Implement all remaining assembly intrinsics for RISC-V.
TEST=ci
Change-Id: Ifbeac4ca5a3af5950b07446896b70ab4e6693ce5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247801
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-15 19:37:48 +00:00
Lasse R.H. Nielsen
0f3dea33f9 Deprecate outdated errors, drop CastError and NullThrownError.
Both `CastError` and `NullThrownError` becomes just (deprecated) aliases for `TypeError`.

`FallThroughError` becomes deprecated. Fall-through was made a compile-time error in Dart 2.0, the error should no longer be used.

`CyclicInitializationError` is deprecated. Null safe Dart doesn't specify which error a late initialization error throws. We use internal errors now.

These errors should not be needed in sound null-safe mode (if they are even needed now), and so should be removed in Dart 3.0.

TEST= No new tests, should not change behavior in a significant way.

Bug: https://github.com/dart-lang/sdk/issues/49141
Change-Id: I636e9a0d0c32021d40bb819a88a1f57db6efc5a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247384
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-15 15:35:58 +00:00
Alexander Markov
058265f4e7 Reland "[vm] More efficient 'await' of not Future and completed _Future"
This is a reland of commit 6b3d1752fa

Fixes b/235734143
TEST=runtime/tests/vm/dart/await_in_custom_zone_test.dart

Original change's description:
> [vm] More efficient 'await' of not Future and completed _Future
>
> When awaiting a value which is not a Future or a completed
> built-in _Future, 'await' implementation can bypass heavyweight
> _Future/_FutureListener machinery and schedule micro-tasks directly.
>
> Benchmarks:
> JIT, x64:
> AsyncLiveVars.* +46-54% (bigger is better)
> Calls.AwaitAsyncCall -46% (less is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -46%
> Calls.AwaitAsyncCallClosureTargetPolymorphic -45%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -45%
> Calls.AwaitFutureOrCall -60%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -60%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -59%
>
> JIT, ia32:
> AsyncLiveVars.* +43-52% (bigger is better)
> Calls.AwaitAsyncCall -42% (less is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -42%
> Calls.AwaitAsyncCallClosureTargetPolymorphic -41%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -39%
> Calls.AwaitFutureOrCall -55%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -54%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -53%
>
> JIT, arm:
> AsyncLiveVars.* +64-71% (bigger is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -51% (less is better)
> Calls.AwaitAsyncCallClosureTargetPolymorphic -47%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -48%
> Calls.AwaitFutureOrCall -64%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -64%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -59%
>
> JIT, arm64:
> AsyncLiveVars.* +65-78% (bigger is better)
> Calls.AwaitAsyncCall -51% (less is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -51%
> Calls.AwaitAsyncCallClosureTargetPolymorphic -50%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -49%
> Calls.AwaitFutureOrCall -69%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -68%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -67%
>
> AOT, x64:
> AsyncLiveVars.* +55-61% (bigger is better)
> Calls.AwaitAsyncCall -47% (less is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -46%
> Calls.AwaitAsyncCallClosureTargetPolymorphic -47%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -46%
> Calls.AwaitFutureOrCall -59%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -59%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -58%
>
> AOT, arm:
> AsyncLiveVars.* 54-66% (bigger is better)
> Calls.AwaitAsyncCall -46-51% (less is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -46-50%
> Calls.AwaitAsyncCallClosureTargetPolymorphic -46-52%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -45-50%
> Calls.AwaitFutureOrCall -63-68%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -63-66%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -63-67%
>
> AOT, arm64:
> AsyncLiveVars.* +53-66% (bigger is better)
> Calls.AwaitAsyncCall -50-51% (less is better)
> Calls.AwaitAsyncCallInstanceTargetPolymorphic -50%
> Calls.AwaitAsyncCallClosureTargetPolymorphic -50-51%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits -49-50%
> Calls.AwaitFutureOrCall -66-68%
> Calls.AwaitFutureOrCallInstanceTargetPolymorphic -66-68%
> Calls.AwaitFutureOrCallClosureTargetPolymorphic -63-67%
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/48378
>
> Change-Id: I65e3702fcd816ee3fee876ff442b9887c035b1ec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243102
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

Change-Id: I245984ace1c768fdcba58dfdd6aa46e52126be4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248442
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-15 15:35:38 +00:00
Ahmed Ashour
85700570f6 Fix typos
Fixes #49241

TEST=ci

Change-Id: I6117bf816fc8c4613cce66927f952fef75632725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248120
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-15 11:08:28 +00:00
Liam Appelbe
d1affb719f [vm] Remove async function deduping in source_report
As of https://dart-review.googlesource.com/c/sdk/+/247603 we no longer
see 2 copies of the function, so now this deduping check entirely skips
those functions.

Fixes: https://github.com/dart-lang/coverage/issues/392
Bug: https://github.com/dart-lang/coverage/issues/392
Change-Id: I7157eec2ad53b3bcff346e4837bec26169b94e5b
TEST=Added coverage_async_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248460
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-14 23:50:17 +00:00
Ryan Macnak
837480f3f6 [vm, gc] Parallelize scavenging large arrays.
TEST=ci
Change-Id: Ie9966aa2a1d8821f486fb8acd7ff4c3fe7c111ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247602
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-14 21:34:08 +00:00
Ryan Macnak
305c3e30c6 [vm, gc] Remove the growth policy's hard limit when concurrent marking is available.
Instead, impose back-pressure by making mutators assist with marking as they allocate.

Synchronous marking may still occur if the heap grows to --old_gen_heap_size or the OS is out of memory.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47492
Change-Id: I2538f9e9b6d67bbbca0951d5162075a950658380
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246180
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-13 18:46:37 +00:00
Johnni Winther
7900e9071a [cfe] Remove support for old super-mixins feature
This CL remove the support for mixing in classes that don't extend
Object. An error has been report by the analyzer for some time and
now also by the CFE.

This puts the breaking change https://github.com/dart-lang/sdk/issues/48167 into effect.

TEST=pkg/front_end/testcases/general/issue48167.dart

Change-Id: Ia7715a27dc1aa18a7c85b24ed86d19a91b6924d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247551
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-13 15:30:57 +00:00
Ahmed Ashour
8bb3a10e40 Fix typos
Fixes #49228

TEST=ci

Change-Id: Idcc625554bcf07807bae9791ea37b73ae9394b87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247960
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-10 15:48:54 +00:00
asiva
6970e0907b [VM | VMService] Fix expression evaluation when recursive types are used.
Bug:49209
TEST=pkg/vm_service/test/eval_issue_49209_test.dart
Change-Id: I7da8a195a624b34519aa64fffc248cad0fb7e6fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247901
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-06-10 15:03:04 +00:00
Alexander Markov
de43a7c16a [vm] Cleanup --lazy-async-stacks VM option
This option was enabled by default in https://dart-review.googlesource.com/c/sdk/+/149288
This change removes old logic behind --no-lazy-async-stacks
and makes --lazy-async-stacks/--no-lazy-async-stacks options no-op.

TEST=ci

Change-Id: I5726690e90e78dd2ac37d8c5944e388042fc3acf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247780
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-10 13:41:24 +00:00
Alexander Markov
a765ba1006 [vm] Handle dropped pragma class in Library::FindPragma
AOT compiler can remove pragma class from ObjectStore.
This change fixes Library::FindPragma to handle this situation.

TEST=service_2/pause_on_unhandled_exceptions_catcherror_test

Change-Id: I5f58ebcb0f1e3b1c2e658ad19bfdea4c72577a7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247763
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-06-09 17:52:19 +00:00
Siva Annamalai
5cb3b37c74 Revert "Refactor _Future."
This reverts commit 69f32d6ad7.

Reason for revert: We seem to have a number of tests failing with timeouts in CBUILD after this change, please see logs at
69f32d6ad7

Original change's description:
> Refactor `_Future`.
>
> This is a major rewrite of the `_Future` class,
> which is the default implementation of the `Future` interface.
>
> The main goal was to reduce the number of expensive type checks
> in the internal passing around of data.
> Expensive type checks are things like
> * `is _Future<T>` (more expensive than just `is _Future`, the latter
>   can be a single class-ID check.
> * Covariant generic parameter checks (using `T` covariantly in a
>   parameter forces a run-time type check).
>
> Also removed some plain unnecessary casts and turned some
> implicit casts from `dynamic` into `unsafeCast`s.
>
> This seems to be an success, at least on very primitive benchmarks, according to Golem:
> FutureCatchErrorTest    41.22% (1.9 noise)
> FutureValueTest         46.51% (2.8 noise)
> EmptyFutureTest         59.15% (3.1 noise)
> FutureWhenCompleteTest  51.10% (3.2 noise)
>
> A secondary goal was to clean up a very old and messy class,
> and make it clearer for other `dart:async` how to interact
> with the future.
>
> The change has a memory cost: The `_FutureListener<S,T>` class,
> which represents a `then`, `catchError` or `whenComplete`
> call on a `_Future`, now contains a reference to its source future,
> the one which provides the inputs to the callbacks,
> as well as the result future returned by the call.
> That's one extra memory slot per listener.
>
> In return, the `_FutureListener` now does not need to
> get its source future as an argument, which needs a covariant
> generic type check, and the methods of `_Future` can be written
> in a way which ignores the type parameters of both `_Future`
> and `_FutureListener`, which reduces complex type checks
> significantly.
>
> In general, typed code is in `_FutureListener`, which knows both
> the source and target types of the listener callbacks, and which
> contains the futures already at that type, so no extra type checking
> is needed.
> The `_Future` class is mostly untyped, except for its "public"
> API, called by other classes, which checks inputs,
> and code interacting with non-native futures.
> Invariants ensure that only correctly typed values
> are stored in the untyped shared `_resultOrListeners` field
> on `_Future`, as determined by its `_state` integer.
> (This was already partially true, and has simply been made
> more consistent.)
>
> Further, we now throw an error in a situation that was previously
> unhandled: When a `_Future` is completed with *itself*.
> That would ensure that the future would never complete
> (it waits for itself to complete before it can complete),
> and may potentially have caused weird loops in the representation.
> In practice, it probably never happens. Now it makes the error
> fail with an error.
> Currently a private `_FutureCyclicDependencyError` which presents
> as an `UnsupportedError`.
> That avoids code like
> ```dart
> import "dart:async";
> void main() {
>   var c = Completer();
>   c.complete(c.future); // bad.
>   print("well!");
>   var d = Completer();
>   d.complete(c.future);
>   print("shucks!");
> }
> ```
> from hanging the runtime by busily searching for the end of a cycle.
>
> See https://github.com/dart-lang/sdk/issues/48225
> Fixes #48225
>
> TEST= refactoring covered by existing tests, few new tests.
>
> Change-Id: Id9fc5af5fe011deb0af3e1e8a4ea3a91799f9da4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244241
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

TBR=lrn@google.com,kustermann@google.com,sra@google.com,sigmund@google.com,nshahan@google.com

Change-Id: I455be5a04b4c346df26d4ded0fa7388baccb0f8c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247762
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-09 16:51:55 +00:00
Lasse R.H. Nielsen
69f32d6ad7 Refactor _Future.
This is a major rewrite of the `_Future` class,
which is the default implementation of the `Future` interface.

The main goal was to reduce the number of expensive type checks
in the internal passing around of data.
Expensive type checks are things like
* `is _Future<T>` (more expensive than just `is _Future`, the latter
  can be a single class-ID check.
* Covariant generic parameter checks (using `T` covariantly in a
  parameter forces a run-time type check).

Also removed some plain unnecessary casts and turned some
implicit casts from `dynamic` into `unsafeCast`s.

This seems to be an success, at least on very primitive benchmarks, according to Golem:
FutureCatchErrorTest    41.22% (1.9 noise)
FutureValueTest         46.51% (2.8 noise)
EmptyFutureTest         59.15% (3.1 noise)
FutureWhenCompleteTest  51.10% (3.2 noise)

A secondary goal was to clean up a very old and messy class,
and make it clearer for other `dart:async` how to interact
with the future.

The change has a memory cost: The `_FutureListener<S,T>` class,
which represents a `then`, `catchError` or `whenComplete`
call on a `_Future`, now contains a reference to its source future,
the one which provides the inputs to the callbacks,
as well as the result future returned by the call.
That's one extra memory slot per listener.

In return, the `_FutureListener` now does not need to
get its source future as an argument, which needs a covariant
generic type check, and the methods of `_Future` can be written
in a way which ignores the type parameters of both `_Future`
and `_FutureListener`, which reduces complex type checks
significantly.

In general, typed code is in `_FutureListener`, which knows both
the source and target types of the listener callbacks, and which
contains the futures already at that type, so no extra type checking
is needed.
The `_Future` class is mostly untyped, except for its "public"
API, called by other classes, which checks inputs,
and code interacting with non-native futures.
Invariants ensure that only correctly typed values
are stored in the untyped shared `_resultOrListeners` field
on `_Future`, as determined by its `_state` integer.
(This was already partially true, and has simply been made
more consistent.)

Further, we now throw an error in a situation that was previously
unhandled: When a `_Future` is completed with *itself*.
That would ensure that the future would never complete
(it waits for itself to complete before it can complete),
and may potentially have caused weird loops in the representation.
In practice, it probably never happens. Now it makes the error
fail with an error.
Currently a private `_FutureCyclicDependencyError` which presents
as an `UnsupportedError`.
That avoids code like
```dart
import "dart:async";
void main() {
  var c = Completer();
  c.complete(c.future); // bad.
  print("well!");
  var d = Completer();
  d.complete(c.future);
  print("shucks!");
}
```
from hanging the runtime by busily searching for the end of a cycle.

See https://github.com/dart-lang/sdk/issues/48225
Fixes #48225

TEST= refactoring covered by existing tests, few new tests.

Change-Id: Id9fc5af5fe011deb0af3e1e8a4ea3a91799f9da4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244241
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-09 15:32:33 +00:00
Alexander Markov
3e0abdbb98 Reland "[vm] Enable new implementation of async/async* in JIT mode"
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I5b8720b8ef5b8d28773d26c7e94c2e78d876c9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247603
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-09 15:24:13 +00:00
Alexander Markov
e505ab1fd2 [vm] Fix stack trace collection while registering async callbacks in the Zone
During 'await', when registering 'then' and 'error' callbacks in
a custom Zone, the stack trace should be collected synchronously
as there are no awaiters yet, but the suspended function and its
callers are still on the stack.

This change corrects the new implementation of async to collect
these stack traces synchronously.

Class StackZoneSpecification from package:stack_trace relies on the
stack traces during callback registration in order to provide more
detailed chain of async stack traces via Chain.capture.
Without this change package:stack_trace captured truncated Chains.

Issue: https://github.com/dart-lang/sdk/issues/48378
Issue: https://github.com/flutter/flutter/issues/105340

TEST=vm/dart/causal_stacks/zone_callback_stack_traces_test

Change-Id: Iee348aa5c9abb4126f6c5d8215a6dc2cee57e124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-09 14:52:33 +00:00
Alexander Markov
3e9290df4f [vm] Skip caching of function entry points in Thread in JIT mode
Cached entry points of core library functions are only used
in AOT mode (JIT mode uses Function/Code objects instead of entry
points in order to call those functions).

This change removes storing entry points into the Thread.
It fixes TSAN error which reports a data race between JIT compilation
which installs Code and caching of entry points when scheduling
a thread.

TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/49194
Issue: https://github.com/dart-lang/sdk/issues/48378

Change-Id: Ib109118df414cd722001dad363e9e05a94ab0556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247501
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-06-09 14:21:33 +00:00
Michael Richards
d635322b3d Added byte registers to the x86-64 disassembler
TEST=CI

Bug: 48656
Change-Id: I099e25d66e62094d471bebed88b8b4bad1df6c2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247463
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Michael Richards <msrichards@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-06-08 22:57:03 +00:00
Ryan Macnak
3e17635bca [vm, gc] Refactor incremental marking to not require reserving a visitor in advance.
Allow multiple threads to contribute to incremental marking.

Also, avoid incremental markers handling large arrays that exceed their budget.

TEST=ci
Change-Id: Icefe490538ff486063a098077aaa962f0a3f2203
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247260
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-06-08 20:33:02 +00:00
Ryan Macnak
6a1749edbc [vm, ffi] Misc fixes for RV32 FFI.
TEST=local
Change-Id: I50f0a848cfd973389a7e903aa89e650aa7420aaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247503
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-06-08 19:41:52 +00:00
Alexander Aprelev
1fddb10107 [vm/heap/metrics] Make sure heap-related metric are reported for the isolate group, rather than isolate.
TEST=ci

Change-Id: Ie0514f05c0a024ce37f10d56dd29b3fa921133d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247504
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-08 18:01:02 +00:00
Ryan Macnak
78d613b37c [vm, gc] Don't cache a thread in marking visitors.
Marking visitors can run on multiple threads during their lifecycle, so this only creates confusion.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48957
Change-Id: Ia2ac68f0e17c985b18a1faf51be7004c972cf27b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247520
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-08 17:11:54 +00:00
Alexander Aprelev
f681734aef [vm/send_and_exit] Allow for safepoints when validating exit message.
``` before
$ dart isolate_exit_pause_time_test.dart
.Min(RunTimeRaw): 0.001 ms.
.Avg(RunTimeRaw): 212.399592 ms.
.Percentile50(RunTimeRaw): 49.055 ms.
.Percentile90(RunTimeRaw): 809.049 ms.
.Percentile95(RunTimeRaw): 1009.049 ms.
.Percentile99(RunTimeRaw): 1169.049 ms.
.Max(RunTimeRaw): 1208.049 ms.
```

``` after
$ dart isolate_exit_pause_time_test.dart
.Min(RunTimeRaw): 0.001 ms.
.Avg(RunTimeRaw): 53.87510125 ms.
.Percentile50(RunTimeRaw): 8.05 ms.
.Percentile90(RunTimeRaw): 174.005 ms.
.Percentile95(RunTimeRaw): 217.975 ms.
.Percentile99(RunTimeRaw): 275.033 ms.
.Max(RunTimeRaw): 314.033 ms.
```

Remaining latency after the change is due to large root set formed by pointers_to_verify_at_exit_ that have to be visited during GC.

Fixes https://github.com/dart-lang/sdk/issues/49050
TEST=ci

Change-Id: I1ed7af017f80890900b137a1514e5ffdeb63f53f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246482
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-08 16:27:22 +00:00
Ryan Macnak
88ca1e95b8 [vm, gc] Evaluate old-gen GC on each new-gen page.
This gives starting or finalizing concurrent marking a chance to run not-immediately-after-a-scavenge.

TEST=ci
Change-Id: Iec1ba7b7440045cc18e01637af1f865d588b24c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246163
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-07 21:56:41 +00:00
Alexander Markov
3e10d8c833 Revert "[vm] Enable new implementation of async/async* in JIT mode"
This reverts commit b3544c44dc.

Reason for revert: avoid incompatibility between Dart->kernel compiler
and Dart VM during Dart and Flutter rolls (b/234850964).

TEST=ci

Original change's description:
> [vm] Enable new implementation of async/async* in JIT mode
>
> TEST=ci
>
> Issue: https://github.com/dart-lang/sdk/issues/48378
> Change-Id: I0fc069508cb1ce5648deb6604171dfdcd5bcb5c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246082
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,johnniwinther@google.com

Change-Id: I6157623857dbfa9bb07eb1f620d100f5b24314d9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/48378
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247243
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-07 17:57:30 +00:00
Aske Simon Christensen
608b95c9b4 [kernel] Add exhaustiveness information to switch statements
Tested: Added flag to text output and updated expectation files
Change-Id: I44bb82242ad608b19894e22c41d8404c5003c2d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245982
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-07 10:45:39 +00:00
Ryan Macnak
4c82eb5836 Reland "[vm, compiler] Prune dictionaries to only contain elements needed at runtime."
This is a reland of commit 6de162e014

Original change's description:
> [vm, compiler] Prune dictionaries to only contain elements needed at runtime.
>
> flutter_gallery
> Isolate(CodeSize): 2116400 -> 1981238 (-6.28%)
>   Total(CodeSize): 7217938 -> 7082600 (-1.87%)
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/48910
> Change-Id: I8cd285ddab3a611cd7a2a91d50414be402f8543a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244303
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48910
Change-Id: I3d3ecd04369585547963fb3efff1b3ff0723d8f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246990
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-06-03 00:09:25 +00:00
Alexander Markov
b3544c44dc [vm] Enable new implementation of async/async* in JIT mode
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I0fc069508cb1ce5648deb6604171dfdcd5bcb5c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246082
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-02 23:40:15 +00:00
Alexander Markov
af4da780be [vm] New async/async* implementation in JIT mode
The new implementation is based on suspend/resume stubs and doesn't
use desugaring of async functions on kernel AST.

Previously, new implementation of async/async* was only supported in
AOT mode. This change adds all necessary bits for the JIT mode:

 * Suspending variable-length frames (for unoptimized code).
 * Handling of Code and pool pointers in Dart stack frames.
 * OSR.
 * Deoptimization.
 * Hot reload.
 * Debugger.

The new implementation is not enabled in JIT mode yet.

Design doc: go/compact-async-await.
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I477d6684bdce7cbc1edb179ae2271ff598b7dcc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246081
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-02 23:39:45 +00:00
Ben Konyi
4e688b1a59 [ Service / AOT ] Include line numbers for Functions in AOT snapshots
Fixes https://github.com/dart-lang/sdk/issues/48839

TEST=Checked CPU profile for Flutter Gallery in profile mode

Change-Id: I83f372aebd77b93b459720ceb2dd9e5fa05b4475
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245200
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-06-02 16:50:19 +00:00
Helin Shiah
d6665ae4cd Reland "[ Service / DDS ] Add method that can return local paths"
This is a reland of commit a091ff7b27

TEST=Check that a supplied URL conversion function is correctly applied when the `local` param is true.

Original change's description:
> [ Service / DDS ] Add method that can return local paths
>
> TEST=Check that a supplied URL conversion function is correctly applied when the `local` param is true.
>
> Change-Id: Ibe80b6229c574c976379a519baca5d1904b684b2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245040
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

Change-Id: I87433a410715393f853a6538dbfe67391e0c773b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246621
Commit-Queue: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-06-01 21:22:34 +00:00
Ryan Macnak
c588224163 [vm] Represent the slow object copy from_to table with a heap array.
- Greatly reduces the size of the root set, thus reducing pauses for scavenges or marking that occur during a copy.
 - Reduces the memory overhead of the from_to table from 6 words per object to 2 words per object.

TEST=ci
Change-Id: Icf81f4b25adff22590a9c84c40068e35dd4d502b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246305
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-06-01 17:52:28 +00:00
Ryan Macnak
188dfbd52b [vm] Check for safepoints while initializing or copying large arrays.
TEST=ci
Change-Id: I5ca25d3996e51210464b06492c0b8b6119c4242c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246304
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-01 17:45:24 +00:00
Siva Annamalai
1e7bc687a7 Revert "[vm, compiler] Prune dictionaries to only contain elements needed at runtime."
This reverts commit 6de162e014.

Reason for revert: Local testing of a large Flutter app with this change causes the app to crash on startup

Original change's description:
> [vm, compiler] Prune dictionaries to only contain elements needed at runtime.
>
> flutter_gallery
> Isolate(CodeSize): 2116400 -> 1981238 (-6.28%)
>   Total(CodeSize): 7217938 -> 7082600 (-1.87%)
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/48910
> Change-Id: I8cd285ddab3a611cd7a2a91d50414be402f8543a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244303
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/48910
Change-Id: Ie51f004e84970907fa1233e8e7c3ed63e2da1c4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246683
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-06-01 00:58:24 +00:00
Ryan Macnak
b6fd6e0593 [vm, gc] Don't double initialize typed data in compressed pointers mode.
Originally, memory in the compressed heap was recycled such that allocating a large page didn't guarentee the page was zeroed. Since 735f96d6a6, allocating a large page results in a freshly committed page that is zeroed.

TEST=ci
Change-Id: I1ab1fdf16fc3d498d676a228187162b2e669f692
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246303
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-31 17:17:53 +00:00
Ryan Macnak
6fd776dd17 [vm] Update --log_growth to use MB to match --verbose_gc.
Also include the soft threshold.

TEST=no
Change-Id: I834bc62518cedff98a4d4dbd16b1b50532cd002e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246050
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-05-31 17:11:54 +00:00
Daco Harkes
437538b169 [vm/ffi] CCallInstr fix product mode
Don't refer to `RepresentationToCString` in product mode.

TEST=product build of SDK

Change-Id: I1356934da926ec910c5d78980b64c9f42b8a60f3
Cq-Include-Trybots: luci.dart.try:app-kernel-linux-product-x64-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246500
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-05-31 07:05:33 +00:00
Daco Harkes
5380fa5d40 [vm/ffi] Introduce CCallInstr and replace handle instructions
The CCallInstr takes unboxed word-sized integers and does a call to C
without any VM transitions.

This can be used for the following.
1) Leaf runtime entries. This CL removes the EnterHandleScope,
   ExitHandleScope, and AllocateHandle instructions.
2) Compilation of isolate independent code where all definitions in IL
   are unboxed integers.

Currently, the CCallInstr expects all it's arguments and the return type
to be word-sized.

This CL also:
- Adds loadImmediate and CCall with a register for each assembler.
- Adds a CSE pass to force-optimized so that LoadThreadInstr gets de-
  duplicated.

TEST=tests/ffi(_2)/*

Change-Id: I67c6aaa1b7d6aa7d60e274477686a54e5a331216
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-simriscv64-try,vm-kernel-precomp-linux-debug-simriscv64-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-05-30 20:58:03 +00:00
Ryan Macnak
38f9b339e3 [vm, compiler] Fix BigInt._rsh intrinsic when shifting out at least one word on RISC-V.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/49067
Change-Id: I3f7041243334da3a106534f7cf4903a7c34b272c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245780
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-26 22:54:29 +00:00
Helin Shiah
a8e6756c74 Revert "[ Service / DDS ] Add method that can return local paths"
This reverts commit a091ff7b27.

Reason for revert: Breaks DevTools and DWDS on internal roll

Original change's description:
> [ Service / DDS ] Add method that can return local paths
>
> TEST=Check that a supplied URL conversion function is correctly applied when the `local` param is true.
>
> Change-Id: Ibe80b6229c574c976379a519baca5d1904b684b2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245040
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

TBR=bkonyi@google.com,kenzieschmoll@google.com,helinx@google.com

Change-Id: I59d7687ba722fb1f5c706196691fc8471fe862ca
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246057
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-05-26 18:46:39 +00:00
Helin Shiah
a091ff7b27 [ Service / DDS ] Add method that can return local paths
TEST=Check that a supplied URL conversion function is correctly applied when the `local` param is true.

Change-Id: Ibe80b6229c574c976379a519baca5d1904b684b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245040
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-05-26 17:45:39 +00:00
Ryan Macnak
6de162e014 [vm, compiler] Prune dictionaries to only contain elements needed at runtime.
flutter_gallery
Isolate(CodeSize): 2116400 -> 1981238 (-6.28%)
  Total(CodeSize): 7217938 -> 7082600 (-1.87%)

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48910
Change-Id: I8cd285ddab3a611cd7a2a91d50414be402f8543a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244303
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-25 15:55:38 +00:00
Daco Harkes
c1d0973e3b [vm/ffi] Implement GetTopHandleScope in IL
With the `LoadThreadInstr` [1], we can now implement getting the top
handle scope in IL rather than machine code.

[1] https://dart-review.googlesource.com/c/sdk/+/235602

TEST=tests/ffi(_2)/

Change-Id: Ib522e1dc0341672079999aa11036564bc00aeda8
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-ia32-try,vm-kernel-linux-debug-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245980
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-05-25 14:05:08 +00:00
Ryan Macnak
3f0461a17c [vm, compiler] Make more use of the zero register on ARM64 and RV.
flutter_gallery
Instructions(CodeSize): 4622928 -> 4611996 (-0.24%)
       Total(CodeSize): 7217938 -> 7207097 (-0.15%)

TEST=ci
Change-Id: I3e0b2bd51a190260ab2c23706815be34000fcb22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245422
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-24 22:12:17 +00:00
Ryan Macnak
2bddaaacc7 [vm, compiler] Implement Smi_bitLength intrinsic on RV.
TEST=ci
Change-Id: Ica3cace6cf6ac416e9db8c1b682df429aaf595e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244740
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-24 20:55:25 +00:00
Paul Berry
0a92b0c3aa Turn on the experimental feature inference-update-1.
Fixes https://github.com/dart-lang/language/issues/731.

Change-Id: I5fee1470efe7b891b79dcfecd33bc3670590efb3
Tested: trybots, and global presubmit in the internal mono repo
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243530
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2022-05-24 13:54:23 +00:00
Ahmed Ashour
a6fcb56901 Fix typos
Fixes #49094

TEST=ci

Change-Id: I23cdcb5ad2fc83e5e91d80e34b66af186c0cb923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-05-24 09:10:51 +00:00
Daco Harkes
42961747fd [vm] Make Shift MayThrow more precise
After https://dart-review.googlesource.com/c/sdk/+/245061,
multiplications guaranteed to not throw, could be turned into shifts
reporting they may throw.

TEST=Existing test suite exercising the new ASSERTs.

Change-Id: Ie464fb1dfe8b0c4c98ac6f462154f909bef53794
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245362
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-05-20 20:28:52 +00:00
Johnni Winther
cb3cac408d [kernel] Add AbstractSuper* nodes
This adds AbstractSuperMethodInvocation, AbstractSuperPropertyGet,
AbstractSuperPropertySet nodes which are to be used for super access
in mixin declaration.

These super accesses do not resolve to their statically bound target
but instead the interface target on the types in the 'on' clauses, and
need to be updated to the statically bound target upon mixin application.
This has lead backends to disregard the interface target provided by
the CFE and instead always compute targets for super accesses.

This change is a step towards creating a clear separation between the
two use cases, enabling a more precise handling of super accesses.

The new nodes are not created yet with this CL.

TEST=existing

Change-Id: I70ea9baf5b4b970b10cc72b7409633d270d57755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245168
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-05-20 09:50:01 +00:00
Martin Kustermann
b83b89a900 [vm/concurrency] Add number of objects / bytes copied to timeline events for inter-isolate messages
Closes https://github.com/dart-lang/sdk/issues/48591

TEST=vm/dart{,_2}/isolates/fast_object_copy_timeline_test

Change-Id: I1de3a6f0d8a31450e45f689e0d67358285204a71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245167
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-05-20 08:16:41 +00:00
Martin Kustermann
31ae00fb13 [vm] Ensure transitive object copy allows low safepoint latencies
To make responsiveness to safepointing requests better when a thread
does a transitive object copy we add safepoint checkins.

In the fast object copy implementation - which runs inside
NoSafepointScope - we bail out to the slow path if there's a safepoint
requested.

The slow path is safe to GC at any point due to having all objects
inside handles / GC-visible objects.

TEST=Existing test suite.

Change-Id: Ie2c37e2f618506ab62a592aa9ff9ab266a02b64b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245166
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-05-19 12:22:24 +00:00
Ryan Macnak
2490f2bdf9 [vm] Add missing logical edges from instances to their class and from types to their type class.
If all other edges to these objects are removed, v8_snapshot_profile_writer_test will complain they appear to be unreachable.

TEST=ci
Change-Id: I291fa285f5c0f9578fad574263d9311adf4c8818
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245203
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-05-18 23:24:30 +00:00
Liam Appelbe
3fd1e1ed7f [vm] Exclude enum constructor from coverage
It's not possible for the user to invoke these constructors.

Fixes: https://github.com/dart-lang/coverage/issues/377
TEST=Updated existing enhanced enum coverage test
Change-Id: I8b1fea269b278fcb92f38ba09f039dd8bccbfd31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245201
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-05-18 21:39:40 +00:00
Ryan Macnak
2b0cd3c892 [vm, compiler] Reduce multiplication by a power of two to left shifts.
TEST=ci
Change-Id: I16f42397e274c68aebc908f9b87cd59332299249
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245061
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-18 19:13:03 +00:00
Liam Appelbe
521ad77689 [cfe] Mark enhanced enum toString method as synthetic
This fixes a bug where this method is showing up in coverage reports.

Also needed some plumbing in the VM for this flag, because we were
ignoring it before.

Change-Id: I9200a16dab488f5f880b9797243bd2f39de993b3
Fixes: https://github.com/dart-lang/coverage/issues/386
TEST=Added a source_report_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245041
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-05-17 22:11:36 +00:00
Ryan Macnak
fa1848ac54 [build] Don't invoke the JIT runtime when using kernel for SDK snapshots.
If this is a cross-word-size configuration, the JIT cannot run.

TEST=local
Bug: https://github.com/dart-lang/sdk/issues/48792
Change-Id: I7aca0c2da4e352c121f531bdf3eb6402aead1569
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244743
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-05-17 21:36:56 +00:00
Johnni Winther
5222bfd90c [cfe] Refactor bounds checking
This CL moves the bounds checking into the TypeBuilder instead of
performing it from the outside on the computed DartType node.
This solves several problems:

  1) Errors are now reported on the type in the code instead of the
     declaration which holds the type.
  2) Checking of type aliases (both function and nonfunction type
     aliases) is now handled correctly in all cases. This achieved by
     computed the aliased type (containing TypedefType nodes)
     internally and performing the checking on this type, and only
     convert the type into the unaliased version (without TypedefType
     nodes) after checks have been performed. Previously this handled
     through the FunctionType.typedefType property for function type
     aliases and through and incomplete work-around for nonfunction
     type aliases.
  3) With 2) FunctionType.typedefType is no longer needed and is
     removed.

TEST=general/bounds_*

Change-Id: I7653bca5ccb0ebf4b3553828a298d1ad918ef235
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-17 14:36:19 +00:00
Ryan Macnak
09b7f36b2f [vm, compiler] Support ShadowCallStack on Fuchsia RISC-V.
Remove fixed uses of X18.

TEST=ci (Linux), speculative (Fuchsia)
Change-Id: I20e31fc2ab7d44cbf02e591be92261067158509d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244943
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-16 22:35:55 +00:00
Ryan Macnak
8a978ffc7f [vm] Don't depend on field objects to populate initial field table.
TEST=ci
Change-Id: Ib4f2a1cf3790f743ab86fe33a4d0c9a3af1c396e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244763
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-16 19:08:45 +00:00
Ryan Macnak
ec56446604 [vm, compiler] Various stub calls do not need to be patchable.
TEST=ci
Change-Id: Icdaed8bd764e72646732e73cb8fbb35d283261f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244540
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-16 17:23:49 +00:00