Commit 62f2e7e8 authored by hpayer's avatar hpayer Committed by Commit bot

Revert "[heap] Temporarily use old live object iterator to investigate Win 10 memory regression."

This reverts commit d2cf6e29.

BUG=chromium:633537

Review-Url: https://codereview.chromium.org/2207383002
Cr-Commit-Position: refs/heads/master@{#38328}
parent 13d2feef
......@@ -148,25 +148,66 @@ HeapObject* LiveObjectIterator<T>::Next() {
second_bit_index = 0x1;
// The overlapping case; there has to exist a cell after the current
// cell.
DCHECK(!it_.Done());
// However, if there is a black area at the end of the page, and the
// last word is a one word filler, we are not allowed to advance. In
// that case we can return immediately.
if (it_.Done()) {
DCHECK(HeapObject::FromAddress(addr)->map() ==
HeapObject::FromAddress(addr)
->GetHeap()
->one_pointer_filler_map());
return nullptr;
}
it_.Advance();
cell_base_ = it_.CurrentCellBase();
current_cell_ = *it_.CurrentCell();
}
if (T == kBlackObjects && (current_cell_ & second_bit_index)) {
object = HeapObject::FromAddress(addr);
} else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) {
object = HeapObject::FromAddress(addr);
} else if (T == kAllLiveObjects) {
object = HeapObject::FromAddress(addr);
if (current_cell_ & second_bit_index) {
// We found a black object. If the black object is within a black area,
// make sure that we skip all set bits in the black area until the
// object ends.
HeapObject* black_object = HeapObject::FromAddress(addr);
Address end = addr + black_object->Size() - kPointerSize;
// One word filler objects do not borrow the second mark bit. We have
// to jump over the advancing and clearing part.
// Note that we know that we are at a one word filler when
// object_start + object_size - kPointerSize == object_start.
if (addr != end) {
DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end));
uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end);
unsigned int end_cell_index =
end_mark_bit_index >> Bitmap::kBitsPerCellLog2;
MarkBit::CellType end_index_mask =
1u << Bitmap::IndexInCell(end_mark_bit_index);
if (it_.Advance(end_cell_index)) {
cell_base_ = it_.CurrentCellBase();
current_cell_ = *it_.CurrentCell();
}
// Clear the second bit of the found object.
current_cell_ &= ~second_bit_index;
// Clear all bits in current_cell, including the end index.
current_cell_ &= ~(end_index_mask | (end_index_mask - 1));
}
if (T == kBlackObjects || T == kAllLiveObjects) {
object = black_object;
}
} else if ((T == kGreyObjects || T == kAllLiveObjects)) {
object = HeapObject::FromAddress(addr);
}
// We found a live object.
if (object != nullptr) break;
if (object != nullptr) {
if (object->IsFiller()) {
// Black areas together with slack tracking may result in black filler
// objects. We filter these objects out in the iterator.
object = nullptr;
} else {
break;
}
}
}
if (current_cell_ == 0) {
if (!it_.Done()) {
it_.Advance();
......
......@@ -6828,6 +6828,164 @@ TEST(Regress615489) {
CHECK_LE(size_after, size_before);
}
TEST(LeftTrimFixedArrayInBlackArea) {
FLAG_black_allocation = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Heap* heap = CcTest::heap();
Isolate* isolate = heap->isolate();
heap->CollectAllGarbage();
i::MarkCompactCollector* collector = heap->mark_compact_collector();
i::IncrementalMarking* marking = heap->incremental_marking();
if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted();
}
CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
CHECK(marking->IsMarking());
marking->StartBlackAllocationForTesting();
// Ensure that we allocate a new page, set up a bump pointer area, and
// perform the allocation in a black area.
heap::SimulateFullSpace(heap->old_space());
isolate->factory()->NewFixedArray(4, TENURED);
Handle<FixedArray> array = isolate->factory()->NewFixedArray(50, TENURED);
CHECK(heap->old_space()->Contains(*array));
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
// Now left trim the allocated black area. A filler has to be installed
// for the trimmed area and all mark bits of the trimmed area have to be
// cleared.
FixedArrayBase* trimmed = heap->LeftTrimFixedArray(*array, 10);
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
heap::GcAndSweep(heap, OLD_SPACE);
}
TEST(ContinuousLeftTrimFixedArrayInBlackArea) {
FLAG_black_allocation = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Heap* heap = CcTest::heap();
Isolate* isolate = heap->isolate();
heap->CollectAllGarbage();
i::MarkCompactCollector* collector = heap->mark_compact_collector();
i::IncrementalMarking* marking = heap->incremental_marking();
if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted();
}
CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
CHECK(marking->IsMarking());
marking->StartBlackAllocationForTesting();
// Ensure that we allocate a new page, set up a bump pointer area, and
// perform the allocation in a black area.
heap::SimulateFullSpace(heap->old_space());
isolate->factory()->NewFixedArray(10, TENURED);
// Allocate the fixed array that will be trimmed later.
Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED);
Address start_address = array->address();
Address end_address = start_address + array->Size();
Page* page = Page::FromAddress(start_address);
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
CHECK(page->markbits()->AllBitsSetInRange(
page->AddressToMarkbitIndex(start_address),
page->AddressToMarkbitIndex(end_address)));
CHECK(heap->old_space()->Contains(*array));
FixedArrayBase* previous = *array;
FixedArrayBase* trimmed;
// First trim in one word steps.
for (int i = 0; i < 10; i++) {
trimmed = heap->LeftTrimFixedArray(previous, 1);
HeapObject* filler = HeapObject::FromAddress(previous->address());
CHECK(filler->IsFiller());
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
previous = trimmed;
}
// Then trim in two and three word steps.
for (int i = 2; i <= 3; i++) {
for (int j = 0; j < 10; j++) {
trimmed = heap->LeftTrimFixedArray(previous, i);
HeapObject* filler = HeapObject::FromAddress(previous->address());
CHECK(filler->IsFiller());
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
previous = trimmed;
}
}
heap::GcAndSweep(heap, OLD_SPACE);
}
TEST(ContinuousRightTrimFixedArrayInBlackArea) {
FLAG_black_allocation = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Heap* heap = CcTest::heap();
Isolate* isolate = heap->isolate();
heap->CollectAllGarbage();
i::MarkCompactCollector* collector = heap->mark_compact_collector();
i::IncrementalMarking* marking = heap->incremental_marking();
if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted();
}
CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
CHECK(marking->IsMarking());
marking->StartBlackAllocationForTesting();
// Ensure that we allocate a new page, set up a bump pointer area, and
// perform the allocation in a black area.
heap::SimulateFullSpace(heap->old_space());
isolate->factory()->NewFixedArray(10, TENURED);
// Allocate the fixed array that will be trimmed later.
Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED);
Address start_address = array->address();
Address end_address = start_address + array->Size();
Page* page = Page::FromAddress(start_address);
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
CHECK(page->markbits()->AllBitsSetInRange(
page->AddressToMarkbitIndex(start_address),
page->AddressToMarkbitIndex(end_address)));
CHECK(heap->old_space()->Contains(*array));
// Trim it once by one word to make checking for white marking color uniform.
Address previous = end_address - kPointerSize;
heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, 1);
HeapObject* filler = HeapObject::FromAddress(previous);
CHECK(filler->IsFiller());
CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
// Trim 10 times by one, two, and three word.
for (int i = 1; i <= 3; i++) {
for (int j = 0; j < 10; j++) {
previous -= kPointerSize * i;
heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, i);
HeapObject* filler = HeapObject::FromAddress(previous);
CHECK(filler->IsFiller());
CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
}
}
heap::GcAndSweep(heap, OLD_SPACE);
}
TEST(Regress618958) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
......
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