OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 TraceTraits_h | 5 #ifndef TraceTraits_h |
6 #define TraceTraits_h | 6 #define TraceTraits_h |
7 | 7 |
8 #include "platform/heap/GCInfo.h" | 8 #include "platform/heap/GCInfo.h" |
9 #include "platform/heap/Heap.h" | 9 #include "platform/heap/Heap.h" |
10 #include "platform/heap/InlinedGlobalMarkingVisitor.h" | 10 #include "platform/heap/InlinedGlobalMarkingVisitor.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 template<typename T> class WeakPersistent; | 32 template<typename T> class WeakPersistent; |
33 | 33 |
34 template<typename T, bool = NeedsAdjustAndMark<T>::value> class AdjustAndMarkTra
it; | 34 template<typename T, bool = NeedsAdjustAndMark<T>::value> class AdjustAndMarkTra
it; |
35 | 35 |
36 template<typename T> | 36 template<typename T> |
37 class AdjustAndMarkTrait<T, false> { | 37 class AdjustAndMarkTrait<T, false> { |
38 STATIC_ONLY(AdjustAndMarkTrait); | 38 STATIC_ONLY(AdjustAndMarkTrait); |
39 public: | 39 public: |
40 static void markWrapper(const WrapperVisitor* visitor, const T* t) | 40 static void markWrapper(const WrapperVisitor* visitor, const T* t) |
41 { | 41 { |
42 if (visitor->markWrapperHeader(t)) { | 42 if (visitor->markWrapperHeader(heapObjectHeader(t))) { |
| 43 visitor->markWrappersInAllWorlds(t); |
43 visitor->dispatchTraceWrappers(t); | 44 visitor->dispatchTraceWrappers(t); |
44 } | 45 } |
45 } | 46 } |
| 47 static HeapObjectHeader* heapObjectHeader(const T* t) |
| 48 { |
| 49 return HeapObjectHeader::fromPayload(t); |
| 50 } |
46 | 51 |
47 template<typename VisitorDispatcher> | 52 template<typename VisitorDispatcher> |
48 static void mark(VisitorDispatcher visitor, const T* t) | 53 static void mark(VisitorDispatcher visitor, const T* t) |
49 { | 54 { |
50 #if ENABLE(ASSERT) | 55 #if ENABLE(ASSERT) |
51 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); | 56 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); |
52 #endif | 57 #endif |
53 // Default mark method of the trait just calls the two-argument mark | 58 // Default mark method of the trait just calls the two-argument mark |
54 // method on the visitor. The second argument is the static trace method | 59 // method on the visitor. The second argument is the static trace method |
55 // of the trait, which by default calls the instance method | 60 // of the trait, which by default calls the instance method |
(...skipping 22 matching lines...) Expand all Loading... |
78 }; | 83 }; |
79 | 84 |
80 template<typename T> | 85 template<typename T> |
81 class AdjustAndMarkTrait<T, true> { | 86 class AdjustAndMarkTrait<T, true> { |
82 STATIC_ONLY(AdjustAndMarkTrait); | 87 STATIC_ONLY(AdjustAndMarkTrait); |
83 public: | 88 public: |
84 static void markWrapper(const WrapperVisitor* visitor, const T* t) | 89 static void markWrapper(const WrapperVisitor* visitor, const T* t) |
85 { | 90 { |
86 t->adjustAndMarkWrapper(visitor); | 91 t->adjustAndMarkWrapper(visitor); |
87 } | 92 } |
| 93 static HeapObjectHeader* heapObjectHeader(const T* t) |
| 94 { |
| 95 return t->adjustAndGetHeapObjectHeader(); |
| 96 } |
88 | 97 |
89 template<typename VisitorDispatcher> | 98 template<typename VisitorDispatcher> |
90 static void mark(VisitorDispatcher visitor, const T* self) | 99 static void mark(VisitorDispatcher visitor, const T* self) |
91 { | 100 { |
92 if (!self) | 101 if (!self) |
93 return; | 102 return; |
94 | 103 |
95 // If you hit this ASSERT, it means that there is a dangling pointer | 104 // If you hit this ASSERT, it means that there is a dangling pointer |
96 // from a live thread heap to a dead thread heap. We must eliminate | 105 // from a live thread heap to a dead thread heap. We must eliminate |
97 // the dangling pointer. | 106 // the dangling pointer. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // needed is when multiple inheritance leads to pointers that are not | 172 // needed is when multiple inheritance leads to pointers that are not |
164 // to the start of the object in the Blink garbage-collected heap. In | 173 // to the start of the object in the Blink garbage-collected heap. In |
165 // that case the pointer has to be adjusted before marking. | 174 // that case the pointer has to be adjusted before marking. |
166 template<typename T> | 175 template<typename T> |
167 class TraceTrait { | 176 class TraceTrait { |
168 STATIC_ONLY(TraceTrait); | 177 STATIC_ONLY(TraceTrait); |
169 public: | 178 public: |
170 static void trace(Visitor*, void* self); | 179 static void trace(Visitor*, void* self); |
171 static void trace(InlinedGlobalMarkingVisitor, void* self); | 180 static void trace(InlinedGlobalMarkingVisitor, void* self); |
172 | 181 |
173 static void markWrapper(const WrapperVisitor* visitor, const T* t) | 182 static void markWrapper(const WrapperVisitor* visitor, const void* t) |
174 { | 183 { |
175 AdjustAndMarkTrait<T>::markWrapper(visitor, t); | 184 AdjustAndMarkTrait<T>::markWrapper(visitor, reinterpret_cast<const T*>(t
)); |
| 185 } |
| 186 static HeapObjectHeader* heapObjectHeader(const void* t) |
| 187 { |
| 188 return AdjustAndMarkTrait<T>::heapObjectHeader(reinterpret_cast<const T*
>(t)); |
176 } | 189 } |
177 | 190 |
178 template<typename VisitorDispatcher> | 191 template<typename VisitorDispatcher> |
179 static void mark(VisitorDispatcher visitor, const T* t) | 192 static void mark(VisitorDispatcher visitor, const T* t) |
180 { | 193 { |
181 AdjustAndMarkTrait<T>::mark(visitor, t); | 194 AdjustAndMarkTrait<T>::mark(visitor, t); |
182 } | 195 } |
183 }; | 196 }; |
184 | 197 |
185 template<typename T> class TraceTrait<const T> : public TraceTrait<T> { }; | 198 template<typename T> class TraceTrait<const T> : public TraceTrait<T> { }; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // since iterating over the hash table backing will find the whole | 607 // since iterating over the hash table backing will find the whole |
595 // chain. | 608 // chain. |
596 visitor->markNoTracing(node); | 609 visitor->markNoTracing(node); |
597 return false; | 610 return false; |
598 } | 611 } |
599 }; | 612 }; |
600 | 613 |
601 } // namespace WTF | 614 } // namespace WTF |
602 | 615 |
603 #endif | 616 #endif |
OLD | NEW |