OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 MarkingVisitorImpl_h | 5 #ifndef MarkingVisitorImpl_h |
6 #define MarkingVisitorImpl_h | 6 #define MarkingVisitorImpl_h |
7 | 7 |
8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
9 #include "platform/heap/ThreadState.h" | 9 #include "platform/heap/ThreadState.h" |
10 #include "platform/heap/Visitor.h" | 10 #include "platform/heap/Visitor.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 inline void registerWeakTable(const void* closure, | 75 inline void registerWeakTable(const void* closure, |
76 EphemeronCallback iterationCallback, | 76 EphemeronCallback iterationCallback, |
77 EphemeronCallback iterationDoneCallback) { | 77 EphemeronCallback iterationDoneCallback) { |
78 DCHECK(toDerived()->getMarkingMode() != VisitorMarkingMode::WeakProcessing); | 78 DCHECK(toDerived()->getMarkingMode() != VisitorMarkingMode::WeakProcessing); |
79 toDerived()->heap().registerWeakTable( | 79 toDerived()->heap().registerWeakTable( |
80 const_cast<void*>(closure), iterationCallback, iterationDoneCallback); | 80 const_cast<void*>(closure), iterationCallback, iterationDoneCallback); |
81 } | 81 } |
82 | 82 |
83 #if ENABLE(ASSERT) | 83 #if DCHECK_IS_ON() |
84 inline bool weakTableRegistered(const void* closure) { | 84 inline bool weakTableRegistered(const void* closure) { |
85 return toDerived()->heap().weakTableRegistered(closure); | 85 return toDerived()->heap().weakTableRegistered(closure); |
86 } | 86 } |
87 #endif | 87 #endif |
88 | 88 |
89 inline void registerMovingObjectReference(MovableReference* slot) { | 89 inline void registerMovingObjectReference(MovableReference* slot) { |
90 if (toDerived()->getMarkingMode() != | 90 if (toDerived()->getMarkingMode() != |
91 VisitorMarkingMode::GlobalMarkingWithCompaction) | 91 VisitorMarkingMode::GlobalMarkingWithCompaction) |
92 return; | 92 return; |
93 toDerived()->heap().registerMovingObjectReference(slot); | 93 toDerived()->heap().registerMovingObjectReference(slot); |
94 } | 94 } |
95 | 95 |
96 inline void registerMovingObjectCallback(MovableReference reference, | 96 inline void registerMovingObjectCallback(MovableReference reference, |
97 MovingObjectCallback callback, | 97 MovingObjectCallback callback, |
98 void* callbackData) { | 98 void* callbackData) { |
99 if (toDerived()->getMarkingMode() != | 99 if (toDerived()->getMarkingMode() != |
100 VisitorMarkingMode::GlobalMarkingWithCompaction) | 100 VisitorMarkingMode::GlobalMarkingWithCompaction) |
101 return; | 101 return; |
102 toDerived()->heap().registerMovingObjectCallback(reference, callback, | 102 toDerived()->heap().registerMovingObjectCallback(reference, callback, |
103 callbackData); | 103 callbackData); |
104 } | 104 } |
105 | 105 |
106 inline bool ensureMarked(const void* objectPointer) { | 106 inline bool ensureMarked(const void* objectPointer) { |
107 if (!objectPointer) | 107 if (!objectPointer) |
108 return false; | 108 return false; |
109 | 109 |
110 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer); | 110 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer); |
111 if (header->isMarked()) | 111 if (header->isMarked()) |
112 return false; | 112 return false; |
113 #if ENABLE(ASSERT) | 113 #if DCHECK_IS_ON() |
114 toDerived()->markNoTracing(objectPointer); | 114 toDerived()->markNoTracing(objectPointer); |
115 #else | 115 #else |
116 // Inline what the above markNoTracing() call expands to, | 116 // Inline what the above markNoTracing() call expands to, |
117 // so as to make sure that we do get all the benefits (asserts excepted.) | 117 // so as to make sure that we do get all the benefits (asserts excepted.) |
118 header->mark(); | 118 header->mark(); |
119 #endif | 119 #endif |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 inline void registerWeakCellWithCallback(void** cell, WeakCallback callback) { | 123 inline void registerWeakCellWithCallback(void** cell, WeakCallback callback) { |
124 DCHECK(toDerived()->getMarkingMode() != VisitorMarkingMode::WeakProcessing); | 124 DCHECK(toDerived()->getMarkingMode() != VisitorMarkingMode::WeakProcessing); |
125 // We don't want to run weak processings when taking a snapshot. | 125 // We don't want to run weak processings when taking a snapshot. |
126 if (toDerived()->getMarkingMode() == VisitorMarkingMode::SnapshotMarking) | 126 if (toDerived()->getMarkingMode() == VisitorMarkingMode::SnapshotMarking) |
127 return; | 127 return; |
128 toDerived()->heap().pushGlobalWeakCallback(cell, callback); | 128 toDerived()->heap().pushGlobalWeakCallback(cell, callback); |
129 } | 129 } |
130 | 130 |
131 Derived* toDerived() { return static_cast<Derived*>(this); } | 131 Derived* toDerived() { return static_cast<Derived*>(this); } |
132 | 132 |
133 private: | 133 private: |
134 static void markNoTracingCallback(Visitor* visitor, void* object) { | 134 static void markNoTracingCallback(Visitor* visitor, void* object) { |
135 visitor->markNoTracing(object); | 135 visitor->markNoTracing(object); |
136 } | 136 } |
137 }; | 137 }; |
138 | 138 |
139 } // namespace blink | 139 } // namespace blink |
140 | 140 |
141 #endif | 141 #endif |
OLD | NEW |