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

Side by Side 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: Re-introduce TraceEagerly 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 EXPECT_TRUE(scope.allThreadsParked()); 226 EXPECT_TRUE(scope.allThreadsParked());
227 return Heap::objectPayloadSizeForTesting(); 227 return Heap::objectPayloadSizeForTesting();
228 } 228 }
229 229
230 #define DEFINE_VISITOR_METHODS(Type) \ 230 #define DEFINE_VISITOR_METHODS(Type) \
231 virtual void mark(const Type* object, TraceCallback callback) override \ 231 virtual void mark(const Type* object, TraceCallback callback) override \
232 { \ 232 { \
233 if (object) \ 233 if (object) \
234 m_count++; \ 234 m_count++; \
235 } \ 235 } \
236 virtual bool isMarked(const Type*) override { return false; } 236 virtual bool isMarked(const Type*) override { return false; } \
237 virtual bool ensureMarked(const Type* objectPointer) override \
238 { \
239 if (!objectPointer || isMarked(objectPointer)) \
240 return true; \
241 markNoTracing(objectPointer); \
242 return false; \
243 }
237 244
238 class CountingVisitor : public Visitor { 245 class CountingVisitor : public Visitor {
239 public: 246 public:
240 CountingVisitor() 247 CountingVisitor()
241 : m_count(0) 248 : m_count(0)
242 { 249 {
243 } 250 }
244 251
245 virtual void mark(const void* object, TraceCallback) override 252 virtual void mark(const void* object, TraceCallback) override
246 { 253 {
(...skipping 14 matching lines...) Expand all
261 } 268 }
262 269
263 virtual void registerDelayedMarkNoTracing(const void*) override { } 270 virtual void registerDelayedMarkNoTracing(const void*) override { }
264 virtual void registerWeakMembers(const void*, const void*, WeakPointerCallba ck) override { } 271 virtual void registerWeakMembers(const void*, const void*, WeakPointerCallba ck) override { }
265 virtual void registerWeakTable(const void*, EphemeronCallback, EphemeronCall back) override { } 272 virtual void registerWeakTable(const void*, EphemeronCallback, EphemeronCall back) override { }
266 #if ENABLE(ASSERT) 273 #if ENABLE(ASSERT)
267 virtual bool weakTableRegistered(const void*) override { return false; } 274 virtual bool weakTableRegistered(const void*) override { return false; }
268 #endif 275 #endif
269 virtual void registerWeakCell(void**, WeakPointerCallback) override { } 276 virtual void registerWeakCell(void**, WeakPointerCallback) override { }
270 virtual bool isMarked(const void*) override { return false; } 277 virtual bool isMarked(const void*) override { return false; }
278 virtual bool ensureMarked(const void* objectPointer) override
279 {
280 if (!objectPointer || isMarked(objectPointer))
281 return true;
282 markNoTracing(objectPointer);
283 return false;
284 }
271 285
272 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) 286 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS)
273 287
274 size_t count() { return m_count; } 288 size_t count() { return m_count; }
275 void reset() { m_count = 0; } 289 void reset() { m_count = 0; }
276 290
277 private: 291 private:
278 size_t m_count; 292 size_t m_count;
279 }; 293 };
280 294
(...skipping 4944 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 5239
5226 TEST(HeapTest, NonNodeAllocatingNodeInDestructor) 5240 TEST(HeapTest, NonNodeAllocatingNodeInDestructor)
5227 { 5241 {
5228 new NonNodeAllocatingNodeInDestructor(); 5242 new NonNodeAllocatingNodeInDestructor();
5229 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 5243 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
5230 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value()); 5244 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value());
5231 delete NonNodeAllocatingNodeInDestructor::s_node; 5245 delete NonNodeAllocatingNodeInDestructor::s_node;
5232 NonNodeAllocatingNodeInDestructor::s_node = 0; 5246 NonNodeAllocatingNodeInDestructor::s_node = 0;
5233 } 5247 }
5234 5248
5249 class TraceTypeEagerly1 : public GarbageCollected<TraceTypeEagerly1>, public Tra ceEagerly { };
5250 class TraceTypeEagerly2 : public TraceTypeEagerly1 { };
5251
5252 class TraceTypeEagerly3 { };
5253 WILL_BE_EAGERLY_TRACED(TraceTypeEagerly3);
5254
5255 class TraceTypeNonEagerly1 : public TraceNonEagerly { };
5256
5257 class TraceTypeNonEagerly2 { };
5258 WILL_NOT_BE_EAGERLY_TRACED(TraceTypeNonEagerly2);
5259
5260 TEST(HeapTest, TraceTypesEagerly)
5261 {
5262 #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
5263 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly1>::value, ShouldBeTrue);
5264 COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly1>>::value, ShouldBe True);
5265 COMPILE_ASSERT(TraceEagerlyTrait<WeakMember<TraceTypeEagerly1>>::value, Shou ldBeTrue);
5266 COMPILE_ASSERT(!TraceEagerlyTrait<RawPtr<TraceTypeEagerly1>>::value, ShouldB eTrue);
5267 COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<Member<TraceTypeEagerly1>>>::val ue, ShouldBeTrue);
5268 COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<WeakMember<TraceTypeEagerly1>>>: :value, ShouldBeTrue);
5269 COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::va lue, ShouldBeTrue);
5270 COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::va lue, ShouldBeTrue);
5271 using HashMapIntToObj = HeapHashMap<int, Member<TraceTypeEagerly1>>;
5272 COMPILE_ASSERT(TraceEagerlyTrait<HashMapIntToObj>::value, ShouldBeTrue);
5273 using HashMapObjToInt = HeapHashMap<Member<TraceTypeEagerly1>, int>;
5274 COMPILE_ASSERT(TraceEagerlyTrait<HashMapObjToInt>::value, ShouldBeTrue);
5275
5276 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly2>::value, ShouldBeTrue);
5277 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly3>::value, ShouldBeTrue);
5278
5279 COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly1>::value, ShouldBeTrue );
5280 COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly2>::value, ShouldBeTrue );
5281 #endif
5282 }
5283
5235 } // namespace blink 5284 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698