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 #include "src/heap/store-buffer.h" | 10 #include "src/heap/store-buffer.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 // Callback function, returns whether an object is alive. The heap size | 15 // Callback function, returns whether an object is alive. The heap size |
16 // of the object is returned in size. It optionally updates the offset | 16 // of the object is returned in size. It optionally updates the offset |
17 // to the first live object in the page (only used for old and map objects). | 17 // to the first live object in the page (only used for old and map objects). |
18 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); | 18 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); |
19 | 19 |
20 // Callback function to mark an object in a given heap. | 20 // Callback function to mark an object in a given heap. |
21 typedef void (*MarkObjectFunction)(Heap* heap, HeapObject* object); | 21 typedef void (*MarkObjectFunction)(Heap* heap, HeapObject* object); |
22 | 22 |
23 // Forward declarations. | 23 // Forward declarations. |
24 class CodeFlusher; | 24 class CodeFlusher; |
25 class MarkCompactCollector; | 25 class MarkCompactCollector; |
26 class MarkingVisitor; | 26 class MarkingVisitor; |
27 class RootMarkingVisitor; | 27 class RootMarkingVisitor; |
28 class LocalSlotsBuffer; | |
29 | 28 |
30 class Marking : public AllStatic { | 29 class Marking : public AllStatic { |
31 public: | 30 public: |
32 INLINE(static MarkBit MarkBitFrom(Address addr)) { | 31 INLINE(static MarkBit MarkBitFrom(Address addr)) { |
33 MemoryChunk* p = MemoryChunk::FromAddress(addr); | 32 MemoryChunk* p = MemoryChunk::FromAddress(addr); |
34 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr)); | 33 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr)); |
35 } | 34 } |
36 | 35 |
37 INLINE(static MarkBit MarkBitFrom(HeapObject* obj)) { | 36 INLINE(static MarkBit MarkBitFrom(HeapObject* obj)) { |
38 return MarkBitFrom(reinterpret_cast<Address>(obj)); | 37 return MarkBitFrom(reinterpret_cast<Address>(obj)); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 void RecordCodeEntrySlot(HeapObject* host, Address slot, Code* target); | 479 void RecordCodeEntrySlot(HeapObject* host, Address slot, Code* target); |
481 void RecordCodeTargetPatch(Address pc, Code* target); | 480 void RecordCodeTargetPatch(Address pc, Code* target); |
482 INLINE(void RecordSlot(HeapObject* object, Object** slot, Object* target)); | 481 INLINE(void RecordSlot(HeapObject* object, Object** slot, Object* target)); |
483 INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, | 482 INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, |
484 Object* target)); | 483 Object* target)); |
485 | 484 |
486 void UpdateSlots(SlotsBuffer* buffer); | 485 void UpdateSlots(SlotsBuffer* buffer); |
487 void UpdateSlotsRecordedIn(SlotsBuffer* buffer); | 486 void UpdateSlotsRecordedIn(SlotsBuffer* buffer); |
488 | 487 |
489 void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 488 void MigrateObject(HeapObject* dst, HeapObject* src, int size, |
490 AllocationSpace to_old_space, | 489 AllocationSpace to_old_space); |
491 LocalSlotsBuffer* old_to_old_slots, | |
492 LocalSlotsBuffer* old_to_new_slots); | |
493 | 490 |
494 void InvalidateCode(Code* code); | 491 void InvalidateCode(Code* code); |
495 | 492 |
496 void ClearMarkbits(); | 493 void ClearMarkbits(); |
497 | 494 |
498 bool is_compacting() const { return compacting_; } | 495 bool is_compacting() const { return compacting_; } |
499 | 496 |
500 MarkingParity marking_parity() { return marking_parity_; } | 497 MarkingParity marking_parity() { return marking_parity_; } |
501 | 498 |
502 // Concurrent and parallel sweeping support. If required_freed_bytes was set | 499 // Concurrent and parallel sweeping support. If required_freed_bytes was set |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 void ReleaseEvacuationCandidates(); | 801 void ReleaseEvacuationCandidates(); |
805 | 802 |
806 // Starts sweeping of a space by contributing on the main thread and setting | 803 // Starts sweeping of a space by contributing on the main thread and setting |
807 // up other pages for sweeping. | 804 // up other pages for sweeping. |
808 void StartSweepSpace(PagedSpace* space); | 805 void StartSweepSpace(PagedSpace* space); |
809 | 806 |
810 // Finalizes the parallel sweeping phase. Marks all the pages that were | 807 // Finalizes the parallel sweeping phase. Marks all the pages that were |
811 // swept in parallel. | 808 // swept in parallel. |
812 void ParallelSweepSpacesComplete(); | 809 void ParallelSweepSpacesComplete(); |
813 | 810 |
814 // Updates store buffer and slot buffer for a pointer in a migrating object. | |
815 void RecordMigratedSlot(Object* value, Address slot, | |
816 LocalSlotsBuffer* old_to_old_slots, | |
817 LocalSlotsBuffer* old_to_new_slots); | |
818 | |
819 #ifdef DEBUG | 811 #ifdef DEBUG |
820 friend class MarkObjectVisitor; | 812 friend class MarkObjectVisitor; |
821 static void VisitObject(HeapObject* obj); | 813 static void VisitObject(HeapObject* obj); |
822 | 814 |
823 friend class UnmarkObjectVisitor; | 815 friend class UnmarkObjectVisitor; |
824 static void UnmarkObject(HeapObject* obj); | 816 static void UnmarkObject(HeapObject* obj); |
825 #endif | 817 #endif |
826 | 818 |
827 Heap* heap_; | 819 Heap* heap_; |
828 base::VirtualMemory* marking_deque_memory_; | 820 base::VirtualMemory* marking_deque_memory_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 private: | 867 private: |
876 MarkCompactCollector* collector_; | 868 MarkCompactCollector* collector_; |
877 }; | 869 }; |
878 | 870 |
879 | 871 |
880 const char* AllocationSpaceName(AllocationSpace space); | 872 const char* AllocationSpaceName(AllocationSpace space); |
881 } // namespace internal | 873 } // namespace internal |
882 } // namespace v8 | 874 } // namespace v8 |
883 | 875 |
884 #endif // V8_HEAP_MARK_COMPACT_H_ | 876 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |