Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: src/heap/spaces-inl.h

Issue 2516303006: [heap] Refactor heap object iteration (Closed)
Patch Set: Final fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_SPACES_INL_H_ 5 #ifndef V8_HEAP_SPACES_INL_H_
6 #define V8_HEAP_SPACES_INL_H_ 6 #define V8_HEAP_SPACES_INL_H_
7 7
8 #include "src/heap/incremental-marking.h" 8 #include "src/heap/incremental-marking.h"
9 #include "src/heap/spaces.h" 9 #include "src/heap/spaces.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 10 matching lines...) Expand all
21 return *this; 21 return *this;
22 } 22 }
23 23
24 template <class PAGE_TYPE> 24 template <class PAGE_TYPE>
25 PageIteratorImpl<PAGE_TYPE> PageIteratorImpl<PAGE_TYPE>::operator++(int) { 25 PageIteratorImpl<PAGE_TYPE> PageIteratorImpl<PAGE_TYPE>::operator++(int) {
26 PageIteratorImpl<PAGE_TYPE> tmp(*this); 26 PageIteratorImpl<PAGE_TYPE> tmp(*this);
27 operator++(); 27 operator++();
28 return tmp; 28 return tmp;
29 } 29 }
30 30
31 NewSpacePageRange::NewSpacePageRange(Address start, Address limit) 31 PageRange::PageRange(Address start, Address limit)
32 : range_(Page::FromAddress(start), 32 : begin_(Page::FromAllocationAreaAddress(start)),
33 Page::FromAllocationAreaAddress(limit)->next_page()) { 33 end_(Page::FromAllocationAreaAddress(limit)->next_page()) {
34 SemiSpace::AssertValidRange(start, limit); 34 #ifdef DEBUG
35 if (begin_->InNewSpace()) {
36 SemiSpace::AssertValidRange(start, limit);
37 }
38 #endif // DEBUG
35 } 39 }
36 40
37 // ----------------------------------------------------------------------------- 41 // -----------------------------------------------------------------------------
38 // SemiSpaceIterator 42 // SemiSpaceIterator
39 43
40 HeapObject* SemiSpaceIterator::Next() { 44 HeapObject* SemiSpaceIterator::Next() {
41 while (current_ != limit_) { 45 while (current_ != limit_) {
42 if (Page::IsAlignedToPageSize(current_)) { 46 if (Page::IsAlignedToPageSize(current_)) {
43 Page* page = Page::FromAllocationAreaAddress(current_); 47 Page* page = Page::FromAllocationAreaAddress(current_);
44 page = page->next_page(); 48 page = page->next_page();
(...skipping 15 matching lines...) Expand all
60 64
61 HeapObject* HeapObjectIterator::Next() { 65 HeapObject* HeapObjectIterator::Next() {
62 do { 66 do {
63 HeapObject* next_obj = FromCurrentPage(); 67 HeapObject* next_obj = FromCurrentPage();
64 if (next_obj != nullptr) return next_obj; 68 if (next_obj != nullptr) return next_obj;
65 } while (AdvanceToNextPage()); 69 } while (AdvanceToNextPage());
66 return nullptr; 70 return nullptr;
67 } 71 }
68 72
69 HeapObject* HeapObjectIterator::FromCurrentPage() { 73 HeapObject* HeapObjectIterator::FromCurrentPage() {
70 while (cur_addr_ != cur_end_) { 74 while (cur_addr_ != cur_end_) {
Hannes Payer (out of office) 2016/11/23 13:07:26 Please add a comment here.
Michael Lippautz 2016/11/23 13:29:07 Done.
71 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { 75 if (cur_addr_ == space_->top() &&
72 cur_addr_ = space_->limit(); 76 (cur_addr_ != space_->limit() || current_page()->InNewSpace())) {
77 cur_addr_ = current_page()->InNewSpace() ? cur_end_ : space_->limit();
73 continue; 78 continue;
74 } 79 }
75 HeapObject* obj = HeapObject::FromAddress(cur_addr_); 80 HeapObject* obj = HeapObject::FromAddress(cur_addr_);
76 const int obj_size = obj->Size(); 81 const int obj_size = obj->Size();
77 cur_addr_ += obj_size; 82 cur_addr_ += obj_size;
78 DCHECK_LE(cur_addr_, cur_end_); 83 DCHECK_LE(cur_addr_, cur_end_);
79 if (!obj->IsFiller()) { 84 if (!obj->IsFiller()) {
80 if (obj->IsCode()) { 85 if (obj->IsCode()) {
81 DCHECK_EQ(space_, space_->heap()->code_space()); 86 DCHECK_EQ(space_, space_->heap()->code_space());
82 DCHECK_CODEOBJECT_SIZE(obj_size, space_); 87 DCHECK_CODEOBJECT_SIZE(obj_size, reinterpret_cast<PagedSpace*>(space_));
83 } else { 88 } else {
84 DCHECK_OBJECT_SIZE(obj_size); 89 DCHECK_OBJECT_SIZE(obj_size);
85 } 90 }
86 return obj; 91 return obj;
87 } 92 }
88 } 93 }
89 return nullptr; 94 return nullptr;
90 } 95 }
91 96
92 // ----------------------------------------------------------------------------- 97 // -----------------------------------------------------------------------------
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 other->allocation_info_.Reset(nullptr, nullptr); 625 other->allocation_info_.Reset(nullptr, nullptr);
621 return true; 626 return true;
622 } 627 }
623 return false; 628 return false;
624 } 629 }
625 630
626 } // namespace internal 631 } // namespace internal
627 } // namespace v8 632 } // namespace v8
628 633
629 #endif // V8_HEAP_SPACES_INL_H_ 634 #endif // V8_HEAP_SPACES_INL_H_
OLDNEW
« no previous file with comments | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698