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 | |
375 static const int kNumberOfElements = 1021; | 366 static const int kNumberOfElements = 1021; |
376 | 367 |
377 private: | 368 private: |
378 static const int kChainLengthThreshold = 15; | 369 static const int kChainLengthThreshold = 15; |
379 | 370 |
380 intptr_t idx_; | 371 intptr_t idx_; |
381 intptr_t chain_length_; | 372 intptr_t chain_length_; |
382 SlotsBuffer* next_; | 373 SlotsBuffer* next_; |
383 ObjectSlot slots_[kNumberOfElements]; | 374 ObjectSlot slots_[kNumberOfElements]; |
384 }; | 375 }; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 | 651 |
661 void EnsureMarkingDequeIsCommittedAndInitialize(); | 652 void EnsureMarkingDequeIsCommittedAndInitialize(); |
662 | 653 |
663 void InitializeMarkingDeque(); | 654 void InitializeMarkingDeque(); |
664 | 655 |
665 void UncommitMarkingDeque(); | 656 void UncommitMarkingDeque(); |
666 | 657 |
667 // The following four methods can just be called after marking, when the | 658 // The following four methods can just be called after marking, when the |
668 // whole transitive closure is known. They must be called before sweeping | 659 // whole transitive closure is known. They must be called before sweeping |
669 // when mark bits are still intact. | 660 // when mark bits are still intact. |
670 bool IsSlotInBlackObject(Page* p, Address slot, HeapObject** out_object); | 661 bool IsSlotInBlackObject(Page* p, Address slot); |
671 bool IsSlotInBlackObjectSlow(Page* p, Address slot); | 662 bool IsSlotInBlackObjectSlow(Page* p, Address slot); |
672 bool IsSlotInLiveObject(Address slot); | 663 bool IsSlotInLiveObject(HeapObject** address, HeapObject* object); |
673 void VerifyIsSlotInLiveObject(Address slot, HeapObject* object); | 664 void VerifyIsSlotInLiveObject(HeapObject** address, HeapObject* object); |
674 | 665 |
675 private: | 666 private: |
676 class SweeperTask; | 667 class SweeperTask; |
677 | 668 |
678 explicit MarkCompactCollector(Heap* heap); | 669 explicit MarkCompactCollector(Heap* heap); |
679 ~MarkCompactCollector(); | 670 ~MarkCompactCollector(); |
680 | 671 |
681 bool MarkInvalidatedCode(); | 672 bool MarkInvalidatedCode(); |
682 bool WillBeDeoptimized(Code* code); | 673 bool WillBeDeoptimized(Code* code); |
683 void RemoveDeadInvalidatedCode(); | 674 void RemoveDeadInvalidatedCode(); |
684 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 675 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
685 void EvictEvacuationCandidate(Page* page); | 676 void EvictEvacuationCandidate(Page* page); |
686 void ClearInvalidSlotsBufferEntries(PagedSpace* space); | |
687 void ClearInvalidStoreAndSlotsBufferEntries(); | |
688 | 677 |
689 void StartSweeperThreads(); | 678 void StartSweeperThreads(); |
690 | 679 |
691 #ifdef DEBUG | 680 #ifdef DEBUG |
692 enum CollectorState { | 681 enum CollectorState { |
693 IDLE, | 682 IDLE, |
694 PREPARE_GC, | 683 PREPARE_GC, |
695 MARK_LIVE_OBJECTS, | 684 MARK_LIVE_OBJECTS, |
696 SWEEP_SPACES, | 685 SWEEP_SPACES, |
697 ENCODE_FORWARDING_ADDRESSES, | 686 ENCODE_FORWARDING_ADDRESSES, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 private: | 947 private: |
959 MarkCompactCollector* collector_; | 948 MarkCompactCollector* collector_; |
960 }; | 949 }; |
961 | 950 |
962 | 951 |
963 const char* AllocationSpaceName(AllocationSpace space); | 952 const char* AllocationSpaceName(AllocationSpace space); |
964 } | 953 } |
965 } // namespace v8::internal | 954 } // namespace v8::internal |
966 | 955 |
967 #endif // V8_HEAP_MARK_COMPACT_H_ | 956 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |