Chromium Code Reviews| Index: Source/platform/heap/GarbageCollected.h |
| diff --git a/Source/platform/heap/GarbageCollected.h b/Source/platform/heap/GarbageCollected.h |
| index eeae21fd15849368198d83ed5ec1875d0b6eee6a..87aeca2a307a63b68adff97ca78051f3459fade1 100644 |
| --- a/Source/platform/heap/GarbageCollected.h |
| +++ b/Source/platform/heap/GarbageCollected.h |
| @@ -112,11 +112,10 @@ class PLATFORM_EXPORT GarbageCollectedMixin { |
| public: |
| typedef int IsGarbageCollectedMixinMarker; |
| virtual void adjustAndMark(Visitor*) const = 0; |
| - virtual bool isHeapObjectAlive(Visitor*) const = 0; |
| virtual void trace(Visitor*) { } |
| virtual void adjustAndMark(InlinedGlobalMarkingVisitor) const = 0; |
| - virtual bool isHeapObjectAlive(InlinedGlobalMarkingVisitor) const = 0; |
| virtual void trace(InlinedGlobalMarkingVisitor); |
| + virtual bool isHeapObjectAlive() const = 0; |
| }; |
| #define DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(VISITOR, TYPE) \ |
| @@ -132,11 +131,7 @@ public: |
| } \ |
| visitor->mark(static_cast<const TYPE*>(this), &blink::TraceTrait<TYPE>::trace); \ |
| } \ |
| - virtual bool isHeapObjectAlive(VISITOR visitor) const override \ |
| - { \ |
| - return visitor->isHeapObjectAlive(this); \ |
| - } \ |
| -private: |
| + private: |
| // A C++ object's vptr will be initialized to its leftmost base's vtable after |
| // the constructors of all its subclasses have run, so if a subclass constructor |
| @@ -157,18 +152,18 @@ private: |
| // GarbageCollectedMixinConstructorMarker's constructor takes care of |
| // this and the field is declared by way of USING_GARBAGE_COLLECTED_MIXIN(). |
| -#define DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ |
| -public: \ |
| - GC_PLUGIN_IGNORE("crbug.com/456823") NO_SANITIZE_UNRELATED_CAST \ |
| - void* operator new(size_t size) \ |
| - { \ |
| - void* object = TYPE::allocateObject(size); \ |
| - ThreadState* state = ThreadStateFor<ThreadingTrait<TYPE>::Affinity>::state(); \ |
| +#define DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ |
| + public: \ |
|
Yuta Kitamura
2015/06/03 04:58:29
This indent looks wrong; inconsistent with ll. 191
|
| + GC_PLUGIN_IGNORE("crbug.com/456823") NO_SANITIZE_UNRELATED_CAST \ |
| + void* operator new(size_t size) \ |
| + { \ |
| + void* object = TYPE::allocateObject(size); \ |
| + ThreadState* state = ThreadStateFor<ThreadingTrait<TYPE>::Affinity>::state(); \ |
| state->enterGCForbiddenScopeIfNeeded(&(reinterpret_cast<TYPE*>(object)->m_mixinConstructorMarker)); \ |
| - return object; \ |
| - } \ |
| - GarbageCollectedMixinConstructorMarker m_mixinConstructorMarker; \ |
| -private: |
| + return object; \ |
| + } \ |
| + GarbageCollectedMixinConstructorMarker m_mixinConstructorMarker; \ |
| + private: |
| // Mixins that wrap/nest others requires extra handling: |
| // |
| @@ -189,10 +184,16 @@ private: |
| // when the "operator new" for B runs, and leaving the forbidden GC scope |
| // when the constructor of the recorded GarbageCollectedMixinConstructorMarker |
| // runs. |
| -#define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ |
| - DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::Visitor*, TYPE) \ |
| +#define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ |
| + DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::Visitor*, TYPE) \ |
| DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::InlinedGlobalMarkingVisitor, TYPE) \ |
| - DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) |
| + DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ |
| +public: \ |
| + virtual bool isHeapObjectAlive() const override \ |
| + { \ |
| + return Heap::isHeapObjectAlive(this); \ |
| + } \ |
| +private: |
| #if ENABLE(OILPAN) |
| #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXIN(TYPE) |
| @@ -403,6 +404,24 @@ private: |
| #define GC_PLUGIN_IGNORE(bug) |
| #endif |
| +template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<T>::Type, GarbageCollected>::value> class NeedsAdjustAndMark; |
| + |
| +template<typename T> |
| +class NeedsAdjustAndMark<T, true> { |
| + static_assert(sizeof(T), "T must be fully defined"); |
| +public: |
| + static const bool value = false; |
| +}; |
| +template <typename T> const bool NeedsAdjustAndMark<T, true>::value; |
| + |
| +template<typename T> |
| +class NeedsAdjustAndMark<T, false> { |
| + static_assert(sizeof(T), "T must be fully defined"); |
| +public: |
| + static const bool value = IsGarbageCollectedMixin<typename WTF::RemoveConst<T>::Type>::value; |
| +}; |
| +template <typename T> const bool NeedsAdjustAndMark<T, false>::value; |
| + |
| } // namespace blink |
| #endif |