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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 template <class T> | 649 template <class T> |
650 void DiscoverGreyObjectsWithIterator(T* it); | 650 void DiscoverGreyObjectsWithIterator(T* it); |
651 void DiscoverGreyObjectsOnPage(MemoryChunk* p); | 651 void DiscoverGreyObjectsOnPage(MemoryChunk* p); |
652 void DiscoverGreyObjectsInSpace(PagedSpace* space); | 652 void DiscoverGreyObjectsInSpace(PagedSpace* space); |
653 void DiscoverGreyObjectsInNewSpace(); | 653 void DiscoverGreyObjectsInNewSpace(); |
654 | 654 |
655 // Callback function for telling whether the object *p is an unmarked | 655 // Callback function for telling whether the object *p is an unmarked |
656 // heap object. | 656 // heap object. |
657 static bool IsUnmarkedHeapObject(Object** p); | 657 static bool IsUnmarkedHeapObject(Object** p); |
658 | 658 |
659 // Map transitions from a live map to a dead map must be killed. | 659 // Clear non-live references in weak cells, transition and descriptor arrays, |
660 // We replace them with a null descriptor, with the same key. | 660 // and deoptimize dependent code of non-live maps. |
661 void ClearNonLiveReferences(); | 661 void ClearNonLiveReferences(); |
662 void ClearNonLiveMapTransitions(Map* map); | 662 void MarkDependentCodeForDeoptimization(DependentCode* list); |
663 void ClearMapTransitions(Map* map, Map* dead_transition); | 663 // Find non-live targets of simple transitions in the given list. Clear |
664 bool ClearMapBackPointer(Map* map); | 664 // transitions to non-live targets and if needed trim descriptors arrays. |
665 void MarkDependentCodeListForDeoptimization(DependentCode* list_head); | 665 void ClearSimpleMapTransitions(Object* non_live_map_list); |
666 void TrimDescriptorArray(Map* map, DescriptorArray* descriptors, | 666 void ClearSimpleMapTransition(Map* map, Map* dead_transition); |
667 int number_of_own_descriptors); | 667 // Compact every array in the global list of transition arrays and |
| 668 // trim the corresponding descriptor array if a transition target is non-live. |
| 669 void ClearFullMapTransitions(); |
| 670 bool CompactTransitionArray(Map* map, TransitionArray* transitions, |
| 671 DescriptorArray* descriptors); |
| 672 void TrimDescriptorArray(Map* map, DescriptorArray* descriptors); |
668 void TrimEnumCache(Map* map, DescriptorArray* descriptors); | 673 void TrimEnumCache(Map* map, DescriptorArray* descriptors); |
669 | 674 |
670 // Mark all values associated with reachable keys in weak collections | 675 // Mark all values associated with reachable keys in weak collections |
671 // encountered so far. This might push new object or even new weak maps onto | 676 // encountered so far. This might push new object or even new weak maps onto |
672 // the marking stack. | 677 // the marking stack. |
673 void ProcessWeakCollections(); | 678 void ProcessWeakCollections(); |
674 | 679 |
675 // After all reachable objects have been marked those weak map entries | 680 // After all reachable objects have been marked those weak map entries |
676 // with an unreachable key are removed from all encountered weak maps. | 681 // with an unreachable key are removed from all encountered weak maps. |
677 // The linked list of all encountered weak maps is destroyed. | 682 // The linked list of all encountered weak maps is destroyed. |
678 void ClearWeakCollections(); | 683 void ClearWeakCollections(); |
679 | 684 |
680 // We have to remove all encountered weak maps from the list of weak | 685 // We have to remove all encountered weak maps from the list of weak |
681 // collections when incremental marking is aborted. | 686 // collections when incremental marking is aborted. |
682 void AbortWeakCollections(); | 687 void AbortWeakCollections(); |
683 | 688 |
684 void ProcessAndClearWeakCells(); | 689 void ClearWeakCells(Object** non_live_map_list, |
| 690 DependentCode** dependent_code_list); |
685 void AbortWeakCells(); | 691 void AbortWeakCells(); |
686 | 692 |
687 void ProcessAndClearTransitionArrays(); | |
688 void AbortTransitionArrays(); | 693 void AbortTransitionArrays(); |
689 | 694 |
690 // After all reachable objects have been marked, those entries within | 695 // After all reachable objects have been marked, those entries within |
691 // optimized code maps that became unreachable are removed, potentially | 696 // optimized code maps that became unreachable are removed, potentially |
692 // trimming or clearing out the entire optimized code map. | 697 // trimming or clearing out the entire optimized code map. |
693 void ProcessAndClearOptimizedCodeMaps(); | 698 void ProcessAndClearOptimizedCodeMaps(); |
694 | 699 |
695 // Process non-live references in maps and optimized code. | |
696 void ProcessWeakReferences(); | |
697 | |
698 // ----------------------------------------------------------------------- | 700 // ----------------------------------------------------------------------- |
699 // Phase 2: Sweeping to clear mark bits and free non-live objects for | 701 // Phase 2: Sweeping to clear mark bits and free non-live objects for |
700 // a non-compacting collection. | 702 // a non-compacting collection. |
701 // | 703 // |
702 // Before: Live objects are marked and non-live objects are unmarked. | 704 // Before: Live objects are marked and non-live objects are unmarked. |
703 // | 705 // |
704 // After: Live objects are unmarked, non-live regions have been added to | 706 // After: Live objects are unmarked, non-live regions have been added to |
705 // their space's free list. Active eden semispace is compacted by | 707 // their space's free list. Active eden semispace is compacted by |
706 // evacuation. | 708 // evacuation. |
707 // | 709 // |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 private: | 870 private: |
869 MarkCompactCollector* collector_; | 871 MarkCompactCollector* collector_; |
870 }; | 872 }; |
871 | 873 |
872 | 874 |
873 const char* AllocationSpaceName(AllocationSpace space); | 875 const char* AllocationSpaceName(AllocationSpace space); |
874 } // namespace internal | 876 } // namespace internal |
875 } // namespace v8 | 877 } // namespace v8 |
876 | 878 |
877 #endif // V8_HEAP_MARK_COMPACT_H_ | 879 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |