Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Unified Diff: Source/platform/heap/GarbageCollected.h

Issue 1166623002: Oilpan: Remove a visitor parameter from isHeapObjectAlive (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/mediastream/RTCDataChannel.cpp ('k') | Source/platform/heap/Handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/GarbageCollected.h
diff --git a/Source/platform/heap/GarbageCollected.h b/Source/platform/heap/GarbageCollected.h
index 87367ea4fbba7a5be5c2dbb5f6a47e58d8db7da9..ce920621a9261b50b4a0f51985a43131018340b0 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) \
- { \
+#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, IsEagerlyFinalizedType<TYPE>::value); \
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
« no previous file with comments | « Source/modules/mediastream/RTCDataChannel.cpp ('k') | Source/platform/heap/Handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698