| 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_SPACES_INL_H_ | 5 #ifndef V8_SPACES_INL_H_ |
| 6 #define V8_SPACES_INL_H_ | 6 #define V8_SPACES_INL_H_ |
| 7 | 7 |
| 8 #include "src/heap-profiler.h" | 8 #include "src/heap-profiler.h" |
| 9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
| 10 #include "src/spaces.h" | 10 #include "src/spaces.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 prev_page_(&space->anchor_), | 33 prev_page_(&space->anchor_), |
| 34 next_page_(prev_page_->next_page()) { } | 34 next_page_(prev_page_->next_page()) { } |
| 35 | 35 |
| 36 | 36 |
| 37 bool PageIterator::has_next() { | 37 bool PageIterator::has_next() { |
| 38 return next_page_ != &space_->anchor_; | 38 return next_page_ != &space_->anchor_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 Page* PageIterator::next() { | 42 Page* PageIterator::next() { |
| 43 ASSERT(has_next()); | 43 DCHECK(has_next()); |
| 44 prev_page_ = next_page_; | 44 prev_page_ = next_page_; |
| 45 next_page_ = next_page_->next_page(); | 45 next_page_ = next_page_->next_page(); |
| 46 return prev_page_; | 46 return prev_page_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 // ----------------------------------------------------------------------------- | 50 // ----------------------------------------------------------------------------- |
| 51 // NewSpacePageIterator | 51 // NewSpacePageIterator |
| 52 | 52 |
| 53 | 53 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 SemiSpace::AssertValidRange(start, limit); | 68 SemiSpace::AssertValidRange(start, limit); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 bool NewSpacePageIterator::has_next() { | 72 bool NewSpacePageIterator::has_next() { |
| 73 return prev_page_ != last_page_; | 73 return prev_page_ != last_page_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 NewSpacePage* NewSpacePageIterator::next() { | 77 NewSpacePage* NewSpacePageIterator::next() { |
| 78 ASSERT(has_next()); | 78 DCHECK(has_next()); |
| 79 prev_page_ = next_page_; | 79 prev_page_ = next_page_; |
| 80 next_page_ = next_page_->next_page(); | 80 next_page_ = next_page_->next_page(); |
| 81 return prev_page_; | 81 return prev_page_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 // ----------------------------------------------------------------------------- | 85 // ----------------------------------------------------------------------------- |
| 86 // HeapObjectIterator | 86 // HeapObjectIterator |
| 87 HeapObject* HeapObjectIterator::FromCurrentPage() { | 87 HeapObject* HeapObjectIterator::FromCurrentPage() { |
| 88 while (cur_addr_ != cur_end_) { | 88 while (cur_addr_ != cur_end_) { |
| 89 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { | 89 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { |
| 90 cur_addr_ = space_->limit(); | 90 cur_addr_ = space_->limit(); |
| 91 continue; | 91 continue; |
| 92 } | 92 } |
| 93 HeapObject* obj = HeapObject::FromAddress(cur_addr_); | 93 HeapObject* obj = HeapObject::FromAddress(cur_addr_); |
| 94 int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj); | 94 int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj); |
| 95 cur_addr_ += obj_size; | 95 cur_addr_ += obj_size; |
| 96 ASSERT(cur_addr_ <= cur_end_); | 96 DCHECK(cur_addr_ <= cur_end_); |
| 97 if (!obj->IsFiller()) { | 97 if (!obj->IsFiller()) { |
| 98 ASSERT_OBJECT_SIZE(obj_size); | 98 DCHECK_OBJECT_SIZE(obj_size); |
| 99 return obj; | 99 return obj; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 return NULL; | 102 return NULL; |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 // ----------------------------------------------------------------------------- | 106 // ----------------------------------------------------------------------------- |
| 107 // MemoryAllocator | 107 // MemoryAllocator |
| 108 | 108 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 135 #endif | 135 #endif |
| 136 | 136 |
| 137 | 137 |
| 138 // -------------------------------------------------------------------------- | 138 // -------------------------------------------------------------------------- |
| 139 // PagedSpace | 139 // PagedSpace |
| 140 Page* Page::Initialize(Heap* heap, | 140 Page* Page::Initialize(Heap* heap, |
| 141 MemoryChunk* chunk, | 141 MemoryChunk* chunk, |
| 142 Executability executable, | 142 Executability executable, |
| 143 PagedSpace* owner) { | 143 PagedSpace* owner) { |
| 144 Page* page = reinterpret_cast<Page*>(chunk); | 144 Page* page = reinterpret_cast<Page*>(chunk); |
| 145 ASSERT(page->area_size() <= kMaxRegularHeapObjectSize); | 145 DCHECK(page->area_size() <= kMaxRegularHeapObjectSize); |
| 146 ASSERT(chunk->owner() == owner); | 146 DCHECK(chunk->owner() == owner); |
| 147 owner->IncreaseCapacity(page->area_size()); | 147 owner->IncreaseCapacity(page->area_size()); |
| 148 owner->Free(page->area_start(), page->area_size()); | 148 owner->Free(page->area_start(), page->area_size()); |
| 149 | 149 |
| 150 heap->incremental_marking()->SetOldSpacePageFlags(chunk); | 150 heap->incremental_marking()->SetOldSpacePageFlags(chunk); |
| 151 | 151 |
| 152 return page; | 152 return page; |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 bool PagedSpace::Contains(Address addr) { | 156 bool PagedSpace::Contains(Address addr) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 | 207 |
| 208 PointerChunkIterator::PointerChunkIterator(Heap* heap) | 208 PointerChunkIterator::PointerChunkIterator(Heap* heap) |
| 209 : state_(kOldPointerState), | 209 : state_(kOldPointerState), |
| 210 old_pointer_iterator_(heap->old_pointer_space()), | 210 old_pointer_iterator_(heap->old_pointer_space()), |
| 211 map_iterator_(heap->map_space()), | 211 map_iterator_(heap->map_space()), |
| 212 lo_iterator_(heap->lo_space()) { } | 212 lo_iterator_(heap->lo_space()) { } |
| 213 | 213 |
| 214 | 214 |
| 215 Page* Page::next_page() { | 215 Page* Page::next_page() { |
| 216 ASSERT(next_chunk()->owner() == owner()); | 216 DCHECK(next_chunk()->owner() == owner()); |
| 217 return static_cast<Page*>(next_chunk()); | 217 return static_cast<Page*>(next_chunk()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 Page* Page::prev_page() { | 221 Page* Page::prev_page() { |
| 222 ASSERT(prev_chunk()->owner() == owner()); | 222 DCHECK(prev_chunk()->owner() == owner()); |
| 223 return static_cast<Page*>(prev_chunk()); | 223 return static_cast<Page*>(prev_chunk()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 | 226 |
| 227 void Page::set_next_page(Page* page) { | 227 void Page::set_next_page(Page* page) { |
| 228 ASSERT(page->owner() == owner()); | 228 DCHECK(page->owner() == owner()); |
| 229 set_next_chunk(page); | 229 set_next_chunk(page); |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 void Page::set_prev_page(Page* page) { | 233 void Page::set_prev_page(Page* page) { |
| 234 ASSERT(page->owner() == owner()); | 234 DCHECK(page->owner() == owner()); |
| 235 set_prev_chunk(page); | 235 set_prev_chunk(page); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 // Try linear allocation in the page of alloc_info's allocation top. Does | 239 // Try linear allocation in the page of alloc_info's allocation top. Does |
| 240 // not contain slow case logic (e.g. move to the next page or try free list | 240 // not contain slow case logic (e.g. move to the next page or try free list |
| 241 // allocation) so it can be used by all the allocation functions and for all | 241 // allocation) so it can be used by all the allocation functions and for all |
| 242 // the paged spaces. | 242 // the paged spaces. |
| 243 HeapObject* PagedSpace::AllocateLinearly(int size_in_bytes) { | 243 HeapObject* PagedSpace::AllocateLinearly(int size_in_bytes) { |
| 244 Address current_top = allocation_info_.top(); | 244 Address current_top = allocation_info_.top(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 AllocationResult NewSpace::AllocateRaw(int size_in_bytes) { | 279 AllocationResult NewSpace::AllocateRaw(int size_in_bytes) { |
| 280 Address old_top = allocation_info_.top(); | 280 Address old_top = allocation_info_.top(); |
| 281 | 281 |
| 282 if (allocation_info_.limit() - old_top < size_in_bytes) { | 282 if (allocation_info_.limit() - old_top < size_in_bytes) { |
| 283 return SlowAllocateRaw(size_in_bytes); | 283 return SlowAllocateRaw(size_in_bytes); |
| 284 } | 284 } |
| 285 | 285 |
| 286 HeapObject* obj = HeapObject::FromAddress(old_top); | 286 HeapObject* obj = HeapObject::FromAddress(old_top); |
| 287 allocation_info_.set_top(allocation_info_.top() + size_in_bytes); | 287 allocation_info_.set_top(allocation_info_.top() + size_in_bytes); |
| 288 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 288 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 289 | 289 |
| 290 return obj; | 290 return obj; |
| 291 } | 291 } |
| 292 | 292 |
| 293 | 293 |
| 294 LargePage* LargePage::Initialize(Heap* heap, MemoryChunk* chunk) { | 294 LargePage* LargePage::Initialize(Heap* heap, MemoryChunk* chunk) { |
| 295 heap->incremental_marking()->SetOldSpacePageFlags(chunk); | 295 heap->incremental_marking()->SetOldSpacePageFlags(chunk); |
| 296 return static_cast<LargePage*>(chunk); | 296 return static_cast<LargePage*>(chunk); |
| 297 } | 297 } |
| 298 | 298 |
| 299 | 299 |
| 300 intptr_t LargeObjectSpace::Available() { | 300 intptr_t LargeObjectSpace::Available() { |
| 301 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); | 301 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 | 304 |
| 305 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 305 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
| 306 Map* map = object->map(); | 306 Map* map = object->map(); |
| 307 Heap* heap = object->GetHeap(); | 307 Heap* heap = object->GetHeap(); |
| 308 return map == heap->raw_unchecked_free_space_map() | 308 return map == heap->raw_unchecked_free_space_map() |
| 309 || map == heap->raw_unchecked_one_pointer_filler_map() | 309 || map == heap->raw_unchecked_one_pointer_filler_map() |
| 310 || map == heap->raw_unchecked_two_pointer_filler_map(); | 310 || map == heap->raw_unchecked_two_pointer_filler_map(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 } } // namespace v8::internal | 313 } } // namespace v8::internal |
| 314 | 314 |
| 315 #endif // V8_SPACES_INL_H_ | 315 #endif // V8_SPACES_INL_H_ |
| OLD | NEW |