Commit 6deb2267 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Untangle Evacuator from MarkCompactCollector

BUG=chromium:651354

Change-Id: I15b2ee763882af369bf4b6274ce04e52dfb657e7
Reviewed-on: https://chromium-review.googlesource.com/457321
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43980}
parent c8a727de
This diff is collapsed.
...@@ -27,6 +27,7 @@ typedef void (*MarkObjectFunction)(Heap* heap, HeapObject* object); ...@@ -27,6 +27,7 @@ typedef void (*MarkObjectFunction)(Heap* heap, HeapObject* object);
// Forward declarations. // Forward declarations.
class CodeFlusher; class CodeFlusher;
class HeapObjectVisitor;
class MarkCompactCollector; class MarkCompactCollector;
class MinorMarkCompactCollector; class MinorMarkCompactCollector;
class MarkingVisitor; class MarkingVisitor;
...@@ -44,11 +45,15 @@ class MarkingState { ...@@ -44,11 +45,15 @@ class MarkingState {
chunk->live_bytes_address<MarkingMode::YOUNG_GENERATION>()); chunk->live_bytes_address<MarkingMode::YOUNG_GENERATION>());
} }
MarkingState(Bitmap* bitmap, intptr_t* live_bytes) MarkingState(Bitmap* bitmap, int* live_bytes)
: bitmap(bitmap), live_bytes(live_bytes) {} : bitmap(bitmap), live_bytes(live_bytes) {}
void IncrementLiveBytes(intptr_t by) const { *live_bytes += by; } void IncrementLiveBytes(intptr_t by) const {
void SetLiveBytes(intptr_t value) const { *live_bytes = value; } *live_bytes += static_cast<int>(by);
}
void SetLiveBytes(intptr_t value) const {
*live_bytes = static_cast<int>(value);
}
void ClearLiveness() const { void ClearLiveness() const {
bitmap->Clear(); bitmap->Clear();
...@@ -56,7 +61,7 @@ class MarkingState { ...@@ -56,7 +61,7 @@ class MarkingState {
} }
Bitmap* bitmap; Bitmap* bitmap;
intptr_t* live_bytes; int* live_bytes;
}; };
// TODO(mlippautz): Remove duplicate accessors once the architecture for // TODO(mlippautz): Remove duplicate accessors once the architecture for
...@@ -488,6 +493,24 @@ class LiveObjectIterator BASE_EMBEDDED { ...@@ -488,6 +493,24 @@ class LiveObjectIterator BASE_EMBEDDED {
MarkBit::CellType current_cell_; MarkBit::CellType current_cell_;
}; };
class LiveObjectVisitor BASE_EMBEDDED {
public:
enum IterationMode {
kKeepMarking,
kClearMarkbits,
};
// Visits black objects on a MemoryChunk until the Visitor returns for an
// object. If IterationMode::kClearMarkbits is passed the markbits and slots
// for visited objects are cleared for each successfully visited object.
template <class Visitor>
bool VisitBlackObjects(MemoryChunk* chunk, const MarkingState& state,
Visitor* visitor, IterationMode iteration_mode);
private:
void RecomputeLiveBytes(MemoryChunk* chunk, const MarkingState& state);
};
enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD }; enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD };
class MinorMarkCompactCollector { class MinorMarkCompactCollector {
...@@ -529,7 +552,6 @@ class MinorMarkCompactCollector { ...@@ -529,7 +552,6 @@ class MinorMarkCompactCollector {
// Mark-Compact collector // Mark-Compact collector
class MarkCompactCollector { class MarkCompactCollector {
public: public:
class Evacuator;
class RootMarkingVisitor; class RootMarkingVisitor;
class Sweeper { class Sweeper {
...@@ -716,15 +738,6 @@ class MarkCompactCollector { ...@@ -716,15 +738,6 @@ class MarkCompactCollector {
#endif #endif
private: private:
template <PageEvacuationMode mode>
class EvacuateNewSpacePageVisitor;
class EvacuateNewSpaceVisitor;
class EvacuateOldSpaceVisitor;
class EvacuateRecordOnlyVisitor;
class EvacuateVisitorBase;
class HeapObjectVisitor;
class ObjectStatsVisitor;
explicit MarkCompactCollector(Heap* heap); explicit MarkCompactCollector(Heap* heap);
bool WillBeDeoptimized(Code* code); bool WillBeDeoptimized(Code* code);
...@@ -881,14 +894,6 @@ class MarkCompactCollector { ...@@ -881,14 +894,6 @@ class MarkCompactCollector {
void UpdatePointersAfterEvacuation(); void UpdatePointersAfterEvacuation();
// Iterates through all live objects on a page using marking information.
// Returns whether all objects have successfully been visited.
template <class Visitor>
bool VisitLiveObjects(MemoryChunk* page, Visitor* visitor,
IterationMode mode);
void RecomputeLiveBytes(MemoryChunk* page);
void ReleaseEvacuationCandidates(); void ReleaseEvacuationCandidates();
......
...@@ -527,11 +527,11 @@ class MemoryChunk { ...@@ -527,11 +527,11 @@ class MemoryChunk {
} }
template <MarkingMode mode = MarkingMode::FULL> template <MarkingMode mode = MarkingMode::FULL>
inline intptr_t* live_bytes_address() { inline int* live_bytes_address() {
// TODO(mlippautz): Fix type of live_byte_count_. // TODO(mlippautz): Fix type of live_byte_count_.
return mode == MarkingMode::FULL return mode == MarkingMode::FULL
? reinterpret_cast<intptr_t*>(&live_byte_count_) ? &live_byte_count_
: &young_generation_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 {
......
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