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 1159003003: 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, 7 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 class TestGCScope { 224 class TestGCScope {
225 public: 225 public:
226 explicit TestGCScope(ThreadState::StackState state) 226 explicit TestGCScope(ThreadState::StackState state)
227 : m_state(ThreadState::current()) 227 : m_state(ThreadState::current())
228 , m_safePointScope(state) 228 , m_safePointScope(state)
229 , m_parkedAllThreads(false) 229 , m_parkedAllThreads(false)
230 { 230 {
231 m_state->checkThread(); 231 m_state->checkThread();
232 if (LIKELY(ThreadState::stopThreads())) { 232 if (LIKELY(ThreadState::stopThreads())) {
233 Heap::preGC(ThreadState::GCWithSweep); 233 Heap::preGC();
234 m_parkedAllThreads = true; 234 m_parkedAllThreads = true;
235 } 235 }
236 } 236 }
237 237
238 bool allThreadsParked() { return m_parkedAllThreads; } 238 bool allThreadsParked() { return m_parkedAllThreads; }
239 239
240 ~TestGCScope() 240 ~TestGCScope()
241 { 241 {
242 // Only cleanup if we parked all threads in which case the GC happened 242 // Only cleanup if we parked all threads in which case the GC happened
243 // and we need to resume the other threads. 243 // and we need to resume the other threads.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 for (int i = 0; i < numberOfAllocations; i++) { 510 for (int i = 0; i < numberOfAllocations; i++) {
511 wrapper = IntWrapper::create(0x0bbac0de); 511 wrapper = IntWrapper::create(0x0bbac0de);
512 if (!(i % 10)) { 512 if (!(i % 10)) {
513 globalPersistent = adoptPtr(new GlobalIntWrapperPersiste nt(IntWrapper::create(0x0ed0cabb))); 513 globalPersistent = adoptPtr(new GlobalIntWrapperPersiste nt(IntWrapper::create(0x0ed0cabb)));
514 } 514 }
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 // Taking snapshot shouldn't have any bad side effect.
521 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::TakeSnapshot, Heap::ForcedGC);
522 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::GCWithSweep, Heap::ForcedGC); 520 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr eadState::GCWithSweep, Heap::ForcedGC);
523 gcCount++; 521 gcCount++;
524 atomicIncrement(&m_gcCount); 522 atomicIncrement(&m_gcCount);
525 } 523 }
526 524
527 // Taking snapshot shouldn't have any bad side effect.
528 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::TakeSnapshot, Heap::ForcedGC);
529 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::GCWithSweep, Heap::ForcedGC); 525 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS tate::GCWithSweep, Heap::ForcedGC);
530 EXPECT_EQ(wrapper->value(), 0x0bbac0de); 526 EXPECT_EQ(wrapper->value(), 0x0bbac0de);
531 EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb); 527 EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb);
532 } 528 }
533 SafePointScope scope(ThreadState::NoHeapPointersOnStack); 529 SafePointScope scope(ThreadState::NoHeapPointersOnStack);
534 Platform::current()->yieldCurrentThread(); 530 Platform::current()->yieldCurrentThread();
535 } 531 }
536 ThreadState::detach(); 532 ThreadState::detach();
537 atomicDecrement(&m_threadsToFinish); 533 atomicDecrement(&m_threadsToFinish);
538 } 534 }
(...skipping 5575 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