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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 new_page->InsertAfter(old_space->anchor()->prev_page()); | 214 new_page->InsertAfter(old_space->anchor()->prev_page()); |
215 return new_page; | 215 return new_page; |
216 } | 216 } |
217 | 217 |
218 void Page::InitializeFreeListCategories() { | 218 void Page::InitializeFreeListCategories() { |
219 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { | 219 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { |
220 categories_[i].Initialize(static_cast<FreeListCategoryType>(i)); | 220 categories_[i].Initialize(static_cast<FreeListCategoryType>(i)); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 void MemoryChunk::IncrementLiveBytesFromGC(HeapObject* object, int by) { | 224 void MemoryChunk::IncrementLiveBytes(HeapObject* object, int by) { |
225 MemoryChunk::FromAddress(object->address())->IncrementLiveBytes(by); | 225 MemoryChunk::FromAddress(object->address())->IncrementLiveBytes(by); |
226 } | 226 } |
227 | 227 |
228 void MemoryChunk::ResetLiveBytes() { | 228 void MemoryChunk::ResetLiveBytes() { |
229 if (FLAG_trace_live_bytes) { | 229 if (FLAG_trace_live_bytes) { |
230 PrintIsolate(heap()->isolate(), "live-bytes: reset page=%p %d->0\n", | 230 PrintIsolate(heap()->isolate(), "live-bytes: reset page=%p %d->0\n", |
231 static_cast<void*>(this), live_byte_count_); | 231 static_cast<void*>(this), live_byte_count_); |
232 } | 232 } |
233 live_byte_count_ = 0; | 233 live_byte_count_ = 0; |
234 } | 234 } |
235 | 235 |
236 void MemoryChunk::IncrementLiveBytes(int by) { | 236 void MemoryChunk::IncrementLiveBytes(int by) { |
237 if (FLAG_trace_live_bytes) { | 237 if (FLAG_trace_live_bytes) { |
238 PrintIsolate( | 238 PrintIsolate( |
239 heap()->isolate(), "live-bytes: update page=%p delta=%d %d->%d\n", | 239 heap()->isolate(), "live-bytes: update page=%p delta=%d %d->%d\n", |
240 static_cast<void*>(this), by, live_byte_count_, live_byte_count_ + by); | 240 static_cast<void*>(this), by, live_byte_count_, live_byte_count_ + by); |
241 } | 241 } |
242 live_byte_count_ += by; | 242 live_byte_count_ += by; |
243 DCHECK_GE(live_byte_count_, 0); | 243 DCHECK_GE(live_byte_count_, 0); |
244 DCHECK_LE(static_cast<size_t>(live_byte_count_), size_); | 244 DCHECK_LE(static_cast<size_t>(live_byte_count_), size_); |
245 } | 245 } |
246 | 246 |
247 void MemoryChunk::IncrementLiveBytesFromMutator(HeapObject* object, int by) { | |
248 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); | |
249 if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->SweepingDone()) { | |
250 static_cast<PagedSpace*>(chunk->owner())->Allocate(by); | |
251 } | |
252 chunk->IncrementLiveBytes(by); | |
253 } | |
254 | |
255 bool PagedSpace::Contains(Address addr) { | 247 bool PagedSpace::Contains(Address addr) { |
256 Page* p = Page::FromAddress(addr); | 248 Page* p = Page::FromAddress(addr); |
257 if (!Page::IsValid(p)) return false; | 249 if (!Page::IsValid(p)) return false; |
258 return p->owner() == this; | 250 return p->owner() == this; |
259 } | 251 } |
260 | 252 |
261 bool PagedSpace::Contains(Object* o) { | 253 bool PagedSpace::Contains(Object* o) { |
262 if (!o->IsHeapObject()) return false; | 254 if (!o->IsHeapObject()) return false; |
263 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); | 255 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); |
264 if (!Page::IsValid(p)) return false; | 256 if (!Page::IsValid(p)) return false; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 HeapObject* object = AllocateLinearly(size_in_bytes); | 424 HeapObject* object = AllocateLinearly(size_in_bytes); |
433 | 425 |
434 if (object == NULL) { | 426 if (object == NULL) { |
435 object = free_list_.Allocate(size_in_bytes); | 427 object = free_list_.Allocate(size_in_bytes); |
436 if (object == NULL) { | 428 if (object == NULL) { |
437 object = SlowAllocateRaw(size_in_bytes); | 429 object = SlowAllocateRaw(size_in_bytes); |
438 } | 430 } |
439 if (object != NULL) { | 431 if (object != NULL) { |
440 if (heap()->incremental_marking()->black_allocation()) { | 432 if (heap()->incremental_marking()->black_allocation()) { |
441 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); | 433 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
442 MemoryChunk::IncrementLiveBytesFromGC(object, size_in_bytes); | 434 MemoryChunk::IncrementLiveBytes(object, size_in_bytes); |
443 } | 435 } |
444 } | 436 } |
445 } | 437 } |
446 | 438 |
447 if (object != NULL) { | 439 if (object != NULL) { |
448 if (update_skip_list == UPDATE_SKIP_LIST && identity() == CODE_SPACE) { | 440 if (update_skip_list == UPDATE_SKIP_LIST && identity() == CODE_SPACE) { |
449 SkipList::Update(object->address(), size_in_bytes); | 441 SkipList::Update(object->address(), size_in_bytes); |
450 } | 442 } |
451 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), size_in_bytes); | 443 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), size_in_bytes); |
452 return object; | 444 return object; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 other->allocation_info_.Reset(nullptr, nullptr); | 620 other->allocation_info_.Reset(nullptr, nullptr); |
629 return true; | 621 return true; |
630 } | 622 } |
631 return false; | 623 return false; |
632 } | 624 } |
633 | 625 |
634 } // namespace internal | 626 } // namespace internal |
635 } // namespace v8 | 627 } // namespace v8 |
636 | 628 |
637 #endif // V8_HEAP_SPACES_INL_H_ | 629 #endif // V8_HEAP_SPACES_INL_H_ |
OLD | NEW |