Chromium Code Reviews| Index: Source/platform/heap/HeapTest.cpp |
| diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp |
| index 30305a3f7027038edc6712f978a3791a4ba53ba5..26d4a86515efc98d4fa1ce7a58e3a226899e0530 100644 |
| --- a/Source/platform/heap/HeapTest.cpp |
| +++ b/Source/platform/heap/HeapTest.cpp |
| @@ -233,7 +233,14 @@ 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 \ |
| + { \ |
| + if (!objectPointer || isMarked(objectPointer)) \ |
| + return true; \ |
| + markNoTracing(objectPointer); \ |
| + return false; \ |
| + } |
| class CountingVisitor : public Visitor { |
| public: |
| @@ -268,6 +275,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 true; |
| + markNoTracing(objectPointer); |
| + return false; |
| + } |
| FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) |
| @@ -5232,4 +5246,39 @@ TEST(HeapTest, NonNodeAllocatingNodeInDestructor) |
| NonNodeAllocatingNodeInDestructor::s_node = 0; |
| } |
| +class TraceTypeEagerly1 : public GarbageCollected<TraceTypeEagerly1>, public TraceEagerly { }; |
| +class TraceTypeEagerly2 : public TraceTypeEagerly1 { }; |
| + |
| +class TraceTypeEagerly3 { }; |
| +WILL_BE_EAGERLY_TRACED(TraceTypeEagerly3); |
| + |
| +class TraceTypeNonEagerly1 : public TraceNonEagerly { }; |
| + |
| +class TraceTypeNonEagerly2 { }; |
| +WILL_NOT_BE_EAGERLY_TRACED(TraceTypeNonEagerly2); |
| + |
| +TEST(HeapTest, TraceTypesEagerly) |
| +{ |
| +#if ENABLE(OILPAN) |
|
haraken
2014/11/28 05:20:05
Do we need #if ENABLE(OILPAN)?
sof
2014/11/28 12:05:08
With these eager-tracing macros expanding to nothi
|
| + 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<TraceTypeNonEagerly1>::value, ShouldBeTrue); |
| + COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly2>::value, ShouldBeTrue); |
| +#endif |
| +} |
| + |
| } // namespace blink |