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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 DCHECK(page->area_size() <= kAllocatableMemory); | 244 DCHECK(page->area_size() <= kAllocatableMemory); |
245 DCHECK(chunk->owner() == owner); | 245 DCHECK(chunk->owner() == owner); |
246 owner->IncreaseCapacity(page->area_size()); | 246 owner->IncreaseCapacity(page->area_size()); |
247 owner->Free(page->area_start(), page->area_size()); | 247 owner->Free(page->area_start(), page->area_size()); |
248 | 248 |
249 heap->incremental_marking()->SetOldSpacePageFlags(chunk); | 249 heap->incremental_marking()->SetOldSpacePageFlags(chunk); |
250 | 250 |
251 return page; | 251 return page; |
252 } | 252 } |
253 | 253 |
| 254 void MemoryChunk::IncrementLiveBytesFromGC(HeapObject* object, int by) { |
| 255 MemoryChunk::FromAddress(object->address())->IncrementLiveBytes(by); |
| 256 } |
| 257 |
| 258 void MemoryChunk::ResetLiveBytes() { |
| 259 if (FLAG_trace_live_bytes) { |
| 260 PrintIsolate(heap()->isolate(), "live-bytes: reset page=%p %d->0\n", this, |
| 261 live_byte_count_); |
| 262 } |
| 263 live_byte_count_ = 0; |
| 264 } |
| 265 |
| 266 void MemoryChunk::IncrementLiveBytes(int by) { |
| 267 if (FLAG_trace_live_bytes) { |
| 268 PrintIsolate(heap()->isolate(), |
| 269 "live-bytes: update page=%p delta=%d %d->%d\n", this, by, |
| 270 live_byte_count_, live_byte_count_ + by); |
| 271 } |
| 272 live_byte_count_ += by; |
| 273 DCHECK_GE(live_byte_count_, 0); |
| 274 DCHECK_LE(static_cast<size_t>(live_byte_count_), size_); |
| 275 } |
| 276 |
| 277 void MemoryChunk::IncrementLiveBytesFromMutator(HeapObject* object, int by) { |
| 278 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); |
| 279 if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->SweepingDone()) { |
| 280 static_cast<PagedSpace*>(chunk->owner())->Allocate(by); |
| 281 } |
| 282 chunk->IncrementLiveBytes(by); |
| 283 } |
254 | 284 |
255 bool PagedSpace::Contains(Address addr) { | 285 bool PagedSpace::Contains(Address addr) { |
256 Page* p = Page::FromAddress(addr); | 286 Page* p = Page::FromAddress(addr); |
257 if (!p->is_valid()) return false; | 287 if (!p->is_valid()) return false; |
258 return p->owner() == this; | 288 return p->owner() == this; |
259 } | 289 } |
260 | 290 |
261 bool PagedSpace::Contains(Object* o) { | 291 bool PagedSpace::Contains(Object* o) { |
262 if (!o->IsHeapObject()) return false; | 292 if (!o->IsHeapObject()) return false; |
263 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); | 293 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 other->allocation_info_.Reset(nullptr, nullptr); | 611 other->allocation_info_.Reset(nullptr, nullptr); |
582 return true; | 612 return true; |
583 } | 613 } |
584 return false; | 614 return false; |
585 } | 615 } |
586 | 616 |
587 } // namespace internal | 617 } // namespace internal |
588 } // namespace v8 | 618 } // namespace v8 |
589 | 619 |
590 #endif // V8_HEAP_SPACES_INL_H_ | 620 #endif // V8_HEAP_SPACES_INL_H_ |
OLD | NEW |