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

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

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

Powered by Google App Engine
This is Rietveld 408576698