Commit 68c99479 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Remove markbits getter from raw address

BUG=651354

Review-Url: https://codereview.chromium.org/2638803002
Cr-Commit-Position: refs/heads/master@{#42397}
parent 98a19629
......@@ -3110,9 +3110,9 @@ AllocationResult Heap::AllocateBytecodeArray(int length,
return result;
}
void Heap::CreateFillerObjectAt(Address addr, int size,
ClearRecordedSlots mode) {
if (size == 0) return;
HeapObject* Heap::CreateFillerObjectAt(Address addr, int size,
ClearRecordedSlots mode) {
if (size == 0) return nullptr;
HeapObject* filler = HeapObject::FromAddress(addr);
if (size == kPointerSize) {
filler->set_map_no_write_barrier(
......@@ -3134,6 +3134,7 @@ void Heap::CreateFillerObjectAt(Address addr, int size,
// none of the maps have been created yet and are NULL.
DCHECK((filler->map() == NULL && !deserialization_complete_) ||
filler->map()->IsMap());
return filler;
}
......@@ -3160,7 +3161,7 @@ void Heap::AdjustLiveBytes(HeapObject* object, int by) {
lo_space()->AdjustLiveBytes(by);
} else if (!in_heap_iterator() &&
!mark_compact_collector()->sweeping_in_progress() &&
Marking::IsBlack(ObjectMarking::MarkBitFrom(object->address()))) {
Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) {
DCHECK(MemoryChunk::FromAddress(object->address())->SweepingDone());
MemoryChunk::IncrementLiveBytes(object, by);
}
......@@ -3196,8 +3197,10 @@ FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
// Transfer the mark bits to their new location if the object is not within
// a black area.
if (!incremental_marking()->black_allocation() ||
!Marking::IsBlack(ObjectMarking::MarkBitFrom(new_start))) {
IncrementalMarking::TransferMark(this, old_start, new_start);
!Marking::IsBlack(
ObjectMarking::MarkBitFrom(HeapObject::FromAddress(new_start)))) {
IncrementalMarking::TransferMark(this, object,
HeapObject::FromAddress(new_start));
}
// Technically in new space this write might be omitted (except for
......@@ -3208,7 +3211,7 @@ FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
// Clear the mark bits of the black area that belongs now to the filler.
// This is an optimization. The sweeper will release black fillers anyway.
if (incremental_marking()->black_allocation() &&
Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(old_start))) {
Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object))) {
Page* page = Page::FromAddress(old_start);
page->markbits()->ClearRange(
page->AddressToMarkbitIndex(old_start),
......@@ -3283,11 +3286,13 @@ void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) {
// TODO(hpayer): We should shrink the large object page if the size
// of the object changed significantly.
if (!lo_space()->Contains(object)) {
CreateFillerObjectAt(new_end, bytes_to_trim, ClearRecordedSlots::kYes);
HeapObject* filler =
CreateFillerObjectAt(new_end, bytes_to_trim, ClearRecordedSlots::kYes);
DCHECK_NOT_NULL(filler);
// Clear the mark bits of the black area that belongs now to the filler.
// This is an optimization. The sweeper will release black fillers anyway.
if (incremental_marking()->black_allocation() &&
Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(new_end))) {
Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(filler))) {
Page* page = Page::FromAddress(new_end);
page->markbits()->ClearRange(
page->AddressToMarkbitIndex(new_end),
......
......@@ -747,7 +747,8 @@ class Heap {
// when introducing gaps within pages. If slots could have been recorded in
// the freed area, then pass ClearRecordedSlots::kYes as the mode. Otherwise,
// pass ClearRecordedSlots::kNo.
void CreateFillerObjectAt(Address addr, int size, ClearRecordedSlots mode);
HeapObject* CreateFillerObjectAt(Address addr, int size,
ClearRecordedSlots mode);
bool CanMoveObjectStart(HeapObject* object);
......
......@@ -136,21 +136,21 @@ static void MarkObjectGreyDoNotEnqueue(Object* obj) {
}
}
void IncrementalMarking::TransferMark(Heap* heap, Address old_start,
Address new_start) {
void IncrementalMarking::TransferMark(Heap* heap, HeapObject* from,
HeapObject* to) {
// This is only used when resizing an object.
DCHECK(MemoryChunk::FromAddress(old_start) ==
MemoryChunk::FromAddress(new_start));
DCHECK(MemoryChunk::FromAddress(from->address()) ==
MemoryChunk::FromAddress(to->address()));
if (!heap->incremental_marking()->IsMarking()) return;
// If the mark doesn't move, we don't check the color of the object.
// It doesn't matter whether the object is black, since it hasn't changed
// size, so the adjustment to the live data count will be zero anyway.
if (old_start == new_start) return;
if (from == to) return;
MarkBit new_mark_bit = ObjectMarking::MarkBitFrom(new_start);
MarkBit old_mark_bit = ObjectMarking::MarkBitFrom(old_start);
MarkBit new_mark_bit = ObjectMarking::MarkBitFrom(to);
MarkBit old_mark_bit = ObjectMarking::MarkBitFrom(from);
#ifdef DEBUG
Marking::ObjectColor old_color = Marking::Color(old_mark_bit);
......@@ -162,8 +162,7 @@ void IncrementalMarking::TransferMark(Heap* heap, Address old_start,
return;
} else if (Marking::IsGrey(old_mark_bit)) {
Marking::GreyToWhite(old_mark_bit);
heap->incremental_marking()->WhiteToGreyAndPush(
HeapObject::FromAddress(new_start), new_mark_bit);
heap->incremental_marking()->WhiteToGreyAndPush(to, new_mark_bit);
heap->incremental_marking()->RestartIfNotMarking();
}
......@@ -808,8 +807,7 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
// them.
if (map_word.IsForwardingAddress()) {
HeapObject* dest = map_word.ToForwardingAddress();
if (Marking::IsBlack(ObjectMarking::MarkBitFrom(dest->address())))
continue;
if (Marking::IsBlack(ObjectMarking::MarkBitFrom(dest))) continue;
array[new_top] = dest;
new_top = ((new_top + 1) & mask);
DCHECK(new_top != marking_deque->bottom());
......
......@@ -184,7 +184,7 @@ class IncrementalMarking {
static void MarkBlack(HeapObject* object, int size);
static void TransferMark(Heap* heap, Address old_start, Address new_start);
static void TransferMark(Heap* heap, HeapObject* from, HeapObject* to);
// Returns true if the color transfer requires live bytes updating.
INLINE(static bool TransferColor(HeapObject* from, HeapObject* to,
......
......@@ -36,13 +36,10 @@ class RootMarkingVisitor;
class ObjectMarking : public AllStatic {
public:
INLINE(static MarkBit MarkBitFrom(Address addr)) {
MemoryChunk* p = MemoryChunk::FromAddress(addr);
return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr));
}
INLINE(static MarkBit MarkBitFrom(HeapObject* obj)) {
return MarkBitFrom(reinterpret_cast<Address>(obj));
V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj) {
const Address address = obj->address();
MemoryChunk* p = MemoryChunk::FromAddress(address);
return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(address));
}
static Marking::ObjectColor Color(HeapObject* obj) {
......
......@@ -6680,7 +6680,7 @@ TEST(ContinuousRightTrimFixedArrayInBlackArea) {
heap->RightTrimFixedArray(*array, 1);
HeapObject* filler = HeapObject::FromAddress(previous);
CHECK(filler->IsFiller());
CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(filler)));
// Trim 10 times by one, two, and three word.
for (int i = 1; i <= 3; i++) {
......@@ -6689,7 +6689,7 @@ TEST(ContinuousRightTrimFixedArrayInBlackArea) {
heap->RightTrimFixedArray(*array, i);
HeapObject* filler = HeapObject::FromAddress(previous);
CHECK(filler->IsFiller());
CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(filler)));
}
}
......
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