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

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, 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
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // When garbage collecting we need to know whether or not there 178 // When garbage collecting we need to know whether or not there
179 // can be pointers to Blink GC managed objects on the stack for 179 // can be pointers to Blink GC managed objects on the stack for
180 // each thread. When threads reach a safe point they record 180 // each thread. When threads reach a safe point they record
181 // whether or not they have pointers on the stack. 181 // whether or not they have pointers on the stack.
182 enum StackState { 182 enum StackState {
183 NoHeapPointersOnStack, 183 NoHeapPointersOnStack,
184 HeapPointersOnStack 184 HeapPointersOnStack
185 }; 185 };
186 186
187 enum GCType { 187 enum GCType {
188 GCWithSweep, // Sweeping is completed in Heap::collectGarbage(). 188 // Run a marking task and a sweeping task in Heap::collectGarbage().
189 GCWithoutSweep, // Lazy sweeping is scheduled. 189 GCWithSweep,
190 // Run only a marking task in Heap::collectGarbage(). A sweeping task
191 // is split into chunks and scheduled lazily.
192 GCWithoutSweep,
193 // Run a marking task just to take a heap snapshot. A sweeping task
194 // doesn't run and the marks are just dropped.
195 TakeSnapshot,
190 }; 196 };
191 197
192 // See setGCState() for possible state transitions. 198 // See setGCState() for possible state transitions.
193 enum GCState { 199 enum GCState {
194 NoGCScheduled, 200 NoGCScheduled,
195 IdleGCScheduled, 201 IdleGCScheduled,
196 PreciseGCScheduled, 202 PreciseGCScheduled,
197 FullGCScheduled, 203 FullGCScheduled,
198 StoppingOtherThreads, 204 StoppingOtherThreads,
199 GCRunning, 205 GCRunning,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // has not yet completed its lazy sweeping of the last GC. 346 // has not yet completed its lazy sweeping of the last GC.
341 // In this case, the next GC just cancels the remaining lazy sweeping. 347 // In this case, the next GC just cancels the remaining lazy sweeping.
342 // Specifically, preGC() of the next GC calls makeConsistentForGC() 348 // Specifically, preGC() of the next GC calls makeConsistentForGC()
343 // and it marks all not-yet-swept objets as dead. 349 // and it marks all not-yet-swept objets as dead.
344 void makeConsistentForGC(); 350 void makeConsistentForGC();
345 void preGC(); 351 void preGC();
346 void postGC(GCType); 352 void postGC(GCType);
347 void preSweep(); 353 void preSweep();
348 void completeSweep(); 354 void completeSweep();
349 void postSweep(); 355 void postSweep();
356 // makeConsistentForMutator() drops marks from marked objects and rebuild
357 // free lists. This is called after taking a snapshot and before resuming
358 // the executions of mutators.
359 void makeConsistentForMutator();
350 360
351 // Support for disallowing allocation. Mainly used for sanity 361 // Support for disallowing allocation. Mainly used for sanity
352 // checks asserts. 362 // checks asserts.
353 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio nCount; } 363 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio nCount; }
354 void enterNoAllocationScope() { m_noAllocationCount++; } 364 void enterNoAllocationScope() { m_noAllocationCount++; }
355 void leaveNoAllocationScope() { m_noAllocationCount--; } 365 void leaveNoAllocationScope() { m_noAllocationCount--; }
356 bool isGCForbidden() const { return m_gcForbiddenCount; } 366 bool isGCForbidden() const { return m_gcForbiddenCount; }
357 void enterGCForbiddenScope() { m_gcForbiddenCount++; } 367 void enterGCForbiddenScope() { m_gcForbiddenCount++; }
358 void leaveGCForbiddenScope() { m_gcForbiddenCount--; } 368 void leaveGCForbiddenScope() { m_gcForbiddenCount--; }
359 bool sweepForbidden() const { return m_sweepForbidden; } 369 bool sweepForbidden() const { return m_sweepForbidden; }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 // to sweep away any objects that are left on this heap. 660 // to sweep away any objects that are left on this heap.
651 // We assert that nothing must remain after this cleanup. 661 // We assert that nothing must remain after this cleanup.
652 // If assertion does not hold we crash as we are potentially 662 // If assertion does not hold we crash as we are potentially
653 // in the dangling pointer situation. 663 // in the dangling pointer situation.
654 void cleanup(); 664 void cleanup();
655 void cleanupPages(); 665 void cleanupPages();
656 666
657 void unregisterPreFinalizerInternal(void*); 667 void unregisterPreFinalizerInternal(void*);
658 void invokePreFinalizers(Visitor&); 668 void invokePreFinalizers(Visitor&);
659 669
670 void takeSnapshot();
660 #if ENABLE(GC_PROFILING) 671 #if ENABLE(GC_PROFILING)
661 void snapshotFreeList(); 672 void snapshotFreeList();
662 #endif 673 #endif
663 void clearHeapAges(); 674 void clearHeapAges();
664 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe apIndex); 675 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe apIndex);
665 676
666 friend class SafePointAwareMutexLocker; 677 friend class SafePointAwareMutexLocker;
667 friend class SafePointBarrier; 678 friend class SafePointBarrier;
668 friend class SafePointScope; 679 friend class SafePointScope;
669 680
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 }; 753 };
743 754
744 template<> class ThreadStateFor<AnyThread> { 755 template<> class ThreadStateFor<AnyThread> {
745 public: 756 public:
746 static ThreadState* state() { return ThreadState::current(); } 757 static ThreadState* state() { return ThreadState::current(); }
747 }; 758 };
748 759
749 } // namespace blink 760 } // namespace blink
750 761
751 #endif // ThreadState_h 762 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698