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

Unified Diff: Source/platform/heap/HeapTest.cpp

Issue 765673004: Oilpan: support eager tracing of objects when marking. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tidying up Created 6 years 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/platform/heap/HeapTerminatedArray.h ('k') | Source/platform/heap/Visitor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/platform/heap/HeapTerminatedArray.h ('k') | Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698