| 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 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 // Callback function, returns whether an object is alive. The heap size | 14 // Callback function, returns whether an object is alive. The heap size |
| 15 // of the object is returned in size. It optionally updates the offset | 15 // of the object is returned in size. It optionally updates the offset |
| 16 // to the first live object in the page (only used for old and map objects). | 16 // to the first live object in the page (only used for old and map objects). |
| 17 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); | 17 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); |
| 18 | 18 |
| 19 // Callback function to mark an object in a given heap. |
| 20 typedef void (*MarkObjectFunction)(Heap* heap, HeapObject* object); |
| 21 |
| 19 // Forward declarations. | 22 // Forward declarations. |
| 20 class CodeFlusher; | 23 class CodeFlusher; |
| 21 class MarkCompactCollector; | 24 class MarkCompactCollector; |
| 22 class MarkingVisitor; | 25 class MarkingVisitor; |
| 23 class RootMarkingVisitor; | 26 class RootMarkingVisitor; |
| 24 | 27 |
| 25 | 28 |
| 26 class Marking { | 29 class Marking { |
| 27 public: | 30 public: |
| 28 explicit Marking(Heap* heap) : heap_(heap) {} | 31 explicit Marking(Heap* heap) : heap_(heap) {} |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 546 |
| 544 // Determine type of object and emit deletion log event. | 547 // Determine type of object and emit deletion log event. |
| 545 static void ReportDeleteIfNeeded(HeapObject* obj, Isolate* isolate); | 548 static void ReportDeleteIfNeeded(HeapObject* obj, Isolate* isolate); |
| 546 | 549 |
| 547 // Distinguishable invalid map encodings (for single word and multiple words) | 550 // Distinguishable invalid map encodings (for single word and multiple words) |
| 548 // that indicate free regions. | 551 // that indicate free regions. |
| 549 static const uint32_t kSingleFreeEncoding = 0; | 552 static const uint32_t kSingleFreeEncoding = 0; |
| 550 static const uint32_t kMultiFreeEncoding = 1; | 553 static const uint32_t kMultiFreeEncoding = 1; |
| 551 | 554 |
| 552 static inline bool IsMarked(Object* obj); | 555 static inline bool IsMarked(Object* obj); |
| 556 static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); |
| 553 | 557 |
| 554 inline Heap* heap() const { return heap_; } | 558 inline Heap* heap() const { return heap_; } |
| 555 inline Isolate* isolate() const; | 559 inline Isolate* isolate() const; |
| 556 | 560 |
| 557 CodeFlusher* code_flusher() { return code_flusher_; } | 561 CodeFlusher* code_flusher() { return code_flusher_; } |
| 558 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } | 562 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } |
| 559 void EnableCodeFlushing(bool enable); | 563 void EnableCodeFlushing(bool enable); |
| 560 | 564 |
| 561 enum SweeperType { | 565 enum SweeperType { |
| 562 CONCURRENT_SWEEPING, | 566 CONCURRENT_SWEEPING, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 bool sweeping_in_progress() { return sweeping_in_progress_; } | 660 bool sweeping_in_progress() { return sweeping_in_progress_; } |
| 657 | 661 |
| 658 void set_evacuation(bool evacuation) { evacuation_ = evacuation; } | 662 void set_evacuation(bool evacuation) { evacuation_ = evacuation; } |
| 659 | 663 |
| 660 bool evacuation() const { return evacuation_; } | 664 bool evacuation() const { return evacuation_; } |
| 661 | 665 |
| 662 // Special case for processing weak references in a full collection. We need | 666 // Special case for processing weak references in a full collection. We need |
| 663 // to artificially keep AllocationSites alive for a time. | 667 // to artificially keep AllocationSites alive for a time. |
| 664 void MarkAllocationSite(AllocationSite* site); | 668 void MarkAllocationSite(AllocationSite* site); |
| 665 | 669 |
| 670 // Mark objects in implicit references groups if their parent object |
| 671 // is marked. |
| 672 void MarkImplicitRefGroups(MarkObjectFunction mark_object); |
| 673 |
| 666 MarkingDeque* marking_deque() { return &marking_deque_; } | 674 MarkingDeque* marking_deque() { return &marking_deque_; } |
| 667 | 675 |
| 668 void EnsureMarkingDequeIsCommittedAndInitialize(); | 676 void EnsureMarkingDequeIsCommittedAndInitialize(); |
| 669 | 677 |
| 670 void InitializeMarkingDeque(); | 678 void InitializeMarkingDeque(); |
| 671 | 679 |
| 672 void UncommitMarkingDeque(); | 680 void UncommitMarkingDeque(); |
| 673 | 681 |
| 674 void OverApproximateWeakClosure(); | |
| 675 | |
| 676 // The following four methods can just be called after marking, when the | 682 // The following four methods can just be called after marking, when the |
| 677 // whole transitive closure is known. They must be called before sweeping | 683 // whole transitive closure is known. They must be called before sweeping |
| 678 // when mark bits are still intact. | 684 // when mark bits are still intact. |
| 679 bool IsSlotInBlackObject(Page* p, Address slot); | 685 bool IsSlotInBlackObject(Page* p, Address slot); |
| 680 bool IsSlotInBlackObjectSlow(Page* p, Address slot); | 686 bool IsSlotInBlackObjectSlow(Page* p, Address slot); |
| 681 bool IsSlotInLiveObject(HeapObject** address, HeapObject* object); | 687 bool IsSlotInLiveObject(HeapObject** address, HeapObject* object); |
| 682 void VerifyIsSlotInLiveObject(HeapObject** address, HeapObject* object); | 688 void VerifyIsSlotInLiveObject(HeapObject** address, HeapObject* object); |
| 683 | 689 |
| 684 private: | 690 private: |
| 685 class SweeperTask; | 691 class SweeperTask; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 // This is for non-incremental marking only. | 775 // This is for non-incremental marking only. |
| 770 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); | 776 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); |
| 771 | 777 |
| 772 // Mark the heap roots and all objects reachable from them. | 778 // Mark the heap roots and all objects reachable from them. |
| 773 void MarkRoots(RootMarkingVisitor* visitor); | 779 void MarkRoots(RootMarkingVisitor* visitor); |
| 774 | 780 |
| 775 // Mark the string table specially. References to internalized strings from | 781 // Mark the string table specially. References to internalized strings from |
| 776 // the string table are weak. | 782 // the string table are weak. |
| 777 void MarkStringTable(RootMarkingVisitor* visitor); | 783 void MarkStringTable(RootMarkingVisitor* visitor); |
| 778 | 784 |
| 779 // Mark objects in implicit references groups if their parent object | |
| 780 // is marked. | |
| 781 void MarkImplicitRefGroups(); | |
| 782 | |
| 783 // Mark objects reachable (transitively) from objects in the marking stack | 785 // Mark objects reachable (transitively) from objects in the marking stack |
| 784 // or overflowed in the heap. | 786 // or overflowed in the heap. |
| 785 void ProcessMarkingDeque(); | 787 void ProcessMarkingDeque(); |
| 786 | 788 |
| 787 // Mark objects reachable (transitively) from objects in the marking stack | 789 // Mark objects reachable (transitively) from objects in the marking stack |
| 788 // or overflowed in the heap. This respects references only considered in | 790 // or overflowed in the heap. This respects references only considered in |
| 789 // the final atomic marking pause including the following: | 791 // the final atomic marking pause including the following: |
| 790 // - Processing of objects reachable through Harmony WeakMaps. | 792 // - Processing of objects reachable through Harmony WeakMaps. |
| 791 // - Objects reachable due to host application logic like object groups | 793 // - Objects reachable due to host application logic like object groups |
| 792 // or implicit references' groups. | 794 // or implicit references' groups. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 809 void EmptyMarkingDeque(); | 811 void EmptyMarkingDeque(); |
| 810 | 812 |
| 811 // Refill the marking stack with overflowed objects from the heap. This | 813 // Refill the marking stack with overflowed objects from the heap. This |
| 812 // function either leaves the marking stack full or clears the overflow | 814 // function either leaves the marking stack full or clears the overflow |
| 813 // flag on the marking stack. | 815 // flag on the marking stack. |
| 814 void RefillMarkingDeque(); | 816 void RefillMarkingDeque(); |
| 815 | 817 |
| 816 // Callback function for telling whether the object *p is an unmarked | 818 // Callback function for telling whether the object *p is an unmarked |
| 817 // heap object. | 819 // heap object. |
| 818 static bool IsUnmarkedHeapObject(Object** p); | 820 static bool IsUnmarkedHeapObject(Object** p); |
| 819 static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); | |
| 820 | 821 |
| 821 // Map transitions from a live map to a dead map must be killed. | 822 // Map transitions from a live map to a dead map must be killed. |
| 822 // We replace them with a null descriptor, with the same key. | 823 // We replace them with a null descriptor, with the same key. |
| 823 void ClearNonLiveReferences(); | 824 void ClearNonLiveReferences(); |
| 824 void ClearNonLivePrototypeTransitions(Map* map); | 825 void ClearNonLivePrototypeTransitions(Map* map); |
| 825 void ClearNonLiveMapTransitions(Map* map, MarkBit map_mark); | 826 void ClearNonLiveMapTransitions(Map* map, MarkBit map_mark); |
| 826 void ClearMapTransitions(Map* map, Map* dead_transition); | 827 void ClearMapTransitions(Map* map, Map* dead_transition); |
| 827 bool ClearMapBackPointer(Map* map); | 828 bool ClearMapBackPointer(Map* map); |
| 828 void TrimDescriptorArray(Map* map, DescriptorArray* descriptors, | 829 void TrimDescriptorArray(Map* map, DescriptorArray* descriptors, |
| 829 int number_of_own_descriptors); | 830 int number_of_own_descriptors); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 private: | 970 private: |
| 970 MarkCompactCollector* collector_; | 971 MarkCompactCollector* collector_; |
| 971 }; | 972 }; |
| 972 | 973 |
| 973 | 974 |
| 974 const char* AllocationSpaceName(AllocationSpace space); | 975 const char* AllocationSpaceName(AllocationSpace space); |
| 975 } | 976 } |
| 976 } // namespace v8::internal | 977 } // namespace v8::internal |
| 977 | 978 |
| 978 #endif // V8_HEAP_MARK_COMPACT_H_ | 979 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |