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

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

Issue 2529663002: Revert of [heap] Refactor heap object iteration (Closed)
Patch Set: 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 PageRange::PageRange(Address start, Address limit) 31 NewSpacePageRange::NewSpacePageRange(Address start, Address limit)
32 : begin_(Page::FromAllocationAreaAddress(start)), 32 : range_(Page::FromAddress(start),
33 end_(Page::FromAllocationAreaAddress(limit)->next_page()) { 33 Page::FromAllocationAreaAddress(limit)->next_page()) {
34 #ifdef DEBUG 34 SemiSpace::AssertValidRange(start, limit);
35 if (begin_->InNewSpace()) {
36 SemiSpace::AssertValidRange(start, limit);
37 }
38 #endif // DEBUG
39 } 35 }
40 36
41 // ----------------------------------------------------------------------------- 37 // -----------------------------------------------------------------------------
42 // SemiSpaceIterator 38 // SemiSpaceIterator
43 39
44 HeapObject* SemiSpaceIterator::Next() { 40 HeapObject* SemiSpaceIterator::Next() {
45 while (current_ != limit_) { 41 while (current_ != limit_) {
46 if (Page::IsAlignedToPageSize(current_)) { 42 if (Page::IsAlignedToPageSize(current_)) {
47 Page* page = Page::FromAllocationAreaAddress(current_); 43 Page* page = Page::FromAllocationAreaAddress(current_);
48 page = page->next_page(); 44 page = page->next_page();
(...skipping 16 matching lines...) Expand all
65 HeapObject* HeapObjectIterator::Next() { 61 HeapObject* HeapObjectIterator::Next() {
66 do { 62 do {
67 HeapObject* next_obj = FromCurrentPage(); 63 HeapObject* next_obj = FromCurrentPage();
68 if (next_obj != nullptr) return next_obj; 64 if (next_obj != nullptr) return next_obj;
69 } while (AdvanceToNextPage()); 65 } while (AdvanceToNextPage());
70 return nullptr; 66 return nullptr;
71 } 67 }
72 68
73 HeapObject* HeapObjectIterator::FromCurrentPage() { 69 HeapObject* HeapObjectIterator::FromCurrentPage() {
74 while (cur_addr_ != cur_end_) { 70 while (cur_addr_ != cur_end_) {
75 // When the current address equals top we have to handle two scenarios: 71 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) {
76 // - Old space page: Move forward to limit if top != limit. We will find 72 cur_addr_ = space_->limit();
77 // a filler following limit.
78 // - New space page: We have to stop iteration before the linear allocation
79 // area as there are no fillers behind it.
80 if (cur_addr_ == space_->top() &&
81 (cur_addr_ != space_->limit() || current_page()->InNewSpace())) {
82 cur_addr_ = current_page()->InNewSpace() ? cur_end_ : space_->limit();
83 continue; 73 continue;
84 } 74 }
85 HeapObject* obj = HeapObject::FromAddress(cur_addr_); 75 HeapObject* obj = HeapObject::FromAddress(cur_addr_);
86 const int obj_size = obj->Size(); 76 const int obj_size = obj->Size();
87 cur_addr_ += obj_size; 77 cur_addr_ += obj_size;
88 DCHECK_LE(cur_addr_, cur_end_); 78 DCHECK_LE(cur_addr_, cur_end_);
89 if (!obj->IsFiller()) { 79 if (!obj->IsFiller()) {
90 if (obj->IsCode()) { 80 if (obj->IsCode()) {
91 DCHECK_EQ(space_, space_->heap()->code_space()); 81 DCHECK_EQ(space_, space_->heap()->code_space());
92 DCHECK_CODEOBJECT_SIZE(obj_size, reinterpret_cast<PagedSpace*>(space_)); 82 DCHECK_CODEOBJECT_SIZE(obj_size, space_);
93 } else { 83 } else {
94 DCHECK_OBJECT_SIZE(obj_size); 84 DCHECK_OBJECT_SIZE(obj_size);
95 } 85 }
96 return obj; 86 return obj;
97 } 87 }
98 } 88 }
99 return nullptr; 89 return nullptr;
100 } 90 }
101 91
102 // ----------------------------------------------------------------------------- 92 // -----------------------------------------------------------------------------
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 other->allocation_info_.Reset(nullptr, nullptr); 620 other->allocation_info_.Reset(nullptr, nullptr);
631 return true; 621 return true;
632 } 622 }
633 return false; 623 return false;
634 } 624 }
635 625
636 } // namespace internal 626 } // namespace internal
637 } // namespace v8 627 } // namespace v8
638 628
639 #endif // V8_HEAP_SPACES_INL_H_ 629 #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