Commit Graph

20310 Commits

Author SHA1 Message Date
Kevin Moore fd836d3b34 vm_service: fix a bunch of comment references
also fix a couple of typos in service.md

TEST=re-ran generate script

Change-Id: I6fb6dbbc3780af14e5721817e20ec0e6370bfc1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284440
Commit-Queue: Kevin Moore <kevmoo@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-22 16:32:28 +00:00
Alexander Markov 143e4e9dc8 [vm/aot/tfa] Static weak references to method tearoffs
TEST=pkg/vm/testcases/transformations/type_flow/transformer/weak.dart
TEST=language/vm/static_weak_reference_test
TEST=language/vm/static_weak_reference_error_test

Bug: b/269223463
Change-Id: I23c8229c39217aa1c3f9fb576d8eefa5ceb1d8ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283421
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-02-22 01:01:29 +00:00
Alexander Markov 967f583e41 [vm/test] Make sure argument is unboxed both with and without sound null safety
Without sound null safety result of int.parse is inferred as nullable,
making the IL test vm/dart/records_allocation_sinking_il_test dependent on
the sound null safety mode.

The test is changed so the argument 'x' of 'test' is always non-nullable
and always unboxed.

Follow-up to the unboxing fix
https://github.com/dart-lang/sdk/commit/85d1a7752eb0196ceff40f8d3a9db843db5205c2

TEST=vm/dart/records_allocation_sinking_il_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I9c532a644d03e0fdb7b70875c323fcbbb5238948
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284382
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-02-21 20:36:22 +00:00
Ryan Macnak 347c49354e [vm] Lock-free management of the profiler's sample blocks.
Add asserts against using mutexes or monitors during the signal handler or suspended thread scopes. Poison use of Thread::Current during these scopes.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51124
Change-Id: If1df06520114105b2b4d8c81b4650bdb4efeaf50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283703
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-21 19:07:57 +00:00
Ryan Macnak f56c45eb37 [vm] Speed up JSON encoding.
TEST=ci
Change-Id: I8bfe00472f3a5e4e6680de631072cea0dacc3f55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283980
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-21 18:58:42 +00:00
Derek Xu 41be8d54b5 [VM/Service] Make _getInstancesAsArray public
This CL updates the VM Service spec to v4.2 and adds the
`getInstancesAsList` service procedure.

This CL also adds `pkg/vm_service/test/get_instances_as_list_rpc_test.dart`
which was based on
`runtime/observatory/tests/service/get_instances_as_array_rpc_test.dart`
and `pkg/vm_service/test/get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart`
which was based on
`runtime/observatory/tests/service/get_instances_as_array_rpc_expression_evaluation_on_internal_test.dart`

TEST=CI

Fixes https://github.com/dart-lang/sdk/issues/51393
Fixes https://github.com/dart-lang/sdk/issues/51003
Change-Id: I0faae80553ec397a1e89be0a714aab30e7854fec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283380
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-21 17:26:52 +00:00
Jens Johansen 39b8f7bef4 [kernel] Shift up specialized kernel tags
Before this CL kernel tags had specialized tags that was marked by the
single high bit, then using the three lowest bits for a value:

128 + value = 0b10000xxx
136 + value = 0b10001xxx
144 + value = 0b10010xxx

So the numbers from 128 to 151 is taken by this scheme, but because of
the high bit marking stuff being special we can't really use 152-256.

This CL shifts the specialized tags up so it instead uses the 3 highest
bits as a marker while still using the lower 3 bits for the value:

224 + value = 0b11100xxx
232 + value = 0b11101xxx
240 + value = 0b11110xxx

This takes up 224-247 and leave 248-255 unused. It would let us use
128-223 though.
(If we eventually need more we can probably remove one of the
specialized ranges (SpecializedVariableSet isn't used very much in
previously sampled dill files) and use 4 bits for tagging).

Additionally, a tool to print free tags has been added (via binary.md),
and the "binary version is in sync with VM" test has been prepared
for version > 99.

TEST=Existing tests.

Change-Id: If77b12cee6fc3801628dd67dc40afbb018ec8a61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284302
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-02-21 15:21:38 +00:00
Martin Kustermann d71a37af18 Support external typed data in heapsnapshot analysis tool
TEST=runtime/tools/heapsnapshot/test/cli_test.dart

Change-Id: I684bfb344f079d9d29bc910b5f2fdda99257821e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284303
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-02-21 12:58:34 +00:00
Vyacheslav Egorov f193356735 [vm/compiler] Remove unused variable to fix RISC-V build
Follow up of https://dart-review.googlesource.com/c/sdk/+/284184.

TEST=RISC-V build

Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-riscv64-try
Change-Id: I493f6533b19a1dc75307fff99a4ed0fc115ffc37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284221
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-02-20 19:28:28 +00:00
Ilya Yanok 029e0cec71 Revert "Enforce current library restrictions."
This reverts commit 0c05e33836.

Reason for revert: breaks ~10% of G3 smoke suite.

Original change's description:
> Enforce current library restrictions.
>
> Mark all currently unimplementable types as `final`, or `sealed` for `num` and `final` for `Function`.
> Mark all current classes intended as mixins as `mixin class`.
>
> More additions and cleanup will follow,
> but this change should make everything keep working as today
> if we flip the switch.
>
> TEST= No new tests, very little actual change, covered by existing tests with few changes. Will add more tests when adding more modifiers.
>
> Change-Id: I40e724f823e7f88cdef186d2f73874df256e2f43
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281683
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Kallen Tu <kallentu@google.com>

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

Change-Id: Ib0cb5b7ec1a8c392bbf9bf4af8dc3efc0b27991d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284187
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ilya Yanok <yanok@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-20 15:29:41 +00:00
Vyacheslav Egorov 93e73bf93a [vm/compiler] Rename PushArgument to MoveArgument
This is follow up to 65f4a733bb,
which switched optimized code to use fixed frame for outgoing
arguments.

Change Kernel to IL translation to handle null-checks in
invocations differently: this code used to duplicate receiver on
the stack to accomodate for PushArgument in unoptimized code, but
PushArgument has not been inserted since f4e61eacfd,
which means duplication of the receiver is no longer necessary.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try
Change-Id: I6c1f1e8c354f9ea92424b6602b83b9e9ebce8b69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284184
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-02-20 14:57:57 +00:00
Martin Kustermann 15ecb9b39f [gardening] Fix vm/cc/IsolateReload_{TypedefToNotTypeDef,NotTypedefToTypeDef} tests
With introduction to Dart 2.0 and Kernel as intermediate format, the VM
consumes kernel. The kernel is produced by CFE which lowers named
function type definitions to function types.

We therefore no longer have name classes between typedefs and classes
and the corresponding vm/cc/IsolateReload_* can be updated to no longer
expect an error.

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

TEST=Fixes vm/cc/IsolateReload_*Typedef* tests

Change-Id: Ic0697c5de03ef28e6cca104f5fbcb214e99d3fd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284182
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-02-20 13:54:29 +00:00
Daco Harkes 14e4a52657 [vm] Fix Dart_CObject_Type breaking change
https://dart-review.googlesource.com/c/sdk/+/257925 added a new entry
in the middle of the `Dart_CObject_Type` enum, which changed the
value of the entries below. However, this enum is part of
`dart_api_dl.h` and versioned by `dart_version.h`.

New entries to `Dart_CObject_Type` should be added at the end of the
enum to avoid making breaking changes to the type.

TEST=tests/ffi/vmspecific_handle_dynamically_linked_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51459

Change-Id: I367b54f62e59ddf925e255bb56c0f8660be7c227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284161
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-02-20 11:59:19 +00:00
Lasse R.H. Nielsen 0c05e33836 Enforce current library restrictions.
Mark all currently unimplementable types as `final`, or `sealed` for `num` and `final` for `Function`.
Mark all current classes intended as mixins as `mixin class`.

More additions and cleanup will follow,
but this change should make everything keep working as today
if we flip the switch.

TEST= No new tests, very little actual change, covered by existing tests with few changes. Will add more tests when adding more modifiers.

Change-Id: I40e724f823e7f88cdef186d2f73874df256e2f43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281683
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2023-02-18 12:37:40 +00:00
Chris Evans 542129731e Change relative_offset and size to 0 when PayloadStart() is 0
TEST=ci
Change-Id: Ie379dba90398000635c13d89576cc1bfd67d5e7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283322
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Chris Evans <cmevans@google.com>
2023-02-17 10:25:17 +00:00
asiva 64f7177f55 [VM/Runtime] Fix shutdown race between drainer thread and main thread in
TimelineEventFileRecorder.
This should fix https://github.com/dart-lang/sdk/issues/51438

TEST=ci TSAN

Change-Id: Ic355bc07723d064afca9009c0ddab1c5d534909b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283705
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-02-17 00:52:01 +00:00
asiva 7ef8c77ad2 [VM/Runtime] Fuse the shutdown and initialization states in the timeline
recorder under a single synchronization scope.

TEST=ci

Change-Id: Iff41297427674b307a8ed0cdef9c3010a15ca03e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283481
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-02-17 00:23:18 +00:00
Vyacheslav Egorov 65f4a733bb [vm/compiler] Stop pushing arguments in optimized code.
After this change we no longer push outgoing arguments for normal
Dart calls, but instead simply move them into an area reserved for
outgoing arguments at the top of the frame. This allows us to stop
mutating SP and avoid explicit Drop(argc) after each call.

There are still other places in the generated code where we
push something onto the stack either to free a temporary
register or spill a value across a slow-path call.

This is the first step towards switching to native SP on ARM64.

# Code Size Impact

I have tested this on a large internal application and got the
following size delta

## ARM

|        | Before   | After    | Delta   |       |
|--------|----------|----------|---------|-------|
| ROData | 6366632  | 6463680  | +97048  | +1.5% |
| Code   | 22714192 | 22043984 | -670208 | -2.9% |
| Total  | 33723701 | 33150477 | -573224 | -1.6% |

## ARM64

|        | Before   | After    | Delta   |       |
|--------|----------|----------|---------|-------|
| ROData | 7122032  | 7214288  | +92256  | +1.3% |
| Code   | 21607196 | 20741788 | -865408 | -4.0% |
| Total  | 33375769 | 32602544 | -773225 | -2.3% |

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-simarm64-try
Bug: https://github.com/dart-lang/sdk/issues/39083
Change-Id: Icace0c986285b9c16e41786cded44f88277bd25f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282029
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-16 19:22:45 +00:00
Vyacheslav Egorov 3128c61d1a [vm/docs] Rename index.md to README.md
R=kevmoo@google.com
TEST=docs only change

Change-Id: I7e0f3a8fd7d4917dead0e8e4c80c0bbdd0ff591c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283683
Reviewed-by: Kevin Moore <kevmoo@google.com>
2023-02-16 17:19:13 +00:00
Vyacheslav Egorov b2d5245dcd [vm/docs] Improve VM docs tooling.
Main change is around removing our custom syntax which allows
to read markdown files directly on GitHub:

* instead of using custom link format `@{xref}` we start
  using normal links. For example, [`dart::ThreadPool`][] is
  understood as a ref to `dart::ThreadPool` class declaration.
  `build.py` script injects an xref section at the end of
  each markdown file.
* similarly we don't use custom syntax for admonitions, but
  instead use blockquotes. `build.py` detects block quotes
  which start with a marker like `**Note**` and renders
  then in a custom way.

This CL also drops dependency on cquery and instead rewrites
indexing in pure Python via libclang.

Change-Id: I0b47ec93f632de89627a3c682d511c8b86c58430
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280262
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-16 13:42:01 +00:00
asiva daab5d49cf [VM/Test] Reduce the iteration count to ensure test does not time out on
debug builds.

Change-Id: I39bf7974ceec4f29bbffa1d32ae12bb7f2485d8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-02-16 00:59:11 +00:00
Derek Xu 52a5f4d9cd [VM/Timeline] Prevent races between reading / modifying the value of Timeline::recorder_
TEST=Checked that the problem described in the GitHub issue has been resolved.

Fixes https://github.com/dart-lang/sdk/issues/51408
Change-Id: I688d32a7cdd81b4f877e212d4f1376735013175c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283141
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-15 17:52:59 +00:00
Derek Xu ec876310e0 [VM/Timeline] Rename RecorderLock to RecorderShutdownSynchronizationLock to make its purpose clearer
TEST=CI

Change-Id: I433bf456fd6f86a76469cb0f0b1f5156871b2edb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283140
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-15 17:52:59 +00:00
Alexander Markov 283d0baeec [vm] Cleanup unused KernelReaderHelper::SkipLibraryPart()
TEST=ci

Change-Id: Iba9e2769e35259c0e77354fd0b31e87058bb00fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283340
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-15 17:33:14 +00:00
Ahmed Ashour 0ed7f7bb4d [observatory] remove unused_imports and some unused variables
Bug: #51401

TEST=ci

Change-Id: If64853565aca66105da43609fa8bea70ea65a7ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283020
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-02-15 16:49:58 +00:00
Alexander Markov 6362064134 [vm] Fix crash when pausing on unhandled exception in async function without awaiter
TEST=service/pause_on_unhandled_async_exceptions4_test
Fixes https://github.com/dart-lang/sdk/issues/51175

