Commit graph

20863 commits

Author SHA1 Message Date
Sam Rawlins a458bab09a Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
Fixes https://github.com/dart-lang/sdk/issues/49025

Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
Tested: try-bots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 18:33:58 +00:00
asiva 5d872a8737 [VM/Runtime] - Deprecate Dart_UpdateExternalSize and Dart_UpdateFinalizableExternalSize from the Dart C API
https://github.com/dart-lang/sdk/issues/52568

TEST=new test added.

Change-Id: I4f4b6b607fa2e0daa14fc25e3bdf99214f6ccb6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314900
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-20 17:06:44 +00:00
Alexander Aprelev bd8cc7bc93 [gardening] Use correct ObjectPtr in DART_COMPRESSED_POINTERS mode.
This is the follow-up to https://dart.googlesource.com/sdk/+/a5936e404b39f4af7b4fbf51d06ad3a99ff9fa36.

TEST=ci

Change-Id: Id0a21952d9f8b044ca207d8f8286fd76c0630cb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314980
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-07-19 21:17:35 +00:00
Alexander Aprelev a5936e404b [vm] Include field and local names in isolate invalid object retaining path message.
Retrieval of local names only works in JIT as it relies on availability of LocalVarDescriptors.

For example, for this
```
import 'dart:isolate';

foo() {
  final x = RawReceivePort();
  RawReceivePort().sendPort.send(() => print("$x"));
}

main() {
   foo();
}
```

error message says
```
Unhandled exception:
Invalid argument(s): Illegal argument in isolate message: (object is a ReceivePort)
 <- field x in foo.<anonymous closure> (from file:///usr/local/google/home/aam/p/d/dart-sdk1/sdk/s1.dart)
```

Bug: https://github.com/dart-lang/sdk/issues/52957
TEST=ci
Change-Id: I684014fd19ea82829e7df17a8a67d386551a5a82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314501
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-07-19 19:58:18 +00:00
Alexander Aprelev 3284c68727 [gardening] Add 'previous-results' option to run_stress_test_shards.dart
Follow-up to https://dart-review.googlesource.com/c/sdk/+/314081
TEST=ci

Change-Id: Ib65a81738cb4b22531765a73becdc9cf7c836ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-07-19 17:34:53 +00:00
Ryan Macnak e50470568b [vm] Remove ValidateConstants.
This is already skipped for AOT and is unfixable after the DropTransitiveUserDefinedConstants optimizations.
This is already skipped for reload and is unfixable for issues related to 40442.
The non-reload JIT case isn't very interesting since each kernel constant will be loaded only once anyway.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/27003
Bug: https://github.com/dart-lang/sdk/issues/44862
Change-Id: I0676a96426142600f4ed9ec638b344a858aab7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314480
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-19 17:26:50 +00:00
Ryan Macnak 7d48bd0e2f [vm] Reset canonical tables together instead of classwise.
TEST=ci
Change-Id: I8867f7981bb15fcf42eec7364394fcca556dca24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-19 16:53:46 +00:00
Ben Konyi 9ca0d413c5 [ Status ] Skip regress_45684_test on AOT configurations
regress_45684_test.dart makes use of the debugger, which isn't supported
in AOT.

TEST=N/A

Change-Id: I454aa92d1ce33638380e6fd02654dc5f925c2bf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314820
Reviewed-by: Dan Chevalier <danchevalier@google.com>
2023-07-19 14:55:48 +00:00
Ryan Macnak ba1577ce85 [vm, gc] Fix the type for the heap usage accessors.
The underlying storage is only intptr_t.

TEST=ci
Change-Id: Ibb687707eb4935d71080193e55ec4366c5b9c8e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314320
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-18 19:33:37 +00:00
Ryan Macnak 906db311ad [vm, gc] Ensure PageSpace::heap_ is never null.
TEST=ci
Change-Id: I65753a62a9e02890555fbceb7870e5189032d282
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314300
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-07-17 22:53:11 +00:00
Derek Xu 24e65bee37 [VM/Service] Add isGetter and isSetter properties to @Function and Function
TEST=pkg/vm_service/test/get_object_rpc_test.dart and
vm/cc/PrintJSONPrimitives

Fixes: https://github.com/dart-lang/sdk/issues/52920
Change-Id: Id3786e48c8827911e7c49af6ab2f0bf0cd97279f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313642
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-17 15:01:21 +00:00
Zach Anderson 24f9c7c961 Add a GN flag for the non-debug optimization level
Change-Id: I687e0f12a03687409abcacc33b6245bacb8a6488
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313881
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-15 14:14:59 +00:00
Martin Kustermann 0ae3368fb6 [vm] Refactor handling of kernel data in compiler frontend
a) Remove 2 fields in our object representation:

  * PatchClass::library_data_
  * Library::kernel_data_

=> This saves O(#libraries + #patch-classes) which can amount up to
  10+ MB for big apps, as we save not just the slots but the
  [ExternalTypedData] objects they used to reference.

Instead we'll compute the KernelLibraryData when we need it by making a
[TypedDataView] of sub parts of the component.

b) We make a kernel binary be represented by a single [ExternalTypedData].

Whenever we need a sub-part of a kernel binary (e.g. one for each
component for concatinated kernels, or one for a library inside a
component) we use proper [TypedDataView]s for that.

c) As we sometimes need to create a view of only a particular library
within a component we need to find start/end of a library based on
index.

=> We store the library index instead of the library offset on
Library/PatchClass.
=> We can easily derive the start/end of a library from it's index by
looking at the kernel component encoding.

d) We make the [Reader] object work purely based on a pointer - instead
of making it have if/else when reading bytes (either from pointer or
from a view).

e) We make the [KernelProgramInfo] store the kernel_component and
various TD views into it.

TEST=ci

Change-Id: Ibe160881ff48635e834c3d647a977a144b5d0565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313561
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-14 10:15:06 +00:00
Martin Kustermann 8d802dd78a [vm] Avoid embedding sources in CFE compilations if we AppJit
Creation of AppJit snapshot will not include the source of [Script]
objects (see `UntaggedScript::snapshot_to`). As a result there's no
point in letting the CFE embed the sources into the kernel if we
only use it to create an AppJit snapshot.

This is also in line with build rules for our dart-sdk, where we do the
kernel compilation separately, see utils/application_snapshot.gni:

```
  template("application_snapshot") {
    ...
    # Build the kernel file using the prebuilt VM to speed up the
    # debug and simulator builds.
    prebuilt_dart_action(target_name + "_dill") {
      ...

      args = [
        ...
        "--no-embed-sources",
        ...
      ]
      [[[
    }
    ...
  }
```

TEST=ci

Change-Id: I4e17e49dc21af6102d62c2278dbd6ebbe387f7e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313560
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-14 09:47:38 +00:00
Tess Strickland 0a1c797b5a [vm] Revert 3fcf660e with the correct fix for --no-sound-null-safety.
Insert CheckNull instructions if in AOT mode prior to checking the
index for being within the bounds in inlined indexing operations.
If we're in --sound-null-safety mode, they'll be canonicalized away
since the indices won't be nullable anyway.

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

TEST=corelib{,_2}/list_removeat_test and
  co19_2/LibTest/core/String/codeUnitAt_A03_t01 on
  vm-kernel-precomp-linux-release-x64-try

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I37212e94c7c5032c75709e3f0bb91734cbc705cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313507
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-14 07:06:41 +00:00
asiva e4f1a10431 [VM/Runtime] Ensure an isolate exists before calling Dart_ShutdownIsolate()
Fixes https://github.com/dart-lang/sdk/issues/52892
TEST=ci

Change-Id: I4f0aa64642d4ba8416ef353dfca7371adc7e6bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313543
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-14 01:31:38 +00:00
Ryan Macnak 327d425a32 [test] Skip chunked_binary_trees tests on slower configurations.
Bug: https://github.com/dart-lang/sdk/issues/52924
Change-Id: Iece24184411f1fdbc63903d893654c74aed3de55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313289
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-13 21:49:08 +00:00
Tess Strickland 3fcf660ed1 [vm] For now, initialize the contents of null with its address.
When running with `--no-sound-null-safety` turned on, it turns out null
is unboxed as an Mint in some cases without checking for null first.
Before, tests would fail because unboxing it would give a really
large int that was unlikely to be acceptable to subsequent range
checks and the like.

However, since 2f63ace, that memory is now zero-initialized, and zero is
more likely to be an acceptable value, so tests either fail for
unexpected reasons or, worse, unexpectedly succeed.

As a stopgap until the appropriate checks are emitted, we initialize
the contents of null with its address as an ObjectPtr like we used to.

TEST=corelib{,_2}/list_removeat_test on dartkp-* configurations.

Issue: https://github.com/dart-lang/sdk/issues/52910
Change-Id: If456d503c86202616f4f566a402118e9c41194ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313500
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-13 09:19:57 +00:00
Tess Strickland db2e318b5d [vm] Fix build on debug IA32.
set_pointer_offsets_length() sets a part of the state_bits bitfield,
so we need to move this check before it's called.

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

TEST=vm-linux-debug-ia32 builds

Cq-Include-Trybots: luci.dart.try:vm-linux-debug-ia32-try
Change-Id: I9f4ec78b03a6b7b2d45f13e9cc277411dcc90493
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313480
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-13 08:59:36 +00:00
Martin Kustermann 148af29811 [vm] Disentagle dependencies in the frontend & compiler
** KernelProgramInfo

The VM can load multiple kernel files into an isolate. Each kernel file
is represented as a [KernelProgramInfo] object. Loading a kernel blob
will result in a tree of objects

  Library
   - TopLevelClass
     + Field
     + Function
   + Class
     + Field
     + Function
       + ... closure functions ...

The entire tree belongs to one [KernelProgramInfo] object. There are
two exceptions
* after a hot-reload we inject [PatchClass]es (as owners of
old [Field]/[Function] objects) that identify the old kernel data
* expression evaluation functions will get a special data array with
information about the expression evaluation kernel data

=> We attach the [KernelProgramInfo] to the root of the tree, namely
  the [Library]

=> We introduce `{Field,Function,Class,Library}::KernelProgramInfo()`
  that will get that object - by walking up the chain.

=> We introduce `UntaggedPatchClass::kernel_program_info_` field that
  allows saving the old [KernelProgramInfo] (on which the old
  [Field]/[Function] objects are based upon) in the [PatchClass].

=> We include the [KernelProgramInfo] in the expression evaluation
  data array.

** Scripts

A [Script] object should represent a .dart source file. It contains the
source, line offsets, etc. of that dart source file. The contents of a
dart source file may be used by many classes/libraries or even many
kernel blobs (e.g. via our copying mixin application).

When we build a tree like above, we'll attach a reference to a
[Script] object to [Class] objects. But members of a class may come from
a different script, in which case we inject an intermediary [PatchClass]
that references that other script.

When the compiler frontend loads kernel, builds flow graph, etc we walk
down the kernel binary (the tree above) - all belonging to the same
[KernelProgramInfo] object, but sub-parts may belong to different
[Script]s.

=> We use the existing [ActiveClass] class that keeps track of the
current class & member inside the class we're operating on.
=> Whenever we need the script we get it from the active member
function/class.

** Misc

We make kernel related classes (e.g. [KernelReaderHelper]) independent
of [Script].

We make the [Script] objects hold on to the [KernelProgramInfo] they are
based upon (e.g. for lazy source reading). But since a given [Script]
doesn't belong to a particular kernel blob (multiple kernel blobs may
contain information about the same script) we don't expose this in the
public API.

=> In the future we could have a unique [Script] object per url (instead
of having several as we do now)

TEST=ci

Change-Id: I7bd698f497b0bd8ab8e546540bb1dad5b5a6dd48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313381
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-13 08:17:38 +00:00
Ryan Macnak 89e24c1aef [vm] Fix assertions in Windows ARM64 feature detection.
TEST=ci (forthcoming)
Change-Id: I3d34ab3af721267f9c586f4a9becdd374455cc76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313182
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-12 17:14:18 +00:00
Ryan Macnak d486c52ff6 [vm, gc] Add flag to disable write barrier elimination.
TEST=ci
Change-Id: Ibf1c8afc21c695c1e959ee7463110dd2c37ed846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311822
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-12 15:46:27 +00:00
Tess Strickland 86d1261dff [vm] Clean up New() methods of Dart classes.
Goals of this CL, a followup to 2f63acea22:

* Ensure that X::New() depends on the initialization guarantees of
  Object::Allocate<X>(...):

  * Ptr fields are guaranteed to be initialized to Object::null().
  * Non-Ptr fields are guaranteed to be zero-initialized.

  In cases where the only uses of the allocated object before return
  was to perform unnecessary field assignments, X::New() just simply
  returns the result of Object::Allocate<X>(...).

  Otherwise, the old now-unnecessary assignments have been changed
  into ASSERTs so that they will be checked in DEBUG mode.

* Ensure that NoSafepointScopes are entered in X::New() only when
  necessary (e.g., to ensure fields used to calculate to(...)
  are properly set before being seen by pointer visitors as the GC
  may run when outside a NoSafepointScope).

  In particular, the often occurring pattern:

  auto& result = X::Handle();
  {
    auto raw = Object::Allocate<X>(...);
    NoSafepointScope no_safepoint;
    result = raw;
  }
  ...

  has been replaced with:

  const auto& result = X::Handle(Object::Allocate<X>(...));

* If a handle was allocated, the only uses of that handle before
  returning must be performed under a NoSafepointScope, and the same
  operations can be done directly on the object pointer, then do so
  and remove the unnecessary handle allocation.

Notable changes outside the above:

* Swapped ObjectPool::EntryType::{kImmediate,kTaggedObject} so that
  kImmediate has value 0, since Object::Allocate<ObjectPool>(len)
  zero-initializes the payload and without this change,
  ObjectPool::New() must set the entry types manually.

* Removed the old static ArrayPtr cached_array_ field on
  SubtypeTestCache as well as SubtypeTestCache::{Init,Cleanup} and
  instead added Object::empty_subtype_test_cache_array().

* Removed the no-arg Closure::New() method, which is never used.

* Inlined the no-arg Script::New() method into its only caller,
  one of the other Script::New() overloads.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/52876
Change-Id: I079b4c9f73c7d2c0146c30cf2cd570b91a1ecf36
Cq-Include-Trybots: luci.dart.try:vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313120
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-12 07:37:16 +00:00
Ryan Macnak 0ff8d76171 [test] Speed-up slow isolate tests.
- Don't need to repeatedly verify function fingerprints for each isolate.
 - Fix test detecting when it runs under debug mode or a simulator.

Change-Id: Iace0ebc274d4c01561a4b563a420e80535b1ff59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313243
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-07-11 22:39:28 +00:00
Ryan Macnak 2a924955e2 [vm] Remove dead VerifyOnTransition.
Dead since b34f11adbd.

TEST=ci
Change-Id: If73b702ea37b68c9f77347ff28fd582dda1e958a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313260
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-11 22:31:57 +00:00
Liam Appelbe eb6baa33ad [vm] Async callback fast path when on target isolate
Skip creating the temporary isolate if the current thread is already
entered into the target isolate. We can marshall the args and send the
message directly from this isolate.

Bug: https://github.com/dart-lang/sdk/issues/52764
Change-Id: I94a1358ad7d2632b53c122cc38cd5675e6f5ecbc
Fixes: https://github.com/dart-lang/sdk/issues/52764
TEST=CI, specifically async_void_function_callbacks_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312351
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-07-11 21:26:48 +00:00
Derek Xu f5080bedb3 [VM/Debugger] Fix behaviour of ActivationFrame::EvaluateCompiledExpression when paused inside a closure
TEST=pkg/vm_service/test/evaluate_inside_closures_test.dart, pkg tryjob

Fixes: https://github.com/dart-lang/sdk/issues/52430
Change-Id: I72b755d31614c7c56c504130656c3668d8b7e72b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313001
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-11 18:41:04 +00:00
Tess Strickland 03689db708 [vm] Fix the RISCV64 SDK build after 2f63acea.
GCC (used in the RISCV64 build) and clang (used to build other
architectures) have different views of what's visible in the return type
position for an external template method definition. Thus, move the
use into the definition body via constexpr if, which works for both.

TEST=dart-sdk-linux-riscv64-try

Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-riscv64-try
Change-Id: Id7adfd93764ff11d99d3ded4893739b90bb25676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313123
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-11 15:47:29 +00:00
Ryan Macnak 453fce9e77 [vm] Enable clang-tidy for arm, arm64, riscv64, product, release, precompiler.
TEST=ci
Change-Id: I319c932a6f4b6e18d7e53b66d69702bf017e4b93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313060
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-07-11 15:13:58 +00:00
Martin Kustermann 9a909ac320 [vm] Remove dead lazy reading code of line starts / ...
This was originally added for kbc in [0]. But it seems this is unused
in the kernel frontend.

For performance reasons we may want to implement this at some point
properly but until then let's remove the dead code.

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

TEST=ci

Change-Id: Ic4f4edd976c625316f77822a4067763ab31ea3ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313122
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-11 13:29:33 +00:00
Tess Strickland 2f63acea22 [vm] Attempt to avoid allocating non-Ptr fields with Object::null().
There have been multiple cases in the past where using Object::null()
as the initializer, even for non-Ptr fields, has caused nondeterministic
snapshot creation. In particular, this can happen if a non-Ptr field
is only used in some versions of an object but not others, and thus
there is no reason to worry about what the value of the field is during
runtime. Only when snapshotting can it become relevant that the field
value is a portion of the address of Object::null(), which can vary
over different runs.

Instead of initializing the entirety of allocated objects (outside
of a few rare cases) with Object::null(), only initialize the portion
of the object corresponding to object pointer fields (in most cases,
between from() and to() inclusively) to Object::null() and initialize
the rest of the object to 0.

With this change, the only special casing in Object::InitializeObject
that remains is to skip initialization for TypedData and Arrays when
the memory is guaranteed to be zero initialized and to initialize the
contents of Instructions objects with the break instruction, not 0.

Note that this behavior does not occur in the following cases, which
all involve copying an arbitrary object:

* Object::Clone(), which zero-initializes the contents of the object
  in all cases. However, the contents of the original object are then
  copied over before the thread can reach a safepoint.
* Inside the ObjectGraphCopier, which uses the old initialization
  behavior. This is safe, as any GC-important fields are immediately
  copied over, and the rest of the contents are eventually copied over
  before the caller receives the root of the copied object graph.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/52876
Change-Id: Ib09fc562a8b6af97b509b493eb2d64109230ec35
Cq-Include-Trybots: luci.dart.try:vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312900
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-11 10:15:58 +00:00
Ryan Macnak b050ec9449 [vm, compiler] Honor --no_inline_alloc in suspend state and record stubs.
TEST=ci
Change-Id: Iae70a0edd776d88f2e26783d7348f2e5daf25ad9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312080
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-07-10 22:03:08 +00:00
Derek Xu f0310b5b7c [VM/Timeline] Change locking scheme used by TimelineEventRingRecorder to prevent races
TEST=Loaded the timeline in DevTools on a debug build with the recorder
set to ring, endless, and startup. Recorded traces on a debug build with
the recorder set to systrace, file, and perfettofile. Ran the
vm/cc/TimelineRingRecorderRace test on ASAN and TSAN.

Issue: https://github.com/flutter/flutter/issues/129258
Change-Id: I39920ac3e4a70e5714915fcd554ae171ed82504a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312721
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-10 20:33:33 +00:00
Derek Xu 3cb3e9a49e [VM/Timeline] Delete unsafe versions of Clear() and ReclaimCachedBlocksFromThreads()
TEST=Recorded traces using the file recorder on ASAN and TSAN builds.

Change-Id: I2251a8373d952d6e3ef1803e9a79de85522f518a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312720
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-10 20:33:33 +00:00
Ryan Macnak 99ef36064f [infra] Make the sanitizer a first-class status variable.
Makes the TSAN skips apply to
 `test.py -mrelease --sanitizer=tsan`
and not just
 `test.py -n vm-tsan-linux-release-x64`.

Also makes the timeouts agree.

Change-Id: I10315e754a4ebb3020f3c2f6cecfac6b77e77a9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311828
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-10 17:46:31 +00:00
asiva abcbcd42cb [Status Files] Update status files to account for the following
- https://github.com/dart-lang/sdk/issues/45128 - test computes the
  script url incorrectly when run in an app-jit scenario

- https://github.com/dart-lang/sdk/issues/51304 - test has some long
  iterations (1000 x 1000) and takes longer on the simulator
  architectures causing timeouts

TEST=ci

Change-Id: Iebde161177a442a2288ccc5d879139099c241a4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312888
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-10 17:42:04 +00:00
Derek Xu 6022e0eee6 [VM/Service] Fix service_2/causal_async_star_stack_contents_test
TEST=service_2/causal_async_star_stack_contents_test

Fixes: https://github.com/dart-lang/sdk/issues/52856
Change-Id: I9e03fdefb6df1498b7d19d365c3673218ec9fe5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312722
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-10 14:02:50 +00:00
Daco Harkes b3cc093e4c [vm/ffi] Fix native assets resolution in iOS release
TEST=Manually tested in local engine build for Flutter.

Bug: https://github.com/dart-lang/sdk/issues/50565
Change-Id: I281f2e3b2fb65091a73fc33d01c0e5e7f79beac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312908
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Hossein Yousefi <yousefi@google.com>
2023-07-10 12:23:15 +00:00
Martin Kustermann daa35fd4fd [gardening] Restore timout multiplier in test runner for linux-arm64
The timeout multipiler for linux-arm64 was originally 4, then lowered to
1 (see [0]), then increased again to 2 (see [1]).

