Index: Source/platform/heap/HeapTest.cpp |
diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp |
index 4e4874366a33c326de9a370b1df5f5bd034af5c6..5c858e7a3c6212306c4b380ae7ea1733796c3a0b 100644 |
--- a/Source/platform/heap/HeapTest.cpp |
+++ b/Source/platform/heap/HeapTest.cpp |
@@ -233,7 +233,11 @@ static size_t objectPayloadSize() |
if (object) \ |
m_count++; \ |
} \ |
- virtual bool isMarked(const Type*) override { return false; } |
+ virtual bool isMarked(const Type*) override { return false; } \ |
+ virtual bool ensureMarked(const Type* objectPointer) override \ |
+ { \ |
+ return ensureMarked(objectPointer); \ |
+ } |
class CountingVisitor : public Visitor { |
public: |
@@ -268,6 +272,13 @@ public: |
#endif |
virtual void registerWeakCell(void**, WeakPointerCallback) override { } |
virtual bool isMarked(const void*) override { return false; } |
+ virtual bool ensureMarked(const void* objectPointer) override |
+ { |
+ if (!objectPointer || isMarked(objectPointer)) |
+ return false; |
+ markNoTracing(objectPointer); |
+ return true; |
+ } |
FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) |
@@ -278,6 +289,8 @@ private: |
size_t m_count; |
}; |
+#undef DEFINE_VISITOR_METHODS |
+ |
class SimpleObject : public GarbageCollected<SimpleObject> { |
public: |
static SimpleObject* create() { return new SimpleObject(); } |
@@ -295,8 +308,6 @@ protected: |
char payload[64]; |
}; |
-#undef DEFINE_VISITOR_METHODS |
- |
class HeapTestSuperClass : public GarbageCollectedFinalized<HeapTestSuperClass> { |
public: |
static HeapTestSuperClass* create() |
@@ -5233,4 +5244,52 @@ TEST(HeapTest, NonNodeAllocatingNodeInDestructor) |
NonNodeAllocatingNodeInDestructor::s_node = 0; |
} |
+class TraceTypeEagerly1 : public GarbageCollected<TraceTypeEagerly1> { }; |
+WILL_BE_EAGERLY_TRACED(TraceTypeEagerly1); |
+class TraceTypeEagerly2 : public TraceTypeEagerly1 { }; |
+ |
+class TraceTypeEagerly3 { }; |
+WILL_BE_EAGERLY_TRACED(TraceTypeEagerly3); |
+ |
+class TraceTypeEagerly4 : public TraceTypeEagerly3 { }; |
+ |
+class TraceTypeEagerly5 { }; |
+WILL_BE_EAGERLY_TRACED_CLASS(TraceTypeEagerly5); |
+ |
+class TraceTypeEagerly6 : public TraceTypeEagerly5 { }; |
+ |
+class TraceTypeEagerly7 { }; |
+ |
+class TraceTypeNonEagerly1 { }; |
+WILL_NOT_BE_EAGERLY_TRACED(TraceTypeNonEagerly1); |
+ |
+TEST(HeapTest, TraceTypesEagerly) |
+{ |
+ COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly1>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly1>>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<WeakMember<TraceTypeEagerly1>>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(!TraceEagerlyTrait<RawPtr<TraceTypeEagerly1>>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<Member<TraceTypeEagerly1>>>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<WeakMember<TraceTypeEagerly1>>>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::value, ShouldBeTrue); |
+ using HashMapIntToObj = HeapHashMap<int, Member<TraceTypeEagerly1>>; |
+ COMPILE_ASSERT(TraceEagerlyTrait<HashMapIntToObj>::value, ShouldBeTrue); |
+ using HashMapObjToInt = HeapHashMap<Member<TraceTypeEagerly1>, int>; |
+ COMPILE_ASSERT(TraceEagerlyTrait<HashMapObjToInt>::value, ShouldBeTrue); |
+ |
+ COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly2>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly3>::value, ShouldBeTrue); |
+ |
+ COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly4>::value, ShouldBeTrue); |
+ |
+ COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly5>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly5>>::value, ShouldBeTrue); |
+ |
+ COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeEagerly6>::value, ShouldBeTrue); |
+ COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeEagerly7>::value, ShouldBeTrue); |
+ |
+ COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly1>::value, ShouldBeTrue); |
+} |
+ |
} // namespace blink |