OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_MARK_COMPACT_H_ | 5 #ifndef V8_HEAP_MARK_COMPACT_H_ |
6 #define V8_HEAP_MARK_COMPACT_H_ | 6 #define V8_HEAP_MARK_COMPACT_H_ |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 | 10 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 buffer->Add(slot); | 356 buffer->Add(slot); |
357 return true; | 357 return true; |
358 } | 358 } |
359 | 359 |
360 static bool IsTypedSlot(ObjectSlot slot); | 360 static bool IsTypedSlot(ObjectSlot slot); |
361 | 361 |
362 static bool AddTo(SlotsBufferAllocator* allocator, | 362 static bool AddTo(SlotsBufferAllocator* allocator, |
363 SlotsBuffer** buffer_address, SlotType type, Address addr, | 363 SlotsBuffer** buffer_address, SlotType type, Address addr, |
364 AdditionMode mode); | 364 AdditionMode mode); |
365 | 365 |
| 366 // Eliminates all stale entries from the slots buffer, i.e., slots that |
| 367 // are not part of live objects anymore. This method must be called after |
| 368 // marking, when the whole transitive closure is known and must be called |
| 369 // before sweeping when mark bits are still intact. |
| 370 static void RemoveInvalidSlots(Heap* heap, SlotsBuffer* buffer); |
| 371 |
| 372 // Ensures that there are no invalid slots in the chain of slots buffers. |
| 373 static void VerifySlots(Heap* heap, SlotsBuffer* buffer); |
| 374 |
366 static const int kNumberOfElements = 1021; | 375 static const int kNumberOfElements = 1021; |
367 | 376 |
368 private: | 377 private: |
369 static const int kChainLengthThreshold = 15; | 378 static const int kChainLengthThreshold = 15; |
370 | 379 |
371 intptr_t idx_; | 380 intptr_t idx_; |
372 intptr_t chain_length_; | 381 intptr_t chain_length_; |
373 SlotsBuffer* next_; | 382 SlotsBuffer* next_; |
374 ObjectSlot slots_[kNumberOfElements]; | 383 ObjectSlot slots_[kNumberOfElements]; |
375 }; | 384 }; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 660 |
652 void EnsureMarkingDequeIsCommittedAndInitialize(); | 661 void EnsureMarkingDequeIsCommittedAndInitialize(); |
653 | 662 |
654 void InitializeMarkingDeque(); | 663 void InitializeMarkingDeque(); |
655 | 664 |
656 void UncommitMarkingDeque(); | 665 void UncommitMarkingDeque(); |
657 | 666 |
658 // The following four methods can just be called after marking, when the | 667 // The following four methods can just be called after marking, when the |
659 // whole transitive closure is known. They must be called before sweeping | 668 // whole transitive closure is known. They must be called before sweeping |
660 // when mark bits are still intact. | 669 // when mark bits are still intact. |
661 bool IsSlotInBlackObject(Page* p, Address slot); | 670 bool IsSlotInBlackObject(Page* p, Address slot, HeapObject** out_object); |
662 bool IsSlotInBlackObjectSlow(Page* p, Address slot); | 671 bool IsSlotInBlackObjectSlow(Page* p, Address slot); |
663 bool IsSlotInLiveObject(HeapObject** address, HeapObject* object); | 672 bool IsSlotInLiveObject(Address slot); |
664 void VerifyIsSlotInLiveObject(HeapObject** address, HeapObject* object); | 673 void VerifyIsSlotInLiveObject(Address slot, HeapObject* object); |
665 | 674 |
666 private: | 675 private: |
667 class SweeperTask; | 676 class SweeperTask; |
668 | 677 |
669 explicit MarkCompactCollector(Heap* heap); | 678 explicit MarkCompactCollector(Heap* heap); |
670 ~MarkCompactCollector(); | 679 ~MarkCompactCollector(); |
671 | 680 |
672 bool MarkInvalidatedCode(); | 681 bool MarkInvalidatedCode(); |
673 bool WillBeDeoptimized(Code* code); | 682 bool WillBeDeoptimized(Code* code); |
674 void RemoveDeadInvalidatedCode(); | 683 void RemoveDeadInvalidatedCode(); |
675 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 684 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
676 void EvictEvacuationCandidate(Page* page); | 685 void EvictEvacuationCandidate(Page* page); |
| 686 void ClearInvalidSlotsBufferEntries(PagedSpace* space); |
| 687 void ClearInvalidStoreAndSlotsBufferEntries(); |
677 | 688 |
678 void StartSweeperThreads(); | 689 void StartSweeperThreads(); |
679 | 690 |
680 #ifdef DEBUG | 691 #ifdef DEBUG |
681 enum CollectorState { | 692 enum CollectorState { |
682 IDLE, | 693 IDLE, |
683 PREPARE_GC, | 694 PREPARE_GC, |
684 MARK_LIVE_OBJECTS, | 695 MARK_LIVE_OBJECTS, |
685 SWEEP_SPACES, | 696 SWEEP_SPACES, |
686 ENCODE_FORWARDING_ADDRESSES, | 697 ENCODE_FORWARDING_ADDRESSES, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 private: | 958 private: |
948 MarkCompactCollector* collector_; | 959 MarkCompactCollector* collector_; |
949 }; | 960 }; |
950 | 961 |
951 | 962 |
952 const char* AllocationSpaceName(AllocationSpace space); | 963 const char* AllocationSpaceName(AllocationSpace space); |
953 } | 964 } |
954 } // namespace v8::internal | 965 } // namespace v8::internal |
955 | 966 |
956 #endif // V8_HEAP_MARK_COMPACT_H_ | 967 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |