| 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 GarbageCollected_h | 5 #ifndef GarbageCollected_h |
| 6 #define GarbageCollected_h | 6 #define GarbageCollected_h |
| 7 | 7 |
| 8 #include "platform/heap/ThreadState.h" | 8 #include "platform/heap/ThreadState.h" |
| 9 #include "wtf/Assertions.h" | 9 #include "wtf/Assertions.h" |
| 10 #include "wtf/ListHashSet.h" | 10 #include "wtf/ListHashSet.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 typedef int IsGarbageCollectedMixinMarker; | 113 typedef int IsGarbageCollectedMixinMarker; |
| 114 virtual void adjustAndMark(Visitor*) const = 0; | 114 virtual void adjustAndMark(Visitor*) const = 0; |
| 115 virtual void trace(Visitor*) { } | 115 virtual void trace(Visitor*) { } |
| 116 virtual void adjustAndMark(InlinedGlobalMarkingVisitor) const = 0; | 116 virtual void adjustAndMark(InlinedGlobalMarkingVisitor) const = 0; |
| 117 virtual void trace(InlinedGlobalMarkingVisitor); | 117 virtual void trace(InlinedGlobalMarkingVisitor); |
| 118 virtual bool isHeapObjectAlive() const = 0; | 118 virtual bool isHeapObjectAlive() const = 0; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 #define DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(VISITOR, TYPE) \ | 121 #define DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(VISITOR, TYPE) \ |
| 122 public: \ | 122 public: \ |
| 123 virtual void adjustAndMark(VISITOR visitor) const override \ | 123 void adjustAndMark(VISITOR visitor) const override \ |
| 124 { \ | 124 { \ |
| 125 typedef WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<TYPE>::Type,
blink::GarbageCollected> IsSubclassOfGarbageCollected; \ | 125 typedef WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<TYPE>::Type,
blink::GarbageCollected> IsSubclassOfGarbageCollected; \ |
| 126 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect
ed objects can have garbage collected mixins"); \ | 126 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect
ed objects can have garbage collected mixins"); \ |
| 127 if (TraceEagerlyTrait<TYPE>::value) { \ | 127 if (TraceEagerlyTrait<TYPE>::value) { \ |
| 128 if (visitor->ensureMarked(static_cast<const TYPE*>(this))) \ | 128 if (visitor->ensureMarked(static_cast<const TYPE*>(this))) \ |
| 129 TraceTrait<TYPE>::trace(visitor, const_cast<TYPE*>(this)); \ | 129 TraceTrait<TYPE>::trace(visitor, const_cast<TYPE*>(this)); \ |
| 130 return; \ | 130 return; \ |
| 131 } \ | 131 } \ |
| 132 visitor->mark(static_cast<const TYPE*>(this), &blink::TraceTrait<TYPE>::
trace); \ | 132 visitor->mark(static_cast<const TYPE*>(this), &blink::TraceTrait<TYPE>::
trace); \ |
| 133 } \ | 133 } \ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // the second one should leave the forbidden GC scope. This is realized by | 182 // the second one should leave the forbidden GC scope. This is realized by |
| 183 // recording the address of B's GarbageCollectedMixinConstructorMarker | 183 // recording the address of B's GarbageCollectedMixinConstructorMarker |
| 184 // when the "operator new" for B runs, and leaving the forbidden GC scope | 184 // when the "operator new" for B runs, and leaving the forbidden GC scope |
| 185 // when the constructor of the recorded GarbageCollectedMixinConstructorMarker | 185 // when the constructor of the recorded GarbageCollectedMixinConstructorMarker |
| 186 // runs. | 186 // runs. |
| 187 #define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ | 187 #define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ |
| 188 DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::Visitor*, TYPE) \ | 188 DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::Visitor*, TYPE) \ |
| 189 DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::InlinedGlobalMarkingVisitor, T
YPE) \ | 189 DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::InlinedGlobalMarkingVisitor, T
YPE) \ |
| 190 DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ | 190 DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ |
| 191 public: \ | 191 public: \ |
| 192 virtual bool isHeapObjectAlive() const override \ | 192 bool isHeapObjectAlive() const override \ |
| 193 { \ | 193 { \ |
| 194 return Heap::isHeapObjectAlive(this); \ | 194 return Heap::isHeapObjectAlive(this); \ |
| 195 } \ | 195 } \ |
| 196 private: | 196 private: |
| 197 | 197 |
| 198 #if ENABLE(OILPAN) | 198 #if ENABLE(OILPAN) |
| 199 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI
N(TYPE) | 199 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI
N(TYPE) |
| 200 #else | 200 #else |
| 201 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) | 201 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) |
| 202 #endif | 202 #endif |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 template<typename U, size_t sz = sizeof(U)> static TrueType isSizeofKnown(U*
); | 433 template<typename U, size_t sz = sizeof(U)> static TrueType isSizeofKnown(U*
); |
| 434 static FalseType isSizeofKnown(...); | 434 static FalseType isSizeofKnown(...); |
| 435 static T& t; | 435 static T& t; |
| 436 public: | 436 public: |
| 437 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); | 437 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); |
| 438 }; | 438 }; |
| 439 | 439 |
| 440 } // namespace blink | 440 } // namespace blink |
| 441 | 441 |
| 442 #endif | 442 #endif |
| OLD | NEW |