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

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

Issue 1159773004: Oilpan: Implement a GC to take a heap snapshot (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months 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/Heap.cpp ('k') | Source/platform/heap/MarkingVisitorImpl.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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 SafePointScope scope(ThreadState::NoHeapPointersOnStack); 515 SafePointScope scope(ThreadState::NoHeapPointersOnStack);
516 Platform::current()->yieldCurrentThread(); 516 Platform::current()->yieldCurrentThread();
517 } 517 }
518 518
519 if (gcCount < gcPerThread) { 519 if (gcCount < gcPerThread) {
520 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::GCWithSweep, Heap::ForcedGC); 520 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::GCWithSweep, Heap::ForcedGC);
521 gcCount++; 521 gcCount++;
522 atomicIncrement(&m_gcCount); 522 atomicIncrement(&m_gcCount);
523 } 523 }
524 524
525 // Taking snapshot shouldn't have any bad side effect.
526 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::TakeSnapshot, Heap::ForcedGC);
525 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::GCWithSweep, Heap::ForcedGC); 527 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::GCWithSweep, Heap::ForcedGC);
526 EXPECT_EQ(wrapper->value(), 0x0bbac0de); 528 EXPECT_EQ(wrapper->value(), 0x0bbac0de);
527 EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb); 529 EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb);
528 } 530 }
529 SafePointScope scope(ThreadState::NoHeapPointersOnStack); 531 SafePointScope scope(ThreadState::NoHeapPointersOnStack);
530 Platform::current()->yieldCurrentThread(); 532 Platform::current()->yieldCurrentThread();
531 } 533 }
532 ThreadState::detach(); 534 ThreadState::detach();
533 atomicDecrement(&m_threadsToFinish); 535 atomicDecrement(&m_threadsToFinish);
534 } 536 }
(...skipping 24 matching lines...) Expand all
559 SafePointScope scope(ThreadState::NoHeapPointersOnStack); 561 SafePointScope scope(ThreadState::NoHeapPointersOnStack);
560 Platform::current()->yieldCurrentThread(); 562 Platform::current()->yieldCurrentThread();
561 } 563 }
562 564
563 if (gcCount < gcPerThread) { 565 if (gcCount < gcPerThread) {
564 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::GCWithSweep, Heap::ForcedGC); 566 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::GCWithSweep, Heap::ForcedGC);
565 gcCount++; 567 gcCount++;
566 atomicIncrement(&m_gcCount); 568 atomicIncrement(&m_gcCount);
567 } 569 }
568 570
571 // Taking snapshot shouldn't have any bad side effect.
572 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::TakeSnapshot, Heap::ForcedGC);
569 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::GCWithSweep, Heap::ForcedGC); 573 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::GCWithSweep, Heap::ForcedGC);
570 EXPECT_TRUE(weakMap->isEmpty()); 574 EXPECT_TRUE(weakMap->isEmpty());
571 EXPECT_TRUE(weakMap2.isEmpty()); 575 EXPECT_TRUE(weakMap2.isEmpty());
572 } 576 }
573 SafePointScope scope(ThreadState::NoHeapPointersOnStack); 577 SafePointScope scope(ThreadState::NoHeapPointersOnStack);
574 Platform::current()->yieldCurrentThread(); 578 Platform::current()->yieldCurrentThread();
575 } 579 }
576 ThreadState::detach(); 580 ThreadState::detach();
577 atomicDecrement(&m_threadsToFinish); 581 atomicDecrement(&m_threadsToFinish);
578 } 582 }
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3629 objectAddresses.append(objectAddress); 3633 objectAddresses.append(objectAddress);
3630 endAddresses.append(objectAddress + sizeof(SimpleObject) - 1); 3634 endAddresses.append(objectAddress + sizeof(SimpleObject) - 1);
3631 } 3635 }
3632 LargeHeapObject* largeObject = LargeHeapObject::create(); 3636 LargeHeapObject* largeObject = LargeHeapObject::create();
3633 largeObjectAddress = reinterpret_cast<Address>(largeObject); 3637 largeObjectAddress = reinterpret_cast<Address>(largeObject);
3634 largeObjectEndAddress = largeObjectAddress + sizeof(LargeHeapObject) - 1; 3638 largeObjectEndAddress = largeObjectAddress + sizeof(LargeHeapObject) - 1;
3635 3639
3636 // This is a low-level test where we call checkAndMarkPointer. This method 3640 // This is a low-level test where we call checkAndMarkPointer. This method
3637 // causes the object start bitmap to be computed which requires the heap 3641 // causes the object start bitmap to be computed which requires the heap
3638 // to be in a consistent state (e.g. the free allocation area must be put 3642 // to be in a consistent state (e.g. the free allocation area must be put
3639 // into a free list header). However when we call makeConsistentForSweeping it 3643 // into a free list header). However when we call makeConsistentForGC it
3640 // also clears out the freelists so we have to rebuild those before trying 3644 // also clears out the freelists so we have to rebuild those before trying
3641 // to allocate anything again. We do this by forcing a GC after doing the 3645 // to allocate anything again. We do this by forcing a GC after doing the
3642 // checkAndMarkPointer tests. 3646 // checkAndMarkPointer tests.
3643 { 3647 {
3644 TestGCScope scope(ThreadState::HeapPointersOnStack); 3648 TestGCScope scope(ThreadState::HeapPointersOnStack);
3645 EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not park all threads. 3649 EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not park all threads.
3646 Heap::flushHeapDoesNotContainCache(); 3650 Heap::flushHeapDoesNotContainCache();
3647 for (size_t i = 0; i < objectAddresses.size(); i++) { 3651 for (size_t i = 0; i < objectAddresses.size(); i++) {
3648 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, objectAddresses[i])) ; 3652 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, objectAddresses[i])) ;
3649 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, endAddresses[i])); 3653 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, endAddresses[i]));
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after
6111 { 6115 {
6112 Persistent<ClassWithMember> object = ClassWithMember::create(); 6116 Persistent<ClassWithMember> object = ClassWithMember::create();
6113 EXPECT_EQ(0, object->traceCount()); 6117 EXPECT_EQ(0, object->traceCount());
6114 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object. get()); 6118 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object. get());
6115 EXPECT_TRUE(mixin); 6119 EXPECT_TRUE(mixin);
6116 EXPECT_GT(object->traceCount(), 0); 6120 EXPECT_GT(object->traceCount(), 0);
6117 EXPECT_GT(mixin->traceCount(), 0); 6121 EXPECT_GT(mixin->traceCount(), 0);
6118 } 6122 }
6119 6123
6120 } // namespace blink 6124 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.cpp ('k') | Source/platform/heap/MarkingVisitorImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698