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

Side by Side Diff: Source/platform/heap/ThreadState.h

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, 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
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // When garbage collecting we need to know whether or not there 171 // When garbage collecting we need to know whether or not there
172 // can be pointers to Blink GC managed objects on the stack for 172 // can be pointers to Blink GC managed objects on the stack for
173 // each thread. When threads reach a safe point they record 173 // each thread. When threads reach a safe point they record
174 // whether or not they have pointers on the stack. 174 // whether or not they have pointers on the stack.
175 enum StackState { 175 enum StackState {
176 NoHeapPointersOnStack, 176 NoHeapPointersOnStack,
177 HeapPointersOnStack 177 HeapPointersOnStack
178 }; 178 };
179 179
180 enum GCType { 180 enum GCType {
181 GCWithSweep, // Sweeping is completed in Heap::collectGarbage(). 181 // Run a marking task and a sweeping task in Heap::collectGarbage().
182 GCWithoutSweep, // Lazy sweeping is scheduled. 182 GCWithSweep,
183 // Run only a marking task in Heap::collectGarbage(). A sweeping task
184 // is split into chunks and scheduled lazily.
185 GCWithoutSweep,
186 // Run a marking task just to take a heap snapshot. A sweeping task
187 // doesn't run and the marks are just dropped.
188 TakeSnapshot,
183 }; 189 };
184 190
185 // See setGCState() for possible state transitions. 191 // See setGCState() for possible state transitions.
186 enum GCState { 192 enum GCState {
187 NoGCScheduled, 193 NoGCScheduled,
188 IdleGCScheduled, 194 IdleGCScheduled,
189 PreciseGCScheduled, 195 PreciseGCScheduled,
190 FullGCScheduled, 196 FullGCScheduled,
191 StoppingOtherThreads, 197 StoppingOtherThreads,
192 GCRunning, 198 GCRunning,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // 333 //
328 // Notes: 334 // Notes:
329 // - We stop the world between 1) and 5). 335 // - We stop the world between 1) and 5).
330 // - isInGC() returns true between 2) and 4). 336 // - isInGC() returns true between 2) and 4).
331 // - isSweepingInProgress() returns true between 6) and 7). 337 // - isSweepingInProgress() returns true between 6) and 7).
332 // - It is valid that the next GC is scheduled while some thread 338 // - It is valid that the next GC is scheduled while some thread
333 // has not yet completed its lazy sweeping of the last GC. 339 // has not yet completed its lazy sweeping of the last GC.
334 // In this case, the next GC just cancels the remaining lazy sweeping. 340 // In this case, the next GC just cancels the remaining lazy sweeping.
335 // Specifically, preGC() of the next GC calls makeConsistentForSweeping() 341 // Specifically, preGC() of the next GC calls makeConsistentForSweeping()
336 // and it marks all not-yet-swept objets as dead. 342 // and it marks all not-yet-swept objets as dead.
337 void makeConsistentForSweeping(); 343 void makeConsistentForSweeping(GCType);
338 void preGC(); 344 void preGC(GCType);
339 void postGC(GCType); 345 void postGC(GCType);
340 void preSweep(); 346 void preSweep();
341 void completeSweep(); 347 void completeSweep();
342 void postSweep(); 348 void postSweep();
343 349
344 // Support for disallowing allocation. Mainly used for sanity 350 // Support for disallowing allocation. Mainly used for sanity
345 // checks asserts. 351 // checks asserts.
346 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio nCount; } 352 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio nCount; }
347 void enterNoAllocationScope() { m_noAllocationCount++; } 353 void enterNoAllocationScope() { m_noAllocationCount++; }
348 void leaveNoAllocationScope() { m_noAllocationCount--; } 354 void leaveNoAllocationScope() { m_noAllocationCount--; }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // to sweep away any objects that are left on this heap. 649 // to sweep away any objects that are left on this heap.
644 // We assert that nothing must remain after this cleanup. 650 // We assert that nothing must remain after this cleanup.
645 // If assertion does not hold we crash as we are potentially 651 // If assertion does not hold we crash as we are potentially
646 // in the dangling pointer situation. 652 // in the dangling pointer situation.
647 void cleanup(); 653 void cleanup();
648 void cleanupPages(); 654 void cleanupPages();
649 655
650 void unregisterPreFinalizerInternal(void*); 656 void unregisterPreFinalizerInternal(void*);
651 void invokePreFinalizers(Visitor&); 657 void invokePreFinalizers(Visitor&);
652 658
659 void takeSnapshot();
653 #if ENABLE(GC_PROFILING) 660 #if ENABLE(GC_PROFILING)
654 void snapshotFreeList(); 661 void snapshotFreeList();
655 #endif 662 #endif
656 void clearHeapAges(); 663 void clearHeapAges();
657 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe apIndex); 664 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe apIndex);
658 665
659 friend class SafePointAwareMutexLocker; 666 friend class SafePointAwareMutexLocker;
660 friend class SafePointBarrier; 667 friend class SafePointBarrier;
661 friend class SafePointScope; 668 friend class SafePointScope;
662 669
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 }; 742 };
736 743
737 template<> class ThreadStateFor<AnyThread> { 744 template<> class ThreadStateFor<AnyThread> {
738 public: 745 public:
739 static ThreadState* state() { return ThreadState::current(); } 746 static ThreadState* state() { return ThreadState::current(); }
740 }; 747 };
741 748
742 } // namespace blink 749 } // namespace blink
743 750
744 #endif // ThreadState_h 751 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698