Commit graph

20862 commits

Author SHA1 Message Date
Ryan Macnak a7e20dd2b0 Revert "[vm, gc] Mark through new-space."
This reverts commit 6194209b28.

Reason for revert: issues on arm32

Original change's description:
> [vm, gc] Mark through new-space.
>
>  - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>  - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>  - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>  - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>  - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: I3668a2e56821f9eadf96e38c228dab27be656016
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309826
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Change-Id: I434eb595c9e7858efc8c9b07cbca954e5649f506
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319321
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-08-09 18:13:17 +00:00
Ryan Macnak 6194209b28 [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
 - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
 - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
 - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
 - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: I3668a2e56821f9eadf96e38c228dab27be656016
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309826
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-09 15:57:17 +00:00
Ryan Macnak b11340bc4a [test] Skip service tests on Linux ARM64.
TEST=ci
Change-Id: I4277a4f4f2c3bd9dedd9e325167b67130b5afc2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319260
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-08-09 15:32:13 +00:00
Vyacheslav Egorov 5ddb1b8ea7 [vm/service] Use getline to read /proc/self/smaps
Previously the code was using `fgets` with a fixed
size buffer. This lead to a confusing behavior where
lines longer than 255 characters would be read
in multiple chunks and cause crashes in the parsing code.

Additionally make extraction of the path component slightly
more robust by searching for path field forward rather than
backwards. Path might contain white space and searching
backwards might stumble on that.

This is a reland of 95474f44f1
with changes to android min-sdk to make android ARM builds
succeed (getline requires SDK 18+).

TEST=manually

Change-Id: I8b36fcd178680aed7f856bc884a5cd188a5f6e85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319480
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-09 12:59:31 +00:00
Martin Kustermann 07549ac9ab [vm] When marking an instruction as deopt to before an instruction, ensure prune-count=0
The [Environment] represents 2 different things:

  * before (env, deopt-id): The state of unoptimized frame right before
    the IL instruction is executed

  * after (env, deopt-id): The state of unoptimized frame right after
    the call machine instruction instruction (i.e. which may not be
    after the IL instruction - as it may still have to drop arguments)

The environment's prune-count specifies the number of entries from the
[Environment] to be removed to get from before-env to after-env.

This prune-count includes generally most of `<IR>::InputCount()` - as
most IR instructions consume their inputs (which location summary may
e.g. require in registers) before doing any call. Though it doesn't include
arguments as we currently have a stack-based calling convention and both
optimized and unoptimized code will explicitly drop them after the machine
call instruction.

Our optimizing compiler may emit speculative instructions. Those will
receive an environment that makes before (env, deopt-id) and after (env,
deopt-id) the same - as both eager and lazy deopt will target a
before (env, deopt-id).

=> We should ensure that the prune-count is set to 0, ensuring we won't
prune anything in case an IL instruction was marked with
`MarkAsLazyDeoptToBeforeDeoptId`.

=> This is a preparation for inlining force-optimized functions: If we
inline them and some callee IL instruction performs lazy deopt it should
re-try the call without any pruned inputs.

TEST=ci

Change-Id: I091c9fa962b376200dc5cfb6ea8c9a47ef43810f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319440
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-08-09 11:31:47 +00:00
Martin Kustermann b11aec8f64 [vm] Change IL instructions to be more precise if instruction only lazy-deopts
TEST=ci

Change-Id: I5b46856dfde192779001abd8edaeb37890ca06af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319420
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-09 10:25:28 +00:00
Martin Kustermann 0d44ee8452 [vm] Remove PortMap state concept, expose isolate main control ports in service
TEST=ci

Change-Id: I18281c5ac05272596fe46baa75e8ec930f6099d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318925
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-08-09 06:01:55 +00:00
Alexander Markov 286e5761e3 [gardening] Skip slow vm/dart/awaiter_stacks/sync_async_start_pkg_test_test on hot reload bots
This test is flaky and timing out on hot reload bots.

Change-Id: If0c9574ac80405d14765e4ada4fdee8e6bce9d79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319001
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-08-08 15:40:49 +00:00
Martin Kustermann 06b2967188 [vm] Disentagle PortMap/MessageHandler from port status tracking
The main purpose of the low-level [PortMap] is to coordinate between
ports being opened & closed and concurrent message senders. That's the
only thing it should do.

Each isolate owns [ReceivePort]s. Only the isolate mutator can create
ports, delete them or change their "keeps-isolate-alive" state. Right
now it requires going via [PortMap] (which acquires lock) and
[MessageHandler] (which acquires lock) to change the
"keeps-isolate-alive" state of a port.

We'll move information whether a dart [ReceivePort] is closed and
whether it keeps the isolate alive into the [ReceivePort] object itself.

=> Changing the "keeps-isolate-alive" state of the port no longer
requires any locks. We could even avoid the runtime call itself in a
future CL.

Isolates are kept alive if there's any open receive ports (that have not
been marked as "does not keep isolate alive"). This is a property of an
isolate not of the message handler. For native message handlers we do
have a 1<->1 correspondence between port and handler (i.e. there's no
"number of open ports" tracking needed).

=> We'll move the logic of counting open receive ports and ports that
keep the isolate alive to the [Isolate].
=> We'll also remove locking around incrementing/decrementing or
accessing the counts.
=> The [IsolateMessageHandler] will ask the [Isolate] whether there's
any open ports for determining whether to shut down.
=> For native ports, the `Dart_NewNativePort()` & `Dart_CloseNativePort()`
functions will manage the lifetime (as their name also suggests).

Overall this makes the [Isolate] responsible for creation of dart
[ReceivePort]s and tracking whether the isolate should be kept alive:
  * Isolate::CreateReceivePort()
  * Isolate::SetReceivePortKeepAliveState()
  * Isolate::CloseReceivePort()

TEST=ci

Change-Id: I847ae357c26254d3810cc277962e05deca18a1de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317960
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-08 10:57:47 +00:00
Martin Kustermann 86adabe0ef [vm] Relax assertion: Allow nested acquires of locks after acquiring safepoint operation
If a thread owns a lock already before acquiring the safepoint
operation, it can re-acquire the same lock inside the safepoint
operation (as it's a NOP and canoot lead to deadlocks).

TEST=ci

Change-Id: I4a7c3526683e09d4408d97aca9e9b59d6ca53d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318662
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-08-08 10:17:36 +00:00
Martin Kustermann a11de5a81b [vm] Initialize state of a port in PortMap on creation
All uses of `PortMap::Create()` would call `PortMap::SetPortState()`
after creating the port. To avoid acquiring the port map lock twice, we
can initialize the state already in `PortMap::Create()`.

Additionally we fix an existing issue by making the isolate's main port
a control port (instead of leaving it as a `kNewPort`).

As a side-effect we'll no longer have any allocated ports with state
`kNewPort`.

We also remove the unused `PortMap::IsLocalPort()`

TEST=ci

Change-Id: I6198792a8e1132580b60262f10a807c5b12f9eaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317680
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-08 08:13:00 +00:00
Ryan Macnak 6d4573aced [test] Skip high-memory tests on Linux ARM64.
Bug: https://github.com/dart-lang/sdk/issues/52589
Bug: https://github.com/dart-lang/sdk/issues/53138
Change-Id: Iaf6e499d80726b5ec8a810a5d3bd1d90a0d93af9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318800
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-08-07 17:58:07 +00:00
Martin Kustermann 8acd7d4dba [gardening] Exclude vm/cc/ManyClasses test from running under TSAN
The test generates many classes, compiles a lot of code and executs very
large function.

This is too slow under TSAN

TEST=Skip vm/cc/ManyClasses on TSAN

Change-Id: I867fe9c1d50e7e976cd0a58659464c3eada5e56c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318640
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-07 07:44:37 +00:00
Derek Xu d0114ec0a2 [dart:developer] Add static Service.getObjectId method
TEST=pkg/vm_service/test/developer_service_get_object_id_test.dart

Fixes: https://github.com/dart-lang/sdk/issues/53012
Change-Id: I4b4dd49363ff2d91361e9054631516ea1520d3b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317160
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-08-04 14:18:38 +00:00
Derek Xu 0d16e25c6c [dart:developer] Deprecate Service.getIsolateID in favour of Service.getIsolateId
TEST=CI

CoreLibraryReviewExempt: This CL just marks Service.getIsolateID as
deprecated in favour of Service.getIsolateId, which is identical in all
aspects other than the name. We agreed that the new name was better here:
https://dart-review.googlesource.com/c/sdk/+/317160/comment/032739dd_b5e6abc1/
Change-Id: I1464ff3ce7430f01dfeeaf95f56ec980561efd21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317220
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-08-04 14:18:38 +00:00
Martin Kustermann 21d8e30728 [vm] Cleanup kernel loader code
After simplifying the handling of annotations in the kernel loader in
[0] we no longer need to use handle-based access to pragmas.

Also use bit field to represent detected pragmas.

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

TEST=ci

Change-Id: I2e21c9e96accce1580964e617f05e4316563b463
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318260
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-04 13:40:32 +00:00
Martin Kustermann 587e6308bf [vm] Fix expression evaluation in context of closures
When evaluating an expressino at a breakpoint that's inside a closure,
the closure may refer to anything it closes over. That includes the
`this` from an enclosing method.

So depending on whether a closure's parent chain is an instance method
or a static method, the expression evaluation function is going to be an
instance method or a static method.

=> We walk up the parent chain to determine the correct enclosing class.
=> This avoids making a Type object with a cid from a top-level class (see [0])

Handling this correctly will now try to get the `this` when invoking an
eval function that has an enclosing instance method. Though we may often
have "<optimized out>" the `this` (e.g. due to not capturing it in
closure context chain).

=> We still allow running the expression evaluation function in this
case, but only if the expression being evaluated doesn't access `this`.

A similar issue occurs when trying to use variables in the eval
expression that the closure didn't capture. This results in a confusing
CFE compile-time error. This is a separate issue and tracked in [1].

=> We update the test to distinuish the cases that this CL makes passing
and those that are failing due to [1].

Fixes [0] https://github.com/dart-lang/sdk/issues/53061
See also [1] https://github.com/dart-lang/sdk/issues/53087

TEST=Fixes part of service/evaluate_activation_test failures

Change-Id: I3bb24e7338c7b2f12d5340311d944cb59a455641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317540
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-04 11:07:46 +00:00
Slava Egorov 83000c689f Revert "[vm/service] Use getline to read /proc/self/smaps"
This reverts commit 95474f44f1.

Reason for revert: getline seems to be missing on some platforms we target (e.g. Android).

Original change's description:
> [vm/service] Use getline to read /proc/self/smaps
>
> Previously the code was using `fgets` with a fixed
> size buffer. This lead to a confusing behavior where
> lines longer than 255 characters would be read
> in multiple chunks and cause crashes in the parsing code.
>
> Additionally make extraction of the path component slightly
> more robust by searching for path field forward rather than
> backwards. Path might contain white space and searching
> backwards might stumble on that.
>
> TEST=manually
>
> Change-Id: I1d23df4a79b04721d3a812e19eae9b8ad0e955fa
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317683
> Commit-Queue: Slava Egorov <vegorov@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

Change-Id: Iaa6886f318884f9ac17487b2ab59621bb44fcb3b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317781
Auto-Submit: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-08-02 18:02:24 +00:00
Vyacheslav Egorov 95474f44f1 [vm/service] Use getline to read /proc/self/smaps
Previously the code was using `fgets` with a fixed
size buffer. This lead to a confusing behavior where
lines longer than 255 characters would be read
in multiple chunks and cause crashes in the parsing code.

Additionally make extraction of the path component slightly
more robust by searching for path field forward rather than
backwards. Path might contain white space and searching
backwards might stumble on that.

TEST=manually

Change-Id: I1d23df4a79b04721d3a812e19eae9b8ad0e955fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317683
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-08-02 17:13:30 +00:00
Ryan Macnak 5e49ea5ad8 [vm, service] Fix discrepancy between VM generating kind _TypeParameters and service.md claiming the existence of kind TypeParameters.
Fix the service type `TypeParameters` to recognize it is a heap object.

Exhaustively test that the service client libraries can handle inflating all types produced by the VM. Compare vm/cc/PrintJSON, which exhaustively tests the VM can generate any type.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52893
Change-Id: Id1f080656ef6e999e69f2ebb5b9961fa3b461e4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316862
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-01 20:34:21 +00:00
Ryan Macnak 79f1e70a32 [vm, reload] Fuse class/library forwarding with enum forwarding when there are no shape changes.
When there is a shape change, class/library forwarding remains fused with the instance forwarding, and enum forwarding happens in a separate become operation.

TEST=ci
Bug: https://github.com/flutter/flutter/issues/131446
Change-Id: Iff2aacc664fbfcbc39c6aabd3698b413d18671cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317521
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-01 19:36:50 +00:00
Ryan Macnak ff4ef0548c [vm, compiler] Refactor the A3/A4/A5 trick so it applies to EmitParamMoves.
This allows FfiCallInstr to accept constant inputs.

TEST=ci
Change-Id: I0436d4a54a5c95d4c6f6abb5215438fe72cf1042
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316721
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-01 17:01:41 +00:00
Ryan Macnak 3f41c1a3f0 [vm] Enable the background compiler under TSAN.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/39611
Change-Id: Ib90eefc3fb55026002ba5f122ea6d62623eac419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316491
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-01 16:11:40 +00:00
Ben Konyi 1f7384beb8 [ VM ] Ensure randomly generated IDs are valid JS integers
Fixes https://github.com/dart-lang/sdk/issues/53081

TEST=Service tests

Change-Id: I0aaf3843c3a186336f5b2a8ee1e9356dd19251b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317460
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-08-01 15:50:11 +00:00
Johnni Winther a76f4d5c34 [cfe] Rename InlineClass to ExtensionTypeDeclaration
This renames InlineClass to ExtensionTypeDeclaration, and InlineType
to ExtensionType. Members of extension type declarations are called
extension type members instead of extension type declaration members
for "brevity".

TEST=existing

Change-Id: I91ed62533ddd345644492f04dc3310d007460288
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316780
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-01 09:04:38 +00:00
Paul Berry 2b8411f626 Enable language feature inference-update-2.
This language feature allows type promotion to apply to private final
fields, e.g.:

    class C {
      final int? _x;
      C(this._x);
    }
    f(C c) {
      if (c._x != null) {
        print(c._x.abs()); // (1)
      }
    }

Previously the line marked (1) would have needed to be written
`print(c._x!.abs());`.

Note that to ensure soundness, there are certain restrictions:

- Public fields don't undergo promotion (because a public field might
  be overridden by a class in some other library).

- Non-final fields don't undergo promotion (because a non-final field
  might be modified as a side effect of code executed between the type
  test and the field's usage).

- Fields that are forwarded to `noSuchMethod` in the same library
  don't undergo promotion (because there's no guarantee that
  `noSuchMethod` will return the same value on every invocation). For
  example:

    class C {
      final int? _x;
      C(this._x);
    }
    class D implements C {
      @override
      noSuchMethod(...) => ...;
    }
    f(C c) {
      if (c._x != null) {
        print(c._x.abs()); // ERROR: `c._x` might dispatch to
                           // `D.noSuchMethod`, in which case there's
                           // no guarantee that it will return a
                           // non-null value the second time it's
                           // invoked.
      }
    }

- If two classes define fields or getters of the same name, and
  promotion is not permitted for one of them, then it isn't permitted
  for the other. This is because there might be a class in some other
  library that's a subclass of both classes, causing a reference to
  one field or getter to dispatch to the other. For example:

    class C {
      final int? _x;
      C(this._x);
    }
    class D {
      int? get _x => ...;
    }
    f(C c) {
      if (c._x != null) {
        print(c._x.abs()); // ERROR: `c._x` might dispatch to `D._x`
                           // (e.g. because some library might declare
                           // `class E extends D implements C`), in
                           // which case there's no guarantee that it
                           // will return a non-null value the second
                           // time it's invoked.
      }
    }

Change-Id: Ib9183581aa0194377e38ab70d37c3e9f0bb57a75
Bug: https://github.com/dart-lang/language/issues/2020
Tested: TAP global presubmit
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314600
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-28 23:56:52 +00:00
Martin Kustermann 23109940e0 [vm] Separate for-snapshot vs embed-sources bools when compiling to kernel
Fixes https://github.com/dart-lang/sdk/issues/53010

TEST=Fixes vm/dart/regress_48523_test

Change-Id: I2066ffd250228c01bb7aa2de5d1d0362ba6f7071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316581
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-28 10:01:53 +00:00
Alexander Markov e417cfb4ad [vm/compiler] Fix IL serialization of FFI trampolines
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/316160,
which introduced FFI trampoline callback functions without
FfiCallbackTarget, which caused mismatch between IL serialization and
deserialization code.

Fixes https://github.com/dart-lang/sdk/issues/53056
TEST=ffi/async_void_function_callbacks_test

Change-Id: I6bd23ac673fc0ea650d08786423dd34159232c8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316601
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-07-27 21:32:40 +00:00
Ryan Macnak cf9a8111bc [vm] Remove dead friend declarations.
TEST=ci
Change-Id: I0054c5057eb24e9117e7d80806270f694d8cbef8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316641
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-27 20:17:17 +00:00
Ryan Macnak 5b2aa424e5 [vm, gc] Card progress bars also need to be reset on an aborted scavenge.
Cf. cac1319768.

