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 <deque> | 8 #include <deque> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj) { | 39 V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj) { |
40 const Address address = obj->address(); | 40 const Address address = obj->address(); |
41 MemoryChunk* p = MemoryChunk::FromAddress(address); | 41 MemoryChunk* p = MemoryChunk::FromAddress(address); |
42 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(address)); | 42 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(address)); |
43 } | 43 } |
44 | 44 |
45 static Marking::ObjectColor Color(HeapObject* obj) { | 45 static Marking::ObjectColor Color(HeapObject* obj) { |
46 return Marking::Color(ObjectMarking::MarkBitFrom(obj)); | 46 return Marking::Color(ObjectMarking::MarkBitFrom(obj)); |
47 } | 47 } |
48 | 48 |
49 V8_INLINE static void MarkWhite(HeapObject* obj) { | |
50 MarkBit markbit = MarkBitFrom(obj); | |
51 if (Marking::IsBlack(markbit)) { | |
52 MemoryChunk::IncrementLiveBytes(obj, -obj->Size()); | |
53 } | |
54 Marking::MarkWhite(markbit); | |
55 } | |
56 | |
Hannes Payer (out of office)
2017/01/18 14:43:35
Should we add DCHECKs to the transitions where we
Michael Lippautz
2017/01/18 15:58:07
Done.
| |
57 V8_INLINE static void BlackToWhite(HeapObject* obj) { | |
58 MarkBit markbit = MarkBitFrom(obj); | |
59 Marking::BlackToWhite(markbit); | |
60 MemoryChunk::IncrementLiveBytes(obj, -obj->Size()); | |
61 } | |
62 | |
63 V8_INLINE static void GreyToWhite(HeapObject* obj) { | |
64 Marking::GreyToWhite(MarkBitFrom(obj)); | |
65 } | |
66 | |
67 V8_INLINE static void BlackToGrey(HeapObject* obj) { | |
68 MarkBit markbit = MarkBitFrom(obj); | |
69 Marking::BlackToGrey(markbit); | |
70 MemoryChunk::IncrementLiveBytes(obj, -obj->Size()); | |
71 } | |
72 | |
73 V8_INLINE static void WhiteToGrey(HeapObject* obj) { | |
74 Marking::WhiteToGrey(MarkBitFrom(obj)); | |
75 } | |
76 | |
77 V8_INLINE static void WhiteToBlack(HeapObject* obj) { | |
78 MarkBit markbit = MarkBitFrom(obj); | |
79 Marking::WhiteToBlack(markbit); | |
80 MemoryChunk::IncrementLiveBytes(obj, obj->Size()); | |
81 } | |
82 | |
83 V8_INLINE static void GreyToBlack(HeapObject* obj) { | |
84 MarkBit markbit = MarkBitFrom(obj); | |
85 Marking::GreyToBlack(markbit); | |
86 MemoryChunk::IncrementLiveBytes(obj, obj->Size()); | |
87 } | |
88 | |
89 V8_INLINE static void AnyToGrey(HeapObject* obj) { | |
90 MarkBit markbit = MarkBitFrom(obj); | |
91 if (Marking::IsBlack(markbit)) { | |
92 MemoryChunk::IncrementLiveBytes(obj, -obj->Size()); | |
93 } | |
94 Marking::AnyToGrey(markbit); | |
95 } | |
96 | |
49 private: | 97 private: |
50 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); | 98 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); |
51 }; | 99 }; |
52 | 100 |
53 // ---------------------------------------------------------------------------- | 101 // ---------------------------------------------------------------------------- |
54 // Marking deque for tracing live objects. | 102 // Marking deque for tracing live objects. |
55 class MarkingDeque { | 103 class MarkingDeque { |
56 public: | 104 public: |
57 explicit MarkingDeque(Heap* heap) | 105 explicit MarkingDeque(Heap* heap) |
58 : backing_store_(nullptr), | 106 : backing_store_(nullptr), |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 | 826 |
779 private: | 827 private: |
780 MarkCompactCollector* collector_; | 828 MarkCompactCollector* collector_; |
781 }; | 829 }; |
782 | 830 |
783 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 831 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); |
784 } // namespace internal | 832 } // namespace internal |
785 } // namespace v8 | 833 } // namespace v8 |
786 | 834 |
787 #endif // V8_HEAP_MARK_COMPACT_H_ | 835 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |