@@ -537,9 +537,9 @@ void Thread::EnterIsolateGroupAsMutator(IsolateGroup* isolate_group,
537
537
isolate_group->IncreaseMutatorCount (/* thread=*/ nullptr ,
538
538
/* is_nested_reenter=*/ true ,
539
539
/* was_stolen=*/ false );
540
+ isolate_group->IncrementIsolateGroupMutatorCount ();
540
541
Thread* thread = AddActiveThread (isolate_group, /* isolate=*/ nullptr ,
541
542
kMutatorTask , bypass_safepoint);
542
- isolate_group->RegisterIsolateGroupMutator (thread);
543
543
544
544
RELEASE_ASSERT (thread != nullptr );
545
545
// Even if [bypass_safepoint] is true, a thread may need mutator state (e.g.
@@ -583,8 +583,8 @@ void Thread::ExitIsolateGroupAsMutator(bool bypass_safepoint) {
583
583
thread->ClearStackLimit ();
584
584
SuspendThreadInternal (thread, VMTag::kInvalidTagId );
585
585
auto group = thread->isolate_group ();
586
- group->UnregisterIsolateGroupMutator (thread);
587
586
FreeActiveThread (thread, /* isolate=*/ nullptr , bypass_safepoint);
587
+ group->DecrementIsolateGroupMutatorCount ();
588
588
group->DecreaseMutatorCount (/* is_nested_exit=*/ true );
589
589
}
590
590
@@ -693,9 +693,12 @@ Thread* Thread::AddActiveThread(IsolateGroup* group,
693
693
thread->isolate_ = isolate; // May be nullptr.
694
694
thread->isolate_group_ = group;
695
695
thread->scheduled_dart_mutator_isolate_ = isolate;
696
- if (isolate != nullptr && task_kind == kMutatorTask ) {
697
- ASSERT (thread_registry->threads_lock ()->IsOwnedByCurrentThread ());
698
- isolate->mutator_thread_ = thread;
696
+ if (task_kind == kMutatorTask ) {
697
+ if (isolate != nullptr ) {
698
+ isolate->mutator_thread_ = thread;
699
+ } else {
700
+ group->RegisterIsolateGroupMutator (thread);
701
+ }
699
702
}
700
703
701
704
// We start at being at-safepoint (in case any safepoint operation is
@@ -750,9 +753,12 @@ void Thread::FreeActiveThread(Thread* thread,
750
753
thread->isolate_ = nullptr ;
751
754
thread->isolate_group_ = nullptr ;
752
755
thread->scheduled_dart_mutator_isolate_ = nullptr ;
753
- if (isolate != nullptr && thread->task_kind () == kMutatorTask ) {
754
- ASSERT (thread_registry->threads_lock ()->IsOwnedByCurrentThread ());
755
- isolate->mutator_thread_ = nullptr ;
756
+ if (thread->task_kind () == kMutatorTask ) {
757
+ if (isolate != nullptr ) {
758
+ isolate->mutator_thread_ = nullptr ;
759
+ } else {
760
+ group->UnregisterIsolateGroupMutator (thread);
761
+ }
756
762
}
757
763
thread->set_execution_state (Thread::kThreadInNative );
758
764
thread->stack_limit_ .store (0 );
0 commit comments