Commit e741957a authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Minor MC cleanups

BUG=chromium:651354

Change-Id: Ie9d39306c3baf2462ea5eee4f5a5ff436912744e
Reviewed-on: https://chromium-review.googlesource.com/458423Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44077}
parent 9b152fda
...@@ -2336,9 +2336,6 @@ void MinorMarkCompactCollector::MarkLiveObjects() { ...@@ -2336,9 +2336,6 @@ void MinorMarkCompactCollector::MarkLiveObjects() {
RootMarkingVisitor root_visitor(this); RootMarkingVisitor root_visitor(this);
marking_deque()->StartUsing(); marking_deque()->StartUsing();
for (Page* p : heap()->new_space()->to_space()) {
p->AllocateExternalBitmap();
}
isolate()->global_handles()->IdentifyWeakUnmodifiedObjects( isolate()->global_handles()->IdentifyWeakUnmodifiedObjects(
&Heap::IsUnmodifiedHeapObject); &Heap::IsUnmodifiedHeapObject);
...@@ -2383,11 +2380,6 @@ void MinorMarkCompactCollector::MarkLiveObjects() { ...@@ -2383,11 +2380,6 @@ void MinorMarkCompactCollector::MarkLiveObjects() {
ProcessMarkingDeque(); ProcessMarkingDeque();
} }
// TODO(mlippautz): External bitmap should be deallocated after evacuation.
for (Page* p : PageRange(heap()->new_space()->FromSpaceStart(),
heap()->new_space()->FromSpaceEnd())) {
p->ReleaseExternalBitmap();
}
marking_deque()->StopUsing(); marking_deque()->StopUsing();
} }
...@@ -2987,8 +2979,8 @@ static inline SlotCallbackResult UpdateSlot(Object** slot) { ...@@ -2987,8 +2979,8 @@ static inline SlotCallbackResult UpdateSlot(Object** slot) {
reinterpret_cast<base::AtomicWord*>(slot), reinterpret_cast<base::AtomicWord*>(slot),
reinterpret_cast<base::AtomicWord>(obj), reinterpret_cast<base::AtomicWord>(obj),
reinterpret_cast<base::AtomicWord>(target)); reinterpret_cast<base::AtomicWord>(target));
DCHECK(!heap_obj->GetHeap()->InFromSpace(target) && DCHECK(!heap_obj->GetHeap()->InFromSpace(target));
!MarkCompactCollector::IsOnEvacuationCandidate(target)); DCHECK(!MarkCompactCollector::IsOnEvacuationCandidate(target));
} }
} }
return REMOVE_SLOT; return REMOVE_SLOT;
...@@ -3047,8 +3039,9 @@ void MarkCompactCollector::EvacuatePrologue() { ...@@ -3047,8 +3039,9 @@ void MarkCompactCollector::EvacuatePrologue() {
new_space->ResetAllocationInfo(); new_space->ResetAllocationInfo();
// Old space. // Old space.
CHECK(old_space_evacuation_pages_.is_empty()); DCHECK(old_space_evacuation_pages_.is_empty());
old_space_evacuation_pages_.Swap(&evacuation_candidates_); old_space_evacuation_pages_.Swap(&evacuation_candidates_);
DCHECK(evacuation_candidates_.is_empty());
} }
void MarkCompactCollector::EvacuateEpilogue() { void MarkCompactCollector::EvacuateEpilogue() {
...@@ -3170,7 +3163,7 @@ class FullEvacuator : public Evacuator { ...@@ -3170,7 +3163,7 @@ class FullEvacuator : public Evacuator {
bool FullEvacuator::EvacuatePage(Page* page, const MarkingState& state) { bool FullEvacuator::EvacuatePage(Page* page, const MarkingState& state) {
bool success = false; bool success = false;
DCHECK(page->SweepingDone()); DCHECK(page->SweepingDone());
int saved_live_bytes = *state.live_bytes; intptr_t saved_live_bytes = *state.live_bytes;
double evacuation_time = 0.0; double evacuation_time = 0.0;
{ {
AlwaysAllocateScope always_allocate(heap()->isolate()); AlwaysAllocateScope always_allocate(heap()->isolate());
...@@ -3232,7 +3225,7 @@ bool FullEvacuator::EvacuatePage(Page* page, const MarkingState& state) { ...@@ -3232,7 +3225,7 @@ bool FullEvacuator::EvacuatePage(Page* page, const MarkingState& state) {
PrintIsolate(heap()->isolate(), PrintIsolate(heap()->isolate(),
"evacuation[%p]: page=%p new_space=%d " "evacuation[%p]: page=%p new_space=%d "
"page_evacuation=%d executable=%d contains_age_mark=%d " "page_evacuation=%d executable=%d contains_age_mark=%d "
"live_bytes=%d time=%f\n", "live_bytes=%" V8PRIdPTR " time=%f\n",
static_cast<void*>(this), static_cast<void*>(page), static_cast<void*>(this), static_cast<void*>(page),
page->InNewSpace(), page->InNewSpace(),
page->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION) || page->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION) ||
......
...@@ -45,7 +45,7 @@ class MarkingState { ...@@ -45,7 +45,7 @@ class MarkingState {
chunk->live_bytes_address<MarkingMode::YOUNG_GENERATION>()); chunk->live_bytes_address<MarkingMode::YOUNG_GENERATION>());
} }
MarkingState(Bitmap* bitmap, int* live_bytes) MarkingState(Bitmap* bitmap, intptr_t* live_bytes)
: bitmap(bitmap), live_bytes(live_bytes) {} : bitmap(bitmap), live_bytes(live_bytes) {}
void IncrementLiveBytes(intptr_t by) const { void IncrementLiveBytes(intptr_t by) const {
...@@ -61,7 +61,7 @@ class MarkingState { ...@@ -61,7 +61,7 @@ class MarkingState {
} }
Bitmap* bitmap; Bitmap* bitmap;
int* live_bytes; intptr_t* live_bytes;
}; };
// TODO(mlippautz): Remove duplicate accessors once the architecture for // TODO(mlippautz): Remove duplicate accessors once the architecture for
......
...@@ -180,6 +180,10 @@ Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable, ...@@ -180,6 +180,10 @@ Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable,
Page* page = static_cast<Page*>(chunk); Page* page = static_cast<Page*>(chunk);
heap->incremental_marking()->SetNewSpacePageFlags(page); heap->incremental_marking()->SetNewSpacePageFlags(page);
page->AllocateLocalTracker(); page->AllocateLocalTracker();
if (FLAG_minor_mc) {
page->AllocateYoungGenerationBitmap();
page->ClearLiveness<MarkingMode::YOUNG_GENERATION>();
}
return page; return page;
} }
......
...@@ -538,7 +538,6 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size, ...@@ -538,7 +538,6 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->mutex_ = new base::Mutex(); chunk->mutex_ = new base::Mutex();
chunk->available_in_free_list_ = 0; chunk->available_in_free_list_ = 0;
chunk->wasted_memory_ = 0; chunk->wasted_memory_ = 0;
chunk->ResetLiveBytes();
chunk->ClearLiveness(); chunk->ClearLiveness();
chunk->young_generation_bitmap_ = nullptr; chunk->young_generation_bitmap_ = nullptr;
chunk->set_next_chunk(nullptr); chunk->set_next_chunk(nullptr);
...@@ -1120,7 +1119,7 @@ void MemoryChunk::ReleaseAllocatedMemory() { ...@@ -1120,7 +1119,7 @@ void MemoryChunk::ReleaseAllocatedMemory() {
ReleaseTypedSlotSet<OLD_TO_NEW>(); ReleaseTypedSlotSet<OLD_TO_NEW>();
ReleaseTypedSlotSet<OLD_TO_OLD>(); ReleaseTypedSlotSet<OLD_TO_OLD>();
if (local_tracker_ != nullptr) ReleaseLocalTracker(); if (local_tracker_ != nullptr) ReleaseLocalTracker();
if (young_generation_bitmap_ != nullptr) ReleaseExternalBitmap(); if (young_generation_bitmap_ != nullptr) ReleaseYoungGenerationBitmap();
} }
static SlotSet* AllocateAndInitializeSlotSet(size_t size, Address page_start) { static SlotSet* AllocateAndInitializeSlotSet(size_t size, Address page_start) {
...@@ -1198,23 +1197,26 @@ void MemoryChunk::ReleaseLocalTracker() { ...@@ -1198,23 +1197,26 @@ void MemoryChunk::ReleaseLocalTracker() {
local_tracker_ = nullptr; local_tracker_ = nullptr;
} }
void MemoryChunk::AllocateExternalBitmap() { void MemoryChunk::AllocateYoungGenerationBitmap() {
DCHECK_NULL(young_generation_bitmap_); DCHECK_NULL(young_generation_bitmap_);
young_generation_bitmap_ = static_cast<Bitmap*>(calloc(1, Bitmap::kSize)); young_generation_bitmap_ = static_cast<Bitmap*>(calloc(1, Bitmap::kSize));
young_generation_live_byte_count_ = 0;
} }
void MemoryChunk::ReleaseExternalBitmap() { void MemoryChunk::ReleaseYoungGenerationBitmap() {
DCHECK_NOT_NULL(young_generation_bitmap_); DCHECK_NOT_NULL(young_generation_bitmap_);
free(young_generation_bitmap_); free(young_generation_bitmap_);
young_generation_bitmap_ = nullptr; young_generation_bitmap_ = nullptr;
} }
template <MarkingMode mode>
void MemoryChunk::ClearLiveness() { void MemoryChunk::ClearLiveness() {
markbits()->Clear(); markbits<mode>()->Clear();
ResetLiveBytes(); ResetLiveBytes<mode>();
} }
template void MemoryChunk::ClearLiveness<MarkingMode::FULL>();
template void MemoryChunk::ClearLiveness<MarkingMode::YOUNG_GENERATION>();
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// PagedSpace implementation // PagedSpace implementation
......
...@@ -342,8 +342,8 @@ class MemoryChunk { ...@@ -342,8 +342,8 @@ class MemoryChunk {
+ 2 * kPointerSize // base::VirtualMemory reservation_ + 2 * kPointerSize // base::VirtualMemory reservation_
+ kPointerSize // Address owner_ + kPointerSize // Address owner_
+ kPointerSize // Heap* heap_ + kPointerSize // Heap* heap_
+ kIntSize // int progress_bar_ + kIntptrSize // intptr_t progress_bar_
+ kIntSize // int live_bytes_count_ + kIntptrSize // intptr_t live_byte_count_
+ kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // SlotSet* array + kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // SlotSet* array
+ kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // TypedSlotSet* array + kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // TypedSlotSet* array
+ kPointerSize // SkipList* skip_list_ + kPointerSize // SkipList* skip_list_
...@@ -442,7 +442,7 @@ class MemoryChunk { ...@@ -442,7 +442,7 @@ class MemoryChunk {
switch (mode) { switch (mode) {
case MarkingMode::FULL: case MarkingMode::FULL:
DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_); DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_);
return live_byte_count_; return static_cast<int>(live_byte_count_);
case MarkingMode::YOUNG_GENERATION: case MarkingMode::YOUNG_GENERATION:
DCHECK_LE(static_cast<unsigned>(young_generation_live_byte_count_), DCHECK_LE(static_cast<unsigned>(young_generation_live_byte_count_),
size_); size_);
...@@ -489,8 +489,8 @@ class MemoryChunk { ...@@ -489,8 +489,8 @@ class MemoryChunk {
void ReleaseTypedSlotSet(); void ReleaseTypedSlotSet();
void AllocateLocalTracker(); void AllocateLocalTracker();
void ReleaseLocalTracker(); void ReleaseLocalTracker();
void AllocateExternalBitmap(); void AllocateYoungGenerationBitmap();
void ReleaseExternalBitmap(); void ReleaseYoungGenerationBitmap();
Address area_start() { return area_start_; } Address area_start() { return area_start_; }
Address area_end() { return area_end_; } Address area_end() { return area_end_; }
...@@ -505,7 +505,7 @@ class MemoryChunk { ...@@ -505,7 +505,7 @@ class MemoryChunk {
int progress_bar() { int progress_bar() {
DCHECK(IsFlagSet(HAS_PROGRESS_BAR)); DCHECK(IsFlagSet(HAS_PROGRESS_BAR));
return progress_bar_; return static_cast<int>(progress_bar_);
} }
void set_progress_bar(int progress_bar) { void set_progress_bar(int progress_bar) {
...@@ -527,11 +527,9 @@ class MemoryChunk { ...@@ -527,11 +527,9 @@ class MemoryChunk {
} }
template <MarkingMode mode = MarkingMode::FULL> template <MarkingMode mode = MarkingMode::FULL>
inline int* live_bytes_address() { inline intptr_t* live_bytes_address() {
// TODO(mlippautz): Fix type of live_byte_count_. return mode == MarkingMode::FULL ? &live_byte_count_
return mode == MarkingMode::FULL : &young_generation_live_byte_count_;
? &live_byte_count_
: reinterpret_cast<int*>(&young_generation_live_byte_count_);
} }
inline uint32_t AddressToMarkbitIndex(Address addr) const { inline uint32_t AddressToMarkbitIndex(Address addr) const {
...@@ -542,6 +540,7 @@ class MemoryChunk { ...@@ -542,6 +540,7 @@ class MemoryChunk {
return this->address() + (index << kPointerSizeLog2); return this->address() + (index << kPointerSizeLog2);
} }
template <MarkingMode mode = MarkingMode::FULL>
void ClearLiveness(); void ClearLiveness();
void PrintMarkbits() { markbits()->Print(); } void PrintMarkbits() { markbits()->Print(); }
...@@ -651,10 +650,10 @@ class MemoryChunk { ...@@ -651,10 +650,10 @@ class MemoryChunk {
// Used by the incremental marker to keep track of the scanning progress in // Used by the incremental marker to keep track of the scanning progress in
// large objects that have a progress bar and are scanned in increments. // large objects that have a progress bar and are scanned in increments.
int progress_bar_; intptr_t progress_bar_;
// Count of bytes marked black on page. // Count of bytes marked black on page.
int live_byte_count_; intptr_t live_byte_count_;
// A single slot set for small pages (of size kPageSize) or an array of slot // A single slot set for small pages (of size kPageSize) or an array of slot
// set for large pages. In the latter case the number of entries in the array // set for large pages. In the latter case the number of entries in the array
......
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