Change-Id: I54c2041a9eb28a9a73d608ebfa0bceca522d1287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283128
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-02-15 15:45:48 +00:00
Vyacheslav Egorov 01adcacbf2 [vm] Adjust unboxing il tests for non-sound null-safe mode.
int.parse() and double.parse() are not known to produce non-nullable
int outside of sound null-safety mode, so instead use simpler way
to define non-constant values for testing.

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

TEST=vm/dart/numeric_unboxing_il_test,vm/dart/records_return_value_unboxing_il_test

Fixed: 51418
Change-Id: Ie0b55c2f3d632f51656b5f273aee5cb9623c43e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283180
Reviewed-by: Liam Appelbe <liama@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-02-15 00:00:11 +00:00
Ryan Macnak 5d1c961e0f [vm] Improve crash reporting for gen_snapshot on Windows.
Cf. 47ec77122a

TEST=ci
Bug: https://github.com/flutter/flutter/issues/97160
Change-Id: Ic224f0668670e005ac4d3bdd04a116cfa1c90e9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282809
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-14 17:56:30 +00:00
Daco Harkes 6a90c21992 [vm/ffi] Fix MemoryCopyInstr on ia32
The MemoryCopyInstr destroys the value in src-TypedDataBase
location. It overwrites it by loading the data_ field.

This requires using a WritableRegister, rather than a Register.

This issue seems to have been already present before the recent
optimizations (the leaq instruction overwrites array_reg), but the
recent optimizations made it exercise this instruction in a loop where
it was assumed the src-position was not destroyed.

TEST=tests/ffi/regress_51315_test.dart

Closes: https://github.com/dart-lang/sdk/issues/51315
Change-Id: If37c6c39de8fd0cba9b8a25a1f38f025a39123d9
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-debug-ia32-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-eager-optimization-linux-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283021
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-02-14 13:20:43 +00:00
Vyacheslav Egorov 59a1e9afeb [vm] Fix failures in il tests for unboxing
* More parameters are now unboxed in records_return_value_unboxing_il_test
* Make numeric_unboxing_il_test more portable by preventing compiler from
  inferring that some int variables always contain smi values.

TEST=vm/dart/numeric_unboxing_il_test,vm/dart/records_return_value_unboxing_il_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try
Change-Id: I8d55cc31c0d4305f3884d6ac5dc77a5dd0205b78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-14 12:18:47 +00:00
Vyacheslav Egorov 85d1a7752e [vm] Fix UnboxedParameterBitmap::SetAt
It was accidentally masking out all low bits under
the given position.

Add a simple smoke test for field/parameter unboxing.

TEST=vm/dart/numeric_unboxing_il_test
R=alexmarkov@google.com

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try
Change-Id: Ic38ae3e14ddf2b8cab8f01cd923a103d900e0dc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282880
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-14 09:01:13 +00:00
Brian Quinlan 11b39ee058 Fix unbalanced call to Dart_TypedDataAcquireData.
Tested: unit test
Change-Id: I63249c3af001e4f1a9b9622bf6179062023f8d2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282824
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-02-14 01:44:17 +00:00
Alexander Markov 27b371ac97 [vm] Fix repeated deoptimization of hoisted instructions
Track hoisted instructions and prevent repeatitive deoptimization
when such instructions deoptimize. The tracking is implemented via
'Hoisted' bit on Environment and supercedes any previous
instruction-specific tracking via licm_hoisted_ flags.

TEST=vm/cc/LICM_Deopt_Regress51220, vm/cc/LICM_Deopt_Regress50245

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

Change-Id: Iaa99479778aeaec00e8e4283bf3ecf6152fdc1ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282389
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-02-13 23:28:30 +00:00
Brian Quinlan 11f7a52b94 [io] Faster readIntoSync for UInt8List.
Adds a specialized code path to File_ReadInto which avoids a memory copy when writing to a UInt8List.

Benchmarks:
https://docs.google.com/spreadsheets/d/1AqT5bDCaRfxalK9WLqGlm_EfVpTmeQT7LEqaJ-Hyl1c/edit?usp=sharing&resourcekey=0-NivVhxs0J1GM4BHXHK5gAQ

Tested: unit tests
Change-Id: I7d6cb5257da1724e8c61412b0f84bee22da298ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280560
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-02-13 21:23:01 +00:00
Alexander Markov c7aa32d07a Reland "[vm] Account for changes in the implicit getters due to load guards"
This is a reland of commit 87810072db

