Commit graph

20069 commits

Author SHA1 Message Date
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
Alexander Thomas 3f19115234 Make code compatible with Trusted Types.
Closes https://github.com/dart-lang/sdk/pull/50567

Co-authored-by: Jakub Vrána <jakub@vrana.cz>
Tested: Standard CQ
GitOrigin-RevId: b916722ddc03d2b57bae6f51122ee1e7af2486b4
Change-Id: I4f638e7262009744504f0b263bf7a8e23549e5bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272380
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-11-30 09:49:42 +00:00
Alexander Markov a9c11acd25 [vm/aot] Unbox 2-field records in return values
Functions returning non-nullable records of 2 fields can now return
them as separate values on 2 registers. This postpones and sometimes
eliminates creation of record instances. As other unboxing
optimizations of return values, this optimization is only
performed in AOT.

Pair of values for an unboxed record are represented using
kPairOfTagged representation, which can be now used for the input of
Return and for the output of StaticCall/InstanceCall
PolymorphicInstanceCall/DispatchTableCall instructions.

In order to combine separate values for Return, a new MakePair
instruction is added. Extracting separate values from the result of
a call is implemented using existing ExtractNthOutput instruction.

Benchmarks (AOT mode):
MultipleReturns.Forwarded.Record +45-57%
MultipleReturns.Forwarded.RecordNamed +43-57%
MultipleReturns.NotInlined.Record +58-79%
MultipleReturns.NotInlined.RecordNamed +53-76%

TEST=runtime/tests/vm/dart/records_return_value_unboxing_il_test.dart
TEST=benchmarks/MultipleReturns/dart/MultipleReturns.dart

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I7117b19a134c1db0ba5117a1ef093867f9ba20e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269100
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-11-29 21:41:49 +00:00
Alexander Aprelev 36e8d9ab6f [vm/compare] Speed up internal one/two-byte strings comparisons.
Ensure padding around data and length fields for these strings is zeroed-out, allowing for comparison to be done in word-sized chunks.
For configurations where the hash is not in the header, swap the length and the hash in string class so that the length is adjacent to the data.

x64
===
LongStringCompare.2.3000reps 109.2%
LongStringCompare.32.1000reps 526.4%
LongStringCompare.1024.30reps 670.1%
===

ia32
===
LongStringCompare.2.3000reps 90.68%
LongStringCompare.32.1000reps 274.5%
LongStringCompare.1024.30reps 211.4%
===

arm64
===
LongStringCompare.2.3000reps 89.28%
LongStringCompare.32.1000reps 454.5%
LongStringCompare.1024.30reps 677.7%
===

arm
===
LongStringCompare.2.3000reps 68.76%
LongStringCompare.32.1000reps 330.9%
LongStringCompare.1024.30reps 426.8%
===


BUG=https://github.com/dart-lang/sdk/issues/50190
TEST=string_equals_test

Change-Id: Ia4ab9bcb4daca5d4f403e0ece364bb6aafb68577
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269600
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-11-29 14:36:19 +00:00
Tess Strickland 4f925105cf [vm] Use a hash map for larger type argument instantiation caches.
Previously, the VM used a linear array to cache previous instantiations
of a type arguments object. Now once the cache hits a certain number
of occupied entries, the VM changes to using a hash-based approach.

The InstantiateTypeArguments stubs have not yet been updated to
traverse the hash-based cache, so once the cache has grown too large,
all attempts at instantiations, even those that are in the cache, go to
the runtime. Thus, until the stubs are updated, this is only an
improvement if the cost of traversing the linear cache dominates the
cost of making a runtime call. Our benchmarks see a ~40% performance
regression for hash-based caches of size 100 but a ~400% performance
improvement for hash-based caches of size 1000. Thus, we currently
split the difference and set the maximum size of linear caches to 500.

TEST=vm/cc/TypeArguments_Cache_ManyInstantiations

Bug: https://github.com/dart-lang/sdk/issues/48344
Change-Id: I7f1376943523bb5bcd8b175cfb1936779ea73d60
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265325
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-11-28 15:00:20 +00:00
Tess Strickland 333d924504 [vm/compiler] Make InstantiateTypeArgs stubs architecture independent.
TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/48344
Change-Id: I7c0cee827a09d981e6e65802304a361ace7ce501
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270102
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-11-28 15:00:20 +00:00
Daco Harkes 827d166ea0 [vm/ffi] Stop reifying type argument in Pointer
All `Pointer`s will now have the `Never` type argument at runtime.

TEST=tests/ffi(_2)/*

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

Change-Id: I83c8bba9461c2cab22992ba2e3cf42b7b5f43c36
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-mac-debug-x64-try,dart-sdk-mac-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272201
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-11-28 09:45:45 +00:00
Daco Harkes da74af72c4 [vm] Fix GCC build
https://dart-review.googlesource.com/c/sdk/+/264520 caused the GCC
build to fail with ambiguous overload for ‘operator<<’ with nullptr.

TEST=luci.dart.try:vm-kernel-gcc-linux-try

Change-Id: Idf452b4de9bd956ae0d19d6355273982a7c59330
Cq-Include-Trybots: luci.dart.try:vm-kernel-gcc-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271900
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-11-24 13:02:49 +00:00
Ryan Macnak ff8caf93b5 [vm] Remove quadratic time spent zapping scoped handles.
TEST=ci
Change-Id: I7faaf61ff33ae54795db4da1b253053abea0d5a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271581
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-11-23 20:24:29 +00:00
Ryan Macnak b166d909c3 Import "Add the ratified portions of the B extension: Zba, Zbb, Zbc, Zbs."
TEST=ci
Change-Id: I7676dabc67762c0c2e4a1a9975100c59edcda769
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271441
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-11-23 18:39:07 +00:00
Ryan Macnak 97f6ac2187 Import "Add missing rounding mode for some variants of fcvt."
TEST=ci
Change-Id: I6f97eed27fe4f35575abc04910ec1c35b86b740f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270803
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-11-22 22:57:50 +00:00
Ryan Macnak 9f84043e69 [observatory] Fix loading class pages in AOT.
TEST=manual
Change-Id: I0de4e7eb0330233fa7571c2fbf7c3c23a15f192c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271503
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-11-22 21:30:58 +00:00
Ben Konyi 8caeaf7a6c [ VM ] Add support for heap sampling profiler
This CL introduces new embedding APIs for supporting heap sample
profiling. A registered sampling callback is invoked approximately every
N bytes based on an exponential distribution, providing information
about the isolate group the allocation occurred in, the user visible
name of the allocated object type, a weak persistent handle to the
allocated object, and the size of the allocation.

Sampling is triggered using artificial TLAB boundaries to cause
allocations to be sampled to take the allocation slow path where the
registered callback can be invoked with the allocation information.

Only new space allocations are currently traced, with old space
allocation support to be added in a future CL.

TEST=Dart_HeapSampling

Change-Id: I22bcdeec6e823bc1ab44898d4c596fbed7169fa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264520
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-11-22 18:05:24 +00:00
Johnni Winther 6f54f6236e [cfe] Add AwaitExpression.runtimeTypeCheck
Add AwaitExpression.runtimeTypeCheck to support easy backend
implementation of runtime type check.

In response to https://github.com/dart-lang/sdk/issues/49396

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

Change-Id: I13b9b14566ebc34cdb0811c16a262421417b68e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270723
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-11-22 10:42:22 +00:00