Commit 22282cab authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Fix WriteBarrierForRangeImpl to use the right marking barrier

Change-Id: Ic00ce0856d6ce3f9c6872fa7f35c469f7177c9c8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2807605
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73830}
parent f645d0b8
......@@ -18,6 +18,11 @@ namespace {
thread_local MarkingBarrier* current_marking_barrier = nullptr;
} // namespace
MarkingBarrier* WriteBarrier::CurrentMarkingBarrier(Heap* heap) {
return current_marking_barrier ? current_marking_barrier
: heap->marking_barrier();
}
void WriteBarrier::SetForThread(MarkingBarrier* marking_barrier) {
DCHECK_NULL(current_marking_barrier);
current_marking_barrier = marking_barrier;
......
......@@ -58,6 +58,8 @@ class V8_EXPORT_PRIVATE WriteBarrier {
static void SetForThread(MarkingBarrier*);
static void ClearForThread(MarkingBarrier*);
static MarkingBarrier* CurrentMarkingBarrier(Heap* heap);
private:
static void MarkingSlow(Heap* heap, HeapObject host, HeapObjectSlot,
HeapObject value);
......
......@@ -6656,7 +6656,7 @@ void Heap::WriteBarrierForRangeImpl(MemoryChunk* source_page, HeapObject object,
STATIC_ASSERT(!(kModeMask & kDoEvacuationSlotRecording) ||
(kModeMask & kDoMarking));
MarkingBarrier* marking_barrier = this->marking_barrier();
MarkingBarrier* marking_barrier = WriteBarrier::CurrentMarkingBarrier(this);
MarkCompactCollector* collector = this->mark_compact_collector();
for (TSlot slot = start_slot; slot < end_slot; ++slot) {
......
......@@ -13,6 +13,7 @@ namespace v8 {
namespace internal {
bool MarkingBarrier::MarkValue(HeapObject host, HeapObject value) {
DCHECK(IsCurrentMarkingBarrier());
DCHECK(is_activated_);
DCHECK(!marking_state_.IsImpossible(value));
// Host may have an impossible markbit pattern if manual allocation folding
......
......@@ -5,6 +5,7 @@
#include "src/heap/marking-barrier.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap-write-barrier.h"
#include "src/heap/heap.h"
#include "src/heap/incremental-marking-inl.h"
#include "src/heap/incremental-marking.h"
......@@ -37,6 +38,7 @@ MarkingBarrier::~MarkingBarrier() { DCHECK(worklist_.IsLocalEmpty()); }
void MarkingBarrier::Write(HeapObject host, HeapObjectSlot slot,
HeapObject value) {
DCHECK(IsCurrentMarkingBarrier());
if (MarkValue(host, value)) {
if (is_compacting_ && slot.address()) {
collector_->RecordSlot(host, slot, value);
......@@ -45,6 +47,7 @@ void MarkingBarrier::Write(HeapObject host, HeapObjectSlot slot,
}
void MarkingBarrier::Write(Code host, RelocInfo* reloc_info, HeapObject value) {
DCHECK(IsCurrentMarkingBarrier());
if (MarkValue(host, value)) {
if (is_compacting_) {
if (is_main_thread_barrier_) {
......@@ -60,6 +63,7 @@ void MarkingBarrier::Write(Code host, RelocInfo* reloc_info, HeapObject value) {
void MarkingBarrier::Write(JSArrayBuffer host,
ArrayBufferExtension* extension) {
DCHECK(IsCurrentMarkingBarrier());
if (!V8_CONCURRENT_MARKING_BOOL && !marking_state_.IsBlack(host)) {
// The extension will be marked when the marker visits the host object.
return;
......@@ -69,6 +73,7 @@ void MarkingBarrier::Write(JSArrayBuffer host,
void MarkingBarrier::Write(DescriptorArray descriptor_array,
int number_of_own_descriptors) {
DCHECK(IsCurrentMarkingBarrier());
DCHECK(is_main_thread_barrier_);
int16_t raw_marked = descriptor_array.raw_number_of_marked_descriptors();
if (NumberOfMarkedDescriptors::decode(collector_->epoch(), raw_marked) <
......@@ -80,6 +85,7 @@ void MarkingBarrier::Write(DescriptorArray descriptor_array,
void MarkingBarrier::RecordRelocSlot(Code host, RelocInfo* rinfo,
HeapObject target) {
DCHECK(IsCurrentMarkingBarrier());
MarkCompactCollector::RecordRelocSlotInfo info =
MarkCompactCollector::PrepareRecordRelocSlot(host, rinfo, target);
if (info.should_record) {
......@@ -204,5 +210,9 @@ void MarkingBarrier::Activate(bool is_compacting) {
}
}
bool MarkingBarrier::IsCurrentMarkingBarrier() {
return WriteBarrier::CurrentMarkingBarrier(heap_) == this;
}
} // namespace internal
} // namespace v8
......@@ -53,6 +53,8 @@ class MarkingBarrier {
void DeactivateSpace(PagedSpace*);
void DeactivateSpace(NewSpace*);
bool IsCurrentMarkingBarrier();
Heap* heap_;
MarkCompactCollector* collector_;
IncrementalMarking* incremental_marking_;
......
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