[vm] If waiting for an active mutator slot for too long, steal a slot from a thread at a native safepoint.

The thread whose slot was stolen will take the slow path attempting to exit its safepoint and wait to reacquire an active mutator slot.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54687
Change-Id: I49c4c12b38d38d7afa4df6b346c2a464f75ef6e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406404
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Ryan Macnak
2025-02-10 09:38:42 -08:00
committed by Commit Queue
parent a78235cf01
commit 2a08770912
23 changed files with 254 additions and 97 deletions
+6
View File
@@ -436,6 +436,8 @@ void Thread::ExitIsolate(bool isolate_shutdown) {
isolate->scheduled_mutator_thread_ = nullptr;
ASSERT(!ActiveMutatorStolenField::decode(thread->safepoint_state_.load()));
// Right now we keep the [Thread] object across the isolate's lifetime. This
// makes entering/exiting quite fast as it mainly boils down to safepoint
// transitions. Though any operation that walks over all active threads will
@@ -1358,6 +1360,10 @@ void Thread::UnwindScopes(uword stack_marker) {
}
}
void Thread::HandleStolen() {
isolate_group()->ReincreaseMutatorCount(this);
}
void Thread::EnterSafepointUsingLock() {
isolate_group()->safepoint_handler()->EnterSafepointUsingLock(this);
}