Skip to content

Commit 7c9ded3

Browse files
aamCommit Queue
authored andcommitted
[vm] Avoid mutex lock when clearing catch entry cache.
Fixes #60535 TEST=iso_stress_linux ci Change-Id: I8f7c6faf23645f6e35b9abdf5b5e8a3684879624 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422346 Commit-Queue: Alexander Aprelev <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent c178c66 commit 7c9ded3

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

runtime/vm/heap/heap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ void Heap::CollectOldSpaceGarbage(Thread* thread,
546546

547547
// Some Code objects may have been collected so invalidate handler cache.
548548
thread->isolate_group()->handler_info_cache()->Clear();
549-
thread->isolate_group()->ClearCatchEntryMovesCache();
549+
thread->isolate_group()->ClearCatchEntryMovesCacheLocked();
550550
assume_scavenge_will_fail_ = false;
551551
}
552552
}

runtime/vm/isolate.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,14 @@ void IsolateGroup::RunWithCachedCatchEntryMoves(
947947
}
948948
}
949949

950-
void IsolateGroup::ClearCatchEntryMovesCache() {
951-
SafepointMutexLocker ml(&cache_mutex_);
950+
void IsolateGroup::ClearCatchEntryMovesCacheLocked() {
951+
auto thread = Thread::Current();
952+
ASSERT(thread->OwnsSafepoint() ||
953+
(thread->task_kind() == Thread::kMutatorTask) ||
954+
(thread->task_kind() == Thread::kMarkerTask) ||
955+
(thread->task_kind() == Thread::kCompactorTask) ||
956+
(thread->task_kind() == Thread::kScavengerTask) ||
957+
(thread->task_kind() == Thread::kIncrementalCompactorTask));
952958
catch_entry_moves_cache_.Clear();
953959
}
954960

runtime/vm/isolate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
780780
const Code& code,
781781
intptr_t pc,
782782
std::function<void(const CatchEntryMoves&)> action);
783-
void ClearCatchEntryMovesCache();
783+
void ClearCatchEntryMovesCacheLocked();
784784

785785
void SetNativeAssetsCallbacks(NativeAssetsApi* native_assets_api) {
786786
native_assets_api_ = *native_assets_api;

0 commit comments

Comments
 (0)