[L] Change in dart/sdk[main]: [vm/shared] Introduce isolate event loop handling dart api.

0 views
Skip to first unread message

Alexander Aprelev (Gerrit)

unread,
Apr 1, 2026, 1:49:02 PMApr 1
to Alexander Aprelev, Slava Egorov, Ryan Macnak, Commit Queue, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Slava Egorov

Alexander Aprelev added 1 comment

Patchset-level comments
File-level comment, Patchset 12 (Latest):
Alexander Aprelev . resolved

Hi Slava, wanted to share with you what I have so far to check whether we are on the same page regarding the approach for dart implementation of isolate api.

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 12
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Ryan Macnak <rma...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Wed, 01 Apr 2026 17:48:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
Apr 13, 2026, 8:18:02 AMApr 13
to Alexander Aprelev, Ryan Macnak, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev

Slava Egorov added 11 comments

Patchset-level comments
File-level comment, Patchset 16 (Latest):
Slava Egorov . resolved

some initial comments

File runtime/lib/isolate.cc
Line 515, Patchset 16 (Latest): // TODO(aam): Ensure isolate group doesn't disappear after we exit,
Slava Egorov . unresolved

It should not disappear because we have a thread stack which uses it. That would be a serious bug if that could happen. We should block any sort of graceful shutdown for a group if there are threads like this.

Line 517, Patchset 16 (Latest): Thread::ExitIsolateGroupAsMutator(/*bypass_safepoint=*/false);
Slava Egorov . unresolved

It's a bit strange that we need to exit isolate group and then re-enter - especially given that we are creating a new isolate within the same isolate group.

I think we should not require exiting the whole group to create an isolate in it - though we should exit the current isolate.

Line 539, Patchset 16 (Latest):class BorrowScope {
Slava Egorov . unresolved

nit: `: public ValueObject`.
nit: consider `IsolateBorrowScope`.

Also this class needs a comment explaining what it does and what expectations we should have about its behavior.

Put this class into anonymous namespace if it is only used in this file.

Line 575, Patchset 16 (Latest):DEFINE_NATIVE_ENTRY(Isolate_shutdown_, 0, 1) {
Slava Egorov . unresolved

I wonder if we should call this `shutdownSync`?

Line 595, Patchset 16 (Latest):DEFINE_NATIVE_ENTRY(Isolate_runEventLoopSync_, 0, 1) {
Slava Egorov . unresolved

nit: We should make sure that we have tests covering situations where mutator slots are exhausted - the code to acquire target isolate should still continue to work correctly and we should not deadlock

Line 613, Patchset 16 (Latest): String::Handle(String::New("Failed to enter isolate in time"));
Slava Egorov . unresolved

Should this be "Reached timeout while trying to enter isolate"?

Line 622, Patchset 16 (Latest): Dart_Handle result_dart_handle = Dart_RunLoop();
Slava Egorov . unresolved

`Dart_RunLoop` actually runs loop on thread pool, while `runEventLoopSync` is intentionally specified to run on the current thread.

(Please also add a test to cover this requirement).

File runtime/vm/isolate.cc
Line 1409, Patchset 16 (Latest): case Isolate::kYieldMutatorMsg: {
Slava Egorov . unresolved

If this is an OOB message then it can be processed in the middle of the other normal message because we schedule an interrupt. I think this is problematic because it allows "unnatural" interleaving of Dart code. I would have expected that we send a normal priority message instead.

We probably want a test which checks that this does not happen.

File runtime/vm/thread.cc
Line 575, Patchset 16 (Latest): Thread* thread = nullptr;
Slava Egorov . unresolved

Should this just be

```
auto thread = suspended_thread;
if (thread != nullptr) {
// ...
}
```
File sdk/lib/isolate/isolate.dart
Line 836, Patchset 16 (Latest): /// Execute the given function in the context of the given isolate.
Slava Egorov . unresolved

nit: please take doc comments from the latest version off the proposal, I made updates based on Lasse's comments.

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 16
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Ryan Macnak <rma...@google.com>
Gerrit-Attention: Alexander Aprelev <a...@google.com>
Gerrit-Comment-Date: Mon, 13 Apr 2026 12:17:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
Apr 17, 2026, 12:35:17 AMApr 17
to Alexander Aprelev, Slava Egorov, Ryan Macnak, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Slava Egorov

Alexander Aprelev added 11 comments

Patchset-level comments
File-level comment, Patchset 24 (Latest):
Alexander Aprelev . resolved

thank you for taking a look, Slava!

File runtime/lib/isolate.cc
Line 515, Patchset 16: // TODO(aam): Ensure isolate group doesn't disappear after we exit,
Slava Egorov . resolved

It should not disappear because we have a thread stack which uses it. That would be a serious bug if that could happen. We should block any sort of graceful shutdown for a group if there are threads like this.

Alexander Aprelev

Yes, makes sense.

Line 517, Patchset 16: Thread::ExitIsolateGroupAsMutator(/*bypass_safepoint=*/false);
Slava Egorov . resolved

It's a bit strange that we need to exit isolate group and then re-enter - especially given that we are creating a new isolate within the same isolate group.

I think we should not require exiting the whole group to create an isolate in it - though we should exit the current isolate.

Alexander Aprelev

We are exiting isolate group as mutator. I don't think we can be expected to enter isolate (as mutator), which we do when we create new isolate, while still staying as mutator in isolate group, even if isolate is in the same group.

Line 539, Patchset 16:class BorrowScope {
Slava Egorov . resolved

nit: `: public ValueObject`.
nit: consider `IsolateBorrowScope`.

Also this class needs a comment explaining what it does and what expectations we should have about its behavior.

Put this class into anonymous namespace if it is only used in this file.

Alexander Aprelev

Done

Line 575, Patchset 16:DEFINE_NATIVE_ENTRY(Isolate_shutdown_, 0, 1) {
Slava Egorov . resolved

I wonder if we should call this `shutdownSync`?

Alexander Aprelev

Done

Line 595, Patchset 16:DEFINE_NATIVE_ENTRY(Isolate_runEventLoopSync_, 0, 1) {
Slava Egorov . resolved

nit: We should make sure that we have tests covering situations where mutator slots are exhausted - the code to acquire target isolate should still continue to work correctly and we should not deadlock

Alexander Aprelev

Done

Line 613, Patchset 16: String::Handle(String::New("Failed to enter isolate in time"));
Slava Egorov . resolved

Should this be "Reached timeout while trying to enter isolate"?

Alexander Aprelev

Done

Line 622, Patchset 16: Dart_Handle result_dart_handle = Dart_RunLoop();
Slava Egorov . resolved

`Dart_RunLoop` actually runs loop on thread pool, while `runEventLoopSync` is intentionally specified to run on the current thread.

(Please also add a test to cover this requirement).

Alexander Aprelev

Ah, I see. Let me work on it a separate cl.

File runtime/vm/isolate.cc
Line 1409, Patchset 16: case Isolate::kYieldMutatorMsg: {
Slava Egorov . resolved

If this is an OOB message then it can be processed in the middle of the other normal message because we schedule an interrupt. I think this is problematic because it allows "unnatural" interleaving of Dart code. I would have expected that we send a normal priority message instead.

We probably want a test which checks that this does not happen.

Alexander Aprelev

Done

File runtime/vm/thread.cc
Line 575, Patchset 16: Thread* thread = nullptr;
Slava Egorov . resolved

Should this just be

```
auto thread = suspended_thread;
if (thread != nullptr) {
// ...
}
```
Alexander Aprelev

Done

File sdk/lib/isolate/isolate.dart
Line 836, Patchset 16: /// Execute the given function in the context of the given isolate.
Slava Egorov . resolved

nit: please take doc comments from the latest version off the proposal, I made updates based on Lasse's comments.

Alexander Aprelev

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 24
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Ryan Macnak <rma...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Fri, 17 Apr 2026 04:35:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
Apr 21, 2026, 10:06:14 AMApr 21
to Alexander Aprelev, Ryan Macnak, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev

Slava Egorov added 1 comment

File runtime/lib/isolate.cc
Line 611, Patchset 25 (Latest):DEFINE_NATIVE_ENTRY(Isolate_runSync_, 1, 3) {
Slava Egorov . unresolved

I think this needs to handle the following cases better:

  • We are doing `runSync` on the current isolate - should just happen.
  • We are dong `runSync` on an isolate which is pinned to the current thread - should just happen.
  • We are doing `runSync` on the isolate which is pinned to some other thread - should error
  • We are doing `runSync` on an isolate which does not have event loop running - we need to decide what this means, but probably it means we need to acquire its ownership, run the code and then release ownership.

All of this needs correponding tests.

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 25
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Ryan Macnak <rma...@google.com>
Gerrit-Attention: Alexander Aprelev <a...@google.com>
Gerrit-Comment-Date: Tue, 21 Apr 2026 14:06:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
Apr 21, 2026, 3:50:22 PMApr 21
to Alexander Aprelev, Slava Egorov, Ryan Macnak, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Slava Egorov

Alexander Aprelev added 1 comment

File runtime/lib/isolate.cc
Line 611, Patchset 25:DEFINE_NATIVE_ENTRY(Isolate_runSync_, 1, 3) {
Slava Egorov . unresolved

I think this needs to handle the following cases better:

  • We are doing `runSync` on the current isolate - should just happen.
  • We are dong `runSync` on an isolate which is pinned to the current thread - should just happen.
  • We are doing `runSync` on the isolate which is pinned to some other thread - should error
  • We are doing `runSync` on an isolate which does not have event loop running - we need to decide what this means, but probably it means we need to acquire its ownership, run the code and then release ownership.

All of this needs correponding tests.

Alexander Aprelev

Is there something particular you have in mind regarding handling those cases better?

Pinned-functionality is not implemented yet, it's not part of this CL.
Otherwise case 1 is tested by testRunRunOnCurrentIsolate, case 4 - by testRunOnCooperatingIsolate, testRunOnNonCooperatingIsolate in threading_test.dart.

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 26
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Ryan Macnak <rma...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Tue, 21 Apr 2026 19:50:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
Apr 22, 2026, 4:39:40 AMApr 22
to Alexander Aprelev, Ryan Macnak, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev and Ryan Macnak

Slava Egorov added 7 comments

Patchset-level comments
File-level comment, Patchset 27 (Latest):
Slava Egorov . resolved

I would like somebody else (in addition to me) to look at this - because it is very subtle code.

I have kinda persuaded myself that this implementation looks reasonable, but maybe we need more eyes.

So I am adding @rma...@google.com as a reviewer.

File runtime/lib/isolate.cc
Line 611, Patchset 25:DEFINE_NATIVE_ENTRY(Isolate_runSync_, 1, 3) {
Slava Egorov . unresolved

I think this needs to handle the following cases better:

  • We are doing `runSync` on the current isolate - should just happen.
  • We are dong `runSync` on an isolate which is pinned to the current thread - should just happen.
  • We are doing `runSync` on the isolate which is pinned to some other thread - should error
  • We are doing `runSync` on an isolate which does not have event loop running - we need to decide what this means, but probably it means we need to acquire its ownership, run the code and then release ownership.

All of this needs correponding tests.

Alexander Aprelev

Is there something particular you have in mind regarding handling those cases better?

Pinned-functionality is not implemented yet, it's not part of this CL.
Otherwise case 1 is tested by testRunRunOnCurrentIsolate, case 4 - by testRunOnCooperatingIsolate, testRunOnNonCooperatingIsolate in threading_test.dart.

Slava Egorov

I would like `Isolate.current.runSync` to be short-ciricuited so that we don't do any dances with entering/exiting/borrowing.

Ack regarding pinning functionality. Though note that some notion of pinning already exists (see `Dart_SetCurrentThreadOwnsIsolate` and its implementation plus my comment about it above) so we need to respect it here.

Ignore my comment about event loop - I realized that I misread the code. The message we are sending serves as an "interruption" for event loop, but we are not required to run an event loop to borrow the isolate.

File runtime/vm/isolate.h
Line 1747, Patchset 27 (Latest): OSThread* owner_tag_ = 0;
Slava Egorov . unresolved

This needs to be unified with `owner_thread_` / `Isolate::SetOwnerThread`, etc. We can't have multiple different notions of ownership.

Line 1285, Patchset 27 (Latest): bool EnsureOwnership(intptr_t timeout_ms = Monitor::kNoTimeout);
Slava Egorov . unresolved

Better name `TryAcquireOwnership` (because it can fail).

Maybe document that it can only fail if timeout is supplied.

File runtime/vm/isolate.cc
Line 1414, Patchset 27 (Latest): ASSERT(priority == Isolate::kAsEventAction);
Slava Egorov . unresolved

Why do we need this dance? Can be just post message like that from the very beginning? It feels strange that we need to post message as OOB first, which then reposts itself as normal message?

(I can see that this is copied from other places - but I think other places are also basically wrong).

Line 3855, Patchset 27 (Latest):void Isolate::HandleBorrowRequests() {
Slava Egorov . unresolved

It's a bit concerning that worker thread is completely blocked while doing this. I would have imagined that we stop handling messages and return worker thread back to the pool.

Line 3902, Patchset 27 (Latest): {
Slava Egorov . unresolved

I wonder if this should have a CompareExchange based fast path for fast acquisition of ownership?

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
  • Ryan Macnak
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 27
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Wed, 22 Apr 2026 08:39:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alexander Aprelev <a...@google.com>
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
Apr 23, 2026, 1:36:32 PMApr 23
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev added 3 comments

File runtime/vm/isolate.h
Line 1747, Patchset 27: OSThread* owner_tag_ = 0;
Slava Egorov . unresolved

This needs to be unified with `owner_thread_` / `Isolate::SetOwnerThread`, etc. We can't have multiple different notions of ownership.

Alexander Aprelev

`owner_thread_`/`SetOwnerThread` enforces constraint that only one thread can even own isolate through isolate's lifetime. This ownership does not have such constraint as different unrelated threads can borrow isolate and run dart code on it. It might be that this infrastructure should stay away from "owner" terminology.

Line 1285, Patchset 27: bool EnsureOwnership(intptr_t timeout_ms = Monitor::kNoTimeout);
Slava Egorov . resolved

Better name `TryAcquireOwnership` (because it can fail).

Maybe document that it can only fail if timeout is supplied.

Alexander Aprelev

Done

File runtime/vm/isolate.cc
Line 1414, Patchset 27: ASSERT(priority == Isolate::kAsEventAction);
Slava Egorov . resolved

Why do we need this dance? Can be just post message like that from the very beginning? It feels strange that we need to post message as OOB first, which then reposts itself as normal message?

(I can see that this is copied from other places - but I think other places are also basically wrong).

Alexander Aprelev

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 28
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Thu, 23 Apr 2026 17:36:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
Apr 24, 2026, 3:59:33 PMApr 24
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev voted and added 2 comments

Votes added by Alexander Aprelev

Commit-Queue+1

2 comments

File runtime/lib/isolate.cc
Line 611, Patchset 25:DEFINE_NATIVE_ENTRY(Isolate_runSync_, 1, 3) {
Slava Egorov . unresolved

I think this needs to handle the following cases better:

  • We are doing `runSync` on the current isolate - should just happen.
  • We are dong `runSync` on an isolate which is pinned to the current thread - should just happen.
  • We are doing `runSync` on the isolate which is pinned to some other thread - should error
  • We are doing `runSync` on an isolate which does not have event loop running - we need to decide what this means, but probably it means we need to acquire its ownership, run the code and then release ownership.

All of this needs correponding tests.

Alexander Aprelev

Is there something particular you have in mind regarding handling those cases better?

Pinned-functionality is not implemented yet, it's not part of this CL.
Otherwise case 1 is tested by testRunRunOnCurrentIsolate, case 4 - by testRunOnCooperatingIsolate, testRunOnNonCooperatingIsolate in threading_test.dart.

Slava Egorov

I would like `Isolate.current.runSync` to be short-ciricuited so that we don't do any dances with entering/exiting/borrowing.

Ack regarding pinning functionality. Though note that some notion of pinning already exists (see `Dart_SetCurrentThreadOwnsIsolate` and its implementation plus my comment about it above) so we need to respect it here.

Ignore my comment about event loop - I realized that I misread the code. The message we are sending serves as an "interruption" for event loop, but we are not required to run an event loop to borrow the isolate.

Alexander Aprelev

Provided fast-path for `Isolate.current.runSync`.

File runtime/vm/isolate.cc
Line 3902, Patchset 27: {
Slava Egorov . resolved

I wonder if this should have a CompareExchange based fast path for fast acquisition of ownership?

Alexander Aprelev

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 30
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Fri, 24 Apr 2026 19:59:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
Apr 27, 2026, 11:23:12 PMApr 27
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev voted and added 1 comment

Votes added by Alexander Aprelev

Commit-Queue+1

1 comment

File runtime/vm/isolate.cc
Line 3855, Patchset 27:void Isolate::HandleBorrowRequests() {
Slava Egorov . resolved

It's a bit concerning that worker thread is completely blocked while doing this. I would have imagined that we stop handling messages and return worker thread back to the pool.

Alexander Aprelev

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 31
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Tue, 28 Apr 2026 03:23:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Ryan Macnak (Gerrit)

unread,
Apr 29, 2026, 8:06:29 PM (14 days ago) Apr 29
to Alexander Aprelev, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev and Slava Egorov

Ryan Macnak added 5 comments

File runtime/lib/isolate.cc
Line 531, Patchset 31 (Latest): send_port = SendPort::New(created_isolate->main_port());
Ryan Macnak . unresolved

also provide origin_id

Line 632, Patchset 31 (Latest): StackZone stack_zone(current_thread);
HandleScope hs(current_thread);
Ryan Macnak . unresolved

Unneeded

Line 666, Patchset 31 (Latest): result = DartEntry::InvokeClosure(thread, args, args_desc);
Ryan Macnak . unresolved

current_thread

Line 683, Patchset 31 (Latest): if (result.IsUnwindError()) {
Ryan Macnak . unresolved

If we did the current-isolate shortcut, maybe we should just propagate the unwind error. Otherwise Dart code has the power to veto VM shutdown, which it didn't have before.

File sdk/lib/_internal/vm/lib/isolate_patch.dart
Line 736, Patchset 31 (Latest): static Isolate create({String? debugName}) {
Ryan Macnak . unresolved

spawnFunction also has

```
bool paused = false,
bool errorsAreFatal = true,
SendPort? onExit,
SendPort? onError,
```

should those also be available here?

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 31
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Alexander Aprelev <a...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Thu, 30 Apr 2026 00:06:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
Apr 30, 2026, 4:50:44 PM (13 days ago) Apr 30
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev voted and added 6 comments

Votes added by Alexander Aprelev

Commit-Queue+1

6 comments

Patchset-level comments
File-level comment, Patchset 32 (Latest):
Alexander Aprelev . resolved

thank you for taking a look!

File runtime/lib/isolate.cc
Line 531, Patchset 31: send_port = SendPort::New(created_isolate->main_port());
Ryan Macnak . resolved

also provide origin_id

Alexander Aprelev

Done

Line 632, Patchset 31: StackZone stack_zone(current_thread);
HandleScope hs(current_thread);
Ryan Macnak . resolved

Unneeded

Alexander Aprelev

Done

Line 666, Patchset 31: result = DartEntry::InvokeClosure(thread, args, args_desc);
Ryan Macnak . resolved

current_thread

Alexander Aprelev

Done

Line 683, Patchset 31: if (result.IsUnwindError()) {
Ryan Macnak . resolved

If we did the current-isolate shortcut, maybe we should just propagate the unwind error. Otherwise Dart code has the power to veto VM shutdown, which it didn't have before.

Alexander Aprelev

Done

File sdk/lib/_internal/vm/lib/isolate_patch.dart
Line 736, Patchset 31: static Isolate create({String? debugName}) {
Ryan Macnak . unresolved

spawnFunction also has

```
bool paused = false,
bool errorsAreFatal = true,
SendPort? onExit,
SendPort? onError,
```

should those also be available here?

Alexander Aprelev

These seems to be properties of isolates message handler, which might not exist for this isolate - user might just have created this isolate with intent of only running some sequential synchronous code via Isolate::runSync, without running event loop handler.

Open in Gerrit

Related details

Attention is currently required from:
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 32
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Thu, 30 Apr 2026 20:50:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Ryan Macnak <rma...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
May 5, 2026, 5:48:30 PM (8 days ago) May 5
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev added 1 comment

Patchset-level comments
Alexander Aprelev . unresolved

There are flaky reload-bot failures https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8682610591257958737/+/u/find_ignored_flaky_test_failure_logs/raw_io.output_text due to failing (GC) stack walking assert that `fp_` is in the expected range due to the fact that thread might get switched during kernel compile request as part of IsolateLeaveScope that happens as part of native port creation and closing. `fp_` is remembered when runtime call to `DN_Isolate_runSync` is made. So it's done before isolate/osthread are released by `IsolateLeaveScope`, and if we end up with a new osthread after kernel compilation, we will get this assert failing. I'm thinking we should remove IsolateLeaveScope from Dart_NewConcurrentNativePort/Dart_CloseNativePort, Dart_InvokeVMServiceMethod, remove check `Isolate::Current() == nullptr` from `NativeMessageHandler::CheckAccess`

Gerrit-Comment-Date: Tue, 05 May 2026 21:48:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
May 6, 2026, 6:43:25 PM (7 days ago) May 6
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev added 1 comment

Patchset-level comments
File-level comment, Patchset 32:
Alexander Aprelev . resolved

There are flaky reload-bot failures https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8682610591257958737/+/u/find_ignored_flaky_test_failure_logs/raw_io.output_text due to failing (GC) stack walking assert that `fp_` is in the expected range due to the fact that thread might get switched during kernel compile request as part of IsolateLeaveScope that happens as part of native port creation and closing. `fp_` is remembered when runtime call to `DN_Isolate_runSync` is made. So it's done before isolate/osthread are released by `IsolateLeaveScope`, and if we end up with a new osthread after kernel compilation, we will get this assert failing. I'm thinking we should remove IsolateLeaveScope from Dart_NewConcurrentNativePort/Dart_CloseNativePort, Dart_InvokeVMServiceMethod, remove check `Isolate::Current() == nullptr` from `NativeMessageHandler::CheckAccess`

Open in Gerrit

Related details

Attention is currently required from:
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 33
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Wed, 06 May 2026 22:43:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alexander Aprelev <a...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
May 7, 2026, 5:17:13 PM (6 days ago) May 7
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Ryan Macnak and Slava Egorov

Alexander Aprelev added 1 comment

File runtime/lib/isolate.cc
Line 611, Patchset 25:DEFINE_NATIVE_ENTRY(Isolate_runSync_, 1, 3) {
Slava Egorov . resolved

I think this needs to handle the following cases better:

  • We are doing `runSync` on the current isolate - should just happen.
  • We are dong `runSync` on an isolate which is pinned to the current thread - should just happen.
  • We are doing `runSync` on the isolate which is pinned to some other thread - should error
  • We are doing `runSync` on an isolate which does not have event loop running - we need to decide what this means, but probably it means we need to acquire its ownership, run the code and then release ownership.

All of this needs correponding tests.

Alexander Aprelev

Is there something particular you have in mind regarding handling those cases better?

Pinned-functionality is not implemented yet, it's not part of this CL.
Otherwise case 1 is tested by testRunRunOnCurrentIsolate, case 4 - by testRunOnCooperatingIsolate, testRunOnNonCooperatingIsolate in threading_test.dart.

Slava Egorov

I would like `Isolate.current.runSync` to be short-ciricuited so that we don't do any dances with entering/exiting/borrowing.

Ack regarding pinning functionality. Though note that some notion of pinning already exists (see `Dart_SetCurrentThreadOwnsIsolate` and its implementation plus my comment about it above) so we need to respect it here.

Ignore my comment about event loop - I realized that I misread the code. The message we are sending serves as an "interruption" for event loop, but we are not required to run an event loop to borrow the isolate.

Alexander Aprelev

Provided fast-path for `Isolate.current.runSync`.

Alexander Aprelev

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 34
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Thu, 07 May 2026 21:17:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alexander Aprelev <a...@google.com>
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Kevin Moore (Gerrit)

unread,
May 7, 2026, 7:55:49 PM (6 days ago) May 7
to Alexander Aprelev, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev, Ryan Macnak and Slava Egorov

Kevin Moore added 2 comments

Patchset-level comments
File-level comment, Patchset 34 (Latest):
Kevin Moore . resolved

Are we going to ship this as stable/supported in v3.13? If so we should document these additions in the changelog, too!

File sdk/lib/isolate/isolate.dart
Line 855, Patchset 34 (Latest): external R runSync<R>(R Function() f, {Duration? timeout});
Kevin Moore . unresolved

We should add @Since annotations here, right?

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 34
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Kevin Moore <kev...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Thu, 07 May 2026 23:55:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
May 8, 2026, 9:48:29 AM (5 days ago) May 8
to Alexander Aprelev, Kevin Moore, Ryan Macnak, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev, Kevin Moore and Ryan Macnak

Slava Egorov added 2 comments

Patchset-level comments
Kevin Moore . resolved

Are we going to ship this as stable/supported in v3.13? If so we should document these additions in the changelog, too!

Slava Egorov

This is not decided so not CHANGELOG.md updates as of yet.

File runtime/vm/isolate.h
Line 1747, Patchset 27: OSThread* owner_tag_ = 0;
Slava Egorov . unresolved

This needs to be unified with `owner_thread_` / `Isolate::SetOwnerThread`, etc. We can't have multiple different notions of ownership.

Alexander Aprelev

`owner_thread_`/`SetOwnerThread` enforces constraint that only one thread can even own isolate through isolate's lifetime. This ownership does not have such constraint as different unrelated threads can borrow isolate and run dart code on it. It might be that this infrastructure should stay away from "owner" terminology.

Slava Egorov

I have spend more time thinking about this, and I have arrived to the conclusion that we should unify it and only allow one owner (and no borrowing for such isolates) in the newly added APIs as well, e.g. we enforce the following invariants:

  • If isolate has an event loop running or has message related callbacks installed - you can't borrow it. Can only communicate with it asynchronously.
  • If isolate has owner thread - you can't borrow it from another thread. You can only message it asynchronously.
  • Otherwise - you can temporary borrow it and enter from different threads. These are like mutexes - a thread needs to fully release a mutex for another thread to be able to enter that isolate.

I think, not only this makes it easier to reason about things, but this also makes implementation much simpler overall - this will allow you to delete a lot of code that causes complexity in this CL.

WDYT?

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
  • Kevin Moore
  • Ryan Macnak
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 37
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Kevin Moore <kev...@google.com>
Gerrit-Attention: Alexander Aprelev <a...@google.com>
Gerrit-Attention: Kevin Moore <kev...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Fri, 08 May 2026 13:48:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alexander Aprelev <a...@google.com>
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
Comment-In-Reply-To: Kevin Moore <kev...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Aprelev (Gerrit)

unread,
May 8, 2026, 12:04:55 PM (5 days ago) May 8
to Alexander Aprelev, Kevin Moore, Ryan Macnak, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Kevin Moore, Ryan Macnak and Slava Egorov

Alexander Aprelev added 1 comment

File runtime/vm/isolate.h
Line 1747, Patchset 27: OSThread* owner_tag_ = 0;
Slava Egorov . unresolved

This needs to be unified with `owner_thread_` / `Isolate::SetOwnerThread`, etc. We can't have multiple different notions of ownership.

Alexander Aprelev

`owner_thread_`/`SetOwnerThread` enforces constraint that only one thread can even own isolate through isolate's lifetime. This ownership does not have such constraint as different unrelated threads can borrow isolate and run dart code on it. It might be that this infrastructure should stay away from "owner" terminology.

Slava Egorov

I have spend more time thinking about this, and I have arrived to the conclusion that we should unify it and only allow one owner (and no borrowing for such isolates) in the newly added APIs as well, e.g. we enforce the following invariants:

  • If isolate has an event loop running or has message related callbacks installed - you can't borrow it. Can only communicate with it asynchronously.
  • If isolate has owner thread - you can't borrow it from another thread. You can only message it asynchronously.
  • Otherwise - you can temporary borrow it and enter from different threads. These are like mutexes - a thread needs to fully release a mutex for another thread to be able to enter that isolate.

I think, not only this makes it easier to reason about things, but this also makes implementation much simpler overall - this will allow you to delete a lot of code that causes complexity in this CL.

WDYT?

Alexander Aprelev

It will simplify the implementation, yes. The most interesting case I can think of that will become impossible is doing `runSync` on regular `Isolate.spawn`-isolates since they always have an event loop running.
Whether this use case is important for the potential users - not sure.
Borrowing the way how it's implemented is rather general, but yes, its interaction with existing vm infrastructure (the way how vm exits/enters isolate at various points) makes implementation complicated. Holding mutex for duration of `runSync` sounds much simpler.

Open in Gerrit

Related details

Attention is currently required from:
  • Kevin Moore
  • Ryan Macnak
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 37
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Kevin Moore <kev...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Kevin Moore <kev...@google.com>
Gerrit-Attention: Ryan Macnak <rma...@google.com>
Gerrit-Comment-Date: Fri, 08 May 2026 16:04:51 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Ryan Macnak (Gerrit)

unread,
May 12, 2026, 7:25:43 PM (14 hours ago) May 12
to Alexander Aprelev, Kevin Moore, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, Ben Konyi, dart-dc-te...@google.com, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Alexander Aprelev, Kevin Moore and Slava Egorov

Ryan Macnak added 1 comment

File runtime/lib/isolate.cc
Line 631, Patchset 32: StackZone stack_zone(current_thread);
Ryan Macnak . unresolved

A stack zone was just created for this native function and is mostly empty at this point, so there's no benefit in starting a new stack zone here.

Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Aprelev
  • Kevin Moore
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Gerrit-Change-Number: 486522
Gerrit-PatchSet: 37
Gerrit-Owner: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Alexander Aprelev <a...@google.com>
Gerrit-Reviewer: Ryan Macnak <rma...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Ben Konyi <bko...@google.com>
Gerrit-CC: Kevin Moore <kev...@google.com>
Gerrit-Attention: Alexander Aprelev <a...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Kevin Moore <kev...@google.com>
Gerrit-Comment-Date: Tue, 12 May 2026 23:25:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages