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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 681 |
673 void EnsureMarkingDequeIsCommittedAndInitialize(); | 682 void EnsureMarkingDequeIsCommittedAndInitialize(); |
674 | 683 |
675 void InitializeMarkingDeque(); | 684 void InitializeMarkingDeque(); |
676 | 685 |
677 void UncommitMarkingDeque(); | 686 void UncommitMarkingDeque(); |
678 | 687 |
679 // The following four methods can just be called after marking, when the | 688 // The following four methods can just be called after marking, when the |
680 // whole transitive closure is known. They must be called before sweeping | 689 // whole transitive closure is known. They must be called before sweeping |
681 // when mark bits are still intact. | 690 // when mark bits are still intact. |
682 bool IsSlotInBlackObject(Page* p, Address slot); | 691 bool IsSlotInBlackObject(Page* p, Address slot, HeapObject** out_object); |
683 bool IsSlotInBlackObjectSlow(Page* p, Address slot); | 692 bool IsSlotInBlackObjectSlow(Page* p, Address slot); |
684 bool IsSlotInLiveObject(HeapObject** address, HeapObject* object); | 693 bool IsSlotInLiveObject(Address slot); |
685 void VerifyIsSlotInLiveObject(HeapObject** address, HeapObject* object); | 694 void VerifyIsSlotInLiveObject(Address slot, HeapObject* object); |
686 | 695 |
687 private: | 696 private: |
688 class SweeperTask; | 697 class SweeperTask; |
689 | 698 |
690 explicit MarkCompactCollector(Heap* heap); | 699 explicit MarkCompactCollector(Heap* heap); |
691 ~MarkCompactCollector(); | 700 ~MarkCompactCollector(); |
692 | 701 |
693 bool MarkInvalidatedCode(); | 702 bool MarkInvalidatedCode(); |
694 bool WillBeDeoptimized(Code* code); | 703 bool WillBeDeoptimized(Code* code); |
695 void RemoveDeadInvalidatedCode(); | 704 void RemoveDeadInvalidatedCode(); |
696 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 705 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 706 void ClearInvalidSlotsBufferEntries(PagedSpace* space); |
| 707 void ClearInvalidStoreAndSlotsBufferEntries(); |
697 | 708 |
698 void StartSweeperThreads(); | 709 void StartSweeperThreads(); |
699 | 710 |
700 #ifdef DEBUG | 711 #ifdef DEBUG |
701 enum CollectorState { | 712 enum CollectorState { |
702 IDLE, | 713 IDLE, |
703 PREPARE_GC, | 714 PREPARE_GC, |
704 MARK_LIVE_OBJECTS, | 715 MARK_LIVE_OBJECTS, |
705 SWEEP_SPACES, | 716 SWEEP_SPACES, |
706 ENCODE_FORWARDING_ADDRESSES, | 717 ENCODE_FORWARDING_ADDRESSES, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 private: | 978 private: |
968 MarkCompactCollector* collector_; | 979 MarkCompactCollector* collector_; |
969 }; | 980 }; |
970 | 981 |
971 | 982 |
972 const char* AllocationSpaceName(AllocationSpace space); | 983 const char* AllocationSpaceName(AllocationSpace space); |
973 } | 984 } |
974 } // namespace v8::internal | 985 } // namespace v8::internal |
975 | 986 |
976 #endif // V8_HEAP_MARK_COMPACT_H_ | 987 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |