Commit 5bc471f4 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[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/+/3563138Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79715}
parent 182a8283
...@@ -358,6 +358,12 @@ void GlobalSafepoint::EnterGlobalSafepointScope(Isolate* initiator) { ...@@ -358,6 +358,12 @@ void GlobalSafepoint::EnterGlobalSafepointScope(Isolate* initiator) {
initiator, &clients.back()); 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 // Iterate all clients again to initiate the safepoint for all of them - even
// if that means blocking. // if that means blocking.
for (PerClientSafepointData& client : clients) { for (PerClientSafepointData& client : clients) {
...@@ -381,6 +387,8 @@ void GlobalSafepoint::EnterGlobalSafepointScope(Isolate* initiator) { ...@@ -381,6 +387,8 @@ void GlobalSafepoint::EnterGlobalSafepointScope(Isolate* initiator) {
} }
void GlobalSafepoint::LeaveGlobalSafepointScope(Isolate* initiator) { void GlobalSafepoint::LeaveGlobalSafepointScope(Isolate* initiator) {
shared_isolate_->heap()->safepoint()->local_heaps_mutex_.Unlock();
IterateClientIsolates([initiator](Isolate* client) { IterateClientIsolates([initiator](Isolate* client) {
Heap* client_heap = client->heap(); Heap* client_heap = client->heap();
client_heap->safepoint()->LeaveGlobalSafepointScope(initiator); client_heap->safepoint()->LeaveGlobalSafepointScope(initiator);
......
...@@ -313,10 +313,6 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting( ...@@ -313,10 +313,6 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting(
// Test serialization. // Test serialization.
{ {
GlobalSafepointScope global_safepoint(isolate); 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; DisallowGarbageCollection no_gc;
Snapshot::SerializerFlags flags( Snapshot::SerializerFlags flags(
......
...@@ -1456,8 +1456,6 @@ ...@@ -1456,8 +1456,6 @@
# Script referenced only through context-dependent SourceTextModule # Script referenced only through context-dependent SourceTextModule
# https://bugs.chromium.org/p/v8/issues/detail?id=11073 # https://bugs.chromium.org/p/v8/issues/detail?id=11073
'tools/processor': [SKIP], 'tools/processor': [SKIP],
# https://crbug.com/v8/12749
'shared-memory/shared-struct-atomics-workers': [SKIP],
}], # variant == stress_snapshot and arch == x64 }], # variant == stress_snapshot and arch == x64
############################################################################## ##############################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment