Skip to content

Commit ce9c2d3

Browse files
aamCommit Queue
authored andcommitted
Revert "[vm/shared] Ensure to iterate over mutators, rather than only isolates during deopt."
This reverts commit e5f6611. Reason for revert: isolate_group_bound_init_test failures on mac bots: https://dart-ci.appspot.com/log/vm-aot-mac-release-x64/vm-aot-mac-release-x64/4425/ffi/isolate_group_bound_init_test/2 Original change's description: > [vm/shared] Ensure to iterate over mutators, rather than only isolates during deopt. > > Iterating over only isolates ignores isolategroup-bound dart code. > > Fixes #61326 > TEST=isolate_group_bound_lazy_deopt_test > > Change-Id: Ic27679ab7eb37aa2ca703937355dc83d751e0054 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448254 > Reviewed-by: Slava Egorov <[email protected]> > Commit-Queue: Alexander Aprelev <[email protected]> No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Ieb04abbf1b4a7fbc7637e5a7c3a3dce2010f2101 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448602 Commit-Queue: Slava Egorov <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]> Reviewed-by: Slava Egorov <[email protected]> Bot-Commit: Rubber Stamper <[email protected]>
1 parent e5f6611 commit ce9c2d3

File tree

7 files changed

+3656
-3744
lines changed

7 files changed

+3656
-3744
lines changed

runtime/vm/compiler/runtime_offsets_extracted.h

Lines changed: 3627 additions & 3627 deletions
Large diffs are not rendered by default.

runtime/vm/heap/weak_code.cc

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "vm/object.h"
1212
#include "vm/runtime_entry.h"
1313
#include "vm/stack_frame.h"
14-
#include "vm/thread_registry.h"
1514

1615
namespace dart {
1716

@@ -56,22 +55,28 @@ void WeakCodeReferences::DisableCode(bool are_mutators_stopped) {
5655
auto isolate_group = IsolateGroup::Current();
5756
auto disable_code_fun = [&]() {
5857
Code& code = Code::Handle();
59-
isolate_group->ForEachMutatorAtASafepoint([&](Thread* thread) {
60-
DartFrameIterator iterator(
61-
thread, StackFrameIterator::kAllowCrossThreadIteration);
62-
StackFrame* frame = iterator.NextFrame();
63-
while (frame != nullptr) {
64-
if (!frame->is_interpreted()) {
65-
code = frame->LookupDartCode();
66-
67-
if (set.ContainsKey(code)) {
68-
ReportDeoptimization(code);
69-
DeoptimizeAt(thread, code, frame);
58+
isolate_group->ForEachIsolate(
59+
[&](Isolate* isolate) {
60+
auto mutator_thread = isolate->mutator_thread();
61+
if (mutator_thread == nullptr) {
62+
return;
7063
}
71-
}
72-
frame = iterator.NextFrame();
73-
}
74-
});
64+
DartFrameIterator iterator(
65+
mutator_thread, StackFrameIterator::kAllowCrossThreadIteration);
66+
StackFrame* frame = iterator.NextFrame();
67+
while (frame != nullptr) {
68+
if (!frame->is_interpreted()) {
69+
code = frame->LookupDartCode();
70+
71+
if (set.ContainsKey(code)) {
72+
ReportDeoptimization(code);
73+
DeoptimizeAt(mutator_thread, code, frame);
74+
}
75+
}
76+
frame = iterator.NextFrame();
77+
}
78+
},
79+
/*at_safepoint=*/true);
7580

7681
// Switch functions that use dependent code to unoptimized code.
7782
Object& owner = Object::Handle();

runtime/vm/isolate.cc

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ IsolateGroup::IsolateGroup(std::shared_ptr<IsolateGroupSource> source,
320320
thread_pool_(),
321321
isolates_lock_(new SafepointRwLock()),
322322
isolates_(),
323-
mutators_(),
324323
start_time_micros_(OS::GetCurrentMonotonicMicros()),
325324
is_system_isolate_group_(source->flags.is_system_isolate),
326325
random_(),
@@ -474,15 +473,13 @@ bool IsolateGroup::UnregisterIsolateDecrementCount() {
474473
return isolate_count_ == 0;
475474
}
476475

477-
void IsolateGroup::RegisterIsolateGroupMutator(Thread* mutator) {
476+
void IsolateGroup::RegisterIsolateGroupMutator() {
478477
SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
479-
mutators_.Append(mutator);
480478
group_mutator_count_++;
481479
}
482480

483-
void IsolateGroup::UnregisterIsolateGroupMutator(Thread* mutator) {
481+
void IsolateGroup::UnregisterIsolateGroupMutator() {
484482
SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
485-
mutators_.Remove(mutator);
486483
group_mutator_count_--;
487484
}
488485

@@ -2917,27 +2914,6 @@ Isolate* IsolateGroup::FirstIsolateLocked() const {
29172914
return isolates_.IsEmpty() ? nullptr : isolates_.First();
29182915
}
29192916

2920-
void IsolateGroup::ForEachMutatorAtASafepoint(
2921-
std::function<void(Thread* thread)> function) {
2922-
auto thread = Thread::Current();
2923-
ASSERT(thread->OwnsSafepoint() ||
2924-
(thread->task_kind() == Thread::kMutatorTask) ||
2925-
(thread->task_kind() == Thread::kMarkerTask) ||
2926-
(thread->task_kind() == Thread::kCompactorTask) ||
2927-
(thread->task_kind() == Thread::kScavengerTask) ||
2928-
(thread->task_kind() == Thread::kIncrementalCompactorTask));
2929-
for (Isolate* isolate : isolates_) {
2930-
auto thread = isolate->mutator_thread();
2931-
if (thread != nullptr) {
2932-
function(thread);
2933-
}
2934-
}
2935-
for (Thread* mutator : mutators_) {
2936-
ASSERT(mutator != nullptr);
2937-
function(mutator);
2938-
}
2939-
}
2940-
29412917
void IsolateGroup::RunWithStoppedMutatorsCallable(Callable* callable) {
29422918
auto thread = Thread::Current();
29432919
StoppedMutatorsScope stopped_mutators_scope(thread);

runtime/vm/isolate.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
374374
// Returns `true` if this was the last isolate and the caller is responsible
375375
// for deleting the isolate group.
376376
bool UnregisterIsolateDecrementCount();
377-
void RegisterIsolateGroupMutator(Thread* mutator);
378-
void UnregisterIsolateGroupMutator(Thread* mutator);
377+
void RegisterIsolateGroupMutator();
378+
void UnregisterIsolateGroupMutator();
379379

380380
bool ContainsOnlyOneIsolate();
381381

@@ -650,8 +650,6 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
650650
Isolate* FirstIsolate() const;
651651
Isolate* FirstIsolateLocked() const;
652652

653-
void ForEachMutatorAtASafepoint(std::function<void(Thread* thread)> function);
654-
655653
// Ensures mutators are stopped during execution of the provided function.
656654
//
657655
// If the current thread is the only mutator in the isolate group,
@@ -909,7 +907,6 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
909907
IntrusiveDList<Isolate> isolates_;
910908
RelaxedAtomic<Dart_Port> interrupt_port_ = ILLEGAL_PORT;
911909
intptr_t isolate_count_ = 0;
912-
IntrusiveDList<Thread> mutators_;
913910
intptr_t group_mutator_count_ = 0;
914911
bool initial_spawn_successful_ = false;
915912
Dart_LibraryTagHandler library_tag_handler_ = nullptr;

runtime/vm/thread.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,10 @@ void Thread::EnterIsolateGroupAsMutator(IsolateGroup* isolate_group,
537537
isolate_group->IncreaseMutatorCount(/*thread=*/nullptr,
538538
/*is_nested_reenter=*/true,
539539
/*was_stolen=*/false);
540+
isolate_group->RegisterIsolateGroupMutator();
541+
540542
Thread* thread = AddActiveThread(isolate_group, /*isolate=*/nullptr,
541543
kMutatorTask, bypass_safepoint);
542-
isolate_group->RegisterIsolateGroupMutator(thread);
543-
544544
RELEASE_ASSERT(thread != nullptr);
545545
// Even if [bypass_safepoint] is true, a thread may need mutator state (e.g.
546546
// parallel scavenger threads write to the [Thread]s storebuffer)
@@ -584,7 +584,7 @@ void Thread::ExitIsolateGroupAsMutator(bool bypass_safepoint) {
584584
SuspendThreadInternal(thread, VMTag::kInvalidTagId);
585585
auto group = thread->isolate_group();
586586
FreeActiveThread(thread, /*isolate=*/nullptr, bypass_safepoint);
587-
group->UnregisterIsolateGroupMutator(thread);
587+
group->UnregisterIsolateGroupMutator();
588588
group->DecreaseMutatorCount(/*is_nested_exit=*/true);
589589
}
590590

runtime/vm/thread.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "vm/handles.h"
2424
#include "vm/heap/pointer_block.h"
2525
#include "vm/heap/sampler.h"
26-
#include "vm/intrusive_dlist.h"
2726
#include "vm/os_thread.h"
2827
#include "vm/pending_deopts.h"
2928
#include "vm/random.h"
@@ -365,7 +364,7 @@ class MutatorThreadVisitor {
365364
// a thread is allocated by ThreadRegistry::GetFromFreelistLocked either
366365
// before entering an isolate or entering an isolate group, and destroyed
367366
// automatically when the underlying OS thread exits.
368-
class Thread : public ThreadState, public IntrusiveDListEntry<Thread> {
367+
class Thread : public ThreadState {
369368
public:
370369
// The kind of task this thread is performing. Sampled by the profiler.
371370
enum TaskKind {

tests/ffi/isolate_group_bound_lazy_deopt_test.dart

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)