[heap] Support safepoint->AssertActive() for shared isolates

Lock mutex for shared isolate in global safepoints, such that e.g. the
StringTable can use isolate->heap()->safepoint()->AssertActive() even
for shared isolates.

Bug: v8:11708, v8:12749
Change-Id: I8d99203581dfa2d7225846e19fa981300f88589e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3563138
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79715}
This commit is contained in:
Dominik Inführ 2022-04-01 11:51:11 +02:00 committed by V8 LUCI CQ
parent 182a82832c
commit 5bc471f47f
3 changed files with 8 additions and 6 deletions

View File

@ -358,6 +358,12 @@ void GlobalSafepoint::EnterGlobalSafepointScope(Isolate* initiator) {
initiator, &clients.back());
});
// Make it possible to use AssertActive() on shared isolates.
CHECK(shared_isolate_->heap()->safepoint()->local_heaps_mutex_.TryLock());
// Shared isolates should never have multiple threads.
shared_isolate_->heap()->safepoint()->AssertMainThreadIsOnlyThread();
// Iterate all clients again to initiate the safepoint for all of them - even
// if that means blocking.
for (PerClientSafepointData& client : clients) {
@ -381,6 +387,8 @@ void GlobalSafepoint::EnterGlobalSafepointScope(Isolate* initiator) {
}
void GlobalSafepoint::LeaveGlobalSafepointScope(Isolate* initiator) {
shared_isolate_->heap()->safepoint()->local_heaps_mutex_.Unlock();
IterateClientIsolates([initiator](Isolate* client) {
Heap* client_heap = client->heap();
client_heap->safepoint()->LeaveGlobalSafepointScope(initiator);

View File

@ -313,10 +313,6 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting(
// Test serialization.
{
GlobalSafepointScope global_safepoint(isolate);
base::Optional<SafepointScope> shared_isolate_safepoint_scope;
if (Isolate* shared_isolate = isolate->shared_isolate()) {
shared_isolate_safepoint_scope.emplace(shared_isolate->heap());
}
DisallowGarbageCollection no_gc;
Snapshot::SerializerFlags flags(

View File

@ -1456,8 +1456,6 @@
# Script referenced only through context-dependent SourceTextModule
# https://bugs.chromium.org/p/v8/issues/detail?id=11073
'tools/processor': [SKIP],
# https://crbug.com/v8/12749
'shared-memory/shared-struct-atomics-workers': [SKIP],
}], # variant == stress_snapshot and arch == x64
##############################################################################