Commit cf37556f authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Minor MC: Implement page moving

BUG=chromium:651354

Review-Url: https://codereview.chromium.org/2855143003
Cr-Commit-Position: refs/heads/master@{#45223}
parent 540419b6
...@@ -5519,8 +5519,7 @@ bool Heap::SetUp() { ...@@ -5519,8 +5519,7 @@ bool Heap::SetUp() {
#else #else
concurrent_marking_ = new ConcurrentMarking(this, nullptr); concurrent_marking_ = new ConcurrentMarking(this, nullptr);
#endif #endif
if (FLAG_minor_mc) minor_mark_compact_collector_ = new MinorMarkCompactCollector(this);
minor_mark_compact_collector_ = new MinorMarkCompactCollector(this);
gc_idle_time_handler_ = new GCIdleTimeHandler(); gc_idle_time_handler_ = new GCIdleTimeHandler();
memory_reducer_ = new MemoryReducer(this); memory_reducer_ = new MemoryReducer(this);
if (V8_UNLIKELY(FLAG_gc_stats)) { if (V8_UNLIKELY(FLAG_gc_stats)) {
......
...@@ -2409,6 +2409,7 @@ class Heap { ...@@ -2409,6 +2409,7 @@ class Heap {
friend class IncrementalMarkingJob; friend class IncrementalMarkingJob;
friend class LargeObjectSpace; friend class LargeObjectSpace;
friend class MarkCompactCollector; friend class MarkCompactCollector;
friend class MarkCompactCollectorBase;
friend class MinorMarkCompactCollector; friend class MinorMarkCompactCollector;
friend class MarkCompactMarkingVisitor; friend class MarkCompactMarkingVisitor;
friend class NewSpace; friend class NewSpace;
......
...@@ -821,7 +821,23 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { ...@@ -821,7 +821,23 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
(obj->IsFiller() && (obj->IsFiller() &&
ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj)))); ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj))));
return dest; return dest;
} else if (heap_->InToSpace(obj)) {
// The object may be on a page that was moved in new space.
DCHECK(
Page::FromAddress(obj->address())->IsFlagSet(Page::SWEEP_TO_ITERATE));
return ObjectMarking::IsBlack<kAtomicity>(obj,
MarkingState::External(obj))
? obj
: nullptr;
} else { } else {
// The object may be on a page that was moved from new to old space.
if (Page::FromAddress(obj->address())
->IsFlagSet(Page::SWEEP_TO_ITERATE)) {
return ObjectMarking::IsBlack<kAtomicity>(obj,
MarkingState::External(obj))
? obj
: nullptr;
}
DCHECK(ObjectMarking::IsGrey<kAtomicity>(obj, marking_state(obj)) || DCHECK(ObjectMarking::IsGrey<kAtomicity>(obj, marking_state(obj)) ||
(obj->IsFiller() && (obj->IsFiller() &&
ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj))) || ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj))) ||
......
This diff is collapsed.
...@@ -277,6 +277,8 @@ class LiveObjectVisitor BASE_EMBEDDED { ...@@ -277,6 +277,8 @@ class LiveObjectVisitor BASE_EMBEDDED {
}; };
enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD }; enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD };
enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE };
enum MarkingTreatmentMode { KEEP, CLEAR };
// Base class for minor and full MC collectors. // Base class for minor and full MC collectors.
class MarkCompactCollectorBase { class MarkCompactCollectorBase {
...@@ -322,6 +324,9 @@ class MarkCompactCollectorBase { ...@@ -322,6 +324,9 @@ class MarkCompactCollectorBase {
MigrationObserver* migration_observer, const intptr_t live_bytes, MigrationObserver* migration_observer, const intptr_t live_bytes,
const int& abandoned_pages); const int& abandoned_pages);
// Returns whether this page should be moved according to heuristics.
bool ShouldMovePage(Page* p, intptr_t live_bytes);
Heap* heap_; Heap* heap_;
}; };
...@@ -345,6 +350,10 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -345,6 +350,10 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
void TearDown() override; void TearDown() override;
void CollectGarbage() override; void CollectGarbage() override;
void MakeIterable(Page* page, MarkingTreatmentMode marking_mode,
FreeSpaceTreatmentMode free_space_mode);
void CleanupSweepToIteratePages();
private: private:
class RootMarkingVisitor; class RootMarkingVisitor;
...@@ -368,6 +377,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -368,6 +377,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
MarkingDeque marking_deque_; MarkingDeque marking_deque_;
base::Semaphore page_parallel_job_semaphore_; base::Semaphore page_parallel_job_semaphore_;
List<Page*> new_space_evacuation_pages_; List<Page*> new_space_evacuation_pages_;
std::vector<Page*> sweep_to_iterate_pages_;
friend class StaticYoungGenerationMarkingVisitor; friend class StaticYoungGenerationMarkingVisitor;
}; };
...@@ -382,7 +392,6 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -382,7 +392,6 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
class SweeperTask; class SweeperTask;
enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST }; enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST };
enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE };
enum ClearOldToNewSlotsMode { enum ClearOldToNewSlotsMode {
DO_NOT_CLEAR, DO_NOT_CLEAR,
CLEAR_REGULAR_SLOTS, CLEAR_REGULAR_SLOTS,
......
...@@ -56,10 +56,14 @@ bool HeapObjectIterator::AdvanceToNextPage() { ...@@ -56,10 +56,14 @@ bool HeapObjectIterator::AdvanceToNextPage() {
DCHECK_EQ(cur_addr_, cur_end_); DCHECK_EQ(cur_addr_, cur_end_);
if (current_page_ == page_range_.end()) return false; if (current_page_ == page_range_.end()) return false;
Page* cur_page = *(current_page_++); Page* cur_page = *(current_page_++);
space_->heap() Heap* heap = space_->heap();
->mark_compact_collector()
->sweeper() heap->mark_compact_collector()->sweeper().SweepOrWaitUntilSweepingCompleted(
.SweepOrWaitUntilSweepingCompleted(cur_page); cur_page);
if (cur_page->IsFlagSet(Page::SWEEP_TO_ITERATE))
heap->minor_mark_compact_collector()->MakeIterable(
cur_page, MarkingTreatmentMode::CLEAR,
FreeSpaceTreatmentMode::IGNORE_FREE_SPACE);
cur_addr_ = cur_page->area_start(); cur_addr_ = cur_page->area_start();
cur_end_ = cur_page->area_end(); cur_end_ = cur_page->area_end();
DCHECK(cur_page->SweepingDone()); DCHECK(cur_page->SweepingDone());
......
...@@ -289,6 +289,10 @@ class MemoryChunk { ...@@ -289,6 +289,10 @@ class MemoryChunk {
// |ANCHOR|: Flag is set if page is an anchor. // |ANCHOR|: Flag is set if page is an anchor.
ANCHOR = 1u << 17, ANCHOR = 1u << 17,
// |SWEEP_TO_ITERATE|: The page requires sweeping using external markbits
// to iterate the page.
SWEEP_TO_ITERATE = 1u << 18,
}; };
typedef base::Flags<Flag, uintptr_t> Flags; typedef base::Flags<Flag, uintptr_t> Flags;
......
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