Though it seems that service tests are still flakily timing out, so
let's try restoring the original multilier.

[0] https://dart-review.googlesource.com/c/sdk/+/306662
[1] https://dart-review.googlesource.com/c/sdk/+/307972

Also special case `ia32` in timeout calculations due to not using
an AppJIT trained `kernel-isolate` snapshot and therefore being
very slow, especially in ia32-debug mode.

Issue https://github.com/dart-lang/sdk/issues/52589
TEST=ci

Change-Id: Iab8c768866aec9e77bb83c7a3242cc5de8fb4e2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312905
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-10 12:02:16 +00:00
Martin Kustermann 389aab624d [vm] Allow non-TSAN gen_snapshot target TSAN AOT runtime
This is a revert of b6bbfff8c0c6c44cdab0d7d78 which temporarily disabled
this.

Turns out that a non-TSAN gen_snapshot would - when emitting code via
`Assembler::TsanLoadAcquire` - use an incorrect `Thread`-offset:

It calculated the offset via `Thread::OffsetFromThread`. That function
took a `dart::RuntimeEntry*` and tried to find its offset.

We happen to have the following leaf runtime entries:

  #define LEAF_RUNTIME_ENTRY_LIST(V)
      ...
      V(void, MsanUnpoison, void*, size_t)
      V(void, MsanUnpoisonParam, size_t)
      V(void, TsanLoadAcquire, void*)
      V(void, TsanStoreRelease, void*)
      ...

It loops over all runtime entries and finds the first one that has the
identical `dart::RuntimeEntry::function_` pointer.

Though all 4 of them are `nullptr` at `gen_snapshot` time, so when
searching for offset for

  `Thread::OffsetFromThread(kTsanLoadAcquireRuntimeEntry)`

it looked for the first runtime entry with `nullptr` function pointer -
which turned out to be `MsanUnpoison` (instead of `TsanLoadAcquire`).

=> The obvious fix is to use the `dart::RuntimeEntry*` pointer for
comparison instead of it's `function_` member.

TEST=ci
Issue b/287638965

Change-Id: I85c06674927978ef8561e9e7bdfab4823c0a8e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312902
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-10 11:53:58 +00:00
Martin Kustermann 9b9a8cf042 [gardening] SkipSlow dart/regress_52703_test in hot-reload test mode
The test is flakily timing out in hot-reload test mode.

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

TEST=ci

Change-Id: I466e1997aa691921d38a672f293b2a7e97df36aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312904
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-10 10:14:07 +00:00
Vyacheslav Egorov 44230dce94 [vm/compiler] Remove assertion from inliner
This assertion hits flakily due to races between compilers
(e.g. mutator vs background compiler or multiple mutators racing
with itself).

The discovered races are benign, so we just going to remove
the assertion.

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

TEST=ci
R=kustermann@google.com

Change-Id: I8c4202bd76acea0fbf3724f19dbbc69958937afc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312903
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-07-10 09:50:54 +00:00
Alexander Aprelev e800d945c7 Revert "[gardening] Populate legacy patched_class_ link."
This reverts commit 83616c9b56 as it was
not needed for flutter roll, which landed anyway.

TEST=ci
Change-Id: I38a85ab117cabd98420bc88e698a481b094d7345
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312886
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
2023-07-07 21:27:56 +00:00
Martin Kustermann 2cb0882a2d [vm] Unblock dart->g3 roll
The adjustments to g3 build rules that allow running non-TSAN
gen_snapshot targeting TSAN AOT runtime aren't quite fleshed out yet.

So we temporarily let `gen_snapshot` detect whether to target TSAN by
whether it is itself compiled in TSAN (instead of via
`-DTARGET_USES_THREAD_SANITIZER`)

TEST=ci
Issue b/287638965

Change-Id: I2cd744f959d8302ba81cb1feceedee2756e02656
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312901
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-07-07 19:28:58 +00:00
Martin Kustermann 9d876d12b2 [vm] Rename kUsingThreadSanitizer->kTargetUsesThreadSanitizer, include tsan in snapshot flags
TEST=ci
Issue b/287638965

Change-Id: I649b28ac0181761d0927e80b8eff7c8af5fe305a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312840
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-07 14:42:22 +00:00
Martin Kustermann 82577191ec [vm] Allow build rules to pass TARGET_USES_THREAD_SANITIZER in any configuration
This may simplify some g3 build rules as it allows passing this define
whenever we compile under TSAN - instead currently it can only be passed
if DART_PRECOPMILER is also passed.

TEST=ci

Change-Id: I73e51243716373cdeca7559b344408bb206e22ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312801
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-07 09:02:32 +00:00
asiva f84cf9413f [vm/runtime] - Fix RegExp exception messages (issue 52691)
TEST=new test added

Fixed: 52691
Change-Id: Ibc8865f8e9b1e908be80d4fbe8b8931eda448df8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312348
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-06 21:10:28 +00:00
Alexander Aprelev 83616c9b56 [gardening] Populate legacy patched_class_ link.
99db606bab renamed patched_class_ to wrapped_class_, but old vm_snapshot_analysis(pre 0.7.4) expects older name.

Addresses https://github.com/flutter/flutter/issues/130009
TEST=ci

Change-Id: Ic73e665171f7c25ae67230fa6dd790fdc94cc2a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312640
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-07-06 20:31:50 +00:00
Tess Strickland dd3707f2d5 [vm] Initialize FfiTrampolineData::callback_kind_ to a set value.
Not all methods that create FfiTrampoline functions set this, and if not
set, it'll default to a byte from the address of Object::null() due to
Object::InitializeObject, which can break the determinism of the build.

Fixes b/290012924.

TEST=ci

Change-Id: I71ee2eb937b288ec3c6e6a0534e9d870511cf968
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312266
Commit-Queue: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2023-07-06 17:01:00 +00:00
Derek Xu f360a09842 [VM/Service] Give StreamInfo::include_private_members_ an atomic type
TEST=Ran reload_many_isolates_live_and_die_test with TSAN

Fixes: https://github.com/dart-lang/sdk/issues/52551
Change-Id: I1fabdcea908987b0dea79bdb776c35c77cbd056e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312600
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-06 14:51:23 +00:00
Martin Kustermann 2287c76724 [vm] Make AOT compiler use TARGET_USES_THREAD_SANITIZER
The VM has two parts related to TSAN: compiler & runtime.

So far both parts used self-detection whether running with TSAN. This
implies that if AOT runtime runs under TSAN that the AOT compiler then
also has to run under TSAN (which is slow).

We separate the two by making the compiler use
`TARGET_USES_THREAD_SANITIZER`. It will be auto-detected by-default
except when `DART_PRECOPMILER` is set. In the precompiler case we
require the build rules to pass in whether the target runs under
TSAN or not.

Issue b/287638965

TEST=ci

Change-Id: Ib333a8a69ed2d7bdca7596014a0d25b103af25b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312480
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-06 08:44:33 +00:00
Tess Strickland d9f15ef891 [vm] Tweak handling of rare types with non-null instance type arguments.
The CFE may return super-bounded types (types that are a strict
supertype of the rare type) for certain type positions like the right
hand sides of `is` and `as` checks, so we can't assume that all types
involving a given class is a subtype of its rare type. Note that this is
only for uses that do not involve instantiation, as all instances of a
class must have runtime types that are a subtype of its rare type.

Keeping this in mind, here are the changes being made in this CL.

-----

In the flow graph builder when producting unoptimized code, we
previously assumed that if the checked type is not equal to the rare
type, then the code can't use _simpleInstanceOf, which only performs
class ID checks.  However, if the checked type is a supertype of the
rare type, we can, because any instance is guaranteed to be a subtype of
the checked type.

Note that this didn't cause incorrect behavior, just more work than
needed in some cases.

-----

In the generation of optimized type testing stubs, we assumed that the
null type argument vector (TAV) is a possible instance TAV for any
instance. However, if the rare type for a class has a non-null TAV, then
no instance of that class can have a null TAV and we can skip the null
check. (We keep it in the DEBUG case, but just to immediately trigger
a breakpoint if seen.)

Again, no incorrect behavior caused here previously, just an unnecessary
check that we now remove in some cases.

------

Also when generating optimized type testing stubs, when checking for the
null TAV prior to instance type argument checks, the code assumed that
it was possible to have to check type arguments if the checked type was
a super type of the rare type for the instance's class.  However, that's
backwards: if the checked type is a super type, then the runtime type of
any instance of the class is guaranteed to be a subtype and we shouldn't
be checking type arguments at all.

Thus, add an ASSERT that checks this, and instead only generate the code
that goes to the runtime if the null TAV is seen, as the runtime type of
the instance is the rare type and the rare type is guaranteed to not be
a subtype of the checked type.

Again, the previous version of this wouldn't have caused incorrect
behavior either, because the VM should never generate type arguments
checking in the type testing stub if the checked type is a supertype of
the class's rare type. Thus, that branch in the code generation was
just dead code.

-----

TEST=vm/cc/TTS, ci (especially DEBUG bots)

Issue: https://github.com/dart-lang/sdk/issues/52848
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-linux-debug-x64-try
Change-Id: I86d159693d6218f88dd1f04dd34cba702744b4d2
Fixed: 52848
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312500
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-06 08:16:47 +00:00
Vyacheslav Egorov fa8b149f81 [vm/io] Fix memory leak in FileSystemWatcher_InitWatcher
OSError has a destructor so we need to be careful when
using it with Dart_ThrowException which does not
invoke destructors.

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

TEST=standalone/regress_52715_test with ASAN

R=sstrickl@google.com

Cq-Include-Trybots: luci.dart.try:vm-aot-asan-linux-release-x64-try
Fixed: 52816
Change-Id: I8933c1ae41991586571bc76c35ec7dfc28bab7f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312301
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-07-04 13:10:42 +00:00
Sergio Martins ea8485e967 [vm] Make Finalizer.attach assert if value is passed as token
It's not supported, as it would prevent the value from being
garbage collected, defeating the purpose of Finalizer.

Not sure if an exception is worth it, so added the assert
as suggested in the bug tracker.

TEST=vm/dart{,_2}/finalizer/finalizer_attach_checks_token_test

Bug: #52731
Change-Id: Id7b457ca1a95e71c1a43d2d2c8569c35659952b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-07-04 08:28:14 +00:00
Tess Strickland 4141158e2b [gardening] Fix MSVC build after a52f2b9617.
Without this, compiling with MSVC fails with the error:
```
error C2397: conversion from 'int' to 'uint8_t' requires a narrowing conversion
```

TEST=vm-msvc-windows builds

Cq-Include-Trybots: luci.dart.try:vm-msvc-windows-try
Change-Id: I157b8ac9f6f6aaaf31b71d2c0a5f5469d6dc21ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312262
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-03 14:59:48 +00:00
Tess Strickland 7cc005ea1a [vm] Make Class::RareType() the instantiated to bounds type.
Previously, Class::RareType() returned a Type where the type arguments
were null (e.g., all dynamic). However, this is an invalid type for
classes that have at least one type parameter with a bound that is not a
top type, and could mean that comparisons (such as subtyping) against
the "rare" type could return incorrect answers.

Instead, use TypeParameters::defaults() to get the canonicalized
instantiated to bounds type argument vector and use that instead.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-release-x64-try
Change-Id: Iea591e93102f53713265b481476f9670cfb81c93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312261
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-03 14:52:19 +00:00
Daniel Bali a3e84160ec Expand collection of object instances.
TEST=vm/dart/analyze_snapshot_binary_test

Change-Id: I96ef5d8fc92292151444e52d189e6b2d10a99375
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308303
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-07-03 12:29:15 +00:00
Tess Strickland 85de9c1d7e [vm] Allow STCs that only store instantiator, not function, type args.
If we are generating a SubtypeTestCache for a known type that only
needs instantiator type arguments to be fully instantiated, then
don't store and check against the unneeded function type arguments.

TEST=vm/cc/STC, vm/cc/TTS, ci

Change-Id: I370adf820168079322b8a87811057670a47ee6b3
Cq-Include-Trybots: luci.dart.try:vm-tsan-linux-release-x64-try,vm-reload-rollback-linux-release-x64-try,vm-reload-linux-release-x64-try,vm-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-aot-mac-release-arm64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-ia32-try,vm-linux-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311382
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-07-03 10:39:53 +00:00
Alexander Markov 4650178857 Revert "[vm] Improve Class::Hash by also hashing its library"
This reverts commit 1cbb5debeb.

Reason for revert: ../../runtime/vm/compiler/aot/precompiler.cc: 3113: error: expected: api_uses_.HasKey(*entry)

Original change's description:
> [vm] Improve Class::Hash by also hashing its library
>
> Class::Hash previously only hashed class name. This could cause
> hash collisions for top-level classes which have the same name.
>
> Function::Hash uses Class::Hash, so it could also
> suffer from hash collisions among top-level functions.
>
> This change adds hashing of library URI when calculating
> Class::Hash / Function::Hash.
>
> TEST=ci
>
> Change-Id: I8bed681ecb8b8a6b0fceb99866c551ff19a36ab7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311930
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

Change-Id: I0ec3746d2756cd681695cf4b4304733783df7192
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312060
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-06-30 17:04:36 +00:00
Alexander Markov 1cbb5debeb [vm] Improve Class::Hash by also hashing its library
Class::Hash previously only hashed class name. This could cause
hash collisions for top-level classes which have the same name.

Function::Hash uses Class::Hash, so it could also
suffer from hash collisions among top-level functions.

This change adds hashing of library URI when calculating
Class::Hash / Function::Hash.

TEST=ci

Change-Id: I8bed681ecb8b8a6b0fceb99866c551ff19a36ab7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311930
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-06-30 15:59:38 +00:00
Vyacheslav Egorov a52f2b9617 [vm] Rework awaiter stack unwinding.
The main contribution of this CL is unification of disparate
handling of various functions like `Future.timeout`,
`Future.wait`, `_SuspendState.createAsyncCallbacks` and
`_SuspendState._createAsyncStarCallback` into a single
`@pragma('vm:awaiter-link')` which allows Dart developers
to specify where awaiter unwinder should look for the next
awaiter.

For example this allows unwinding to succeed for the code like this:

    Future<int> outer(Future<int> inner) {
      @pragma('vm:awaiter-link')
      final completer = Completer<int>();

      inner.then((v) => completer.complete(v));

      return completer.future;
   }

This refactoring also ensures that we preserve information
(including Function & Code objects) required for awaiter
unwinding across all modes (JIT, AOT and AOT with DWARF stack
traces). This guarantees users will get the same information
no matter which mode they are running in. Previously
we have been disabling awaiter_stacks tests in some AOT
modes - which led to regressions in the quality of produced
stacks.