Original change's description:
> [vm] Account for changes in the implicit getters due to load guards
>
> Hot reload may mark certain fields as 'needs_load_guard', meaning
> types of their values should be checked on access, in the implicit
> getters.
>
> Unoptimized code for implicit getters of such fields should be
> forcefully recompiled during hot reload in order to update their
> code. This ensures that optimized code in future can deoptimize
> into the updated unoptimized code of implicit getters.

TEST=vm/cc/IsolateReload_ImplicitGetterWithLoadGuard
TEST=corelib/string_fromcharcodes_test, lib/convert/json_utf8_chunk_test
and vm/dart/string_equals_test on vm-reload-linux-{debug,release}-x64
configurations.

Fixes https://github.com/dart-lang/sdk/issues/51215
Fixes https://github.com/flutter/flutter/issues/103268

Change-Id: I22eb0f7addce387e7773e45c170c3f9050003083
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282807
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-02-13 21:14:38 +00:00
Alexander Markov 20acd94a88 [vm] Fix type of _FfiAbiSpecificMapping.nativeTypes
This field was incorrectly typed as List<Object>, but FFI kernel
transformation put a constant of List<Type?> there. With sound
null safety List<Type?> is not assignable to List<Object>, which
was flagged by an assertion during hot reload.

TEST=ci (ffi tests on vm-reload-linux-debug-x64)
Fixes https://github.com/dart-lang/sdk/issues/51216

Change-Id: Ic6060183525036aecba0bfc51cfb7283ed7b1aeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282760
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-02-13 18:52:40 +00:00
Ryan Macnak d733fcb5c2 [vm] Avoid spurious race on the field table when entering an isolate as a helper.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/51268
Change-Id: Ibb43d89bc899657a1213d9304054c4f754d437f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282124
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-13 18:32:36 +00:00
Ryan Macnak 97d302aaae [vm] Remove KBC support from NativeArguments.
TEST=ci
Change-Id: If28557e41839ac767992e4dc342d47cce3a6d93a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282122
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-02-13 18:24:32 +00:00
Martin Kustermann fae934c4b1 Revert part of "[vm] Allow sharing of deeply immutable lists across isolates"
It did have noticable xx% performance regression on

  ListCopy.List.int.unmodifiable.100

TEST=ci

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

Change-Id: I160d7cc98aee2e064b1767519f4b5033656ee115
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282400
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-02-10 20:25:59 +00:00
Derek Xu 94f9fba3ce Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
TEST=MSVC tryjob

This is a reland of commit d9f1aefe9e

Original change's description:
> Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
>
> This is a reland of commit 8a39d781ce
>
> Fixed by changing accidental usages of `kInvalidThreadId` to
> `kInvalidThreadJoinId`.
>
> TEST=Windows tryjobs
>
> Original change's description:
> > [VM/Timeline] Add test that makes TSAN check the track metadata map
> >
> > TEST=CI
> >
> > Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Derek Xu <derekx@google.com>
>
> Fixes https://github.com/dart-lang/sdk/issues/51328
> Change-Id: I9219ed9bee212ecb50e3d0a0ed639d3ac8676238
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281920
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I6bcc9e02c1ac1e35ba08559d3098ba0cf69b7eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282360
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-10 18:05:00 +00:00
Tess Strickland 2c0484c720 [pkg/vm] Initial work on constant operating system fields and getters.
* Add an `targetOS` argument to `pkg/vm`'s `compileToKernel`,
  that contains the target operating system's name.

* Add a new `--target-os` command line argument for all binaries
  that use `compileToKernel` for clients to provide the target
  operating system, if known.

* Add a new`"vm:platform:const"` annotation to certain field and
  getters in the Platform class.

  This annotation is used to annotate static getters and fields with
  initializers where the getter body or field initializer must evaluate
  to a constant value if the target operating system is known. This
  annotation may be used outside the Platform class and in user code.

  For example, this annotation can be used on a static `String` field
  that is initialized with one value if `Platform.isWindows` is true
  and to a different value if `Platform.isWindows` is false.

  Note: If the const functions experimental flag is disabled, then
  any annotated static methods can only contain a single expression
  whose value is returned. If it is enabled, then the static method
  is evaluated as if it is a const function with the special
  handling of annotated static fields and getters above.

* Create a VM constant evaluator that evaluates uses of static getters
  and fields marked with the above annotations when a target operating
  system is provided.

* Use the new VM constant evaluator in the unreachable code elimination
  transformer.

TEST=pkg/vm/test/transformations/platform_use_transformer
     pkg/vm/test/transformations/unreachable_code_elimination

Change-Id: Ie381de70486a767fd7b1d515fd9e6bb58c6bf090
Bug: https://github.com/dart-lang/sdk/issues/31969
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try
CoreLibraryReviewExempt: Just adding vm-specific annotations.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274386
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-02-10 16:29:50 +00:00
asiva 3a096ab1ce [VM/Runtime] Fix error message from type error exception string.
(Should fix https://github.com/dart-lang/sdk/issues/50756)

TEST=ci

Change-Id: Id605aac4157c774c51577603d77e8ce21f58bd40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282123
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-02-10 14:26:19 +00:00
Derek Xu 41d6db8ce5 Revert "Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map""
This reverts commit d9f1aefe9e.

Reason for revert: broke vm-kernel-msvc-windows

Original change's description:
> Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
>
> This is a reland of commit 8a39d781ce
>
> Fixed by changing accidental usages of `kInvalidThreadId` to
> `kInvalidThreadJoinId`.
>
> TEST=Windows tryjobs
>
> Original change's description:
> > [VM/Timeline] Add test that makes TSAN check the track metadata map
> >
> > TEST=CI
> >
> > Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Derek Xu <derekx@google.com>
>
> Fixes https://github.com/dart-lang/sdk/issues/51328
> Change-Id: I9219ed9bee212ecb50e3d0a0ed639d3ac8676238
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281920
> 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: Iea36a34a392a51b53699527a7af36b93f924057f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282340
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-10 13:49:06 +00:00
Martin Kustermann a03cb5841e [vm] Manually unpoison memory that Dart allocates and passes to C
Closes https://github.com/dart-lang/sdk/issues/51345

TEST=vm/dart/isolates/fast_object_copy2_test

Change-Id: I09cf0b896b9e0bc268168c27c7f6cf1220ccd1c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282028
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-02-09 21:22:12 +00:00
Ryan Macnak cbebeeb746 [vm] Refactor handle initialization to avoid duplication.
Reduces VM code size by about 17k.

Cf. dc6875b64a

TEST=ci
Change-Id: I04a1a440f5ae5db4d67c54d754e6ef558675bd44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281901
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-09 19:16:20 +00:00
Ryan Macnak 1873228ebb [observatory] Fix NNBD damage to malloc profiler page.
TEST=--profiler-native-memory
Change-Id: I8333359e516d9cb30d57d85d32c4328a450c3579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281864
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-09 17:29:20 +00:00
Derek Xu d9f1aefe9e Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
This is a reland of commit 8a39d781ce

Fixed by changing accidental usages of `kInvalidThreadId` to
`kInvalidThreadJoinId`.

TEST=Windows tryjobs

Original change's description:
> [VM/Timeline] Add test that makes TSAN check the track metadata map
>
> TEST=CI
>
> Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Fixes https://github.com/dart-lang/sdk/issues/51328
Change-Id: I9219ed9bee212ecb50e3d0a0ed639d3ac8676238
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281920
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-09 16:25:14 +00:00
Martin Kustermann 7db7bd0573 [vm] Simplify is-deeply-immutable check in transitive object copy
Now that we have an immutability bit, we can set the bit in object
header of newly allocated objects if those objects are always
deeply immutable.

That allows only checking for the immutable bit instead of checking
against a whole range of cids when sending objects via
`SendPort.send()` / `Isolate.exit()`.

TEST=ci

Change-Id: I4451a9fe11f68c7dd874d49ab632daa3102be19e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281842
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-02-09 00:23:22 +00:00
Alexander Aprelev 91ea69d96d [gardening] Skip fast_object_copy2_test on sim archs where ffi is not available.
Fixes https://github.com/dart-lang/sdk/issues/51329
TEST=ci

Change-Id: Ide0a2a00dd978afbb1fad1d52280ff904d197818
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281900
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-02-08 23:15:34 +00:00
Alexander Aprelev ec6712542c Revert "[VM/Timeline] Add test that makes TSAN check the track metadata map"
This reverts commit 8a39d781ce.

Reason for revert: https://github.com/dart-lang/sdk/issues/51328 - breaks windows buildbot

Original change's description:
> [VM/Timeline] Add test that makes TSAN check the track metadata map
>
> TEST=CI
>
> Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> 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: I1228676f3a6a3e622b47a3e15f2b40b2e68fe676
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281865
Reviewed-by: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-02-08 21:55:43 +00:00