Commit 51c62b3c authored by Adam Klein's avatar Adam Klein Committed by V8 LUCI CQ

Revert "[heap] Support client-to-shared refs in Code objects"

This reverts commit 12e46091.

Reason for revert: new test fails on GC stress bot:
https://cr-buildbucket.appspot.com/build/8823858142855002833

Original change's description:
> [heap] Support client-to-shared refs in Code objects
>
> Support references from code objects in the client heaps to shared heap objects. Such references are stored in a remembered set during marking, which is later used for updating pointers.
>
> Bug: v8:11708
> Change-Id: I8aeb508ddd14514ca65fa5acf3030dd8c2040168
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3401588
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Camillo Bruni <cbruni@chromium.org>
> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#78819}

Bug: v8:11708
Change-Id: If8d15a22651f8b1cfca61be21a81f60b43f008a4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3421725
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78821}
parent 84cf3230
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include "src/execution/vm-state-inl.h" #include "src/execution/vm-state-inl.h"
#include "src/flags/flags.h" #include "src/flags/flags.h"
#include "src/handles/maybe-handles.h" #include "src/handles/maybe-handles.h"
#include "src/heap/parked-scope.h"
#include "src/init/v8.h" #include "src/init/v8.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/logging/counters.h" #include "src/logging/counters.h"
...@@ -4621,12 +4620,6 @@ int Shell::RunMain(Isolate* isolate, bool last_run) { ...@@ -4621,12 +4620,6 @@ int Shell::RunMain(Isolate* isolate, bool last_run) {
} }
} }
CollectGarbage(isolate); CollectGarbage(isolate);
// Park the main thread here to prevent deadlocks in shared GCs when waiting
// in JoinThread.
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::ParkedScope parked(i_isolate->main_thread_local_isolate());
for (int i = 1; i < options.num_isolates; ++i) { for (int i = 1; i < options.num_isolates; ++i) {
if (last_run) { if (last_run) {
options.isolate_sources[i].JoinThread(); options.isolate_sources[i].JoinThread();
......
...@@ -2296,7 +2296,7 @@ void Heap::PerformSharedGarbageCollection(Isolate* initiator, ...@@ -2296,7 +2296,7 @@ void Heap::PerformSharedGarbageCollection(Isolate* initiator,
v8::Isolate::Scope isolate_scope(reinterpret_cast<v8::Isolate*>(isolate())); v8::Isolate::Scope isolate_scope(reinterpret_cast<v8::Isolate*>(isolate()));
const char* collector_reason = nullptr; const char* collector_reason = nullptr;
const GarbageCollector collector = GarbageCollector::MARK_COMPACTOR; GarbageCollector collector = GarbageCollector::MARK_COMPACTOR;
tracer()->Start(collector, gc_reason, collector_reason); tracer()->Start(collector, gc_reason, collector_reason);
...@@ -2308,22 +2308,11 @@ void Heap::PerformSharedGarbageCollection(Isolate* initiator, ...@@ -2308,22 +2308,11 @@ void Heap::PerformSharedGarbageCollection(Isolate* initiator,
// As long as we need to iterate the client heap to find references into the // As long as we need to iterate the client heap to find references into the
// shared heap, all client heaps need to be iterable. // shared heap, all client heaps need to be iterable.
client->heap()->MakeHeapIterable(); client->heap()->MakeHeapIterable();
if (FLAG_concurrent_marking) {
client->heap()->concurrent_marking()->Pause();
}
}); });
PerformGarbageCollection(collector); PerformGarbageCollection(GarbageCollector::MARK_COMPACTOR);
tracer()->Stop(collector); tracer()->Stop(collector);
isolate()->global_safepoint()->IterateClientIsolates([](Isolate* client) {
if (FLAG_concurrent_marking &&
client->heap()->incremental_marking()->IsMarking()) {
client->heap()->concurrent_marking()->RescheduleJobIfNeeded();
}
});
} }
void Heap::CompleteSweepingYoung(GarbageCollector collector) { void Heap::CompleteSweepingYoung(GarbageCollector collector) {
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "src/heap/marking-barrier.h" #include "src/heap/marking-barrier.h"
#include "src/heap/marking-visitor-inl.h" #include "src/heap/marking-visitor-inl.h"
#include "src/heap/marking-visitor.h" #include "src/heap/marking-visitor.h"
#include "src/heap/memory-chunk-layout.h"
#include "src/heap/memory-measurement-inl.h" #include "src/heap/memory-measurement-inl.h"
#include "src/heap/memory-measurement.h" #include "src/heap/memory-measurement.h"
#include "src/heap/object-stats.h" #include "src/heap/object-stats.h"
...@@ -1212,13 +1211,17 @@ class MarkCompactCollector::SharedHeapObjectVisitor final ...@@ -1212,13 +1211,17 @@ class MarkCompactCollector::SharedHeapObjectVisitor final
} }
void VisitCodeTarget(Code host, RelocInfo* rinfo) override { void VisitCodeTarget(Code host, RelocInfo* rinfo) override {
#if DEBUG
Code target = Code::GetCodeFromTargetAddress(rinfo->target_address()); Code target = Code::GetCodeFromTargetAddress(rinfo->target_address());
RecordRelocSlot(host, rinfo, target); DCHECK(!BasicMemoryChunk::FromHeapObject(target)->InSharedHeap());
#endif // DEBUG
} }
void VisitEmbeddedPointer(Code host, RelocInfo* rinfo) override { void VisitEmbeddedPointer(Code host, RelocInfo* rinfo) override {
#if DEBUG
HeapObject target = rinfo->target_object(cage_base()); HeapObject target = rinfo->target_object(cage_base());
RecordRelocSlot(host, rinfo, target); DCHECK(!BasicMemoryChunk::FromHeapObject(target)->InSharedHeap());
#endif // DEBUG
} }
private: private:
...@@ -1232,20 +1235,6 @@ class MarkCompactCollector::SharedHeapObjectVisitor final ...@@ -1232,20 +1235,6 @@ class MarkCompactCollector::SharedHeapObjectVisitor final
collector_->MarkObject(host, heap_object); collector_->MarkObject(host, heap_object);
} }
V8_INLINE void RecordRelocSlot(Code host, RelocInfo* rinfo,
HeapObject target) {
if (ShouldRecordRelocSlot(host, rinfo, target)) {
RecordRelocSlotInfo info = ProcessRelocInfo(host, rinfo, target);
RememberedSet<CLIENT_TO_SHARED>::InsertTyped(info.memory_chunk,
info.slot_type, info.offset);
}
}
V8_INLINE bool ShouldRecordRelocSlot(Code host, RelocInfo* rinfo,
HeapObject target) {
return BasicMemoryChunk::FromHeapObject(target)->InSharedHeap();
}
MarkCompactCollector* const collector_; MarkCompactCollector* const collector_;
}; };
...@@ -4577,8 +4566,6 @@ void MarkCompactCollector::UpdatePointersInClientHeap(Isolate* client) { ...@@ -4577,8 +4566,6 @@ void MarkCompactCollector::UpdatePointersInClientHeap(Isolate* client) {
while (chunk_iterator.HasNext()) { while (chunk_iterator.HasNext()) {
MemoryChunk* chunk = chunk_iterator.Next(); MemoryChunk* chunk = chunk_iterator.Next();
CodePageMemoryModificationScope unprotect_code_page(chunk);
RememberedSet<CLIENT_TO_SHARED>::Iterate( RememberedSet<CLIENT_TO_SHARED>::Iterate(
chunk, chunk,
[cage_base](MaybeObjectSlot slot) { [cage_base](MaybeObjectSlot slot) {
...@@ -4587,20 +4574,6 @@ void MarkCompactCollector::UpdatePointersInClientHeap(Isolate* client) { ...@@ -4587,20 +4574,6 @@ void MarkCompactCollector::UpdatePointersInClientHeap(Isolate* client) {
SlotSet::KEEP_EMPTY_BUCKETS); SlotSet::KEEP_EMPTY_BUCKETS);
chunk->ReleaseSlotSet<CLIENT_TO_SHARED>(); chunk->ReleaseSlotSet<CLIENT_TO_SHARED>();
RememberedSet<CLIENT_TO_SHARED>::IterateTyped(
chunk, [this](SlotType slot_type, Address slot) {
// Using UpdateStrongSlot is OK here, because there are no weak
// typed slots.
PtrComprCageBase cage_base = heap_->isolate();
return UpdateTypedSlotHelper::UpdateTypedSlot(
heap_, slot_type, slot, [cage_base](FullMaybeObjectSlot slot) {
return UpdateStrongSlot<AccessMode::NON_ATOMIC>(cage_base,
slot);
});
});
chunk->ReleaseTypedSlotSet<CLIENT_TO_SHARED>();
} }
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "src/heap/code-object-registry.h" #include "src/heap/code-object-registry.h"
#include "src/heap/memory-allocator.h" #include "src/heap/memory-allocator.h"
#include "src/heap/memory-chunk-inl.h" #include "src/heap/memory-chunk-inl.h"
#include "src/heap/memory-chunk-layout.h"
#include "src/heap/spaces.h" #include "src/heap/spaces.h"
#include "src/objects/heap-object.h" #include "src/objects/heap-object.h"
...@@ -134,8 +133,6 @@ MemoryChunk* MemoryChunk::Initialize(BasicMemoryChunk* basic_chunk, Heap* heap, ...@@ -134,8 +133,6 @@ MemoryChunk* MemoryChunk::Initialize(BasicMemoryChunk* basic_chunk, Heap* heap,
nullptr); nullptr);
base::AsAtomicPointer::Release_Store(&chunk->typed_slot_set_[OLD_TO_OLD], base::AsAtomicPointer::Release_Store(&chunk->typed_slot_set_[OLD_TO_OLD],
nullptr); nullptr);
base::AsAtomicPointer::Release_Store(
&chunk->typed_slot_set_[CLIENT_TO_SHARED], nullptr);
chunk->invalidated_slots_[OLD_TO_NEW] = nullptr; chunk->invalidated_slots_[OLD_TO_NEW] = nullptr;
chunk->invalidated_slots_[OLD_TO_OLD] = nullptr; chunk->invalidated_slots_[OLD_TO_OLD] = nullptr;
if (V8_EXTERNAL_CODE_SPACE_BOOL) { if (V8_EXTERNAL_CODE_SPACE_BOOL) {
...@@ -316,7 +313,6 @@ void MemoryChunk::ReleaseSlotSet(SlotSet** slot_set) { ...@@ -316,7 +313,6 @@ void MemoryChunk::ReleaseSlotSet(SlotSet** slot_set) {
template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_NEW>(); template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_NEW>();
template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_OLD>(); template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_OLD>();
template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<CLIENT_TO_SHARED>();
template <RememberedSetType type> template <RememberedSetType type>
TypedSlotSet* MemoryChunk::AllocateTypedSlotSet() { TypedSlotSet* MemoryChunk::AllocateTypedSlotSet() {
...@@ -333,7 +329,6 @@ TypedSlotSet* MemoryChunk::AllocateTypedSlotSet() { ...@@ -333,7 +329,6 @@ TypedSlotSet* MemoryChunk::AllocateTypedSlotSet() {
template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_NEW>(); template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_NEW>();
template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_OLD>(); template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_OLD>();
template void MemoryChunk::ReleaseTypedSlotSet<CLIENT_TO_SHARED>();
template <RememberedSetType type> template <RememberedSetType type>
void MemoryChunk::ReleaseTypedSlotSet() { void MemoryChunk::ReleaseTypedSlotSet() {
......
...@@ -1476,11 +1476,5 @@ RUNTIME_FUNCTION(Runtime_IsSharedString) { ...@@ -1476,11 +1476,5 @@ RUNTIME_FUNCTION(Runtime_IsSharedString) {
Handle<String>::cast(obj)->IsShared()); Handle<String>::cast(obj)->IsShared());
} }
RUNTIME_FUNCTION(Runtime_SharedGC) {
SealHandleScope scope(isolate);
isolate->heap()->CollectSharedGarbage(GarbageCollectionReason::kTesting);
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -545,7 +545,6 @@ namespace internal { ...@@ -545,7 +545,6 @@ namespace internal {
F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \ F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
F(SetForceSlowPath, 1, 1) \ F(SetForceSlowPath, 1, 1) \
F(SetIteratorProtector, 0, 1) \ F(SetIteratorProtector, 0, 1) \
F(SharedGC, 0, 1) \
F(SimulateNewspaceFull, 0, 1) \ F(SimulateNewspaceFull, 0, 1) \
F(StringIteratorProtector, 0, 1) \ F(StringIteratorProtector, 0, 1) \
F(SystemBreak, 0, 1) \ F(SystemBreak, 0, 1) \
......
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --shared-string-table --allow-natives-syntax --stress-compaction
function foo() { return "foo"; }
%PrepareFunctionForOptimization(foo);
let value = foo();
assertTrue(%IsSharedString(value));
%OptimizeFunctionOnNextCall(foo);
value = foo();
assertTrue(%IsSharedString(value));
%SharedGC();
value = foo();
assertTrue(%IsSharedString(value));
assertEquals("foo", value);
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