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

Side by Side Diff: Source/platform/heap/HeapTest.cpp

Issue 783823002: Oilpan: enable eager tracing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tidying + add a test for marking stack fallback 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/HeapTerminatedArray.h ('k') | Source/platform/heap/Visitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 static const int magic = 1337; 666 static const int magic = 1337;
667 int m_magic; 667 int m_magic;
668 668
669 Bar() 669 Bar()
670 : m_magic(magic) 670 : m_magic(magic)
671 { 671 {
672 s_live++; 672 s_live++;
673 } 673 }
674 }; 674 };
675 675
676 WILL_NOT_BE_EAGERLY_TRACED(Bar);
677
676 unsigned Bar::s_live = 0; 678 unsigned Bar::s_live = 0;
677 679
678 class Baz : public GarbageCollected<Baz> { 680 class Baz : public GarbageCollected<Baz> {
679 public: 681 public:
680 static Baz* create(Bar* bar) 682 static Baz* create(Bar* bar)
681 { 683 {
682 return new Baz(bar); 684 return new Baz(bar);
683 } 685 }
684 686
685 void trace(Visitor* visitor) 687 void trace(Visitor* visitor)
(...skipping 4591 matching lines...) Expand 10 before | Expand all | Expand 10 after
5277 TEST(HeapTest, NonNodeAllocatingNodeInDestructor) 5279 TEST(HeapTest, NonNodeAllocatingNodeInDestructor)
5278 { 5280 {
5279 new NonNodeAllocatingNodeInDestructor(); 5281 new NonNodeAllocatingNodeInDestructor();
5280 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 5282 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
5281 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value()); 5283 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value());
5282 delete NonNodeAllocatingNodeInDestructor::s_node; 5284 delete NonNodeAllocatingNodeInDestructor::s_node;
5283 NonNodeAllocatingNodeInDestructor::s_node = 0; 5285 NonNodeAllocatingNodeInDestructor::s_node = 0;
5284 } 5286 }
5285 5287
5286 class TraceTypeEagerly1 : public GarbageCollected<TraceTypeEagerly1> { }; 5288 class TraceTypeEagerly1 : public GarbageCollected<TraceTypeEagerly1> { };
5287 WILL_BE_EAGERLY_TRACED(TraceTypeEagerly1);
5288 class TraceTypeEagerly2 : public TraceTypeEagerly1 { }; 5289 class TraceTypeEagerly2 : public TraceTypeEagerly1 { };
5289 5290
5290 class TraceTypeEagerly3 { };
5291 WILL_BE_EAGERLY_TRACED(TraceTypeEagerly3);
5292
5293 class TraceTypeEagerly4 : public TraceTypeEagerly3 { };
5294
5295 class TraceTypeEagerly5 { };
5296 WILL_BE_EAGERLY_TRACED_CLASS(TraceTypeEagerly5);
5297
5298 class TraceTypeEagerly6 : public TraceTypeEagerly5 { };
5299
5300 class TraceTypeEagerly7 { };
5301
5302 class TraceTypeNonEagerly1 { }; 5291 class TraceTypeNonEagerly1 { };
5303 WILL_NOT_BE_EAGERLY_TRACED(TraceTypeNonEagerly1); 5292 WILL_NOT_BE_EAGERLY_TRACED(TraceTypeNonEagerly1);
5293 class TraceTypeNonEagerly2 : public TraceTypeNonEagerly1 { };
5294
5295 class TraceTypeNonEagerly3 { };
5296 WILL_NOT_BE_EAGERLY_TRACED_CLASS(TraceTypeNonEagerly3);
5297 class TraceTypeNonEagerly4 : public TraceTypeNonEagerly3 { };
5304 5298
5305 TEST(HeapTest, TraceTypesEagerly) 5299 TEST(HeapTest, TraceTypesEagerly)
5306 { 5300 {
5307 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly1>::value, ShouldBeTrue); 5301 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly1>::value, ShouldBeTrue);
5308 COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly1>>::value, ShouldBe True); 5302 COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly1>>::value, ShouldBe True);
5309 COMPILE_ASSERT(TraceEagerlyTrait<WeakMember<TraceTypeEagerly1>>::value, Shou ldBeTrue); 5303 COMPILE_ASSERT(TraceEagerlyTrait<WeakMember<TraceTypeEagerly1>>::value, Shou ldBeTrue);
5310 COMPILE_ASSERT(ENABLE_EAGER_TRACING_BY_DEFAULT || !TraceEagerlyTrait<RawPtr< TraceTypeEagerly1>>::value, ShouldBeTrue); 5304 COMPILE_ASSERT(TraceEagerlyTrait<RawPtr<TraceTypeEagerly1>>::value == MARKER _EAGER_TRACING, ShouldBeTrue);
5311 COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<Member<TraceTypeEagerly1>>>::val ue, ShouldBeTrue); 5305 COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<Member<TraceTypeEagerly1>>>::val ue, ShouldBeTrue);
5312 COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<WeakMember<TraceTypeEagerly1>>>: :value, ShouldBeTrue); 5306 COMPILE_ASSERT(TraceEagerlyTrait<HeapVector<WeakMember<TraceTypeEagerly1>>>: :value, ShouldBeTrue);
5313 COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::va lue, ShouldBeTrue); 5307 COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::va lue, ShouldBeTrue);
5314 COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::va lue, ShouldBeTrue); 5308 COMPILE_ASSERT(TraceEagerlyTrait<HeapHashSet<Member<TraceTypeEagerly1>>>::va lue, ShouldBeTrue);
5315 using HashMapIntToObj = HeapHashMap<int, Member<TraceTypeEagerly1>>; 5309 using HashMapIntToObj = HeapHashMap<int, Member<TraceTypeEagerly1>>;
5316 COMPILE_ASSERT(TraceEagerlyTrait<HashMapIntToObj>::value, ShouldBeTrue); 5310 COMPILE_ASSERT(TraceEagerlyTrait<HashMapIntToObj>::value, ShouldBeTrue);
5317 using HashMapObjToInt = HeapHashMap<Member<TraceTypeEagerly1>, int>; 5311 using HashMapObjToInt = HeapHashMap<Member<TraceTypeEagerly1>, int>;
5318 COMPILE_ASSERT(TraceEagerlyTrait<HashMapObjToInt>::value, ShouldBeTrue); 5312 COMPILE_ASSERT(TraceEagerlyTrait<HashMapObjToInt>::value, ShouldBeTrue);
5319 5313
5320 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly2>::value, ShouldBeTrue); 5314 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly2>::value, ShouldBeTrue);
5321 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly3>::value, ShouldBeTrue); 5315 COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly2>>::value, ShouldBe True);
5322
5323 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly4>::value, ShouldBeTrue);
5324
5325 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeEagerly5>::value, ShouldBeTrue);
5326 COMPILE_ASSERT(TraceEagerlyTrait<Member<TraceTypeEagerly5>>::value, ShouldBe True);
5327
5328 COMPILE_ASSERT(ENABLE_EAGER_TRACING_BY_DEFAULT || !TraceEagerlyTrait<TraceTy peEagerly6>::value, ShouldBeTrue);
5329 COMPILE_ASSERT(ENABLE_EAGER_TRACING_BY_DEFAULT || !TraceEagerlyTrait<TraceTy peEagerly7>::value, ShouldBeTrue);
5330 5316
5331 COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly1>::value, ShouldBeTrue ); 5317 COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly1>::value, ShouldBeTrue );
5318 COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly2>::value, ShouldBeTrue );
5319 COMPILE_ASSERT(!TraceEagerlyTrait<TraceTypeNonEagerly3>::value, ShouldBeTrue );
5320 COMPILE_ASSERT(TraceEagerlyTrait<TraceTypeNonEagerly4>::value == MARKER_EAGE R_TRACING, ShouldBeTrue);
5321 }
5322
5323 class DeepEagerly final : public GarbageCollected<DeepEagerly> {
5324 public:
5325 DeepEagerly(DeepEagerly* next)
5326 : m_next(next)
5327 {
5328 }
5329
5330 void trace(Visitor* visitor)
5331 {
5332 int calls = ++sTraceCalls;
5333 visitor->trace(m_next);
5334 if (sTraceCalls == calls)
5335 sTraceLazy++;
5336 }
5337
5338 Member<DeepEagerly> m_next;
5339
5340 static int sTraceCalls;
5341 static int sTraceLazy;
5342 };
5343
5344 int DeepEagerly::sTraceCalls = 0;
5345 int DeepEagerly::sTraceLazy = 0;
5346
5347 TEST(HeapTest, TraceDeepEagerly)
5348 {
5349 #if !ENABLE(ASSERT)
5350 DeepEagerly* obj = nullptr;
5351 for (int i = 0; i < 2000; i++)
5352 obj = new DeepEagerly(obj);
5353
5354 Persistent<DeepEagerly> persistent(obj);
5355 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
5356
5357 // Verify that the DeepEagerly chain isn't completely unravelled
5358 // by performing eager trace() calls, but the explicit mark
5359 // stack is switched once some nesting limit is exceeded.
5360 EXPECT_GT(DeepEagerly::sTraceLazy, 2);
5361 #endif
5332 } 5362 }
5333 5363
5334 } // namespace blink 5364 } // namespace blink
OLDNEW
« 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