TEST=ci
Change-Id: I3545943071334b7c1114999ce8f4a77fe22718f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316602
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-27 19:27:46 +00:00
Johnni Winther bf9ea56ff7 [kernel] Remove nodes used for the old 'extension-types' experiment
This removes ExtensionType, ExtensionTypeShowHideClause and
CallSiteAccessKind from package:kernel which where only used by the now
removed 'extension-types' experiment.

A follow-up CL will rename InlineClass/InlineType to
ExtensionTypeDeclaration/ExtensionType to match the names of the
Extension Type feature currently being implemented.

TEST=existing

Change-Id: I58d2e8b0a92ac61329ee161cc6884a2c0e6f87ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-07-27 10:47:08 +00:00
Liam Appelbe edeac698c2 [vm/ffi] Closure callbacks for async callbacks
This change is almost trivial. The closure is stored on the callback's
RawReceivePort, not in the VM. So we can basically just remove the CFE
check and it pretty much works. The only problem is that we can't set
function.FfiCallbackTarget anymore, so most of the CL is dealing with
that.

A few places were deciding whether an FFI trampoline was a call or a
callback based on whether function.FfiCallbackTarget() was null. But
now the target will be null for async callbacks. So instead I've added
a new value to the FfiCallbackKind enum (and renamed it), and changed
those checks.

Sync callback closures will be a separate CL, because they're more
complicated.

Bug: https://github.com/dart-lang/sdk/issues/52689
Change-Id: I8e5dfb557362e679f66195b735c3c382e6792840
TEST=async_void_function_callbacks_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316160
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-07-26 23:23:26 +00:00
Ryan Macnak f2611b7c8e [vm] Update lingering references to RawObject.
TEST=ci
Change-Id: If01ff0f7a9b10dc4e6f6d3139bd421df9ecc9855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316528
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-26 21:53:49 +00:00
Ryan Macnak 5cf55de409 [vm, reload] Delay enum forwarding until after instance morphing.
Enum forwarding requires evaluating and canonicalizing the new enum instances. If these in turn refer to other instances of classes with shape changes, canonicalization may try to compare instances of the old and new shapes and dereference past the end of an object. By waiting for instance morphing to complete, canonicalization can only see instances with the new shape.

Also, don't attempt to forward Enum.values. When an enum member is added or removed, this has the same merging problem as 40442.

Cf. bad074cc49.

TEST=ci
Bug: https://github.com/flutter/flutter/issues/129177
Bug: https://github.com/dart-lang/sdk/issues/53039
Change-Id: Ib7a54db30c4d16a6ae6e1acd595dc7482134165b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316527
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-26 21:14:09 +00:00
Ryan Macnak bb9583bf99 [vm, reload] Fix assertion failure when instance morphing encounters a field value that is an already morphed instance.
TEST=ci
Change-Id: I0d04b92fafc7ccb655e67e1fa3805d00e92a7e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316488
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-26 20:47:25 +00:00
Ryan Macnak f8feb29a69 Revert "[vm, reload] Delay enum forwarding until after instance morphing."
This reverts commit 6ef967fb07.

Reason for revert: https://github.com/dart-lang/sdk/issues/53039

Original change's description:
> [vm, reload] Delay enum forwarding until after instance morphing.
>
> Enum forwarding requires evaluating and canonicalizing the new enum instances. If these in turn refer to other instances of classes with shape changes, canonicalization may try to compare instances of the old and new shapes and dereference past the end of an object. By waiting for instance morphing to complete, canonicalization can only see instances with the new shape.
>
> Also, don't attempt to forward Enum.values. When an enum member is added or removed, this has the same merging problem as 40442.
>
> Cf. bad074cc49.
>
> TEST=ci
> Bug: https://github.com/flutter/flutter/issues/129177
> Change-Id: I19d0508059bade8496000eeea257bb0730f11d17
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316041
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Bug: https://github.com/flutter/flutter/issues/129177
Change-Id: I8aa09be5d8fd72460ab26294ed94a5075135d48b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316501
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-07-26 18:13:42 +00:00
Derek Xu 0ba8d4ef77 [VM/Debugger] Fix the behaviour of setting inline breakpoints in uncompiled functions
TEST=pkg/vm_service/test/column_breakpoint_test.dart, other debugger
tests in tryjobs

Fixes: https://github.com/dart-lang/sdk/issues/51563
Change-Id: I87ef7e52cfc7e922904b267b7eb74fc783214b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-26 17:15:36 +00:00
Ryan Macnak cac1319768 [vm, gc] Run weak processing in parallel for new-space GCs.
Allow updating weak handles etc to happen in parallel with work-stealing.

Also make LocalBlockWorklist more symmetric with BlockWorklist.

Cf. 4495c2b30a

TEST=ci
Change-Id: Id58fe16be92028b1aa4dd8f097769b4107f2a3f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316043
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-26 16:45:01 +00:00
Ryan Macnak be5c3c123e [vm, gc] Record pending weaklings during minor GC without using next_seen_by_gc_.
Instead use external pointer block lists so that the same weakling can be pending for both minor and major GC at the same time. When we begin marking through new-space in major GCs, this will need to happen for weaklings in new-space. Once the pending lists are independent, it is easy to handle the reverse case. This also improves the promptness with which old-space weaklings with unreachable new-space targets are clear.

TEST=ci
Change-Id: I46a0a78eeae0210caad48a162c8d64a9af79e749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314863
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-25 16:32:15 +00:00
Ryan Macnak 6ef967fb07 [vm, reload] Delay enum forwarding until after instance morphing.
Enum forwarding requires evaluating and canonicalizing the new enum instances. If these in turn refer to other instances of classes with shape changes, canonicalization may try to compare instances of the old and new shapes and dereference past the end of an object. By waiting for instance morphing to complete, canonicalization can only see instances with the new shape.

Also, don't attempt to forward Enum.values. When an enum member is added or removed, this has the same merging problem as 40442.

Cf. bad074cc49.

TEST=ci
Bug: https://github.com/flutter/flutter/issues/129177
Change-Id: I19d0508059bade8496000eeea257bb0730f11d17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316041
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-25 15:40:22 +00:00
Alexander Thomas a3d48885e7 [release] Bump version on main to 3.2
Tested: CQ
Change-Id: I16210697b47dd85aec8743b457e773b044cab81f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316200
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-07-25 15:12:49 +00:00
asiva 08b76a50fc [VM/Runtime] - Turn on reachabilityBarrier in product mode.
Fixes https://github.com/dart-lang/leak_tracker/issues/25

TEST=ci (existing test has been turned on for product mode)

Change-Id: I8ead4924846947016998c9c8870b5a0c851f0185
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315981
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-24 22:44:39 +00:00
Ryan Macnak 8462db66b0 [vm, gc] Add tests for weakness across generations.
TEST=ci
Change-Id: I4bbe7ef47b8d8042eccc8f3d18521053cdc45d23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315000
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:55:47 +00:00
Ryan Macnak 41548aa698 [test] May rarely reach OOM without an aborted scavenge.
Whether the reordered objects fail to fit depends non-deterministically on the parallel worker speeds and the exact contents of new-space that vary with each VM or core library change.

Bug: https://github.com/dart-lang/sdk/issues/52936
Change-Id: I6e287d42b5ca77d2ffafd9a5a053118617d6fe51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313940
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-24 16:50:48 +00:00
Samuel Rawlins 008cb0bbc1 Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT"
This reverts commit a458bab09a.

Reason for revert: broke flutter snippet tests, and maybe customer tests

Work towards https://github.com/flutter/flutter/issues/131096

Original change's description:
> 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>

Change-Id: Ib0c9afc4911efd620013896fb895ab7825c50aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315940
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:25:07 +00:00
Martin Kustermann 8c60c4e70f [vm] Rewrite tools/offset_extractors.sh in Dart
Also

* Make C++ offset_extractor binaries emit entire if/def condition
  (including product vs non-product)
  => This makes it much nicer to look up offsets, as the preceding
     #if condition will be the whole condition.

* Run the builds & offset extractions in parallel

This will make it easier to extend the cross product of our
configurations that require different offsets (e.g. sanitizers)

TEST=Manually run.

Change-Id: I458deb7a1c9403ab3624dd6b6ca51df72d6a6b28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312442
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2023-07-24 12:47:52 +00:00
Martin Kustermann 11d820890e Use utf8.encode() instead of longer const Utf8Encoder.convert()
The change in [0] has propagated now everywhere, so we can use
`utf8.encode()` instead of the longer `const Utf8Encoder.convert()`.

As the checked-in SDK has been rolled to include [0] we can now rely on
the better return type.

[0] https://github.com/dart-lang/sdk/issues/52801

TEST=ci

CoreLibraryReviewExempt: Minor cleanup.
Change-Id: I2c0144023e03b2c265582d83a7fb9469b02f1570
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313563
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-24 09:28:38 +00:00
Ryan Macnak d29235cdb5 [vm] Speed up the ARM simulators.
Cf. 01a7f207c3.

TEST=ci
Change-Id: I8b6f9b827c1725d85013de70a1346303bdd9129e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283200
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-21 19:06:43 +00:00
Ryan Macnak cdddf869f2 [vm, compiler] Use acquire ordering to load the type arguments instantiation cache.
TEST=tsan
Change-Id: I6dea219ecb26949f01fc51b1c46fd53d3921aba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315246
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-21 17:13:31 +00:00
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