| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 bool in_to_space = (owner->id() != kFromSpace); | 175 bool in_to_space = (owner->id() != kFromSpace); |
| 176 chunk->SetFlag(in_to_space ? MemoryChunk::IN_TO_SPACE | 176 chunk->SetFlag(in_to_space ? MemoryChunk::IN_TO_SPACE |
| 177 : MemoryChunk::IN_FROM_SPACE); | 177 : MemoryChunk::IN_FROM_SPACE); |
| 178 DCHECK(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE | 178 DCHECK(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE |
| 179 : MemoryChunk::IN_TO_SPACE)); | 179 : MemoryChunk::IN_TO_SPACE)); |
| 180 Page* page = static_cast<Page*>(chunk); | 180 Page* page = static_cast<Page*>(chunk); |
| 181 heap->incremental_marking()->SetNewSpacePageFlags(page); | 181 heap->incremental_marking()->SetNewSpacePageFlags(page); |
| 182 page->AllocateLocalTracker(); | 182 page->AllocateLocalTracker(); |
| 183 if (FLAG_minor_mc) { | 183 if (FLAG_minor_mc) { |
| 184 page->AllocateYoungGenerationBitmap(); | 184 page->AllocateYoungGenerationBitmap(); |
| 185 page->ClearLiveness<MarkingMode::YOUNG_GENERATION>(); | 185 MarkingState::External(page).ClearLiveness(); |
| 186 } | 186 } |
| 187 return page; | 187 return page; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // -------------------------------------------------------------------------- | 190 // -------------------------------------------------------------------------- |
| 191 // PagedSpace | 191 // PagedSpace |
| 192 | 192 |
| 193 template <Page::InitializationMode mode> | 193 template <Page::InitializationMode mode> |
| 194 Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable, | 194 Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable, |
| 195 PagedSpace* owner) { | 195 PagedSpace* owner) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 223 new_page->InsertAfter(old_space->anchor()->prev_page()); | 223 new_page->InsertAfter(old_space->anchor()->prev_page()); |
| 224 return new_page; | 224 return new_page; |
| 225 } | 225 } |
| 226 | 226 |
| 227 void Page::InitializeFreeListCategories() { | 227 void Page::InitializeFreeListCategories() { |
| 228 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { | 228 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { |
| 229 categories_[i].Initialize(static_cast<FreeListCategoryType>(i)); | 229 categories_[i].Initialize(static_cast<FreeListCategoryType>(i)); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 template <MarkingMode mode> | |
| 234 void MemoryChunk::IncrementLiveBytes(HeapObject* object, int by) { | |
| 235 MemoryChunk::FromAddress(object->address())->IncrementLiveBytes<mode>(by); | |
| 236 } | |
| 237 | |
| 238 template <MarkingMode mode> | |
| 239 void MemoryChunk::TraceLiveBytes(intptr_t old_value, intptr_t new_value) { | |
| 240 if (!FLAG_trace_live_bytes) return; | |
| 241 PrintIsolate(heap()->isolate(), | |
| 242 "live-bytes[%p:%s]: %" V8PRIdPTR "-> %" V8PRIdPTR "\n", | |
| 243 static_cast<void*>(this), | |
| 244 mode == MarkingMode::FULL ? "internal" : "external", old_value, | |
| 245 new_value); | |
| 246 } | |
| 247 | |
| 248 template <MarkingMode mode> | |
| 249 void MemoryChunk::ResetLiveBytes() { | |
| 250 switch (mode) { | |
| 251 case MarkingMode::FULL: | |
| 252 TraceLiveBytes(live_byte_count_, 0); | |
| 253 live_byte_count_ = 0; | |
| 254 break; | |
| 255 case MarkingMode::YOUNG_GENERATION: | |
| 256 TraceLiveBytes(young_generation_live_byte_count_, 0); | |
| 257 young_generation_live_byte_count_ = 0; | |
| 258 break; | |
| 259 } | |
| 260 } | |
| 261 | |
| 262 template <MarkingMode mode> | |
| 263 void MemoryChunk::IncrementLiveBytes(int by) { | |
| 264 switch (mode) { | |
| 265 case MarkingMode::FULL: | |
| 266 TraceLiveBytes(live_byte_count_, live_byte_count_ + by); | |
| 267 live_byte_count_ += by; | |
| 268 DCHECK_GE(live_byte_count_, 0); | |
| 269 DCHECK_LE(static_cast<size_t>(live_byte_count_), size_); | |
| 270 break; | |
| 271 case MarkingMode::YOUNG_GENERATION: | |
| 272 TraceLiveBytes(young_generation_live_byte_count_, | |
| 273 young_generation_live_byte_count_ + by); | |
| 274 young_generation_live_byte_count_ += by; | |
| 275 DCHECK_GE(young_generation_live_byte_count_, 0); | |
| 276 DCHECK_LE(static_cast<size_t>(young_generation_live_byte_count_), size_); | |
| 277 break; | |
| 278 } | |
| 279 } | |
| 280 | |
| 281 bool PagedSpace::Contains(Address addr) { | 233 bool PagedSpace::Contains(Address addr) { |
| 282 return MemoryChunk::FromAnyPointerAddress(heap(), addr)->owner() == this; | 234 return MemoryChunk::FromAnyPointerAddress(heap(), addr)->owner() == this; |
| 283 } | 235 } |
| 284 | 236 |
| 285 bool PagedSpace::Contains(Object* o) { | 237 bool PagedSpace::Contains(Object* o) { |
| 286 if (!o->IsHeapObject()) return false; | 238 if (!o->IsHeapObject()) return false; |
| 287 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); | 239 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); |
| 288 if (!Page::IsValid(p)) return false; | 240 if (!Page::IsValid(p)) return false; |
| 289 return p->owner() == this; | 241 return p->owner() == this; |
| 290 } | 242 } |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 other->allocation_info_.Reset(nullptr, nullptr); | 621 other->allocation_info_.Reset(nullptr, nullptr); |
| 670 return true; | 622 return true; |
| 671 } | 623 } |
| 672 return false; | 624 return false; |
| 673 } | 625 } |
| 674 | 626 |
| 675 } // namespace internal | 627 } // namespace internal |
| 676 } // namespace v8 | 628 } // namespace v8 |
| 677 | 629 |
| 678 #endif // V8_HEAP_SPACES_INL_H_ | 630 #endif // V8_HEAP_SPACES_INL_H_ |
| OLD | NEW |