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_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 kHuge, | 124 kHuge, |
125 | 125 |
126 kFirstCategory = kTiniest, | 126 kFirstCategory = kTiniest, |
127 kLastCategory = kHuge, | 127 kLastCategory = kHuge, |
128 kNumberOfCategories = kLastCategory + 1, | 128 kNumberOfCategories = kLastCategory + 1, |
129 kInvalidCategory | 129 kInvalidCategory |
130 }; | 130 }; |
131 | 131 |
132 enum FreeMode { kLinkCategory, kDoNotLinkCategory }; | 132 enum FreeMode { kLinkCategory, kDoNotLinkCategory }; |
133 | 133 |
| 134 enum RememberedSetType { |
| 135 OLD_TO_NEW, |
| 136 OLD_TO_OLD, |
| 137 NUMBER_OF_REMEMBERED_SET_TYPES = OLD_TO_OLD + 1 |
| 138 }; |
| 139 |
134 // A free list category maintains a linked list of free memory blocks. | 140 // A free list category maintains a linked list of free memory blocks. |
135 class FreeListCategory { | 141 class FreeListCategory { |
136 public: | 142 public: |
137 static const int kSize = kIntSize + // FreeListCategoryType type_ | 143 static const int kSize = kIntSize + // FreeListCategoryType type_ |
138 kIntSize + // padding for type_ | 144 kIntSize + // padding for type_ |
139 kSizetSize + // size_t available_ | 145 kSizetSize + // size_t available_ |
140 kPointerSize + // FreeSpace* top_ | 146 kPointerSize + // FreeSpace* top_ |
141 kPointerSize + // FreeListCategory* prev_ | 147 kPointerSize + // FreeListCategory* prev_ |
142 kPointerSize; // FreeListCategory* next_ | 148 kPointerSize; // FreeListCategory* next_ |
143 | 149 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 kSizeOffset // NOLINT | 337 kSizeOffset // NOLINT |
332 + kSizetSize // size_t size | 338 + kSizetSize // size_t size |
333 + kIntptrSize // Flags flags_ | 339 + kIntptrSize // Flags flags_ |
334 + kPointerSize // Address area_start_ | 340 + kPointerSize // Address area_start_ |
335 + kPointerSize // Address area_end_ | 341 + kPointerSize // Address area_end_ |
336 + 2 * kPointerSize // base::VirtualMemory reservation_ | 342 + 2 * kPointerSize // base::VirtualMemory reservation_ |
337 + kPointerSize // Address owner_ | 343 + kPointerSize // Address owner_ |
338 + kPointerSize // Heap* heap_ | 344 + kPointerSize // Heap* heap_ |
339 + kIntSize // int progress_bar_ | 345 + kIntSize // int progress_bar_ |
340 + kIntSize // int live_bytes_count_ | 346 + kIntSize // int live_bytes_count_ |
341 + kPointerSize // SlotSet* old_to_new_slots_ | 347 + kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // SlotSet* array |
342 + kPointerSize // SlotSet* old_to_old_slots_ | 348 + kPointerSize * NUMBER_OF_REMEMBERED_SET_TYPES // TypedSlotSet* array |
343 + kPointerSize // TypedSlotSet* typed_old_to_new_slots_ | 349 + kPointerSize // SkipList* skip_list_ |
344 + kPointerSize // TypedSlotSet* typed_old_to_old_slots_ | 350 + kPointerSize // AtomicValue high_water_mark_ |
345 + kPointerSize // SkipList* skip_list_ | 351 + kPointerSize // base::Mutex* mutex_ |
346 + kPointerSize // AtomicValue high_water_mark_ | 352 + kPointerSize // base::AtomicWord concurrent_sweeping_ |
347 + kPointerSize // base::Mutex* mutex_ | 353 + 2 * kSizetSize // AtomicNumber free-list statistics |
348 + kPointerSize // base::AtomicWord concurrent_sweeping_ | 354 + kPointerSize // AtomicValue next_chunk_ |
349 + 2 * kSizetSize // AtomicNumber free-list statistics | 355 + kPointerSize // AtomicValue prev_chunk_ |
350 + kPointerSize // AtomicValue next_chunk_ | |
351 + kPointerSize // AtomicValue prev_chunk_ | |
352 + FreeListCategory::kSize * kNumberOfCategories | 356 + FreeListCategory::kSize * kNumberOfCategories |
353 // FreeListCategory categories_[kNumberOfCategories] | 357 // FreeListCategory categories_[kNumberOfCategories] |
354 + kPointerSize // LocalArrayBufferTracker* local_tracker_ | 358 + kPointerSize // LocalArrayBufferTracker* local_tracker_ |
355 + kIntptrSize // intptr_t young_generation_live_byte_count_ | 359 + kIntptrSize // intptr_t young_generation_live_byte_count_ |
356 + kPointerSize; // Bitmap* young_generation_bitmap_ | 360 + kPointerSize; // Bitmap* young_generation_bitmap_ |
357 | 361 |
358 // We add some more space to the computed header size to amount for missing | 362 // We add some more space to the computed header size to amount for missing |
359 // alignment requirements in our computation. | 363 // alignment requirements in our computation. |
360 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. | 364 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. |
361 static const size_t kHeaderSize = kMinHeaderSize; | 365 static const size_t kHeaderSize = kMinHeaderSize; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 460 |
457 size_t size() const { return size_; } | 461 size_t size() const { return size_; } |
458 void set_size(size_t size) { size_ = size; } | 462 void set_size(size_t size) { size_ = size; } |
459 | 463 |
460 inline Heap* heap() const { return heap_; } | 464 inline Heap* heap() const { return heap_; } |
461 | 465 |
462 inline SkipList* skip_list() { return skip_list_; } | 466 inline SkipList* skip_list() { return skip_list_; } |
463 | 467 |
464 inline void set_skip_list(SkipList* skip_list) { skip_list_ = skip_list; } | 468 inline void set_skip_list(SkipList* skip_list) { skip_list_ = skip_list; } |
465 | 469 |
466 inline SlotSet* old_to_new_slots() { return old_to_new_slots_.Value(); } | 470 template <RememberedSetType type> |
467 inline SlotSet* old_to_old_slots() { return old_to_old_slots_; } | 471 SlotSet* slot_set() { |
468 inline TypedSlotSet* typed_old_to_new_slots() { | 472 return slot_set_[type].Value(); |
469 return typed_old_to_new_slots_.Value(); | |
470 } | 473 } |
471 inline TypedSlotSet* typed_old_to_old_slots() { | 474 |
472 return typed_old_to_old_slots_; | 475 template <RememberedSetType type> |
| 476 TypedSlotSet* typed_slot_set() { |
| 477 return typed_slot_set_[type].Value(); |
473 } | 478 } |
| 479 |
474 inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; } | 480 inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; } |
475 | 481 |
476 V8_EXPORT_PRIVATE void AllocateOldToNewSlots(); | 482 template <RememberedSetType type> |
477 void ReleaseOldToNewSlots(); | 483 SlotSet* AllocateSlotSet(); |
478 V8_EXPORT_PRIVATE void AllocateOldToOldSlots(); | 484 template <RememberedSetType type> |
479 void ReleaseOldToOldSlots(); | 485 void ReleaseSlotSet(); |
480 void AllocateTypedOldToNewSlots(); | 486 template <RememberedSetType type> |
481 void ReleaseTypedOldToNewSlots(); | 487 TypedSlotSet* AllocateTypedSlotSet(); |
482 void AllocateTypedOldToOldSlots(); | 488 template <RememberedSetType type> |
483 void ReleaseTypedOldToOldSlots(); | 489 void ReleaseTypedSlotSet(); |
484 void AllocateLocalTracker(); | 490 void AllocateLocalTracker(); |
485 void ReleaseLocalTracker(); | 491 void ReleaseLocalTracker(); |
486 void AllocateExternalBitmap(); | 492 void AllocateExternalBitmap(); |
487 void ReleaseExternalBitmap(); | 493 void ReleaseExternalBitmap(); |
488 | 494 |
489 Address area_start() { return area_start_; } | 495 Address area_start() { return area_start_; } |
490 Address area_end() { return area_end_; } | 496 Address area_end() { return area_end_; } |
491 size_t area_size() { return static_cast<size_t>(area_end() - area_start()); } | 497 size_t area_size() { return static_cast<size_t>(area_end() - area_start()); } |
492 | 498 |
493 bool CommitArea(size_t requested); | 499 bool CommitArea(size_t requested); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 // Used by the incremental marker to keep track of the scanning progress in | 644 // Used by the incremental marker to keep track of the scanning progress in |
639 // large objects that have a progress bar and are scanned in increments. | 645 // large objects that have a progress bar and are scanned in increments. |
640 int progress_bar_; | 646 int progress_bar_; |
641 | 647 |
642 // Count of bytes marked black on page. | 648 // Count of bytes marked black on page. |
643 int live_byte_count_; | 649 int live_byte_count_; |
644 | 650 |
645 // A single slot set for small pages (of size kPageSize) or an array of slot | 651 // A single slot set for small pages (of size kPageSize) or an array of slot |
646 // set for large pages. In the latter case the number of entries in the array | 652 // set for large pages. In the latter case the number of entries in the array |
647 // is ceil(size() / kPageSize). | 653 // is ceil(size() / kPageSize). |
648 base::AtomicValue<SlotSet*> old_to_new_slots_; | 654 base::AtomicValue<SlotSet*> slot_set_[NUMBER_OF_REMEMBERED_SET_TYPES]; |
649 SlotSet* old_to_old_slots_; | 655 base::AtomicValue<TypedSlotSet*> |
650 base::AtomicValue<TypedSlotSet*> typed_old_to_new_slots_; | 656 typed_slot_set_[NUMBER_OF_REMEMBERED_SET_TYPES]; |
651 TypedSlotSet* typed_old_to_old_slots_; | |
652 | 657 |
653 SkipList* skip_list_; | 658 SkipList* skip_list_; |
654 | 659 |
655 // Assuming the initial allocation on a page is sequential, | 660 // Assuming the initial allocation on a page is sequential, |
656 // count highest number of bytes ever allocated on the page. | 661 // count highest number of bytes ever allocated on the page. |
657 base::AtomicValue<intptr_t> high_water_mark_; | 662 base::AtomicValue<intptr_t> high_water_mark_; |
658 | 663 |
659 base::Mutex* mutex_; | 664 base::Mutex* mutex_; |
660 | 665 |
661 base::AtomicValue<ConcurrentSweepingState> concurrent_sweeping_; | 666 base::AtomicValue<ConcurrentSweepingState> concurrent_sweeping_; |
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 PageIterator old_iterator_; | 2962 PageIterator old_iterator_; |
2958 PageIterator code_iterator_; | 2963 PageIterator code_iterator_; |
2959 PageIterator map_iterator_; | 2964 PageIterator map_iterator_; |
2960 LargePageIterator lo_iterator_; | 2965 LargePageIterator lo_iterator_; |
2961 }; | 2966 }; |
2962 | 2967 |
2963 } // namespace internal | 2968 } // namespace internal |
2964 } // namespace v8 | 2969 } // namespace v8 |
2965 | 2970 |
2966 #endif // V8_HEAP_SPACES_H_ | 2971 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |