Index: src/heap/spaces-inl.h |
diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h |
index 515a2027693c7d46954733df88e552dd225ef0ea..ccfb24f6e546d56b08e2dc6994190026a156ee89 100644 |
--- a/src/heap/spaces-inl.h |
+++ b/src/heap/spaces-inl.h |
@@ -147,6 +147,19 @@ HeapObject* HeapObjectIterator::FromCurrentPage() { |
return NULL; |
} |
+// ----------------------------------------------------------------------------- |
+// LargePageIterator |
+ |
+LargePageIterator::LargePageIterator(LargeObjectSpace* space) |
+ : next_page_(space->first_page()) {} |
+ |
+LargePage* LargePageIterator::next() { |
+ LargePage* result = next_page_; |
+ if (next_page_ != nullptr) { |
+ next_page_ = next_page_->next_page(); |
+ } |
+ return result; |
+} |
// ----------------------------------------------------------------------------- |
// MemoryAllocator |
@@ -308,15 +321,15 @@ Page* Page::FromAnyPointerAddress(Heap* heap, Address addr) { |
return static_cast<Page*>(MemoryChunk::FromAnyPointerAddress(heap, addr)); |
} |
- |
-PointerChunkIterator::PointerChunkIterator(Heap* heap) |
+MemoryChunkIterator::MemoryChunkIterator(Heap* heap, Mode mode) |
: state_(kOldSpaceState), |
+ mode_(mode), |
old_iterator_(heap->old_space()), |
+ code_iterator_(heap->code_space()), |
map_iterator_(heap->map_space()), |
lo_iterator_(heap->lo_space()) {} |
- |
-MemoryChunk* PointerChunkIterator::next() { |
+MemoryChunk* MemoryChunkIterator::next() { |
switch (state_) { |
case kOldSpaceState: { |
if (old_iterator_.has_next()) { |
@@ -326,33 +339,34 @@ MemoryChunk* PointerChunkIterator::next() { |
// Fall through. |
} |
case kMapState: { |
- if (map_iterator_.has_next()) { |
+ if (mode_ != ALL_BUT_MAP_SPACE && map_iterator_.has_next()) { |
return map_iterator_.next(); |
} |
+ state_ = kCodeState; |
+ // Fall through. |
+ } |
+ case kCodeState: { |
+ if (mode_ != ALL_BUT_CODE_SPACE && code_iterator_.has_next()) { |
+ return code_iterator_.next(); |
+ } |
state_ = kLargeObjectState; |
// Fall through. |
} |
case kLargeObjectState: { |
- HeapObject* heap_object; |
- do { |
- heap_object = lo_iterator_.Next(); |
- if (heap_object == NULL) { |
- state_ = kFinishedState; |
- return NULL; |
- } |
- // Fixed arrays are the only pointer-containing objects in large |
- // object space. |
- } while (!heap_object->IsFixedArray()); |
- MemoryChunk* answer = MemoryChunk::FromAddress(heap_object->address()); |
- return answer; |
+ MemoryChunk* answer = lo_iterator_.next(); |
+ if (answer != nullptr) { |
+ return answer; |
+ } |
+ state_ = kFinishedState; |
+ // Fall through; |
} |
case kFinishedState: |
- return NULL; |
+ return nullptr; |
default: |
break; |
} |
UNREACHABLE(); |
- return NULL; |
+ return nullptr; |
} |