OLD | NEW |
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 11 matching lines...) Expand all Loading... |
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 NewSpacePageRange::NewSpacePageRange(Address start, Address limit) |
32 : start_(start), limit_(limit) { | 32 : range_(Page::FromAddress(start), |
| 33 Page::FromAllocationAreaAddress(limit)->next_page()) { |
33 SemiSpace::AssertValidRange(start, limit); | 34 SemiSpace::AssertValidRange(start, limit); |
34 } | 35 } |
35 | 36 |
36 // ----------------------------------------------------------------------------- | 37 // ----------------------------------------------------------------------------- |
37 // Bitmap | 38 // Bitmap |
38 | 39 |
39 void Bitmap::Clear(MemoryChunk* chunk) { | 40 void Bitmap::Clear(MemoryChunk* chunk) { |
40 Bitmap* bitmap = chunk->markbits(); | 41 Bitmap* bitmap = chunk->markbits(); |
41 for (int i = 0; i < bitmap->CellsCount(); i++) bitmap->cells()[i] = 0; | 42 for (int i = 0; i < bitmap->CellsCount(); i++) bitmap->cells()[i] = 0; |
42 chunk->ResetLiveBytes(); | 43 chunk->ResetLiveBytes(); |
(...skipping 20 matching lines...) Expand all Loading... |
63 } | 64 } |
64 HeapObject* object = HeapObject::FromAddress(current_); | 65 HeapObject* object = HeapObject::FromAddress(current_); |
65 current_ += object->Size(); | 66 current_ += object->Size(); |
66 if (!object->IsFiller()) { | 67 if (!object->IsFiller()) { |
67 return object; | 68 return object; |
68 } | 69 } |
69 } | 70 } |
70 return nullptr; | 71 return nullptr; |
71 } | 72 } |
72 | 73 |
73 | |
74 HeapObject* SemiSpaceIterator::next_object() { return Next(); } | |
75 | |
76 | |
77 // ----------------------------------------------------------------------------- | 74 // ----------------------------------------------------------------------------- |
78 // HeapObjectIterator | 75 // HeapObjectIterator |
79 | 76 |
80 HeapObject* HeapObjectIterator::Next() { | 77 HeapObject* HeapObjectIterator::Next() { |
81 do { | 78 do { |
82 HeapObject* next_obj = FromCurrentPage(); | 79 HeapObject* next_obj = FromCurrentPage(); |
83 if (next_obj != NULL) return next_obj; | 80 if (next_obj != nullptr) return next_obj; |
84 } while (AdvanceToNextPage()); | 81 } while (AdvanceToNextPage()); |
85 return NULL; | 82 return nullptr; |
86 } | 83 } |
87 | 84 |
88 | |
89 HeapObject* HeapObjectIterator::next_object() { return Next(); } | |
90 | |
91 | |
92 HeapObject* HeapObjectIterator::FromCurrentPage() { | 85 HeapObject* HeapObjectIterator::FromCurrentPage() { |
93 while (cur_addr_ != cur_end_) { | 86 while (cur_addr_ != cur_end_) { |
94 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { | 87 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { |
95 cur_addr_ = space_->limit(); | 88 cur_addr_ = space_->limit(); |
96 continue; | 89 continue; |
97 } | 90 } |
98 HeapObject* obj = HeapObject::FromAddress(cur_addr_); | 91 HeapObject* obj = HeapObject::FromAddress(cur_addr_); |
99 int obj_size = obj->Size(); | 92 const int obj_size = obj->Size(); |
100 cur_addr_ += obj_size; | 93 cur_addr_ += obj_size; |
101 DCHECK(cur_addr_ <= cur_end_); | 94 DCHECK_LE(cur_addr_, cur_end_); |
102 // TODO(hpayer): Remove the debugging code. | |
103 if (cur_addr_ > cur_end_) { | |
104 space_->heap()->isolate()->PushStackTraceAndDie(0xaaaaaaaa, obj, NULL, | |
105 obj_size); | |
106 } | |
107 | |
108 if (!obj->IsFiller()) { | 95 if (!obj->IsFiller()) { |
109 if (obj->IsCode()) { | 96 if (obj->IsCode()) { |
110 DCHECK_EQ(space_, space_->heap()->code_space()); | 97 DCHECK_EQ(space_, space_->heap()->code_space()); |
111 DCHECK_CODEOBJECT_SIZE(obj_size, space_); | 98 DCHECK_CODEOBJECT_SIZE(obj_size, space_); |
112 } else { | 99 } else { |
113 DCHECK_OBJECT_SIZE(obj_size); | 100 DCHECK_OBJECT_SIZE(obj_size); |
114 } | 101 } |
115 return obj; | 102 return obj; |
116 } | 103 } |
117 } | 104 } |
118 return NULL; | 105 return nullptr; |
119 } | 106 } |
120 | 107 |
121 // ----------------------------------------------------------------------------- | 108 // ----------------------------------------------------------------------------- |
122 // MemoryAllocator | 109 // MemoryAllocator |
123 | 110 |
124 #ifdef ENABLE_HEAP_PROTECTION | 111 #ifdef ENABLE_HEAP_PROTECTION |
125 | 112 |
126 void MemoryAllocator::Protect(Address start, size_t size) { | 113 void MemoryAllocator::Protect(Address start, size_t size) { |
127 base::OS::Protect(start, size); | 114 base::OS::Protect(start, size); |
128 } | 115 } |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 other->allocation_info_.Reset(nullptr, nullptr); | 646 other->allocation_info_.Reset(nullptr, nullptr); |
660 return true; | 647 return true; |
661 } | 648 } |
662 return false; | 649 return false; |
663 } | 650 } |
664 | 651 |
665 } // namespace internal | 652 } // namespace internal |
666 } // namespace v8 | 653 } // namespace v8 |
667 | 654 |
668 #endif // V8_HEAP_SPACES_INL_H_ | 655 #endif // V8_HEAP_SPACES_INL_H_ |
OLD | NEW |