This CL also cleans up relationship between debugger and awaiter
stack returned by StackTrace.current - which makes stack trace
displayed by debugger (used for stepping out and determinining
whether exception is caught or not) and `StackTrace.current`
consistent.

Finally we make one user visible change to the stack trace:
awaiter stack will no always include intermediate listeners
created through `Future.then`. Previously we would sometimes
include these listeners at the tail of the stack trace,
which was inconsistent.

Ultimately this means that code like this:

    Future<int> inner() async {
      await null;  // asynchronous gap
      print(StackTrace.current); // (*)
      return 0;
    }

    Future<int> outer() async {
      int process(int v) {
        return v + 1;
      }

      return await inner().then(process);
    }

    void main() async {
      await outer();
    }

Produces stack trace like this:

    inner
    <asynchronous suspension>
    outer.process
    <asynchronous suspension>
    outer
    <asynchronous suspension>
    main
    <asynchronous suspension>

And when stepping out of `inner` execution will stop at `outer.process`
first and the next step out will bring execution to `outer` next.

Fixes https://github.com/dart-lang/sdk/issues/52797
Fixes https://github.com/dart-lang/sdk/issues/52203
Issue https://github.com/dart-lang/sdk/issues/47985

TEST=ci

Bug: b/279929839
CoreLibraryReviewExempt: CL just adds @pragma to facilitate unwinding
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-dwarf-linux-product-x64-try
Change-Id: If377d5329d6a11c86effb9369dc603a7ae616fe7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-30 14:03:03 +00:00
Martin Kustermann 45038a2e71 [vm] Avoid repeatedly re-setting stack limits on each dart invocation
Currently every invocation of a dart function will set and later on
reset the stack limits. Doing so requires acquiring locks.

Similarly because we have async ffi callbacks (another way to invoke
dart code) the logic was duplicated there.

Though the stack limit never changes for a given [OSThread]. Isolates
can run on different [OSThread]s throughtout its lifetime. But an
isolate always has to be entered on a native thread before it can
execute dart code.

=> We initialize the stack limit when we scheduling an isolate on a
thread and re-set it when unscheduling it.

=> That centralizes the place to one where we have to deal with stack
limits and avoids repeated acquiring of locks on each embedder dart
function invocation.

TEST=ci

Change-Id: Ia59ba8f92b93c58a990010ec75dfcd879aea2c43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311960
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-29 17:29:48 +00:00
Ryan Macnak ac77af1c07 Group the GC tests into a common directory.
The makes it possible to run just these tests with `test.py vm/gc/`.

Change-Id: Ied4aa0b2fb045c19b1aced68f58a1ef195a5df8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311145
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-29 17:27:48 +00:00
Ryan Macnak 41bb44e93e [vm, gc] Update the write barrier stub to allow for both the generational and incremental barriers triggering.
Currently the generational and incremental barriers cannot both apply for the same store because the former only applies for old->new stores and the latter only applies for old->old stores. Marking through new-space will cause the incremental barrier to apply to all stores.

TEST=ci
Change-Id: I40d492cc8b5b2fff8d5d4bc8625d45f2e6a2d488
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309830
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-29 16:26:48 +00:00
Martin Kustermann 99db606bab [vm] Cleanup [PatchClass] in the VM
The [PatchClass] no longer needs to refer to a original [Class] and a
patched [Class] objects: Since the CFE does handling of patches the VM
only has a single [Class] object, so those two fields are always the
same.

=> Change `PatchClass::{origin_class,patched_class} -> `PatchClass::wrapped_class`

We also remove the `Field::Origin()` / `Function::origin()` methods
as they return the same as the `Owner()` would return.

TEST=ci

Change-Id: Iec0849f6ffc2026760dad89a9bcf07e9469bc8b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-06-29 15:03:37 +00:00
Martin Kustermann 63b567add2 [vm] Split isolate initialization logic into two pieces
This splits `Dart::InitializeIsolate()` into

* `Dart::InitializeIsolateGroup()` that sets up an `IsolateGroup`
  => This is only done at isolate group creation time when the very
     first isolate is created.

* `Dart::InitializeIsolate()` that sets up an `Isolate`.
  => This is done for every isolate.

This is purely refactoring / code cleanup.

TEST=ci

Change-Id: Ica906444f79fe49849b9e11e96f7c89184cb9d09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311603
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-06-29 08:04:20 +00:00
Ryan Macnak 8853472dd6 [vm, gc] Pause concurrent marking during scavenge.
TEST=ci
Change-Id: I7c3deaf4383b993c4c0253a4f94a1d503b2d9a92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309802
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-06-28 16:49:07 +00:00
Slava Egorov 8b6e39696f [vm/io] Avoid leaking Handle::data_ready_ on Windows.
Handle::data_ready_ contains bytes which are ready to be sent to Dart
side. Not all code paths fully drain this buffer and delete it
before destroying the handle, for example directory watch implementation
was prone to leaking data_ready_ when subscription was cancelled.

This CL switches the code to use unique_ptr to hold on to data_ready_
which makes sure that it is deleted when Handle is destroyed.

The code would benefit from holding all OverlappedBuffer instances
through unique_ptr but that is a much larger refactoring which
we leave for a later date.

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

TEST=standalone{,_2}/regress_52715_test

Bug: 52715
Cq-Include-Trybots: luci.dart.try:vm-win-release-x64-try,vm-win-debug-x64-try,vm-aot-win-release-x64-try,analyzer-win-release-try
Change-Id: Ie8d728b823de7e8f9de1489898e270580c2af269
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311841
Commit-Queue: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2023-06-28 13:06:51 +00:00
Vyacheslav Egorov 86c311607a [vm] Fix HeapProfileSampler::SampleOldSpaceAllocation
When Isolate is just starting up and no TLABs are yet present
we were setting interval_to_next_sample_ to -1 which caused
every old space allocation to be sampled.

This CL properly initializes the interval to sampling_interval_
instead.

TEST=vm/cc/DartAPI_HeapSampling_CorrectSamplingIntervalForOldSpaceAllocations

Change-Id: Ieb29234379d3afa4716ebdf3591f9fc0cbcaef71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311844
Commit-Queue: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-28 12:58:32 +00:00
Martin Kustermann 8f7cf7724c [gardening] Ensure functions use stable hashes across reload
Root cause is that `Function::Hash()` depends on the owner class
id. This causes two issues

a) Issue with reload:

During reload the reloader code will change `Function::owner()`
from a `Class` to a `PatchClass`. This in return will cause a change in
the function's hash, which means we won't find the function in the
closure cache anymore.

b) Issue with app-jit:

As part of app-jit we re-number class ids. This re-numbering would also
render the closure cache as invalid - as the function hash code would
change. So instead the closure cache was cleared entirely. While this
works for AOT, in app-jit we may serialize closure functions and their
code. Though at app-jit runtime we then fail to find the functions in
the closure function cache (as it was cleared during snapshoting)

(This will surface by us triggering an optimizing compile of a function
in the background compiler which will try to make a new `Function`
object for a closure, even though the app-jit snapshot already has one)

To fix these issues we make the `Function::Hash()` stable across reload

  * we use `Function::Owner()` instead of `Function::owner()` (the
    former will always return the actual class, the ladder can return
    the `PatchClass`)

  * we avoid re-hashing the closure cache by making `Function::Hash()`
    use the name of the class instead of the class id

  * we clear out the closure cache array during AOT snapshoting, as this
    is not used in AOT runtime.

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

TEST=Fixes various issues on CI.

Change-Id: I352d0a768df0f29d504cdd80e3533cbedc437b9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311744
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-28 11:48:26 +00:00
Martin Kustermann 29509e0124 [gardening] Fix riscv32/riscv64 build
The constants in [0] were not quite correct for riscv.

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

TEST=ci

Change-Id: I194cde2541293935ef89861f3d1607c1913068f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311743
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2023-06-28 09:21:11 +00:00
Johnni Winther 0c8ded72dc [cfe] Add FileUriConstantExpression
This adds FileUriConstantExpression, a subclass of ConstantExpression, to support correct file offset of annotations for augmentations and patches.
The FileUriExpression is used to carry the file uri of the expression
before constant evaluation.

TEST=general/patch_annotations

Change-Id: I0dc8a0cb97dd530fd1960785d38c2d5e4883c3dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-28 07:52:09 +00:00
Liam Appelbe 13ec07415b [vm] Async FFI callbacks
More details about the design:
https://docs.google.com/document/d/1QDjyY_6wOTOgURwpeYMKU9qEz0gKxx2MUrdruC6Kp6c/edit?usp=sharing

Change-Id: Ie3985d86dca7f5010044ca46c33ca177588c0f69
Bug: #37022
CoreLibraryReviewExempt: Reviewed by vm and api groups. web and wasm groups not affected because FFI isn't on those platforms.
TEST=async_void_function_callbacks_test.dart, ffi_callback_metadata_test.cc, other front end tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305900
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-28 01:00:18 +00:00
Alexander Markov 12c7455436 [vm] Reset closure functions cache when sorting class ids
Hashes of functions depend on the class ids, so cache of the closure
functions should be cleared when class ids are sorted.
This is safe to do because at that point all compiled code is cleared.

TEST=ci

Change-Id: Iaf3a66d1026611fc0a3df3903cb4e09e6d6c4c17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311723
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-27 23:08:26 +00:00
Ryan Macnak 274db26c57 [vm, gc] Refactor weak mourning.
TEST=ci
Change-Id: I0d60ed9284651eb49ea2b44edc877083c8c8390d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311152
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-06-27 22:23:17 +00:00
Ryan Macnak 4949f6185e [vm, gc] The GC cares about immediate-ness not Smi-ness.
TEST=ci
Change-Id: Ib7bae6df6becf0ed696a4c00257cedaf46f750aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311148
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-27 19:47:04 +00:00
Alexander Markov dc30f815f1 [vm] Inline local functions declared in outer functions
Previously, inliner was able to inline closure calls only when closure
was allocated in the current function (or in a function which was
inlined so far). This is not true for local functions declared in outer
functions (they are allocated at declaration site).

Now, when calling local functions, target of closure call is always
known regardless of where the function is declared, so calls to local
functions can be inlined.

TEST=runtime/tests/vm/dart/inline_local_functions_il_test.dart
Fixes https://github.com/dart-lang/sdk/issues/52695
Fixes https://github.com/dart-lang/sdk/issues/15558

Change-Id: I0e51dbaf63a6d4427bff366b40414ca5fac3d418
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311465
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-06-27 19:42:15 +00:00
Tess Strickland 3a9c1e6d6d [vm] Remove extra DEBUG-only checking in SubtypeNTestCache.
These checks convert what would likely be a segfault into a breakpoint
instead, but they're heavyweight enough on certain tests to cause
timeouts. Remove them as issues here are easily debugged without them.

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

TEST=vm/dart/regress_48523 on debug reload bots

Change-Id: Icf9ea6191eb82c254d9a01fbc9f8ba6255602084
Cq-Include-Trybots: luci.dart.try:vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311621
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-27 15:36:38 +00:00
Slava Egorov 758727dd12 [vm] Rename tests causal_stacks -> awaiter_stacks and improve harness.
The main difference from the previous harness is that it
allows auto updating the expectations instead of
maintaining them manually.

This relands 0c1b2722ed with
changes to harness which fix issues on Windows.

Note: some amount of AOT failures are expected and should just
be approved. They will be fixed with the last CL in the series.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-win-release-x64-try
Change-Id: I7ae84769ed54bc447ebf71acc68ba9d0b6717bac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311604
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-06-27 11:50:32 +00:00
Tess Strickland 516f238aa6 Revert "[vm] Rename tests causal_stacks -> awaiter_stacks and improve harness."
This reverts commit 0c1b2722ed.

Reason for revert: Failures on AOT (stack expectations unmet) and Windows (parse errors due to Windows paths) trybots.

Original change's description:
> [vm] Rename tests causal_stacks -> awaiter_stacks and improve harness.
>
> The main difference from the previous harness is that it
> allows auto updating the expectations instead of
> maintaining them manually.
>
> TEST=ci
>
> Change-Id: I80e303d3ecbcc834ac94fa089cabe4f8834cc661
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311400
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

Change-Id: I7311bf08403f4167f88f6204fde1a6fdee353f7d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311600
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-27 09:02:28 +00:00
Tess Strickland 1df39e243a [gardening] Marking test that creates several snapshots slow on TSAN.
Change-Id: Iba88e9807a7d58d17fe6b2cf103d0f18fe7dbef5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311580
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-06-27 08:04:31 +00:00
Vyacheslav Egorov 0c1b2722ed [vm] Rename tests causal_stacks -> awaiter_stacks and improve harness.
The main difference from the previous harness is that it
allows auto updating the expectations instead of
maintaining them manually.

TEST=ci

Change-Id: I80e303d3ecbcc834ac94fa089cabe4f8834cc661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311400
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-27 07:47:39 +00:00
Vyacheslav Egorov 8d5dbbdf69 [vm/debugger] Rename "causal" to "awaiter" internally
The name is more accurately reflects what this stack trace
contains: despite what causal implies it does *not* actually
reflect the stack which initiated the async operation. Instead
it contains the chain of listeners which will run when
the async operation completes - its awaiters.

TEST=ci

Change-Id: Ie7309c9b1c39246e0fd4c14f7b9c515bcdfbbe10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311384
Reviewed-by: Derek Xu <derekx@google.com>
2023-06-27 07:47:39 +00:00
Vyacheslav Egorov 6e46d4f896 [vm/debugger] Cleanup HandleSteppingRequest
No need to pass parameter explicitly because it is always
equal to the field.

TEST=ci

Change-Id: I04d86786d5278ad4ab4ce6c67e61b1fc94f692d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311383
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-27 07:18:50 +00:00
Vyacheslav Egorov ec15052c7f [vm] Remove old async_debugger flag.
Effectively it is true for all environments where
debugger is actually present.

TEST=service tests

Change-Id: I0592e83004271ca32c107f4347f7bd82172b0a62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310622
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-27 07:18:50 +00:00
Ryan Macnak bbeed85932 [vm, gc] Add some documentation about weakness.
Change-Id: I10ca59a29e3ac951b3e7830e6b90a36a6ac55a75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311524
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-06-26 23:14:26 +00:00
Ryan Macnak 95bd742546 [vm, gc] Fix missing longjump scope when parallel scavenge processes weak properties.
TEST=ci
Change-Id: I55661f92ec942a1adf36cff1cd020958b531bd8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311522
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-26 23:12:57 +00:00
Vyacheslav Egorov 4a6f9328a2 [vm/debugger] Simplify async breakpoints implementation
We no longer rewrite suspendable function into closures nested
inside the original function, so the whole synthetic async breakpoint
machinery is not needed.

Refactor `Breakpoint` class to make one-shot and per-closure
separate properties of breakpoint, which allows creating
one-shot-per-closure breakpoints.

TEST=existing service tests

Change-Id: I208afe13f36efa40f5746e44867bd24684cf5f03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310601
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-26 22:45:10 +00:00
Vyacheslav Egorov 401a11d309 [vm] Remove obsolete code from inliner.
Described case no longer happens: either function
is marked as not-inlinable from the very beginning
or graph construction bails out entirely.

TEST=ci

Change-Id: I7e345dc948370050bd6e03a327f1fd1054fc8240
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311401
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-26 21:55:40 +00:00
Vyacheslav Egorov 1a582a6714 [infra] Fix update_line_numbers.dart script
TEST=manually tested

Change-Id: If2132e5610e8965f291b776bcc5cf5bc87a5001f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311341
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-06-26 20:01:31 +00:00
Alexander Aprelev 238ce4685a [vm/debugger] Update service_2/* tests with debugger() expectations.
Follow-up to bbdf87d277
TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/52785
Change-Id: Ia5c83743efe6222396f63d5df77ebb4e39cbd768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311440
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-06-26 18:46:46 +00:00
Tess Strickland 4aebac3d28 [vm] Verify STC input count matches stub expected input count in DEBUG.
If these checks fail, then a `SubtypeNTestCache` stub has been called
with a `SubtypeTestCache` that uses a different number of inputs
than the stub expects, which could lead to unexpected false negatives
or false positives, so catch it early.

TEST=vm/cc/TTS, ci

Change-Id: Ia9c48aad4c35872cad32b7b6f3eead3ee9e59680
Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-linux-debug-x64c-try,vm-linux-debug-x64-try,vm-linux-debug-simriscv64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311380
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-26 11:54:00 +00:00
Vyacheslav Egorov f1cd87e58e [infra] Tool for updating LINE_* in service tests.
Some of the service tests contain LINE_*
constants which match line numbers of `// LINE_*`
comments in the body of the test. Previously
we would manually maintain these constants,
which is rather tedious.

This CL adds a scripts for updating the
constants automatically.

TEST=manually tested the tool

Change-Id: I3a5cdbd4cae2ab6eaec51c9bb5f48b351bfbbd7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310602
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-26 10:48:30 +00:00
Tess Strickland 719c0a91dc [vm] Remove UntaggedField::type_test_cache_.
This field is now only used when reloading to check assignability
during `ProgramReloadContext::ReloadPhase4CommitFinish()` (via
`PostCommit()` -> `InvalidateWorld()` -> `InvalidateFields`).

However, the method `DeoptimizeDependentCode()` is called near the
start of the actual reloading process in `Reload` prior to the
commit/rollback phases. This calls `DeoptimizeTypeTestingStubs()`, which
walks the heap and resets the contents of all `SubtypeTestCaches`
(`STC`s).

That means that the `STC` information isn't actually kept between
different reloads, so all this does is cause a number of `STC` objects
to be allocated during reload whose backing arrays are not used
post-reload for anything and so are unnecessary garbage.

That, and the creation of the `STC`s during `InvalidateFields` creates
all-input `STC`s, as they don't just check assignability to a given field type but also for checking elements of `RecordTypes`. That means
the per-field `STC`s contain way more information needed to check for
valid assignments to the corresponding field type, even if the `STC`
was used between reloads.

This CL removes the unnecessary field and changes `InvalidateFields`
so that the `STC`s used during reload are instead lazily allocated once
per `FieldInvalidator` object and now both the `STC` and its backing
array are now garbage post-field invalidation.

TEST=reload ci

Change-Id: I3ffa199551ba69f0afd4eba6303c6ff73d7473a3
Cq-Include-Trybots: luci.dart.try:vm-reload-linux-debug-x64-try,vm-reload-linux-release-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-reload-rollback-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-dwarf-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311220
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-26 09:27:59 +00:00
Tess Strickland 06e099884b [vm] Adjust default value of FLAG_max_subtype_cache_entries flag.
The round default value used in f7e26c50 means that we allocate
a new backing array shortly before hitting the cap, and once we
hit the cap the max load factor for the new backing array is only ~49%.

Instead, given a desired maximum, calculate an appropriate default
value that ensures the cap is only hit shortly before the array reaches
the max load factor that causes reallocation.

TEST=ci

Change-Id: I4c4fc3f5726aea3b260cf288cd00f886c2a1bd96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311280
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-06-26 09:24:57 +00:00
Tess Strickland cefda02d24 [vm] Specify default capture mode for closures used in stub generation.
Without this, when building on Windows using MSVC, we get `error C3493:
'kCacheArrayReg' cannot be implicitly captured because no default
capture mode has been specified`.

TEST=vm-msvc-windows builds

Change-Id: Iebc443ce887dd32b186d51695cbc0bfd95d09f35
Cq-Include-Trybots: luci.dart.try:vm-msvc-windows-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311320
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-26 08:40:50 +00:00
Tess Strickland f7e26c508d [vm] Add support for hash-based caches in SubtypeNTestCache stubs.
This also lowers the threshold for converting from a linear cache
to a hash-based cache from 100 to 30 on non-IA32 architectures.
(IA32 still goes to runtime if there's a hash-based cache.)

For SubtypeTestCache benchmarks above this threshold, we see an
improvement varying from ~50-100% to ~700-800% on all architectures,
from lowest number of checks (50) to highest (1000).

For SubtypeTestCache benchmarks below this threshold, no major
changes are seen: generally <5% improvement or <5% regression per
check at most.

TEST=vm/cc/TTS

Change-Id: I83aa7c085ab5a411e944ec660d6b8eba7a788ee0
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-simarm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-x64c-try,vm-aot-tsan-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-release-ia32-try,vm-linux-debug-x64c-try,vm-linux-debug-x64-try,vm-linux-debug-simriscv64-try,vm-linux-release-simarm64-try,vm-linux-release-simarm-try,vm-mac-release-arm64-try,vm-mac-release-x64-try,vm-tsan-linux-release-x64-try,vm-reload-rollback-linux-release-x64-try,vm-reload-linux-release-x64-try,vm-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308941
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-06-24 12:56:12 +00:00
Ryan Macnak 1f953c3fe1 [vm, gc] Remove some dead code.
TEST=ci
Change-Id: Ia0d0f181b8d54c3ec0e1cc8f2076bea7854379ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311142
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-06-23 20:35:00 +00:00
Ryan Macnak b9843b876d [vm] Prevent nested handling of SIGPROF.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52765
Change-Id: I14301d67ad245d3df96624155b383cb5f4c7f981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310975
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-23 17:01:58 +00:00
Alexander Aprelev bbdf87d277 [vm/debugger] Have debug step check point after debugger() call.
Fixes https://github.com/dart-lang/sdk/issues/46006
TEST=ci

Change-Id: I89a7ad248b75204d1754668cfb23c8d98f554b28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310779
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-06-23 16:53:48 +00:00