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 13 matching lines...) Expand all Loading... |
24 { | 24 { |
25 ASSERT(header); | 25 ASSERT(header); |
26 ASSERT(objectPointer); | 26 ASSERT(objectPointer); |
27 // Check that we are not marking objects that are outside | 27 // Check that we are not marking objects that are outside |
28 // the heap by calling Heap::contains. However we cannot | 28 // the heap by calling Heap::contains. However we cannot |
29 // call Heap::contains when outside a GC and we call mark | 29 // call Heap::contains when outside a GC and we call mark |
30 // when doing weakness for ephemerons. Hence we only check | 30 // when doing weakness for ephemerons. Hence we only check |
31 // when called within. | 31 // when called within. |
32 ASSERT(!ThreadState::current()->isInGC() || Heap::containedInHeapOrOrpha
nedPage(header)); | 32 ASSERT(!ThreadState::current()->isInGC() || Heap::containedInHeapOrOrpha
nedPage(header)); |
33 | 33 |
34 if (toDerived()->checkSkipForObjectInTerminatingThreadHeap(objectPointer
)) | 34 if (!toDerived()->shouldMarkObject(objectPointer)) |
35 return; | 35 return; |
36 | 36 |
37 // If you hit this ASSERT, it means that there is a dangling pointer | 37 // If you hit this ASSERT, it means that there is a dangling pointer |
38 // from a live thread heap to a dead thread heap. We must eliminate | 38 // from a live thread heap to a dead thread heap. We must eliminate |
39 // the dangling pointer. | 39 // the dangling pointer. |
40 // Release builds don't have the ASSERT, but it is OK because | 40 // Release builds don't have the ASSERT, but it is OK because |
41 // release builds will crash in the following header->isMarked() | 41 // release builds will crash in the following header->isMarked() |
42 // because all the entries of the orphaned heaps are zapped. | 42 // because all the entries of the orphaned heaps are zapped. |
43 ASSERT(!pageFromObject(objectPointer)->orphaned()); | 43 ASSERT(!pageFromObject(objectPointer)->orphaned()); |
44 | 44 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 inline bool isMarked(const void* objectPointer) | 87 inline bool isMarked(const void* objectPointer) |
88 { | 88 { |
89 return GeneralHeapObjectHeader::fromPayload(objectPointer)->isMarked(); | 89 return GeneralHeapObjectHeader::fromPayload(objectPointer)->isMarked(); |
90 } | 90 } |
91 | 91 |
92 inline bool ensureMarked(const void* objectPointer) | 92 inline bool ensureMarked(const void* objectPointer) |
93 { | 93 { |
94 if (!objectPointer) | 94 if (!objectPointer) |
95 return false; | 95 return false; |
96 if (toDerived()->checkSkipForObjectInTerminatingThreadHeap(objectPointer
)) | 96 if (!toDerived()->shouldMarkObject(objectPointer)) |
97 return false; | 97 return false; |
98 #if ENABLE(ASSERT) | 98 #if ENABLE(ASSERT) |
99 if (isMarked(objectPointer)) | 99 if (isMarked(objectPointer)) |
100 return false; | 100 return false; |
101 | 101 |
102 toDerived()->markNoTracing(objectPointer); | 102 toDerived()->markNoTracing(objectPointer); |
103 #else | 103 #else |
104 // Inline what the above markNoTracing() call expands to, | 104 // Inline what the above markNoTracing() call expands to, |
105 // so as to make sure that we do get all the benefits. | 105 // so as to make sure that we do get all the benefits. |
106 GeneralHeapObjectHeader* header = GeneralHeapObjectHeader::fromPayload(o
bjectPointer); | 106 GeneralHeapObjectHeader* header = GeneralHeapObjectHeader::fromPayload(o
bjectPointer); |
107 if (header->isMarked()) | 107 if (header->isMarked()) |
108 return false; | 108 return false; |
109 header->mark(); | 109 header->mark(); |
110 #endif | 110 #endif |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 #if ENABLE(ASSERT) | 114 #if ENABLE(ASSERT) |
115 #define DEFINE_ENSURE_MARKED_METHOD(Type)
\ | 115 #define DEFINE_ENSURE_MARKED_METHOD(Type)
\ |
116 inline bool ensureMarked(const Type* objectPointer)
\ | 116 inline bool ensureMarked(const Type* objectPointer)
\ |
117 {
\ | 117 {
\ |
118 if (!objectPointer)
\ | 118 if (!objectPointer)
\ |
119 return false;
\ | 119 return false;
\ |
120 if (toDerived()->checkSkipForObjectInTerminatingThreadHeap(objectPointer
)) \ | 120 if (!toDerived()->shouldMarkObject(objectPointer))
\ |
121 return false;
\ | 121 return false;
\ |
122 if (isMarked(objectPointer))
\ | 122 if (isMarked(objectPointer))
\ |
123 return false;
\ | 123 return false;
\ |
124 toDerived()->markNoTracing(objectPointer);
\ | 124 toDerived()->markNoTracing(objectPointer);
\ |
125 return true;
\ | 125 return true;
\ |
126 } | 126 } |
127 #else | 127 #else |
128 #define DEFINE_ENSURE_MARKED_METHOD(Type)
\ | 128 #define DEFINE_ENSURE_MARKED_METHOD(Type)
\ |
129 inline bool ensureMarked(const Type* objectPointer)
\ | 129 inline bool ensureMarked(const Type* objectPointer)
\ |
130 {
\ | 130 {
\ |
131 if (!objectPointer)
\ | 131 if (!objectPointer)
\ |
132 return false;
\ | 132 return false;
\ |
133 if (toDerived()->checkSkipForObjectInTerminatingThreadHeap(objectPointer
)) \ | 133 if (!toDerived()->shouldMarkObject(objectPointer))
\ |
134 return false;
\ | 134 return false;
\ |
135 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer);
\ | 135 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer);
\ |
136 if (header->isMarked())
\ | 136 if (header->isMarked())
\ |
137 return false;
\ | 137 return false;
\ |
138 header->mark();
\ | 138 header->mark();
\ |
139 return true;
\ | 139 return true;
\ |
140 } | 140 } |
141 #endif | 141 #endif |
142 | 142 |
143 // This macro defines the necessary visitor methods for typed heaps | 143 // This macro defines the necessary visitor methods for typed heaps |
(...skipping 29 matching lines...) Expand all Loading... |
173 private: | 173 private: |
174 static void markNoTracingCallback(Visitor* visitor, void* object) | 174 static void markNoTracingCallback(Visitor* visitor, void* object) |
175 { | 175 { |
176 visitor->markNoTracing(object); | 176 visitor->markNoTracing(object); |
177 } | 177 } |
178 }; | 178 }; |
179 | 179 |
180 } // namespace blink | 180 } // namespace blink |
181 | 181 |
182 #endif | 182 #endif |
OLD | NEW |