Commit 4526365f authored by ulan's avatar ulan Committed by Commit bot

Speed up clearing of old to new slots in dead objects.

Since we clear invalid slots eagerly, there is no need to check if a slot is a valid slot.

BUG=chromium:578883
LOG=NO

Review URL: https://codereview.chromium.org/1817523002

Cr-Commit-Position: refs/heads/master@{#34898}
parent 25cb0b4d
......@@ -2811,22 +2811,10 @@ static String* UpdateReferenceInExternalStringTableEntry(Heap* heap,
return String::cast(*p);
}
bool MarkCompactCollector::IsSlotInBlackObject(Page* p, Address slot,
HeapObject** out_object) {
bool MarkCompactCollector::IsSlotInBlackObject(MemoryChunk* p, Address slot) {
Space* owner = p->owner();
if (owner == heap_->lo_space() || owner == NULL) {
Object* large_object = heap_->lo_space()->FindObject(slot);
// This object has to exist, otherwise we would not have recorded a slot
// for it.
CHECK(large_object->IsHeapObject());
HeapObject* large_heap_object = HeapObject::cast(large_object);
if (IsMarked(large_heap_object)) {
*out_object = large_heap_object;
return true;
}
return false;
}
DCHECK(owner != heap_->lo_space() && owner != nullptr);
USE(owner);
// If we are on a black page, we cannot find the actual object start
// easiliy. We just return true but do not set the out_object.
......@@ -2906,7 +2894,6 @@ bool MarkCompactCollector::IsSlotInBlackObject(Page* p, Address slot,
// in a live object.
// Slots pointing to the first word of an object are invalid and removed.
// This can happen when we move the object header while left trimming.
*out_object = object;
return true;
}
return false;
......@@ -2953,27 +2940,6 @@ HeapObject* MarkCompactCollector::FindBlackObjectBySlotSlow(Address slot) {
}
bool MarkCompactCollector::IsSlotInLiveObject(Address slot) {
// The target object is black but we don't know if the source slot is black.
// The source object could have died and the slot could be part of a free
// space. Find out based on mark bits if the slot is part of a live object.
Page* page = Page::FromAddress(slot);
HeapObject* object = NULL;
if (!IsSlotInBlackObject(page, slot, &object)) {
return false;
}
// If the slot is on a black page, the object will be live.
DCHECK(object != NULL || page->IsFlagSet(Page::BLACK_PAGE));
if (page->IsFlagSet(Page::BLACK_PAGE)) {
return true;
}
int offset = static_cast<int>(slot - object->address());
return object->IsValidSlot(offset);
}
void MarkCompactCollector::EvacuateNewSpacePrologue() {
NewSpace* new_space = heap()->new_space();
NewSpacePageIterator it(new_space->bottom(), new_space->top());
......
......@@ -561,12 +561,11 @@ class MarkCompactCollector {
void InitializeMarkingDeque();
// The following four methods can just be called after marking, when the
// The following two methods can just be called after marking, when the
// whole transitive closure is known. They must be called before sweeping
// when mark bits are still intact.
bool IsSlotInBlackObject(Page* p, Address slot, HeapObject** out_object);
bool IsSlotInBlackObject(MemoryChunk* p, Address slot);
HeapObject* FindBlackObjectBySlotSlow(Address slot);
bool IsSlotInLiveObject(Address slot);
// Removes all the slots in the slot buffers that are within the given
// address range.
......
......@@ -22,9 +22,9 @@ void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) {
chunk = it.next();
SlotSet* slots = GetSlotSet(chunk);
if (slots != nullptr) {
slots->Iterate([heap](Address addr) {
slots->Iterate([heap, chunk](Address addr) {
Object** slot = reinterpret_cast<Object**>(addr);
return IsValidSlot(heap, slot) ? KEEP_SLOT : REMOVE_SLOT;
return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT;
});
}
}
......@@ -54,7 +54,8 @@ void RememberedSet<direction>::VerifyValidSlots(Heap* heap) {
}
template <PointerDirection direction>
bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) {
bool RememberedSet<direction>::IsValidSlot(Heap* heap, MemoryChunk* chunk,
Object** slot) {
STATIC_ASSERT(direction == OLD_TO_NEW);
Object* object = *slot;
if (!heap->InNewSpace(object)) {
......@@ -64,8 +65,8 @@ bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) {
// If the target object is not black, the source slot must be part
// of a non-black (dead) object.
return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) &&
heap->mark_compact_collector()->IsSlotInLiveObject(
reinterpret_cast<Address>(slot));
heap->mark_compact_collector()->IsSlotInBlackObject(
chunk, reinterpret_cast<Address>(slot));
}
template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap);
......
......@@ -236,7 +236,7 @@ class RememberedSet {
return REMOVE_SLOT;
}
static bool IsValidSlot(Heap* heap, Object** slot);
static bool IsValidSlot(Heap* heap, MemoryChunk* chunk, Object** slot);
};
// Buffer for keeping thead local migration slots during compaction.
......
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