Commit graph

20382 commits

Author SHA1 Message Date
Liam Appelbe 9ad59be793 Revert "Suppress sign-compare warnings for musl libc"
This reverts commit 9fefe1054e.

Reason for revert: Breaks the riscv64 bot: https://logs.chromium.org/logs/dart-internal/buildbucket/cr-buildbucket/8790248947000585777/+/u/build_dart/stdout

Original change's description:
> Suppress sign-compare warnings for musl libc
>
> Closes https://github.com/dart-lang/sdk/pull/51225
>
> GitOrigin-RevId: 0c2d3d4b79a461d1af2127061b3857f08c22856d
> Change-Id: I9e58cccfdf65604baf0789c2a4294dfb50590e95
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280252
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

TBR=vegorov@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com,copybara-worker-blackhole@google.com

Change-Id: I05c64d556b7bd6f4099f8468a94557d9a51e5260
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280480
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-02-02 20:28:46 +00:00
Dan Chevalier deca6a66e7 Reland "Update HTTP Profiling ids to use Strings"
This is a reland of commit e7d8261f9a




Original change's description:
> Update HTTP Profiling ids to use Strings
>
> The internal Dart Ids can be 64 bit integers, and are passed to Dev Tools as integers. This is causing errors fetching requests as the ids can overflow once they get to dev tools.
>
> Interaction between `getHttpProfile` and `getHttpProfileRequest` are already performed in https://dart-review.googlesource.com/c/sdk/+/279122/3/pkg/vm_service/test/get_http_profile_test.dart
>
> https://github.com/flutter/devtools/issues/2860
>
> TEST=The original tests test the surface of the RPCs that are updated here. Any tests that needed tweaking have also been fixed. https://github.com/flutter/devtools/pull/5127 is being submitted to Devtools and G3, and the regressions have been tested against vm_service:10.0.0 and vm_service:11.0.0
> CoreLibraryReviewExempt: Changes are only to http profiling
> Change-Id: Ie560dde7629f91f4221c1fe18d153cd999691086
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279122
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Dan Chevalier <danchevalier@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

TEST=The original tests test the surface of the RPCs that are updated here. Any tests that needed tweaking have also been fixed. https://github.com/flutter/devtools/pull/5127 is being submitted to Devtools and G3, and the regressions have been tested against vm_service:10.0.0 and vm_service:11.0.0
CoreLibraryReviewExempt: Changes are only to http profiling
Change-Id: I132f30111ca9c4c53dec377f6038453cacfc6243
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280020
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
2023-02-02 19:22:49 +00:00
asiva df84ed6d35 Fix leak memory leak in Dart_GetObfuscationMap.
TEST=ci (fixes an existing test failure).

Bug:51224
Change-Id: I73e6f954f3c36a8675c94a919964b8403abc1498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280254
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-02-02 17:42:58 +00:00
Ben Konyi 0d5f297bc7 [ VM ] Don't attempt to build a Profile with a null sample buffer
TEST=N/A

Change-Id: I7c3c505fb73a9d568ab567fcf41c91c8fc9216d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280440
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-02-02 17:34:57 +00:00
Alexander Markov a9d9b7395b [kernel] Enable sound null safety in TargetFlags by default
TargetFlags.enableNullSafety is set to true by default and
also renamed to TargetFlags.soundNullSafety to better reflect its
meaning.

TEST=ci

Change-Id: I2c2f30c2af6502fd9a96141dc60e4afbf8c524fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280216
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-02-02 14:54:18 +00:00
なつき 9fefe1054e Suppress sign-compare warnings for musl libc
Closes https://github.com/dart-lang/sdk/pull/51225

GitOrigin-RevId: 0c2d3d4b79a461d1af2127061b3857f08c22856d
Change-Id: I9e58cccfdf65604baf0789c2a4294dfb50590e95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280252
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-02 09:07:58 +00:00
Ryan Macnak 1f7ac27eec Revert "Suppress clang warning for musl libc inline"
This reverts commit ddc19f7f92.

Reason for revert: Breaks gcc build
../../runtime/bin/socket_base_posix.cc:161: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]
  161 |     cmsg = CMSG_NEXTHDR(&msg, cmsg);
      |
cc1plus: all warnings being treated as errors

Original change's description:
> Suppress clang warning for musl libc inline
>
> Closes https://github.com/dart-lang/sdk/pull/51191
>
> GitOrigin-RevId: d7064c43adce0b115c79e818800e44ba4f60739e
> Change-Id: Ie73e96c83294d43baf3be6772cb84705ba2d2712
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280136
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

TBR=vegorov@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com,copybara-worker-blackhole@google.com

Change-Id: I8b726d616ba1b5434b92c239c3b8897a942fad5b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280300
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-02-01 23:25:47 +00:00
Alexander Markov 638b3aa8c5 [vm] Correct rebind rule for static call to Record.get:_fieldNames
This change fixes assertion

../../runtime/vm/object_reload.cc: 942: error: expected: old_target_.is_static() || old_target_.kind() == UntaggedFunction::kConstructor

which happened when updating a target of static call from
record field getter to Record._fieldNames.

TEST=language/records/simple/dynamic_field_access_test
(on vm-reload-linux-debug-x64 configuration)

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I0e80a91969778ca5a14805d79f4127ba53bc4aa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280246
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-02-01 23:24:09 +00:00
Derek Xu 68c0ebe48a [VM/Service] Add optional parameters to getInstances
This CL updates the VM Service spec to v4.1 and adds the optional
`includeSubclasses` and `includeImplementers` parameters to the
`getInstances` service procedure.

This CL also adds `pkg/vm_service/test/get_instances_rpc_test.dart`
which is based on
`runtime/observatory/tests/service/get_instances_as_array_rpc_test.dart`

TEST=CI

Fixes https://github.com/dart-lang/sdk/issues/51003
Change-Id: Ia1ebec0ebeb6cba274621853e6486bab7cb7eb78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279201
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-01 22:04:29 +00:00
なつき ddc19f7f92 Suppress clang warning for musl libc inline
Closes https://github.com/dart-lang/sdk/pull/51191

GitOrigin-RevId: d7064c43adce0b115c79e818800e44ba4f60739e
Change-Id: Ie73e96c83294d43baf3be6772cb84705ba2d2712
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280136
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-01 21:58:18 +00:00
Alexander Markov 6074b4ff0d [vm/compiler] Handle uninitialized late local variables at OSR entries
TEST=tests/language/nnbd/syntax/late_modifier_edge_cases_test.dart
(on vm-eager-optimization-linux-release-x64 configuration)

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

Change-Id: I8eea931722f665d6ee8e5fa2602ba6b08edb8a7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280052
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-02-01 09:15:49 +00:00
Derek Xu 5577eafdba [VM] Add OSThread::GetCurrentThreadName() method
Some fields of `OSThread` are initialized by retrieving information by
calling OS functions. For example, `trace_id_` is initialized by calling
`OSThread::GetCurrentThreadTraceId()`. Similarly, this CL adds the
`OSThread::GetCurrentThreadName()` method and uses it to initialize
`name_`.

TEST=CI

Change-Id: Iee121d71e660be01ff684a298144fa7d59e3b61d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278662
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-31 22:37:30 +00:00
Alexander Markov 9be13288b0 [vm] Support multiple local variables with the same name in the same scope
When lowering patterns, front-end can add multiple distinct local
variables with the same name into the same local scope.
Previously, VM identified local variables in a local scope by name.
However, this no longer works with patterns.

With this change, local variables are now identified by pair (name,
kernel offset). Name is still taken into account as compiler can add
extra variables which do not correspond to kernel variables,
such as 'this'.

TEST=runtime/tests/vm/dart/regress_51091_test.dart
Fixes https://github.com/dart-lang/sdk/issues/51091
Issue https://github.com/dart-lang/sdk/issues/49755

Change-Id: I0263769cb31f3f8d9652f5d6534800510ac882fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279650
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-31 18:47:46 +00:00
Brian Quinlan 252015b30b [io] Fix a bug where large reads would return partial data.
Bug: https://github.com/dart-lang/sdk/issues/51071
Change-Id: Ia64d803c9709b106e52a1c671c1c3288c051bd85
Tested: ci + new test
CoreLibraryReviewExempt: bug fix only for vm
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279204
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-01-31 18:41:39 +00:00
Ryan Macnak 0c87126ea2 [vm] Finish removing legacy restart mechanism.
Cf. a4adbffb50.

TEST=ci
Change-Id: I9d2517c6cb0b5630990d087812e9a54241f41bb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280043
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-31 18:28:59 +00:00
Roland McGrath 82664d0a26 [fuchsia] Fix zx_thread_state_general_regs_t type name
The public API is the zx_thread_state_general_regs_t typedef,
not the zx_thread_state_general_regs struct tag.

TEST=ci
Change-Id: I4ce2f3dd08b5873378326fe4d162add33317a9c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280047
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Roland McGrath <mcgrathr@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-31 18:16:39 +00:00
Alexander Aprelev 4443d2d561 [vm/isolate] Ensure that isolate can correctly resume and exit if paused on exit.
It could happen that an isolate gets stuck unable to exit if paused on exit when using Isolate.exit.

Fixes https://github.com/dart-lang/sdk/issues/51164
TEST=isolate_exit_resume_test

Change-Id: I114686ce0637434827e56988821932cb91238032
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280044
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-31 17:15:38 +00:00
Alexander Markov f2304f9ec0 [vm/compiler] Fix numbering of SSA values during inlining
When building SSA form for callee graph during inlining, numbering of
SSA values starts with the number of SSA values in the caller graph.
However, parameter stubs may contain constants which are already added
to the callee graph and occupy certain range of SSA numbers. If that
number is larger than number of SSA values in the caller graph, then
numbers, already assigned to constants, can be incorrectly reused
during SSA construction.

The fix is to adjust number of SSA values in the callee graph
before parameter stubs are created, and then use current number of
SSA values as a starting point when building SSA.

TEST=runtime/tests/vm/dart/regress_flutter119220_test.dart
Fixes https://github.com/flutter/flutter/issues/119220

Change-Id: I7efd52e626b63bf64fb47861ec210b291911ef28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280041
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-01-31 16:47:44 +00:00
Josh Soref 77978889eb Spelling
Closes https://github.com/dart-lang/sdk/pull/51143

GitOrigin-RevId: 9e21c99a222d588e4fc95980725a2f8c9784965c
Change-Id: If0870e8936c7649935dce7e23cd783d62aa5610c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279916
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-30 18:29:59 +00:00
Lasse R.H. Nielsen bee7ab2b32 Make record positional field getters start at $1.
An update for co19 is available at https://github.com/dart-lang/co19/pull/1759

TEST=Existing tests run after change, two new tests for edge cases.

Change-Id: I408e398d532ba2c2e8e60777bb4f7bd0057e27fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278912
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-01-30 08:14:28 +00:00
Ryan Macnak 92972ff5cf [vm, gc] Disable time-based components of the growth policy when running under --deterministic.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51125
Change-Id: Ic716a0cc917b9237a4d1b452714bfc4c54f6aae6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279470
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-28 00:24:09 +00:00
Alexander Aprelev 7c409eaa42 [vm/gardening] Skip two failing tests on iso-stress-linux.
The tests were not included into non-nnbd testing.
BUG=https://github.com/dart-lang/sdk/issues/51148
TEST=ci

Change-Id: Ib838cd0d70ebffe83ba2c5f2482e403c18f55317
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280060
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-27 20:48:17 +00:00
Ryan Macnak 2b8ca6f2f5 [vm, gc] Set the idle duration to effectively infinite.
This applies only to isolates running on the VM's thread pool.

TEST=manually inspect timeline in program with very large heap
Bug: https://github.com/dart-lang/sdk/issues/51125
Change-Id: Ib70cee7c163231b7aef4d723f35d056d4cb1cbf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279477
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-01-27 19:03:18 +00:00
Alexander Aprelev c09d4d1c3d [vm/reload] Reject failed compilation during isolate reload
This is needed so that the expression evaluation works correctly after attempt to reload to bad source code.

Bug: https://github.com/dart-lang/sdk/issues/45846
Change-Id: Ib9fccc54141433bc662cbca923037fd12616ccd2
TEST=bad_reload_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278664
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-01-27 17:47:38 +00:00
Martin Kustermann b15da0b0e9 [gardening] Build analyze_snapshot/gen_snapshot in both host & target toolchain
This should make vm/dart_2/analyze_snapshot_binary_test pass on
dartkp-linux-release-arm64 & dartk-linux-release-arm64

by ensuring arm64 `gen_snapshot` & `analyze_snapshot` binaries
are available on the device when running tests on arm64 HW.

Change-Id: Icd814ff6df22a33b651733e4c3dc99873cf56a58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279970
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-27 12:44:30 +00:00
Martin Kustermann 0a78aac714 [vm] Make iso-stress builder compile & run null safety tests
Change-Id: I2a85491ac63635b4bd1d1f531466a0760f54e9e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279969
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-27 10:31:14 +00:00
Martin Kustermann f12592b984 [vm] Make vm/dart/isolates/concurrency_stress_sanity_test compile iso-stress tests in sound-null safety mode
Change-Id: Id63e234353981100155530e592a95c993ffd8d77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279968
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-01-27 10:29:25 +00:00
Alexander Aprelev bb63927fed [vm/regexp] Follow-up to RegExp sharing change 438b81c4f2.
Avoid ZoneHandles unless needed, use field initializer, few more nits.

This is based on feedback on https://dart-review.googlesource.com/c/sdk/+/279747.
TEST=ci

Change-Id: I59b462ca70a912b270b089fb114d6029b7fa5856
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279903
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-01-27 00:43:59 +00:00
Ryan Macnak 5cbd424bdf [vm, gc] Use right flag to decide the idle period's duration.
Broken in e31c7ff591.

TEST=manually inspect timeline
Change-Id: I3067a986f4ffed4e83e414948b1498e4da44cb78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279476
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-27 00:36:08 +00:00
Ryan Macnak 18c9f52aaf [observatory] Fix NNBD damage to VM flags page.
TEST=view vm flags
Change-Id: Ifaa35bef21715962774e77524618fd1ac25b4b39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279906
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-27 00:04:28 +00:00
Alexander Aprelev f9fb896455 [vm/isolates] Fix isolate_send_function_types_test
The test has been quietly broken for a while now as it expected that function types can't be send(which is not the case).

TEST=isolate_send_function_types_test

Change-Id: I09b107ef7f6b6229a2a28ee5c3f94f3bc8d7751e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279902
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-01-26 23:10:01 +00:00
Ryan Macnak 3b57bac701 [vm] Use a weak set to represent dependent code.
Fixes a scaling limitation where compiling N functions using the same guarded field or CHA guarded interface will result in O(N^2) comparisons when registering the dependencies.

Don't use Instructions' address as the hash, as this gets relocated between the snapshot writer and reader.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51125
Change-Id: I9a13d57455e10865d9c5f7c12009d869a4ef0488
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279753
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-26 22:56:48 +00:00
Oleh Prypin 74849bae46 Revert "Update HTTP Profiling ids to use Strings"
This reverts commit e7d8261f9a.

Reason for revert: will not be able to roll devtools_app (at least in google3) with this backwards-incompatible change

Original change's description:
> Update HTTP Profiling ids to use Strings
>
> The internal Dart Ids can be 64 bit integers, and are passed to Dev Tools as integers. This is causing errors fetching requests as the ids can overflow once they get to dev tools.
>
> Interaction between `getHttpProfile` and `getHttpProfileRequest` are already performed in https://dart-review.googlesource.com/c/sdk/+/279122/3/pkg/vm_service/test/get_http_profile_test.dart
>
> https://github.com/flutter/devtools/issues/2860
>
> TEST=The original tests test the surface of the RPCs that are updated here. Any tests that needed tweaking have also been fixed
> CoreLibraryReviewExempt: Changes are only to http profiling
> Change-Id: Ie560dde7629f91f4221c1fe18d153cd999691086
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279122
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Dan Chevalier <danchevalier@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

TBR=bkonyi@google.com,asiva@google.com,sigmund@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com,danchevalier@google.com

Change-Id: I9b6c9ec1cb00cca56816959fc83a70ec35ac9b21
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279980
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
2023-01-26 16:42:26 +00:00
Dan Chevalier e7d8261f9a Update HTTP Profiling ids to use Strings
The internal Dart Ids can be 64 bit integers, and are passed to Dev Tools as integers. This is causing errors fetching requests as the ids can overflow once they get to dev tools.

Interaction between `getHttpProfile` and `getHttpProfileRequest` are already performed in https://dart-review.googlesource.com/c/sdk/+/279122/3/pkg/vm_service/test/get_http_profile_test.dart

https://github.com/flutter/devtools/issues/2860

TEST=The original tests test the surface of the RPCs that are updated here. Any tests that needed tweaking have also been fixed
CoreLibraryReviewExempt: Changes are only to http profiling
Change-Id: Ie560dde7629f91f4221c1fe18d153cd999691086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279122
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-26 15:08:56 +00:00
Tess Strickland 2967b148ec [gardening] Fix genSnapshot detection in use_flag_test_helper.dart.
Previously handled cases:
- No cross compilation, gen_snapshot in same `buildDir` as rest.
- X64->SIMARM cross compilation, gen_snapshot in `${buildDir}_X64`.

Newly handled case:
- X64->ARM64 cross compilation, gen_snapshot in `${buildDir}/clang_x64`.

TEST=vm/dart{,_2}/analyze_snapshot_binary_test

Change-Id: I3d3a23be445496ab068926f7d76b56299e06d950
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-01-26 13:42:29 +00:00
Vyacheslav Egorov 4482709d45 [vm] Mark ListMixin.iterator with prefer-inline
This helps to improve the code quality in for-in loops
where iterable has a known List type.

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

Tested: tests updated due to line number changes in list.dart
CoreLibraryReviewExempt: no public API changes
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: Ia5d815009a699061961c331cf43e68d2c96fc58b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279518
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-26 10:16:51 +00:00
Josh Soref 01b28894e7 Spelling pkg dev compiler
Closes https://github.com/dart-lang/sdk/pull/50861

GitOrigin-RevId: 71005e6f5bf5a151cb5c1aefb6a2a300fc40f592
Change-Id: Iadfafb5787a62e9a379437f6a3763d31f99ba7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277743
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-26 09:12:41 +00:00
Vyacheslav Egorov c3d8f46c5b [vm/compiler] Devirtualize calls while inlining.
Inlined functions might contain call-sites which can be devirtualized
in the context of the caller. To achieve that we add a pass which
calls canonicalization on all dynamic calls (and their data
dependencies) between rounds of inlining.

More specifically this helps cases which require interleaving
some redundancy elimination and inlining to remove the cost of
abstractions. The primary example is for-in loop with an array of
a known type which usually requires inlining `get:iterator` and
propagating iterable value through interator's fields to specialize
and inline `get:length` and `operator[]` on the `Iterable`.

See https://github.com/dart-lang/sdk/issues/48433 for example.

TEST=vm/dart/devirtualization_during_inlining_il_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: I1fae50484a111f8c21c81bcf0c3d6a63a856338a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279517
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-26 08:52:18 +00:00
Vyacheslav Egorov cc8877fcc7 [vm/compiler] Improve canonicalization rules
* Add rule forwarding stores to non-late final fields to
consequitive loads.
* Allow specialization of InstanceCall with an empty ICData in AOT
mode.

Additionally rewrite regression test for 836c04f using explicit
block building. The source based test was too fragile and sensitive
to various optimizations.

TEST=vm/cc/IL_Canonicalize_FinalFieldForwarding,vm/cc/IL_Canonicalize_InstanceCallWithNoICDataInAOT

Bug: https://github.com/dart-lang/sdk/issues/48433
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: Icb766d48ebaed6626c8d010f528fa6d82c432930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279515
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-26 08:52:18 +00:00
Derek Xu 4e9370ae1d [VM/Service] Clean up exceptional GetVMTimeline cases
TEST=CI

Change-Id: Ic70f00ac6efde2cb32d541eb62b868a3e4645fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279469
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-01-25 21:23:27 +00:00
Derek Xu 8766952c13 [VM/Service] Populate length property for PlainInstance Instances and InstanceRefs
TEST=CI

Change-Id: I0c112513849e4057a08d6068101927ee6aec6b25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279466
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-01-25 18:32:57 +00:00
Ben Konyi b1b1c3bf78 [ VM ] Ensure heap profiler state is updated on TLAB release due to scavenge
Also fixes some race conditions and flaky test behavior.

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

TEST=DartAPI_HeapSampling_* looped in GDB under load

Change-Id: I0c1f297ecb140575e28650837158b707b9dc4b41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279590
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-01-25 17:56:39 +00:00
Josh Soref ef42a0b110 Spelling pkg analyzer lib
Closes https://github.com/dart-lang/sdk/pull/50860

GitOrigin-RevId: b27066c37f93c8c6d1123d6ebd6a4c0afcf59844
Change-Id: I15fa4aea1dad45daf168e34d1c4450320ec9b40a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277742
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-01-25 14:08:27 +00:00
Martin Kustermann 9361e15353 Revert "[vm] Use a weak set to represent dependent code."
This reverts commit 391ce71a0f.

Reason for revert: This seems to be the root cause of test failures
on unrelated CLs. It also seems that this is one reason that can
make app-jit snapshots no longer deterministic.

More information will be posed on:
https://github.com/dart-lang/sdk/issues/51125

Original change's description:
> [vm] Use a weak set to represent dependent code.
>
> Fixes a scaling limitation where compiling N functions using the same guarded field or CHA guarded interface will result in O(N^2) comparisons when registering the dependencies.
>
> TEST=ci
> Change-Id: Ic48f29fa0ce8f43a6f60bc00fa95a60763d333a0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278943
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>

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

Change-Id: I823365b2c30906c40f77c6ef186b636b7fdc5691
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279760
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-25 13:15:14 +00:00
Derek Xu 0031f67ba0 [VM/Service] Populate length property for Record InstanceRefs and Instances
TEST=CI

Issue: https://github.com/dart-lang/sdk/issues/51104
Change-Id: I4fa812c22f2ea0bdf5cc472a9e7198bf64442e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279465
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-01-25 00:17:21 +00:00
Ryan Macnak 06e9ff6edc [vm] Use the right size in vm/cc/StoreHalfWordUnaligned.
Fixes clobbering whatever happens to be after the test's buffer.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51110
Change-Id: I661b643cf5f7d6a1a7781683f43ef02c4279f1e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279720
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-01-24 21:22:15 +00:00
Josh Soref f7a2ea5e06 Spelling
Closes https://github.com/dart-lang/sdk/pull/50922

GitOrigin-RevId: 58fd7cfd5ef470a65a52ea28e0407244d853c917
Change-Id: I2e5a5ed991cb05270170a18b8f0169daa9eabdb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278537
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-24 18:00:25 +00:00
Ryan Macnak da57d8a308 [vm] Remove giant initialized data from run_vm_tests.
out/ReleaseXRISCV64/exe.stripped/run_vm_tests 75MB -> 42MB

TEST=ci
Change-Id: I29f644e8b12c442a87f926cb644198ad8e3e9b34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279561
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-24 17:28:19 +00:00
Ryan Macnak b77866340c [vm] Do not allocate handles during RawCast.
RawCast is sometimes used in contexts that might not have a zone (idle GC), might have a long lived zone (the former interpreter), or otherwise should not allocate handles (the GC should not create handles after any phase that needs to visit them all).

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51099
Change-Id: I0a8a6e4dfa600d5b78fadc5c558ac2e7245ff4bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279620
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-24 17:26:37 +00:00
Derek Xu 899d9074a8 [VM] Factor out a base class for timeline event file recorders
TEST=I recorded a trace with the file recorder and made sure its contents were correct.

Change-Id: Id899083866b6d98260d4c6ef4c5016b43422db4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278482
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-01-24 15:26:08 +00:00
Chris Evans 0b8ab17feb Fix analyze_snapshot tests and build configuration
Updated strictness on build configuration for analyze_snapshot
Will run only under Linux/Android 64 bit arm, arm64c, simarm64,
simarm64c and x64 architectures.

analyze_snapshot just has a single target that links into product precompiled programatically

Testing suite updated to comply with null-safety requirements and
fix for simulated platform failing to use gen_snapshot with assembly.
TEST=ci
Change-Id: I3d58400db2e26a441a40fe7197b22510a52732b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279391
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Chris Evans <cmevans@google.com>
2023-01-24 14:07:26 +00:00
Ryan Macnak 1aa7f17b56 [build] Default to -O2 instead of -O3.
This moderately reduces code size without large regressions on Golem. Going further to -Os still produces noticeable regressions.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38647
Change-Id: I8409908ca37d4a2b18cb989d9748e35a15072df6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217504
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-24 00:54:29 +00:00
Derek Xu d81b48c6b1 [VM/Service] Add private _getImplementationFields procedure
TEST=CI

Change-Id: I4e4871ac4df74cb4daca7ef42a66489b2afbdc64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270260
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-01-23 21:07:23 +00:00
Sam Rawlins 4baa99e932 [observatory] Fix 'unused_catch_clause' issues
This is required in order to migrate Hints to Warnings This CL migrates
this code: https://dart-review.googlesource.com/c/sdk/+/279443

TESTED=presubmit

Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I1e0c360e6ed366b6452474338679acc8b1e1399c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279458
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-23 19:51:48 +00:00
Vyacheslav Egorov d0887dc524 [cpplint] Disable runtime/references lint
Google Style Guide now prefers references to pointers because references
are non-nullable.

See https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs which now says:

> Non-optional input parameters should usually be values or const references, while non-optional
> output and input/output parameters should usually be references (which cannot be null).

This means runtime/references lint is outdated and can be disabled.

R=kustermann@google.com

Change-Id: Idec650603982387c000671aad7d77727a008f5cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279388
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-23 18:21:48 +00:00
Josh Soref b3df0a4bd5 Spelling tests standalone
Closes https://github.com/dart-lang/sdk/pull/50863

GitOrigin-RevId: e514be37c7f3b48cbce1048c359df00be7d2b18a
Change-Id: I45ad308db60a5935f18a877f5480874acfef0efd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277780
Reviewed-by: Alexander Thomas <athom@google.com>
2023-01-23 12:55:22 +00:00
Martin Kustermann 2ffbc88fc6 Make package:heapsnapshot prefer to mmap files over reading them.
Change-Id: I23de18aac05beae8005e471335b72a2ed22d1eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279349
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-23 10:22:41 +00:00
Josh Soref ba15a61271 Spelling build
Closes https://github.com/dart-lang/sdk/pull/50859

GitOrigin-RevId: 7b056018c2925745701bdecdd7da325d9458204d
Change-Id: Iff037d773713bf73efde6951599becfd7297b921
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277740
Reviewed-by: Alexander Thomas <athom@google.com>
2023-01-23 08:56:14 +00:00
Daco Harkes 17f4198cfe [vm/ffi] Native assets Windows fixes
Some artifacts are .exe instead of .bat.

Library uris with file schemes use the Uri.path (using forward slashes
on Windows), so the tests emitting native asset mappings should use
Uri.path as well. (Not Uri.toFilePath() which uses backwards slashes.)
The paths of the dynamic libraries in the assets should use the
toFilePath(), as these are passed to the system API which expects
correct paths.

The Platform.script Uri has a path with file:///C: and back slashes.
The uri RFC does not support back slashes, and our ResolveUri does
neither. So for Windows we replace backslashes with forward slashes.

TEST=tests/ffi/native_assets/

Bug: https://github.com/dart-lang/sdk/issues/51066
Bug: https://github.com/dart-lang/sdk/issues/51067
Change-Id: I2e168e0549fe80d9a5366d636c6f1ef971942130
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-win-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-msvc-windows-try,dart-sdk-win-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279356
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-01-20 18:20:17 +00:00
Josh Soref 9f6bcadb22 Spelling runtime observatory
Closes https://github.com/dart-lang/sdk/pull/50810

GitOrigin-RevId: 5edc2fb9b7b693190bc34fe1941591bdaf3405fe
Change-Id: Ia6627bc075fc5d4ab9dfaeec91da164820cdefee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276880
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-20 14:29:08 +00:00
Alexander Thomas b9b6511ca6 Spelling sdk
Closes https://github.com/dart-lang/sdk/pull/50918

Co-authored-by: Josh Soref <jsoref@gmail.com>
GitOrigin-RevId: 1fd275051c561b63d374fb47e76a22424c4a12a9
Change-Id: I97790d9c79ff659f2c1fa2d2d46d041fe67957cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278530
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2023-01-20 12:37:49 +00:00
Tess Strickland dce6d89062 [gardening] Mark vm/cc/ManyClasses as Slow on qemu bots.
Change-Id: I7184e7a28fbbe956bcb898bc4e50f7f61784e7f3
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276480
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2023-01-20 11:34:31 +00:00
Daco Harkes 6ef57b86c1 [vm/ffi] Support varargs
This CL introduces `VarArgs` to `NativeFunction` signatures. The
`VarArgs` type takes a single type argument. This type argument is a
subtype of `NativeType` if there is a single variadic argument, and a
record with native types if there are multiple variadic arguments.
For example:
`NativeFunction<Void Function(Pointer<Char>, VarArgs<(Int32,Int32)>)>`
for calling refering to a `printf` binding with two `int32_t` arguments
passed as variadic arguments.

The logic of the native calling conventions are detailed in
https://dart-review.googlesource.com/c/sdk/+/278342.
Here we explain how this influences the FFI pipeline.

First, now that `VarArgs` is part of signatures, we have to unwrap
that when with the C types in the CFE transform and checking (analyzer
is in a separate CL), and also in the marshaller when looking up the
C type of arguments.

Second, we have to deal with `BothNativeLocations`. On windows x64,
floating point arguments must be passed both in FPU _and_ CPU
registers. For FFI calls, we solve this in the argument moves by just
copying to both locations. For FFI callbacks, we just take the FPU
register location (which avoids an extra bitcast).

Third, on System-V, we have to pass an upper bound of the number of
XMM registers used in AL. This means we instead RAX, we use R13 for the
target address. For variadic calls, we always pass 8 in AL as the valid
upper bound. We could consider passing the actual number of XMM
registers used.
We keep using RAX as default register for the function address on non-
variadic calls, because changing to R13 (the first free) register
creates more spilling in leaf calls. R13 is callee-saved while RAX is
not, so using R13 instead of RAX causes us to have to spill the value
from RAX on leaf calls.

Fourth, on both x64 and RISC-V, we pass floats in integer locations.
`EmitNativeMove` has been modified to deal with this, so that we do not
have to insert more `BitCastInstr`s.

The tests are generated by a test generator: `tests/ffi/generator/`.

The formatter doesn't support records yet, so the tests are not properly
formatted.
Bug: https://github.com/dart-lang/sdk/issues/50798

TEST=tests/ffi/*_varargs_*

Closes: https://github.com/dart-lang/sdk/issues/38578
Closes: https://github.com/dart-lang/sdk/issues/49460
Closes: https://github.com/dart-lang/sdk/issues/50858

Change-Id: I6a6296fe972527f8a54ac75a630131769e3cc540
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,app-kernel-linux-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276921
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-20 10:30:41 +00:00
Daco Harkes 1854bb00c6 [vm/ffi] Support varargs in the backend
On ARM64 macos and ios, when varargs are used, the first vararg blocks
all cpu and fpu registers.

On Windows x64, when varargs are used, floating point arguments are
passed _both_ in the integer and double register.

The Windows logic requires a new kind of native location:
`BothNativeLocations`, which signals that a value needs to be copied
to both locations before an FFI call, and can be copied from any of
the two locations when getting an FFI callback.
TEST=runtime/vm/compiler/ffi/unit_tests/variadic_double/x64_win.expect

Note that integer arguments already block out the corresponding xmm
registers on Windows x64.

On System-V, an upper bound of the number of XMM registers used must
be passed in AL. (Not reflected in the unit tests here, but will be in
the dependent CL.)

On ARM (32 bit), using varargs forces the calling convention to be in
softfp mode even on hardfp supported devices.

On RISC-V, the FPU registers are blocked when using varargs.

TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc
Test outputs in: runtime/vm/compiler/ffi/unit_tests/variadic_*
Run test with `tools/test.py ffi_unit`.

Bug: https://github.com/dart-lang/sdk/issues/38578
Change-Id: Ic568f8156c1c28ac3d6a2144805edf8caaa0169c
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278342
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-20 10:30:41 +00:00
Kallen Tu 1cdd496a51 [cfe] Add class modifiers to AST and dill files.
TEST=pkg/front_end/testcases/class_modifiers/...

Change-Id: I8befd64c359eb33a6acf003525b0c8cc6096df3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279331
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-01-19 22:55:20 +00:00
Alexander Markov acccac2b64 [vm/compiler] Improve canonicalization of box/unbox instructions
Unnecessary boxing/unboxing instruction can be eliminated if
their operand already has a desired representation.

This change also schedules Canonicalize pass before
TypePropagation/SelectRepresentations_Final so it has a final chance
to cleanup IL after preceeding passes but before the representations are frozen
and certain canonicalizations are disallowed.

TEST=vm/cc/IL_Canonicalize_RepresentationChange
Related issue: https://github.com/dart-lang/sdk/issues/51019

Change-Id: I187767e3efa69497cdd1f44dd916a8b9fb9f7261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279274
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-01-19 21:24:14 +00:00
Ryan Macnak 391ce71a0f [vm] Use a weak set to represent dependent code.
Fixes a scaling limitation where compiling N functions using the same guarded field or CHA guarded interface will result in O(N^2) comparisons when registering the dependencies.

TEST=ci
Change-Id: Ic48f29fa0ce8f43a6f60bc00fa95a60763d333a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278943
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-01-19 20:44:57 +00:00
Ryan Macnak e210ee3577 [vm] Internal-only String.intern.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50648
Change-Id: I02e89c0def9913f12bf7fdd2ef8f3ff6cba231e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278808
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-19 17:49:08 +00:00
Ryan Macnak f9524f8509 [observatory] Fix some damage from NNBD and changes to InboundReference/RetainingPath.
TEST=view allocation profile, inbound references, retaining path
Change-Id: Id72fff5eaa1f892e9d54703f2f29787067c54055
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279202
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-19 17:36:20 +00:00
Vyacheslav Egorov b2dff24bd7 [gn] Remove dart_sysroot check from runtime/BUILD.gn
We should not use dart_sysroot outside of our own
build/config/sysroot.gni, Flutter buildroot does not
define this variable.

We don't actually need -Wall -Werror -Wextra in dart_config
because default config already contains chromium_code config
which does this.

Change-Id: Id7843809dcecc8871af1df6b8d3899511545cd51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279355
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-01-19 16:47:22 +00:00
Josh Soref 84e3c8b50f Spelling tests
Closes https://github.com/dart-lang/sdk/pull/50920

GitOrigin-RevId: fa87531bd0f52b69485c9d02ff9e44a4a29c6a91
Change-Id: I0ae8574a5b77087895e004079f221201bb550cf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278535
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-19 16:24:29 +00:00
Martin Kustermann 8d8782f659 Make runtime/tools/heapsnapshot/README.md more elaborate
Change-Id: I8ee4952d3889b8eec10495f900d26be1e3f7c34e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279354
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-19 13:12:02 +00:00
なつき afe9219026 [infra] Support for Alpine Linux Sysroot
Closes https://github.com/dart-lang/sdk/pull/51044

TEST=manually tested by the contributor

GitOrigin-RevId: 86c85da0680047e08caf81cc4c12098ae85c0d2b
Change-Id: I591d7e17ce3a87cf8ce8380c9511f70d738d44c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279267
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-19 10:36:51 +00:00
Josh Soref 9e4dc755cb Spelling pkg
Closes https://github.com/dart-lang/sdk/pull/50921

GitOrigin-RevId: 6b1ca502b6722b0a987f33ace66f65cbd2c24e23
Change-Id: I74e4ff3c8e759c576036d6b791bd7734ebd215d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278536
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-19 10:06:29 +00:00
Daco Harkes 3868b30e21 [vm] Fix RISC-V build
TEST=risc-v sdk bot

Change-Id: I57df7b0ff267931b6dd5fe00260d80a42d1789b6
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279179
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-01-19 00:00:08 +00:00
Ryan Macnak 79bcad6453 [vm, compiler] Use a proper sentinel instead of a string to represent eliminated values.
- Prevents the VM from behaving incorrectly when the Dart program happens to use the string "<optimized out>".
 - Prevents the VM from executing eval functions for non-String classes with a String receiver.

TEST=<optimized out>
Bug: https://github.com/dart-lang/sdk/issues/51027
Change-Id: I4b6ee856492dee86d641a0200a40a25fa78bcb88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279261
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-01-18 23:34:12 +00:00
Daco Harkes 9a8508ebff [vm/ffi] FfiNative assets
Adds support for `asset: 'asset-id'` in `FfiNative`s.
Symbols in assets are resolved by
1. the provided [asset] (the bulk of this CL),
2. the native resolver set with `Dart_SetFfiNativeResolver` in
   `dart_api.h` (old behavior), and
3. the current process.

Symbols in assets are resolved by the Dart VM through the mapping
provided in the `vm:ffi:native_assets` library:
```
@pragma('vm:ffi:native-assets', {
  "linux_x64": {
    "<asset1>": [
      "absolute",
      "<absolute-path>"
    ],
    "<asset2>": [
      "relative",
      "<relative-path>"
    ],
    "<asset3>": [
      "system",
      "<system-path>"
    ],
    "<asset4>": [
      "process",
    ],
    "<asset5>": [
      "executable",
    ],
  }
})
library;
```

There are 5 asset path types. Symbols resolved in these asset types are
resolved as follows.
A. Absolute paths are dlopened, after which the symbol is looked up.
B. Relative paths are resolved relative to `Platform.script.uri`, and
   dlopened, after which the symbol is looked up.
C. System paths are treated as absolute paths. (But we might explicitly
   try to use `PATH` in the future.)
D. Symbols looked up in Process assets are looked up in the current
   process.
E. Symbols looked up in Executable assets are looked up in the current
   executable.

The native assets mapping can be provided in three ways.

X. In the invocation to `gen_kernel` with the `--native-assets`
   argument. This uses the gen_kernel entry point for compiling
   kernel.
Y. By placing a `native_assets.yaml` next to the
   `package_config.json` used by the isolate group. This works for
   `dart <source file>` and `Isolate.spawnUri(<dart source file>)`.
   This uses the kernel_service entry point for compiling kernel.
Z. By sending a String containing the native assets mapping when
   invoking the kernel_service directly from within the VM. Currently,
   only used for unit tests.

TEST=tests/ffi/native_assets/asset_*_test.dart (X)
TEST=tests/ffi/native_assets/infer_native_assets_yaml_*.dart (Y)
TEST=runtime/vm/ffi/native_assets_test.cc (Z)

The library is synthesized from yaml in pkg:vm as AST.

Design doc: go/dart-native-assets

Bug: https://github.com/dart-lang/sdk/issues/49803
Change-Id: I8bf7000bfcc03b362948efd3baf168838948e6b9
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-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-precomp-nnbd-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264842
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-18 21:08:38 +00:00
Daco Harkes 476e13a5e9 [vm] Enable annotations on libraries in AOT
We have no use cases for this until the dependent CL.
TEST=dependent CL

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

Change-Id: Iee91f90ddd474cef3b7218def4d3e716ab2639ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272421
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-18 21:08:38 +00:00
Ryan Macnak 49a135ab7e [vm] Extend the hash_table.h templates to support weak sets.
Make the canonical string table weak.

Remove incorrect assumption that a symbol not already existing implies there is no target. This would be true but for all the call-through-field/method-extractor nonsense.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50648
Bug: b/265897936
Change-Id: I463807a5d8c064888abbdc3dc75e916c2bdc8fa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279273
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-18 20:16:11 +00:00
Ryan Macnak d23d074bb9 [vm] Fix determining the scope class for evaluation with mixin applications.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51027
Change-Id: I02b31187c2dd81ff61db01d5922a2b283e7f2541
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279238
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-18 17:48:31 +00:00
Martin Kustermann 3e05b6849e [gardening] Remove unused field
TEST=Fixes build due to unused-private-field warning.

Change-Id: Ieff80e1a376ff225dda3ed78a5e22fff923341d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279174
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-01-18 17:38:29 +00:00
Tess Strickland c8ca74d380 [vm] Fix broken failure code in Dwarf::WriteLineNumberProgram.
TEST=riscv64 build combined with CL 279174

Bug: https://github.com/dart-lang/sdk/issues/51051
Change-Id: I016f3a67510ea2a1fa8067aa61fa485ecb5cf172
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-precomp-asan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279177
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-01-18 17:21:13 +00:00
Sam Rawlins 59561320dc [dartfuzz] Remove duplicate map keys
In dartfuzz_api_table.dart, both `DartType.VOID` and `DartType.VOID_NULLABLE` are added to the Map keys. At runtime, the last value for a given key wins, so I removed the `DartType.VOID` key-value pair.

In gen_api_table.dart, both `assertionErrorEncoding` and `errorEncoding` are added to the Map keys. At runtime, the last value for a given key wins, so I removed the `assertionErrorEncoding` key-value pair.

This CL should be a no-op.

Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Ifcfeb3e84930267f60efd2eb009a722f8ac2453e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279234
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-01-18 15:57:00 +00:00
Alexander Markov 3fc896f7b2 [vm/compiler] Avoid introducing mismatched representations during instruction canonicalization
After 'SelectRepresentations_Final' mismatched representations
are not allowed. So 'Canonicalize' pass should not replace
an instruction with another instruction when they have
different representations.

TEST=vm/cc/IL_Canonicalize_RepresentationChange
Fixes https://github.com/dart-lang/sdk/issues/51019

Change-Id: I087e16cda6e196337e7636746172d9e28ae07374
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279230
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-01-18 15:23:07 +00:00
Emmanuel Pellereau 3b97b75a99 Revert "[vm] Extend the hash_table.h templates to support weak sets."
This reverts commit a1dd92d345.

Reason for revert: breaks google (b/265897936)

Original change's description:
> [vm] Extend the hash_table.h templates to support weak sets.
>
> Make the canonical string table weak.
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/50648
> Change-Id: I04d84a917bd71469d43483cefba8165628b9a63f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278673
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,asiva@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I5f5f1dc3327d02165c3cec70b74a61ce9ef9667b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/50648
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279280
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
2023-01-18 10:02:06 +00:00
Martin Kustermann 163f30f1b5 [vm] Ensure unoptimized compilations do not have an active isolate
Our compiler shouldn't depend on current isolate, since it can
run on any isolate within an IG.

Doing this change, reveals two existing dependencies on current
isolate from compiler
- resolving native symbols in unoptimized compilations
- issuing of debug events for breakpoints

For the former we'll re-enter the currently active isolate that
triggered unoptimized compilation.
=> We may want to change that embedder API to not be based on
   handles and instead give embedder a simple `const char*`.

For the ladder we'll enter the isolate corresponding to the
breakpoint debug event to be issued. We are at place where
all mutators are stopped, so that does seem okish.
=> Future could remove this by making Object Id Ring per-IG

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

TEST=service_2/break_on_function_many_child_isolates_test/dds

Change-Id: Id246db5972ae505e82f637ce04bb2302bed76257
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278901
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-18 08:45:31 +00:00
Ryan Macnak a1dd92d345 [vm] Extend the hash_table.h templates to support weak sets.
Make the canonical string table weak.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50648
Change-Id: I04d84a917bd71469d43483cefba8165628b9a63f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278673
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-17 21:45:02 +00:00
Ryan Macnak f3067e8740 [vm] Add WeakArray; to be used to create weak canonical sets.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50648
Change-Id: I788a8e3e5e8383c0b8d6f248d64a33dc67013260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-17 20:33:03 +00:00
Tess Strickland 8bcc849138 [vm] Test and fix resolving DWARF paths in obfuscated mode.
The DWARF generator would always attempt to deobfuscate the URL
retrieved from `Script` objects, whether it came from the `url`
or `resolved_url` field. However, the `resolved_url` field is not
obfuscated, and thus attempting to deobfuscate it could result in a different (and incorrect) string. Thus, only deobfuscate when not
resolving DWARF paths.

TEST=vm/dart{,_2}/use_resolve_dwarf_paths_flag

Bug: https://github.com/dart-lang/sdk/issues/44325
Change-Id: I57a3d47cc78035508082ccba23a2b1cd726ed6bb
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279086
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-01-17 12:34:49 +00:00
Ben Konyi 6f633c364a Reland "[ VM ] Add support for sampling old space allocations"
This reverts commit 0bd5a2b05e.

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

TEST=CQ

Change-Id: I4b643976a59adba8bd228a96ac75ae25ef8e206c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279120
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2023-01-16 16:28:43 +00:00
Daco Harkes f1a4f0e462 [vm] Split out main from main.cc
This enables running other C/C++ code before the Dart main function
without having to implement the full embedder API by including
main_lib and friends in a build but excluding `main.cc`.

TEST=ci build + flutter bot

Change-Id: I5739eb21fa6918b0a2c0f33f7d97dad73c5cf0b1
Cq-Include-Trybots: luci.dart.try:flutter-engine-linux-try,flutter-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278518
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-01-16 15:12:38 +00:00
Tess Strickland 0bd5a2b05e Revert "[ VM ] Add support for sampling old space allocations"
This reverts commit 6e4c0c2196.

Reason for revert: Broke ASAN builds

See https://github.com/dart-lang/sdk/issues/51023

Original change's description:
> [ VM ] Add support for sampling old space allocations
>
> TEST=DartAPI_HeapSampling
>
> Change-Id: Idf26fca6ae59720557d73627f727b00229dd1e9c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273860
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

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

Change-Id: Id704f9070c430234b7cd78d8c2b67a5ed3e503fe
Cq-Include-Trybots: luci.dart.try:vm-kernel-asan-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279100
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-01-16 11:42:45 +00:00
Brian Quinlan 3571b97b24 [win/io] Fix a bug where RawDataSocket would send truncated data on Windows.
Bug:https://github.com/dart-lang/sdk/issues/31873
Change-Id: I8856bad941330f24671fc2c61af736fc54cd9459
Tested: unit tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278981
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-01-13 20:36:55 +00:00
Ben Konyi 6e4c0c2196 [ VM ] Add support for sampling old space allocations
TEST=DartAPI_HeapSampling

Change-Id: Idf26fca6ae59720557d73627f727b00229dd1e9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-01-13 19:06:37 +00:00
Ryan Macnak cfd0c25ac3 [test] Run the service suite with --nnbd=strong.
TEST=ci
Change-Id: I6753a0a5eb9d93e4c33af0dc8d21dffe3e6aee54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278944
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-13 18:32:27 +00:00
Martin Kustermann 30878542b8 [vm] Add vm/dart_2/isolates/reload* tests to vm/dart/isolates/* test suite
We do not want to lose coverage when no longer running _2 test suites.
Those tests were originally written at a time when package:front_end
wasn't migrated yet - and as such couldn't be run in sound null safety.

TEST=ci

Change-Id: Id26da7e5896345a9e165829ba4a22d36695b6da3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279007
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-13 15:29:20 +00:00
Martin Kustermann 23d3e86f95 [vm/compiler] Ensure the compiler runs without an active isolate
The compiler should not depend on isolate specific details since
compiled code is shared across isolates in an isolate group.

TEST=ci

Change-Id: I77332c2dea6b5a8e75c1a3be544d1b73a7a69497
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278900
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-13 14:38:41 +00:00
Alexander Markov cd3fc2b27d [vm] Regression test for #50148
Add a test for hot reload which involves a constructor tear-off
taken from a generic class.

TEST=vm/cc/IsolateReload_GenericConstructorTearOff

Issue: https://github.com/dart-lang/sdk/issues/50148
Change-Id: I690374e083e8c1bca61827d589e59c017a1fc1ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278945
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-12 20:32:38 +00:00
Sam Rawlins b9a42c82bc Move seven more Hints to be StaticWarnings:
* ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER
* BODY_MIGHT_COMPLETE_NORMALLY_CATCH_ERROR
* BODY_MIGHT_COMPLETE_NORMALLY_NULLABLE
* DEPRECATED_EXTENDS_FUNCTION
* DEPRECATED_IMPLEMENTS_FUNCTION
* DEPRECATED_MIXIN_FUNCTION
* DEPRECATED_NEW_IN_COMMENT_REFERENCE

This requires allowing these warnings to be reported in language tests without being expected.

Also, observatory now must comply with BODY_MIGHT_COMPLETE_NORMALLY_NULLABLE (or we could ignore the diagnostic).

TESTED=unit tests

Change-Id: I8facfa48a8645bac5bf8037163076a8f0a0ad05e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275740
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-01-12 19:17:35 +00:00
Vyacheslav Egorov 30964ae17a [vm/compiler] Fix IsRedundant predicate used by IL printing
Apply ShouldPrintInstruction in more places in IlTestPrinter.

TEST=run il tests

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try
Change-Id: I5290e4ced904c0c6eaf9df8e93397fcad29efc55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278907
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-11 21:57:33 +00:00
Ryan Macnak 44da85cc3b [vm, gc] Account for Smi targets of weaklings.
TEST=ci
Change-Id: I11183b1f9657d12aa58b440a2cf49b6a9e796da7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278672
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-11 17:00:59 +00:00
Vyacheslav Egorov 7e82a87658 [vm/compiler] Cleanup IL dumps a bit
* Do not print redundant ParallelMove instructions unless
  `--print_redundant_il` is specified.
* Do not print `;; Inlined` comments if
  `--no_include_inlining_info_in_disassembly` is specified.

TEST=manually

Change-Id: I9a8c83514e2a749484863a4cc010c8ea7950b0fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278748
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-01-11 15:51:55 +00:00
Alexander Aprelev 1ee5cdbe30 [vm/regexp] Make concurrent RegExp updates safe.
Fixes https://github.com/dart-lang/sdk/issues/50820.
TEST=one_regexp_many_workers_test on tsan

Change-Id: I2a5bd19dfe46b39515e980c82f43433bde514fbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277202
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-11 01:59:48 +00:00
Alexander Aprelev e1abb3490d [vm/gardening] Fix race in regress_46419_test
Service event listener is set up as isolate being resumed, races to get isolate paused event.

Fixes https://github.com/dart-lang/sdk/issues/50834
TEST=regress_46419_test

Change-Id: I29c7fe6d684b4ee0c28b70f92540a6860e38e075
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277182
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-01-10 18:51:00 +00:00
Ryan Macnak ab287309e5 [vm] Don't wait for the idle timeout when the thread pool is shutting down.
TEST=time taskset --cpu-list 0 dart hello.dart
Bug: https://github.com/dart-lang/sdk/issues/47448
Change-Id: Iae3e8861bae4466d0f1aad7cf45707356ff7b98e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278665
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-01-10 17:46:38 +00:00
Alexander Markov 88400bdc42 [vm] Update number of parent function type arguments
Number of parent type arguments in function types is critical
for instantiation and subtype checks when there are nested
generic function types. So it is important to update
number of parent type arguments when parent function type is updated.

This change adds mechanism for updating number of parent
type arguments and uses the new mechanism in 2 cases:

1) When a type parameter is substituted during type instantiation.
   The substituted type can have nested generic function types and
   it should be updated if substituted inside another generic
   function type.

2) When creating a constructor tear-off for a generic class.
   Parameter types of the constructor could have nested generic
   function types and they should be updated as tear-off itself is a
   generic function.

TEST=language/function_subtype/generic_function_type_substitution_test
TEST=language/regress/regress50905_test

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

Change-Id: If13baa420939f5ac002ce32f3909953fb6998bd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278525
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-01-10 03:10:14 +00:00
Josh Soref 46ee7eb873 Spelling samples
Closes https://github.com/dart-lang/sdk/pull/50919

TEST=ci

GitOrigin-RevId: 5ac389ee109d6a06f89d405da916945c36e1d24d
Change-Id: Ica078a14e87234459c0703c41c8bae5157132b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278532
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-09 17:44:29 +00:00
Josh Soref aee77b9a33 Spelling tools
Closes https://github.com/dart-lang/sdk/pull/50880

TEST=ci

GitOrigin-RevId: ea8ecf4b7b921de0549df325be1a1f7879e86b72
Change-Id: I39315609a8390b012196a08c9ce4a9a6a50b1558
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278061
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2023-01-09 15:48:57 +00:00
Josh Soref 7a129d6b91 spelling: is_signed
Closes https://github.com/dart-lang/sdk/pull/50808

TEST=ci

GitOrigin-RevId: ea4034173f9028fc4dfe0adb6a3e9bae34027843
Change-Id: I588cfe0765476705d7da8130e6121e25275be7f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276774
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-01-09 13:21:55 +00:00
Alexander Markov b214bb03b0 [vm/compiler] Propagate static types through record field accesses
TEST=TypePropagator_RecordFieldAccess

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I18f8fc1ca1c97722f10b280afbe943bb4c948e17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278520
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-01-06 15:15:08 +00:00
Josh Soref 50b94ef9fc Spelling runtime bin
TEST=build VM

Closes: https://github.com/dart-lang/sdk/pull/50862

GitOrigin-RevId: ae54b37666f70f670ee3af11c984c7e9a7e9da26
Change-Id: I459fda0439a1cd368f488a70d84ee6bb915e60bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277761
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-06 07:48:22 +00:00
Josh Soref 1ab011a2a7 Spelling tests web
Closes https://github.com/dart-lang/sdk/pull/50879

TEST=only changes to spelling to comments and internal string messages
GitOrigin-RevId: 3fa4104fa17054ea2247118a1b6213c62f2749e0
Change-Id: I776120bb2492c662dd32612dd2f6a670b5891e42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278060
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-01-05 01:26:52 +00:00
Vyacheslav Egorov 15230e41e5 [vm] Improve crash output from gen_snapshot
* Don't compile it with omit frame pointer even in PRODUCT.
* Dump the first frame even if we give up on unwinding.
* Dump compiler state even if we give up on unwinding.
* Don't abort stack dump if PC for the outermost frame is 0 (can happen
when calling pure virtual method for example).

TEST=manually tested by making compiler crash during code generation

Change-Id: Iddeafbdad8e8588f19197d5dd49af14b8fc63134
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278341
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-04 18:14:56 +00:00
Josh Soref 512b540664 Spelling runtime: deduper
Closes https://github.com/dart-lang/sdk/pull/50807

TEST=ci

GitOrigin-RevId: 81d5ac80c1dcc65e784585c7bc61724a3b8c36ec
Change-Id: Iaaaac18a9b2edc1f709e690b6ebcffc37993f25a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276802
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-04 16:00:26 +00:00
Alexander Markov b205ea18cb [vm] Fix compiler crash when returning a value of uninitialized late variable from async function
This change fixes CompileType::CanBeFuture() which previously attempted
to use Class objects by class id without first checking if cid is internal.

Cid can be internal (SentinelCid) when CompileType::CanBeFuture() is
called for a return value of an async function when it is returning
a value of an uninitialized late local variable (such Return
instruction is unreachable).

TEST=runtime/tests/vm/dart/regress_flutter117892_test.dart
Fixes https://github.com/flutter/flutter/issues/117892

Change-Id: I63f0ca32d6246487f5c33d983cef9bd22aaa2fb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278094
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-01-04 15:26:34 +00:00
Johnni Winther df9b753dc2 [cfe] Add support for inline class field access
The representation field of an inline class is not part of the
generated code - it does not have a corresponding synthesized top-level
methods like the other inline class members. Therefore, to support
access to the representation field, a new `representationName` field
is added to `InlineClass` that holds the name by which the
representation field can be accessed.

An access to the representation field is at runtime an access of the
receiver itself. To show that the static type of the expression changes
from the inline type of the receiver to the declared representation
type, an `AsExpression` is inserted. Since this check is not needed
at runtime, this node is marked with the new `isUnchecked` flag, that
backends can use to skip the check.

TEST=pkg/front_end/testcases/inline_class/field_access.dart

Change-Id: I635af414af2ddc541352078766ce57a9d8ded601
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277983
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-01-04 14:46:03 +00:00
Haidar cbe458703c [vm/api] Make CObject as_string const char* instead of const
Closes https://github.com/dart-lang/sdk/pull/50884

TEST=ci

GitOrigin-RevId: f898451bb21f1e49550698fcf08ec5dfc1036dce
Change-Id: I808d37afe3e953afd632e4ffc4ab4b152b468e4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278140
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-04 12:51:03 +00:00
xiao xiao 7fa17936a6 [samples/ffi] Use the function arguments instead of static value
TEST=samples/ffi/async/async_test.dart

Closes: https://github.com/dart-lang/sdk/pull/50890

GitOrigin-RevId: 265298d1529dc01a8ee75aff595a647878ece1bc
Change-Id: I688ffb2369f3028a2d490ae21f50e176c9227185
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278099
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-04 11:34:27 +00:00
Derek Xu e738858aae [3.0 alpha][VM/Service] Update VM Service spec to v4.0
This is a reland of commit c21f7c847c,
BUT the `setExceptionPauseMode` procedure is no longer deleted in this
commit. We are not ready to delete that procedure yet, because deleting
it breaks IDE support: https://github.com/flutter/flutter/issues/117526.

TEST=CI

Original change's description:
> [3.0 alpha][VM/Service] Update VM Service spec to v4.0
>
> This CL updates the VM Service spec to version 4.0 in order to add
> support for records. Some deprecated procedures and properties will also
> be removed in v4.0.
>
> As described in service.md's changelog, this CL:
> Adds `Record` and `RecordType` `InstanceKind`s, adds a deprecation
> notice to the `decl` property of `BoundField`, adds `name` property to
> `BoundField`, adds a deprecation notice to the `parentListIndex`
> property of `InboundReference`, changes the type of the `parentField`
> property of `InboundReference` from `@Field` to `@Field|string|int`,
> adds a deprecation notice to the `parentListIndex` property of
> `RetainingObject`, changes the type of the `parentField` property of
> `RetainingObject` from `string` to `string|int`, removes the deprecated
> `setExceptionPauseMode` procedure, removes the deprecated `timeSpan`
> property from `CpuSamples`, and removes the deprecated `timeSpan`
> property from `CpuSamplesEvent.
>
> TEST=CI
>
> Issue: https://github.com/dart-lang/sdk/issues/49725
> Change-Id: I7bf61c1ba11a0c7fd95a10c9c02c14282062b802
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268521
> Commit-Queue: Derek Xu <derekx@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

Change-Id: Ieb96d426b622745e653afd6ca8c9718b1deae0a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278160
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-03 16:16:18 +00:00
Daco Harkes 5d0325d3f1 [vm/ffi] Optimize struct copies
Replace the `_memCopy` implementation in Dart with `MemoryCopyInstr`.

Speeds up copying from and to `Pointer`s by up to a 100x for large
structs.

TEST=tests/ffi/function_callbacks_structs_by_value_test.dart

BENCHMARK=benchmarks/FfiStructCopy/dart/FfiStructCopy.dart

Before (x64 JIT):

FfiStructCopy.Copy1Bytes(RunTimeRaw): 86.26189953740506 ns.
FfiStructCopy.Copy16Bytes(RunTimeRaw): 14.006969563521945 ns.
FfiStructCopy.Copy1024Bytes(RunTimeRaw): 8.567228629242734 ns.
FfiStructCopy.Copy65536Bytes(RunTimeRaw): 8.469047080663412 ns.

After (x64 JIT):

FfiStructCopy.Copy1Bytes(RunTimeRaw): 56.79513144264321 ns.
FfiStructCopy.Copy16Bytes(RunTimeRaw): 3.562479879234367 ns.
FfiStructCopy.Copy1024Bytes(RunTimeRaw): 0.10771875669750132 ns.
FfiStructCopy.Copy65536Bytes(RunTimeRaw): 0.02758346614218262 ns.

Bug: https://github.com/dart-lang/sdk/issues/43967
Change-Id: I5d51c39a13b8c9522ee88d81bba7365caef70a27
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-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277523
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-01-02 17:56:19 +00:00
Lasse R.H. Nielsen 81b137d8fe [3.0 alpha] Remove deprecated BidirectionalIterator.
Requires releasing `package:quiver` 3.2.0 so Flutter can upgrade to that.


Change-Id: Ibd9acc5fa11a67ca50d06172dfe0f9175b240522
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276741
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-01-02 16:14:08 +00:00
Josh Soref a11bd0ce91 Spelling runtime vm heap
Closes https://github.com/dart-lang/sdk/pull/50785

TEST=ci

GitOrigin-RevId: a09e4d5c6ccf5514fe7fccab26c220525d3a9feb
Change-Id: I0896a003fab240f8edf828955cd827f63dcd4a31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276683
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-02 10:36:03 +00:00
Josh Soref 0633041729 Spelling runtime vm
Closes https://github.com/dart-lang/sdk/pull/50786

TEST=ci

GitOrigin-RevId: 781a38e2925ba505f0223ecd578faa9be8e1485c
Change-Id: Ia3c615012d1bac3f0cf64dc01c2ceb40d50d1193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276684
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-12-29 10:18:02 +00:00
Siva Annamalai dcaf392d34 Revert "[3.0 alpha][VM/Service] Update VM Service spec to v4.0"
This reverts commit c21f7c847c.

Reason for revert: Appears to cause issues when flutter app is launched with VSCode or Android Studio, please see https://github.com/flutter/flutter/issues/117526

Original change's description:
> [3.0 alpha][VM/Service] Update VM Service spec to v4.0
>
> This CL updates the VM Service spec to version 4.0 in order to add
> support for records. Some deprecated procedures and properties will also
> be removed in v4.0.
>
> As described in service.md's changelog, this CL:
> Adds `Record` and `RecordType` `InstanceKind`s, adds a deprecation
> notice to the `decl` property of `BoundField`, adds `name` property to
> `BoundField`, adds a deprecation notice to the `parentListIndex`
> property of `InboundReference`, changes the type of the `parentField`
> property of `InboundReference` from `@Field` to `@Field|string|int`,
> adds a deprecation notice to the `parentListIndex` property of
> `RetainingObject`, changes the type of the `parentField` property of
> `RetainingObject` from `string` to `string|int`, removes the deprecated
> `setExceptionPauseMode` procedure, removes the deprecated `timeSpan`
> property from `CpuSamples`, and removes the deprecated `timeSpan`
> property from `CpuSamplesEvent.
>
> TEST=CI
>
> Issue: https://github.com/dart-lang/sdk/issues/49725
> Change-Id: I7bf61c1ba11a0c7fd95a10c9c02c14282062b802
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268521
> Commit-Queue: Derek Xu <derekx@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

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

Issue: https://github.com/dart-lang/sdk/issues/49725
Change-Id: Ieb2a09653192e165ea8cf68965647e346e3a318b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277181
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-12-22 20:19:00 +00:00
Alexander Aprelev 8e7b1119b3 [vm/reload] Ensure FileModifiedCallback can handle uris on Windows.
Bug: https://github.com/dart-lang/sdk/issues/49634
Change-Id: I65b5c2a0559fdc51c003ffa6e955008850137a1c
TEST=bad_reload_test on Windows
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277044
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-12-21 23:11:30 +00:00
Alexander Aprelev 1071e3e068 [vm/isolate] Avoid isolate scan when exiting known isolate.
IsolateFibonacci before 3291867, after 3061103

Fixes https://github.com/dart-lang/sdk/issues/50789
TEST=benchmark/IsolateFibonacci

Change-Id: I667838c4ae089b9ac8889ae3eb3d773115437397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276760
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-21 18:07:58 +00:00
Alexander Markov 81f0959372 [vm] Fix record instance layout with compressed pointers
After record shape representation changed in https://dart-review.googlesource.com/c/sdk/+/276201,
clang started to insert an extra alignment padding
between 'shape' and 'data' fields in record instances
in compressed pointers mode. This padding is not initialized
in the allocation stubs, but GC scans it as it falls between
'from' (shape) and 'to' (end of data). This change adjusts
layout of UntaggedRecord in compressed pointers mode to avoid
the implicit padding and GC visiting garbage.

TEST=Manual run of language/records/simple tests and
RecordCollections benchmark on x64c and simarm64c architectures.

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I4b8a5b36c3ff757ccbbdb46c20d9ed8d12c53f96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276775
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-12-21 16:07:03 +00:00
Brian Quinlan 9b2b9df09e [io] Remove incorrect docs that listSupport is not available on Android.
Bug:https://github.com/dart-lang/sdk/issues/47894
Change-Id: Id79a37f5ba6a8118a30d2297c95cff5a7ca1a03f
TEST=unit
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276660
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-12-21 00:23:02 +00:00
Alexander Markov 51d672e77d [dartfuzz] Regenerate API and types tables
DartFuzz tables were regenerated to pick up the latest core library
additions and removals.

Change-Id: I549715aa5dd36bed7c04ee78e5908c923f1538be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276767
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-12-20 23:09:58 +00:00
Alexander Markov 3675fd25f4 [vm] Packed representation of record shape
The representation of record shape in record instances and record
types is changed from a pair

  int num_fields
  Array field_names

to a single integer - packed bitfield

  int num_fields(16)
  int field_names_index(kSmiBits-16)

where field names index is an index in the array available from
ObjectStore.

With the new representation of record shapes:
1) Size of record instances is reduced.
2) Number of comparisons for a shape test reduced from 2 to 1
(shape test is used during type checks).
3) A few operations removed from Record.hashCode.
4) Type testing stubs (TTS) are now supported for record types with
named fields. Previously it was not possible to check shape of records
with named fields in TTS as TTS cannot access object pool and cannot
load field names array).

TEST=existing

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

Change-Id: I7cdcbb53938aba5d561cd24dc99530395dbbea7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276201
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-12-20 20:11:48 +00:00
Josh Soref 1aeece5e31 Spelling runtime vm compiler
Closes https://github.com/dart-lang/sdk/pull/50784

Co-authored-by: Josh Soref 2119212+jsoref@users.noreply.github.com

TEST=ci
GitOrigin-RevId: dbb20e7ee532a3490e86a633b5164ebab54bd38d
Change-Id: I9bd29543c4417efd4f338ff1c0e45c4ddbcc044d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276622
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-12-20 17:01:52 +00:00
Alexander Aprelev 438b81c4f2 [vm/regexp] Share RegExp objects between isolates, keep isolate-specific state in static members.
Revert "[vm/regexp] Copy, rather than share RegExp objects between isolates." is in patchset 1.

Isolate RegEx-sharing benchmarks show 24-100x improvements.

Bug: https://github.com/dart-lang/sdk/issues/50639
TEST=ci
Change-Id: I87943c9b9928869f7a20052cb0dc71d24ad36087
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276240
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-12-20 02:28:04 +00:00
Derek Xu c21f7c847c [3.0 alpha][VM/Service] Update VM Service spec to v4.0
This CL updates the VM Service spec to version 4.0 in order to add
support for records. Some deprecated procedures and properties will also
be removed in v4.0.

As described in service.md's changelog, this CL:
Adds `Record` and `RecordType` `InstanceKind`s, adds a deprecation
notice to the `decl` property of `BoundField`, adds `name` property to
`BoundField`, adds a deprecation notice to the `parentListIndex`
property of `InboundReference`, changes the type of the `parentField`
property of `InboundReference` from `@Field` to `@Field|string|int`,
adds a deprecation notice to the `parentListIndex` property of
`RetainingObject`, changes the type of the `parentField` property of
`RetainingObject` from `string` to `string|int`, removes the deprecated
`setExceptionPauseMode` procedure, removes the deprecated `timeSpan`
property from `CpuSamples`, and removes the deprecated `timeSpan`
property from `CpuSamplesEvent.

TEST=CI

Issue: https://github.com/dart-lang/sdk/issues/49725
Change-Id: I7bf61c1ba11a0c7fd95a10c9c02c14282062b802
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268521
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-12-19 19:41:41 +00:00
Kallen Tu 7bd4aee94a [cfe] Add mixin class flag to dill and binary.
Additionally, make class flags a uint because there are now more than 8 flags.

TEST=pkg/front_end/testcases/mixin_class/*

Change-Id: I4fe7babfa9911df0821cc73528e6b10b2ea3b92d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275402
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-16 19:12:59 +00:00
Nicholas Shahan 352ba74453 [3.0 alpha][core] Delete NullThrownError
TESTED=Ran CQ dryrun and approved failures for co19 tests that will be updated soon.

Change-Id: Ic0dc5fc084b1d0f3fce80dd88062f879abd7b556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275840
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2022-12-16 17:46:48 +00:00
Daco Harkes 2435f0b398 [vm/ffi] Make elementAt an extension method
The CFE rewrite for structs, unions, and abi-specific integers is now
done on the extension methods.
The other native types are implemented in the extension methods
directly.

TEST=test/ffi

Closes: https://github.com/dart-lang/sdk/issues/50714
Change-Id: I578325733e3cd66200e80949d47ff12a13115b99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276102
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-12-16 16:33:12 +00:00
Ryan Macnak 6d41f47d45 [vm, compiler] Decide how many Q registers are available based on target OS.
TEST=ci
Change-Id: Ieefb6d56a4110a9277c5f217a800c3297de8964e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238383
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-12-15 18:05:31 +00:00
Nate Bosch f065dca391 Avoid permanently paused isolates
These tests have some exceptions caused by missing fields on the
dynamic variable. The exceptions cause the `isolate.resume()` call to
not run, which also cause the test body to not complete.

Currently this is masked by the test runner, which immediately ignores
the test body once the first error occurs. That behavior is changing,
and a failure will not immediately end a test when the body is still
running. https://github.com/dart-lang/test/pull/1815

Some of these tests are currently are expected to fail, but not to
timeout. Fix the test implementations to more reliably complete the test
body, even when the test had an error. This does not fix the tests
themselves, it maintains the current pattern of failure, even after
updating the test runner.

- Use `Stream.firstWhere` over cancelling the stream subscription after
  the first breakpoint.
- Use `Future.whenComplete` to ensure the isolate is always unpaused,
  including after an exception in the expectations.

Tested: Passes with updated test runner in https://dart-review.googlesource.com/c/sdk/+/275401/4
Change-Id: If5a7f0264c580cb38bcc1bd95c035aaf5644124b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275787
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-12-15 17:37:13 +00:00
Ryan Macnak f181b50249 [build] Address warnings in gcc 11 and 12.
TEST=local builds
Bug: https://github.com/dart-lang/sdk/issues/50645
Change-Id: If6cd26620feff06abd449be0f7d1dd1e620b8411
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275841
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-15 17:36:39 +00:00
Alexander Aprelev ff2d661d5b [vm/compiler] Choose correct unboxed float representation for phi instructions.
BUG=https://github.com/dart-lang/sdk/issues/50622
TEST=FlowGraph_UnboxedFloatPhi

Change-Id: Ie7bfbb6c4028907a18243d44be8128999c1efcae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275180
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-15 15:24:12 +00:00
Vyacheslav Egorov d02e1de5b1 [vm] Add Dart_SetDwarfStackTraceFootnoteCallback
This API allows embedder to append arbitrary footers to DWARF stack
traces. For example, embedder can append a link to a symbolizer
service, which could be used to symbolize the stack-trace.

TEST=manually tested, hard to create automatic tests because vm/cc tests  only support JIT, not AOT.

Bug: b/255741575
Change-Id: Id034b9b3194f7b91a8405574ea771c4a06fda2c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-12-15 13:45:10 +00:00
Jens Johansen dde72f78a2 [vm] Heap snapshot tool can load file from arguments
This CL allows the heap snapshot tool to load a file as it is launched
via a command like
```
../../../out/ReleaseX64/dart bin/explore.dart my_snapshot.heapsnapshot
```

Change-Id: I4eca4ec18daef4d3361c754018d234045e725ef5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275860
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-15 12:31:45 +00:00
Michael Thomsen e4cc3c98e5 [3.0 alpha] Remove deprecated dart:core List() constructor.
TEST=ci

Bug: Contributes to https://github.com/dart-lang/sdk/issues/49529
Change-Id: Ic129ef2d89f625d9ec6a7a1c301cffddd60b2ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258920
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-12-15 11:36:22 +00:00
Alexander Markov 7ebd4dd61c [3.0 alpha] Remove deprecated public class CyclicInitializationError
This deprecated class cannot be removed just yet because
we still need to throw something in case of cyclic initialization
in Dart legacy libraries (which are still supported).

Class CyclicInitializationError is copied for each implementation
(VM, dart2js and DDC) and made private. Each implementation now has
an independent private class which can be removed separately.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/49529
Change-Id: I8100bbe16636c12c4cbabbb5fe770f4c648c4249
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275120
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-15 11:20:58 +00:00
Ryan Macnak 78732b243e [vm] Fail describing errno if mmap fails for any reason except ENOMEM.
Avoids the VM later failing with a misleading "Out of Memory" message when allocation fails for lack of permission, etc.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50719
Change-Id: I52b2478092a5e5b59680f31d37ab3c6d6d816ba0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275783
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-15 00:52:58 +00:00
Ryan Macnak 98af4110ad [vm] Increase supported range of TypeParameters to 16 bits.
TypeParameter::set_index was already asserting for 16 bits but silently truncating to 8 bits. The size of TypeParameter does not increase due to allocation rounding.

Add explicit range check to class finalization.

TEST=ci
Change-Id: Id4017f74b7dba47b00d64e77e787712c70290dac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275560
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-14 23:34:18 +00:00
Alexander Markov 987775d6fb [vm] Type testing stubs for record types
Benchmarks improved by:
JIT:
RecordCollections.ListAddPoly.Record ~9.6 times
RecordCollections.ListSetIndexed.Record ~8.3 times
RecordCollections.ListSetIndexedPoly.Record ~16.1 times
RecordCollections.MapAdd.RecordKey ~3.6 times
RecordCollections.MapAdd.RecordValue ~4.4 times
RecordCollections.SetAdd.Record ~4.1 times
AOT:
RecordCollections.ListAdd.Record ~8.7 times
RecordCollections.ListAddPoly.Record ~8.8 times
RecordCollections.ListSetIndexed.Record ~19.5 times
RecordCollections.ListSetIndexedPoly.Record ~18.3 times
RecordCollections.MapAdd.RecordKey ~7.1 times
RecordCollections.MapAdd.RecordValue ~8.8 times
RecordCollections.SetAdd.Record ~8.9 times

TEST=vm/cc/TTS_RecordSubtypeRangeCheck

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I96e4c6a40a897a72b3570b59e014c8af77a9ef99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275082
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-14 22:33:38 +00:00
Ryan Macnak 8a37b70a53 [vm, compiler] More consistently support large load/store offsets.
TEST=ci
Change-Id: I7691808679c57c6f16f3859641cf52b9e606e304
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275381
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-14 22:17:35 +00:00
Ryan Macnak 4baa958d08 [vm] Remove overly-narrow NoSafepointScopes.
These NoSafepointScopes are active for only one load/store where there is little need to guard against someone adding an allocation. They have been observed to take up to 15% of program execution in debug builds.

TEST=ci
Change-Id: I923baa28a3a72decacbfcdec3331ce9c7c620b67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275540
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-14 20:55:29 +00:00
Johnni Winther 81845864ca [kernel] Rename View* to Inline*
TEST=existing

Change-Id: I8726c936261ceb770b489f264d14fff02a1b4998
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275243
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-12-14 08:36:57 +00:00
Ryan Macnak 138a69a150 [vm, compiler] Conditionally use RV-B instructions.
TEST=ci, local qemu
Change-Id: I3321264b524d52e5a63a32f70b62f27182ebc247
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273833
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-13 23:43:18 +00:00
Vyacheslav Egorov 2f117ba43c [vm/aot] Fix ProgramElementKeyValueTrait::Hash.
It was returning library's index which is an unstable
value. This instability could cause `Precompiler::HasApiUse`
to stop returning `true` after `Precompiler::DropLibraries` even
if library was added to the `api_uses_` set. This in turn could cause
`Precompiler::PruneDictionaries` to drop library entries it should
not have dropped.

TEST=added assertion that verifies stability of the set

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Change-Id: I0685bd75562f83e2b9d8b3a03fa410ba218df2ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275241
Reviewed-by: Tess Strickland <sstrickl@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-12-13 19:46:41 +00:00
Ryan Macnak fa2e1c70ca [vm] Fix various scaling limitations.
- Quadratic behavior recording field guards
 - Quadratic behavior looking up dynamic invocation forwarders
 - Incorrect limit generating allocation stubs

TEST=class with 64k fields
Change-Id: I7a9aba617e71eff9b28711e99c689cb04be0dde7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273285
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-13 19:28:37 +00:00
Dan Chevalier fd6fa010ec [ VM Service / DDS ] Add custom service stream support (Revised)
NOTES:
Original CL: https://dart-review.googlesource.com/c/sdk/+/274061
Revert CL: https://dart-review.googlesource.com/c/sdk/+/274802

Regression tests that failed after merging Original CL:
- https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/pkg-mac-release/24046/overview
- https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/pkg-mac-release-arm64/5999/overview

----------
DESCRIPTION:
Setting the `stream` parameter on `developer.postEvent` will now forward those events to a custom stream inside DDS.


The first use of this will be for widget inspection. A navigation event will be posted to a custom stream. Our IDE DAP can listen for the Event and react to it by navigating to the desired location in the code.

TEST=Made sure that regression from original PR could be reproduced, and then resolved by applying this change. Updated observatory tests. Created new developer test to check assertions. Added DDS tests for new custom stream behaviour. Manually tested the postEvent and StreamListen with multiple clients

https://github.com/flutter/devtools/issues/4533

Change-Id: I2b04a84b4daf11dd9d72f899928b5e1f62a5ae02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275121
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-12-13 16:31:37 +00:00
Derek Xu 53d859f6b9 Revert "[VM/CLI] Remove dartdev.dill"
This reverts commit c09f790d37.

Reason for revert: CI failures

Original change's description:
> [VM/CLI] Remove dartdev.dill
>
> Incompatible VM flags will no longer break the CLI when running from an
> AppJIT snapshot, so the fallback logic is no longer required. This CL
> thus removes dartdev.dill and the fallback logic.
>
> Relevant past CLs: https://dart-review.googlesource.com/c/sdk/+/157601
> and https://dart-review.googlesource.com/c/sdk/+/178300
>
> Fixes https://github.com/dart-lang/sdk/issues/50504
>
> TEST=I tried running `out/ReleaseX64/dart --observe --sound-null-safety test.dart`
> and `out/ReleaseX64/dart --observe --no-sound-null-safety test.dart` and
> both worked.
>
> Change-Id: I5cdcfbccf71ec557964014fdb80733b4a7c76b4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274520
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

TBR=bkonyi@google.com,derekx@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I5117f990dfabf93f5a9bae56098831280845e84e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275181
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2022-12-13 15:28:19 +00:00
Ryan Macnak de310a0c7b [vm, compiler] Fix address encoding limit when loading type arguments.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50671
Change-Id: I3a5ab9492d74fa770efd8e4c7cf90002a3793b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275081
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-12-12 23:23:53 +00:00
Derek Xu c09f790d37 [VM/CLI] Remove dartdev.dill
Incompatible VM flags will no longer break the CLI when running from an
AppJIT snapshot, so the fallback logic is no longer required. This CL
thus removes dartdev.dill and the fallback logic.

Relevant past CLs: https://dart-review.googlesource.com/c/sdk/+/157601
and https://dart-review.googlesource.com/c/sdk/+/178300

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

TEST=I tried running `out/ReleaseX64/dart --observe --sound-null-safety test.dart`
and `out/ReleaseX64/dart --observe --no-sound-null-safety test.dart` and
both worked.

Change-Id: I5cdcfbccf71ec557964014fdb80733b4a7c76b4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274520
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2022-12-12 18:02:47 +00:00
Daco Harkes e3e355e16a [vm/ffi] Fix FfiTrampolineData GC bug
This lets the GC visit FfiTrampolineData::c_signature again.

https://dart-review.googlesource.com/c/sdk/+/272201 stopped adding
FfiTrampolineData::c_signature to snapshots. However, instead of
skipping it manually in app_shapshot.cc, we skipped it in
raw_object.h, which also caused the GC to skip it.
This CL adds it back in as we need it in JIT snapshots. This way we
keep it consistent between AOT/JIT snapshots.

TEST=tests/ffi/regress_b_261224444_test.dart

The c signatures of FFI trampolines were not properly traced in the
precompiler, causing us to hit an assert when the classes mentioned in
those types where only referenced from a signature and not retained
for any other reason.

TEST=tests/ffi/native_assets/process_test.dart (dartkp)

Closes: https://github.com/dart-lang/sdk/issues/50678
Bug: b/261224444
Change-Id: I84fc880744c2045ea3e2ef4f37df454b80b2faeb
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,app-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274387
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-12-12 15:46:33 +00:00
Martin Kustermann 14508968f0 [vm] Ensure platform/globals.h is included before using defines
Defines may be defined/modified/cleared in `platform/globals.h`. All VM
sources should directly or indirectly include `platform/globals.h`
before using defines.

TEST=ci

Change-Id: Icf67eddd94a18775d4247259049906c9cc6014cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275020
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-12-12 15:38:30 +00:00
Lasse R.H. Nielsen 767049139a [3.0 alpha] Remove deprecated dart:core apis
- Remove `proxy` and `Provisional` annotations.
  - Remove `Deprecated.expires` getter.

Change-Id: I4521b48bb92e5f8420c778686f4efa9c6426cebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258004
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-12-12 11:46:58 +00:00
Dan Chevalier 3ed65601b0 Revert "[ VM Service / DDS ] Add custom service stream support"
This reverts commit 4981cbffe2.

Reason for revert: Mac regression test failed.

Original change's description:
> [ VM Service / DDS ] Add custom service stream support
>
> Setting the `stream` parameter on `developer.postEvent` will now forward those events to a custom stream inside DDS.
>
>
> The first use of this will be for widget inspection. A navigation event will be posted to a custom stream. Our IDE DAP can listen for the Event and react to it by navigating to the desired location in the code.
>
> TEST=Updated observatory tests. Created new developer test to check assertions. Added DDS tests for new custom stream behaviour. Manually tested the postEvent and StreamListen with multiple clients
>
> https://github.com/flutter/devtools/issues/4533
>
> Change-Id: I870dc634c9a9a7d2ee3a6605319c2a18517ad197
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274061
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Dan Chevalier <danchevalier@google.com>

TBR=bkonyi@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com,danchevalier@google.com

Change-Id: Ia1dce25444a6329c0553c931c9a6dbbec65ee583
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274802
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Dan Chevalier <danchevalier@google.com>
2022-12-12 11:24:37 +00:00
Michael Thomsen b3304af17d [3.0 alpha] Remove deprecated onError API on int.parse, double.parse, and num.parse
Change-Id: I9ed24c380bf716cb893b99ba228e34f4671cc8fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259042
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-12 09:54:54 +00:00
Alexander Aprelev e07321ec9d [vm] Factor StringEqual out of platform-specific intrinsifiers into single asm_intrinsifier.
TEST=ci
Change-Id: Iaab92c4a4c5a04355778c17ce564672c1e97814c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272349
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-11 02:49:28 +00:00
Ryan Macnak a429d2ff91 [vm, gc] Remove dead code from weak handle visitors.
TEST=ci
Change-Id: I10619b7970de19047c9af77fc82dc9d3009f34f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274801
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-12-09 22:22:28 +00:00
Dan Chevalier 4981cbffe2 [ VM Service / DDS ] Add custom service stream support
Setting the `stream` parameter on `developer.postEvent` will now forward those events to a custom stream inside DDS.


The first use of this will be for widget inspection. A navigation event will be posted to a custom stream. Our IDE DAP can listen for the Event and react to it by navigating to the desired location in the code.

TEST=Updated observatory tests. Created new developer test to check assertions. Added DDS tests for new custom stream behaviour. Manually tested the postEvent and StreamListen with multiple clients

https://github.com/flutter/devtools/issues/4533

Change-Id: I870dc634c9a9a7d2ee3a6605319c2a18517ad197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274061
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
2022-12-09 20:18:30 +00:00
Ben Konyi 0971185695 [ VM ] Remove unnecessary condition check
TEST=N/A

Change-Id: I4c738a9be1aee9fab636ee2cbdb796f0ed226a86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274060
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-12-09 19:27:27 +00:00
Michael Thomsen 9f2a622d79 [3.0 alpha] Update CFE messages for Dart 3 sound null safety by-default
Fixes https://github.com/dart-lang/sdk/issues/50638

Change-Id: I511c5337099ae9576377ac8a82ef1bb78f6d34b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273844
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2022-12-09 16:55:03 +00:00
Daco Harkes 56e581aa34 [3.0 alpha] Move AbstractClassInstantiationError to dart:mirrors
Split off https://dart-review.googlesource.com/c/sdk/+/259041 so that
the VM changes can be landed separately.

TEST=tests/lib/mirrors/instantiate_abstract_class_test.dart

Bug: https://github.com/dart-lang/sdk/issues/49529
Change-Id: Ic06dee0dfeaea64d9d9ffd9511ec66d9d0837e7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274383
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-09 12:53:28 +00:00
Alexander Aprelev fb22336c28 [vm/sse41] Fix use of pextrd when sse41 is not available.
BUG=https://github.com/dart-lang/sdk/issues/50640
TEST=ci

Change-Id: Ief12c270cb59dace99e3a2845cb44ed5085dbdaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274081
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-08 23:29:14 +00:00
Ryan Macnak 15c8dad750 [vm] Reorder fields on Thread to reduce code size on X64.
dart2js.jit.x64 48139536 -> 47867344 (-0.57%)
dart2js.aot.x64 27077952 -> 26799256 (-1.03%)

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48182
Change-Id: Ibc7d2ae7473936530307eadfcb4aeb83a9fdb873
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274282
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-08 18:24:19 +00:00
Ryan Macnak 0150cddace [vm] Fix call-through-getter runtime handling.
This should look for `dyn:call` instead of `call`. If it was a non-dynamic call, we would hit an invoke-field-dispatcher instead.

TEST=ci
Bug: https://github.com/flutter/flutter/issues/116405
Change-Id: I98c441fec2eb53ab23ac1dd52db3aa4eaa5cbc6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274265
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-08 17:48:49 +00:00
Daco Harkes 1d567c888f [vm] Remove use of CastError
`CastError` is replaced by `TypeError`.

Also makes the fields of TypeError nullable. See:
https://github.com/dart-lang/sdk/issues/49279

TEST=build SDK and run default suites.

Bug: https://github.com/dart-lang/sdk/issues/49529
Change-Id: I7e880ff2d8b18c4bffdd7a942efd743244a12734
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274381
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-12-08 17:07:33 +00:00
Tess Strickland a43d3cb993 [vm/compiler] Use CombineHashes/FinalizeHash methods in intrinsifier.
AsmIntrinsifier::OneByteString_getHashCode now uses the CombineHashes
and FinalizeHash Assembler methods introduced in 49f998dc31.

To avoid having to check for 0 again after masking the result of
FinalizeHash to fit the desired bit size, we create a more general
FinalizeHashForSize that also takes the desired bit size of the result.

The intrinsified versions for ARM/ARM64/RISCV are also modified to
remove the special casing for the empty string, and instead just check
the size of the string against the loop counter at the start of the
loop, similarly to X64/IA32. This is less efficient for the empty
string case, but avoids the need to create a version of FinalizeHash
that elides the zero check.

TEST=ci

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-mac-release-arm64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-debug-simriscv64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-nnbd-linux-debug-simriscv64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-linux-release-ia32-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-mac-release-arm64-try,vm-kernel-linux-debug-x64c-try
Change-Id: I53db731acb8bf35d16efb55fa2c5a79d8302399f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272800
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-12-08 12:58:28 +00:00
Daco Harkes d86c043cbb [vm] Remove FallThroughError code in the VM
Since Dart 2.0 we can never have FallThroughErrors.

The CFE does not synthesize breaks unterminated cases which never
reach the end of the block. For example:
* Call to something that returns never.
* Nested complete switch which returns from every branch.

In these cases we need to construct a correct control flow in the VM,
even though it is dead code. Because the CFE does not make the outer
switch a labelled statement, we cannot find a jump target in the VM.

Therefore, throw something (just not a FallThroughError). This should
never be hit at runtime, because it's dead code.

When the CFE emits synthetic breaks, we can remove this workaround.

TEST=build SDK and run default suites.

Bug: https://github.com/dart-lang/sdk/issues/50595
Change-Id: I595dd3baf7253b0ac4931445bd5b6da49e84cae4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273740
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-12-08 11:51:31 +00:00
Alexander Markov 66f1dee48c [vm] Runtime type check in await
'await e' should check that e is a Future<flatten(S)>, where S is a
static type of e before awaiting e. If e is not a Future<flatten(S)>,
then 'await e' should await Future.value(e) instead of e. So futures
of incompatible type are not awaited and soundness is not violated.

TEST=tests/language/async/await_type_check_test.dart
(Based on https://dart-review.git.corp.google.com/c/sdk/+/267422.)

Fixes https://github.com/dart-lang/sdk/issues/50529
Part of https://github.com/dart-lang/sdk/issues/49396

Change-Id: Ia418db1be6736710abc9be87d95584c50cbc677e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273002
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-07 22:46:22 +00:00
Alexander Aprelev efaad34a46 [vm/simd] Recognize TypedData Float64x2 getter/setters
```
import 'dart:typed_data';

@pragma("vm:never-inline")
fetch(l, i) => l[i];

main() {
  const n = 16*1024*1024;
  final l = ByteData(16 * n).buffer.asFloat64x2List();
  for (int i = 0; i < n; i++) {
    fetch(l, i);
  }
  final sw = Stopwatch()..start();
  for (int i = 0; i < n; i++) {
    fetch(l, i);
  }
  print(sw.elapsedMilliseconds);
}
```

on x64
before 1137ms
after 101ms

BUG=https://github.com/dart-lang/sdk/issues/50636
TEST=ci

Change-Id: I90ef8ccfa1161d4d8bb076a3c1a0e3c7d6521289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274263
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-07 22:25:25 +00:00
Martin Kustermann 4be2981c2d [vm/ffi] Ensure there's a single Function object per ffi-callback + exceptional-return combination
Right each `Pointer.fromFunction()` invocation will lead to creation of
a new ffi trampoline function & it's following JITed code. In AOT we
have exactly one ffi trampoline per target/native-signature/exceptional-return
combination.
=> This CL ensures we have only one such function.

Furthermore each `Pointer.fromFunction()` will currently perform 2
runtime calls in JIT: One to create a `Function` object, the other to
JIT that function & register callback metadata.
=> This CL ensures we won't do a runtime call to get a function, instead
   do it at compile-time (as in AOT)

Furthermore we eagerly assign a callback-id to the unique/deduped ffi
trampoline callbacks. Only when the application requests a pointer, do
we populate metadata on the `Thread` object.

This CL doesn't (yet) change the fact that in JIT mode we have
isolate-specific jit trampolines (that will call now shared ffi trampoline
functions).

We also avoid baking in C++ runtime function pointers in generated
code. As a result we can now preserve ffi trampolines across AppJIT
serialization.

As a nice side-effect, we remove 100 lines of code.

TEST=ffi{,_2}/ffi_callback_unique_test

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

Change-Id: I458831a47b041a088086f28f825de2a3849f6adc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273420
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-12-07 20:47:13 +00:00
Martin Kustermann 896675c462 [vm] Always share double/float32x4/float64x2/int32x4 in inter-isolate messages
The JIT support for dynamically unboxing has been removed in [0]. As
such all double/float32x4/float64x2/int32x4 objects are immutable and
can therefore be shared across isolates.

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

TEST=ci

Change-Id: Ifd4e7c2444415b2e3b5269d9fbeb6570cc5d6768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273680
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-12-07 00:48:28 +00:00
asiva 606a64a743 [3.0 alpha][VM/Runtime] - Flip flag to make strong null safety the default.
- Flip flag to make strong null safety the default
- Remove code that auto detects null safety mode from source files,
  it is necessary to specify --no-strong-null-safety to opt out.
- Retains sniffing of AOT/JIT snapshots and kernel files to determine
  null safety mode, the opt out has to be done when generating these
  file.

TEST=ci

Change-Id: If2c9608eedb7c46d9c3cd85e261ee9640e0d28eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261140
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-12-06 04:04:23 +00:00
Alexander Thomas 7e0d92d69d [3.0 alpha] Bump version to 3.0.0
Tested: Standard CQ.
Bug: https://github.com/dart-lang/sdk/issues/49529
Change-Id: I329b9940db7309c7e48f17eecd7a66d5b853a484
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271922
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-06 02:40:36 +00:00
Ryan Macnak d9dd8300ca [vm, gc] Fix rare failure to update target of FinalizerBase or WeakReference.
At the end of a scavenge, ObjectPtr::IsRawNull was used on what is either a pointer into old-space or a pointer into from-space. If a pointer into from-space, the header may be a forwarding pointer. When IsRawNull interprets this is an object header, the bits in the ClassIdTag position will sometimes happen to equal kNullCid, causing the pointer to be incorrectly interpreted as null instead of a forwarding pointer and thus leaving behind a dangling pointer into from-space.

This separate null check can simply be removed because null is always an old-space object.

TEST=splay_{weak/c_finalizer/dart_finalizer}_test
Bug: https://github.com/dart-lang/sdk/issues/50578
Bug: https://github.com/dart-lang/sdk/issues/50612
Change-Id: Ifc7dc19c36703222a9302a8dbb68982fdbbc91fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273560
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-05 18:08:46 +00:00
Ben Konyi 3850a595b9 [ VM ] Ensure heap sampling profiler is initialized on newly spawned threads
Also fixes some incorrect TLAB boundary calculations

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

TEST=DartAPI_HeapSampling looped under full system load for 30 minutes

Change-Id: I6e56cc659b58f9b246d20dc5b649fc367af9c672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273500
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-12-05 17:41:08 +00:00
Jens Johansen 93ef21b00b [vm] Add examples to heapsnapshot tool
Change-Id: I2b3735341146e532a747e302050e3983ee8f7e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-05 15:02:27 +00:00
Jens Johansen b0ca324b08 [VM] Fix crash on >num filter in heapsnapshot tool
Change-Id: I873d98452e88d2b55b485cc14daa1823af2ba0f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273741
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-05 14:49:50 +00:00
Alexander Aprelev 4275d595b6 [vm/regexp] Copy, rather than share RegExp objects between isolates.
RegExp code objects keep backtracking and registers stacks in object pools, can't be shared between isolates.

BUG=https://github.com/dart-lang/sdk/issues/50082
TEST=one_regexp_many_workers

Change-Id: Ic7db8d7a75a0951178b2f4800f96224d52506545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273480
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-02 22:45:21 +00:00
Ryan Macnak ed2899ea4a [vm] Don't unroll initialization code based on macro lists.
-30k (-0.07%) out/ReleaseX64/exe.stripped/dart
-29k (-0.25%) out/ReleaseX64/exe.stripped/dart_precompiled_runtime

TEST=ci
Change-Id: I7c05705ada10dcaa388d9c8a8abd4edd9495cdc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273009
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-02 18:45:03 +00:00
Ryan Macnak 16149782ef [test] Make less memory be gated by finalization in splay_dart_finalizer_test.dart.
When the heap limit is reached, directly unreachable objects are reclaimed but objects that will be unreachable after a finalization are not, and there needs to be enough headroom between opportunities for finalizers to run (returning to the event loop).

So only do the finalization thing with the upper, high-mutation part of the splay tree and remove it from the lower, write-once part. The high-mutation part is what's more interesting for GC stress testing.

Bug: https://github.com/dart-lang/sdk/issues/50597
Change-Id: Id02b38b0ac1e9bb640954ef1b686ce3eef8370af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273300
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-02 17:04:38 +00:00
Tess Strickland 5fd3d4b810 [gardening] Fix debug build for ARM64C.
4-byte ldar zero extends, so can just use kObjectBytes here.

TEST=ci

Change-Id: I3b3aa792350100fd24c474c85d8ea1613c9f197b
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273242
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-12-01 16:55:52 +00:00
Vyacheslav Egorov c704e11ee2 [vm/api] Introduce Dart_WriteHeapSnapshot API
Allows embedders to programmatically request heap snapshot from a
running isolate group instead of relying on a vm-service or hidden
internal Dart APIs

Additionally we allow to include snapshot writing functionality into
PRODUCT builds using DART_ENABLE_HEAP_SNAPSHOT_WRITER define.

TEST=vm/cc/DartAPI_WriteHeapSnapshot

Bug: b/259115846
Change-Id: Ic3ef76e5fb9adcf8f23a1959f5238742b64ecde2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273181
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-12-01 14:38:44 +00:00
Jens Johansen 89b6ba91ba [vm] tools/heapsnapshot has download util
Change-Id: I11e8a750a3a40d3fbc2733f4120c50b25194cc82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273183
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-01 13:25:47 +00:00
Martin Kustermann e7bd696ce0 [vm] Update CPU register comments on runtime/vm/constants_<arch>.h
TEST=ci

Change-Id: Ibc2225314a18818ac14c8b3047c369017e524210
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273140
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-12-01 10:24:05 +00:00
Tess Strickland 49f998dc31 [vm/compiler] Handle hash caches in the InstantiateTypeArguments stubs.
Lower the threshold for converting from a linear to a hash-based cache
on most architectures from 500 to 10.

Due to register pressure, the InstantiateTypeArguments stub on IA32
continues to go to the runtime for hash caches, and so we do not
lower the threshold for converting to a hash-based cache there.

The following are benchmark results for those benchmark that use enough
Instantiations to trigger the use of hash-based caches. In the following
tables, "Results 1" denotes the benchmark results from only this change,
whereas "Results 2" include from comparing to the results prior to
4f925105cf, when only linear caches were used.

Dart AOT:

* InstantiateTypeArguments.Instantiate100

Arch   | CPU            | Results 1 | Results 2
-------|----------------|-----------------------
ARM    | Odroid-C2      |   382.8%  |   381.5%
ARM    | Raspberry Pi 4 |   486.7%  |   449.2%
ARM64  | Odroid-C2      |   328.1%  |   372.8%
ARM64  | Raspberry Pi 4 |  1283%    |  1281%
ARM64C | Raspberry Pi 4 |  2353%    |  2811%
X64    | Intel Xeon     |   568.7%  |   584.9%

* InstantiateTypeArguments.Instantiate1000

Arch   | CPU            | Results 1  | Results 2
-------|----------------|------------------------
ARM    | Odroid-C2      |   743.7%   |  3821%
ARM    | Raspberry Pi 4 |   486.7%   |  3218%
ARM64  | Odroid-C2      |   584.7%   |  3222%
ARM64  | Raspberry Pi 4 |   430.7%   |  8172%
ARM64C | Raspberry Pi 4 |   491.4%   | 16699%
X64    | Intel Xeon     |   954.1%   |  5528%


Dart JIT:

* InstantiateTypeArguments.Instantiate100

Arch   | CPU            | Results 1 | Results 2
-------|----------------|-----------------------
ARM    | Raspberry Pi 4 |   315.7%  |   295.1%
ARM64  | Raspberry Pi 4 |  1070%    |  1058%
ARM64C | Raspberry Pi 4 |  1769%    |  2095%
X64    | Intel Xeon     |   507.4%  |   496.2%

* InstantiateTypeArguments.Instantiate1000

Arch   | CPU            | Results 1 | Results 2
-------|----------------|-----------------------
ARM    | Raspberry Pi 4 |   565.2%  |  2550%
ARM64  | Raspberry Pi 4 |   406.8%  |  7375%
ARM64C | Raspberry Pi 4 |   379.6%  | 12996%
X64    | Intel Xeon     |   807.9%  |  4459%

During work on this change, an issue was found where cache lookups
in the stub on ARM64C always failed and went to runtime, even with
the old linear-only caches, hence the much larger performance gains
in those rows above.

TEST=vm/cc/TypeArguments_Cache_{Some,Many}Instantiations

Fixes: https://github.com/dart-lang/sdk/issues/48344
Change-Id: I3d29566ba0582502954c9fc59626ceb8fd40317a
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-mac-release-arm64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-debug-simriscv64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-nnbd-linux-debug-simriscv64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-linux-release-ia32-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-mac-release-arm64-try,vm-kernel-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270702
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-01 10:15:58 +00:00
Johnni Winther 5994c04ef4 [cfe] Initial support for view methods
TEST=pkg/front_end/testcases/views/procedures.dart

Change-Id: I62c26183d8160a3841b74381a256d0a4b5bb9365
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272624
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-12-01 09:54:40 +00:00
Liam Appelbe 32bfc38a20 Revert "[vm] Skip filtered class earlier in source report."
This reverts commit 86233b55bc.

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

Original change's description:
> [vm] Skip filtered class earlier in source report.
>
> The main benefit of this is that it avoids cls.EnsureIsFinalized for
> skipped classes. In some cases (eg very small tests with dependencies
> on very large 3rd party packages, such as flutter) this can reduce
> coverage collection time by 20%.
>
> Change-Id: Id756af7f2d2ecdd07a5d1d05a400cea4de7ec408
> Bug: https://github.com/flutter/flutter/issues/100751
> TEST=CI
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266640
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

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

Bug: https://github.com/flutter/flutter/issues/100751
Change-Id: Ie1e9f29fa6e3966f25040aebad8cb1d55b50a745
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273100
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-12-01 02:54:18 +00:00
Siva Annamalai be8e94162e Revert "[vm, gc] Assert the whole object is in to-space, not just its beginning."
This reverts commit c870932e45.

Reason for revert: We have a build failure on arm64c
../../third_party/dart/runtime/vm/virtual_memory_compressed.cc:143:35: error: out-of-line definition of 'Contains' does not match any declaration in 'dart::VirtualMemoryCompressedHeap'

TEST=ci

Original change's description:
> [vm, gc] Assert the whole object is in to-space, not just its beginning.
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/50564
> Change-Id: I60e7637600a1a7a99d546e8c674901175a119ba5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272863
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I62c83c8e8fa5b263bdc53d2afcf27b1fdd07c087
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/50564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273060
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Auto-Submit: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-12-01 01:35:26 +00:00
Ryan Macnak 1ac82e6463 [vm] Fix uninitialized tail elements from Array::Grow.
These elements were unintialized in the uncommon case that the new array was large enough to get its own page.

Broken in 188dfbd52b.

TEST=ci
Change-Id: I8b07da992aa11eed9c80b6eac3a7fd6716cb3abc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272961
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-11-30 23:33:31 +00:00
Ryan Macnak 26b9cbe36b [vm, compiler] Factor out PrepareLargeOffset for RISC-V.
Compare ARM64.

TEST=ci
Change-Id: If77e056d31a4f787a2874233910b40f2eb64eeda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273006
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-11-30 23:25:28 +00:00
Ryan Macnak c870932e45 [vm, gc] Assert the whole object is in to-space, not just its beginning.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50564
Change-Id: I60e7637600a1a7a99d546e8c674901175a119ba5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272863
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-11-30 22:42:16 +00:00
Ryan Macnak 288e524abe [test] Skip new tests with FFI on simulators.
Change-Id: I453ac23b8c07a6eedfbb1f53735bb6f6d5acdca9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273004
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-11-30 22:24:06 +00:00
Ryan Macnak f4b34ad31b [vm, gc] Add missing promotion of Finalizer external size. Remove race incrementing external size.
When a FinalizerEntry's target gets promoted, the associated external size needs to also get promoted. We were handling the cases where the FinalizerEntry itself was either already old or remained new, but not the case where it was promoted. Failing to promote the external size meant that when the finalizer was collected, external size was subtraced from old space that was still being attributed to new space, so the old space total external size became negative.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50537
Change-Id: Id2fe2d748311de73f04de367c9cd153d87b74ad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272350
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-11-30 17:14:59 +00:00