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