OLD | NEW |
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 Loading... |
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 makeConsistentForGC() | 341 // Specifically, preGC() of the next GC calls makeConsistentForGC() |
336 // and it marks all not-yet-swept objets as dead. | 342 // and it marks all not-yet-swept objets as dead. |
337 void makeConsistentForGC(); | 343 void makeConsistentForGC(); |
338 void preGC(); | 344 void preGC(); |
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(); |
| 349 // makeConsistentForMutator() drops marks from marked objects and rebuild |
| 350 // free lists. This is called after taking a snapshot and before resuming |
| 351 // the executions of mutators. |
| 352 void makeConsistentForMutator(); |
343 | 353 |
344 // Support for disallowing allocation. Mainly used for sanity | 354 // Support for disallowing allocation. Mainly used for sanity |
345 // checks asserts. | 355 // checks asserts. |
346 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } | 356 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } |
347 void enterNoAllocationScope() { m_noAllocationCount++; } | 357 void enterNoAllocationScope() { m_noAllocationCount++; } |
348 void leaveNoAllocationScope() { m_noAllocationCount--; } | 358 void leaveNoAllocationScope() { m_noAllocationCount--; } |
349 bool isGCForbidden() const { return m_gcForbiddenCount; } | 359 bool isGCForbidden() const { return m_gcForbiddenCount; } |
350 void enterGCForbiddenScope() { m_gcForbiddenCount++; } | 360 void enterGCForbiddenScope() { m_gcForbiddenCount++; } |
351 void leaveGCForbiddenScope() { m_gcForbiddenCount--; } | 361 void leaveGCForbiddenScope() { m_gcForbiddenCount--; } |
352 bool sweepForbidden() const { return m_sweepForbidden; } | 362 bool sweepForbidden() const { return m_sweepForbidden; } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 // to sweep away any objects that are left on this heap. | 653 // to sweep away any objects that are left on this heap. |
644 // We assert that nothing must remain after this cleanup. | 654 // We assert that nothing must remain after this cleanup. |
645 // If assertion does not hold we crash as we are potentially | 655 // If assertion does not hold we crash as we are potentially |
646 // in the dangling pointer situation. | 656 // in the dangling pointer situation. |
647 void cleanup(); | 657 void cleanup(); |
648 void cleanupPages(); | 658 void cleanupPages(); |
649 | 659 |
650 void unregisterPreFinalizerInternal(void*); | 660 void unregisterPreFinalizerInternal(void*); |
651 void invokePreFinalizers(Visitor&); | 661 void invokePreFinalizers(Visitor&); |
652 | 662 |
| 663 void takeSnapshot(); |
653 #if ENABLE(GC_PROFILING) | 664 #if ENABLE(GC_PROFILING) |
654 void snapshotFreeList(); | 665 void snapshotFreeList(); |
655 #endif | 666 #endif |
656 void clearHeapAges(); | 667 void clearHeapAges(); |
657 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); | 668 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); |
658 | 669 |
659 friend class SafePointAwareMutexLocker; | 670 friend class SafePointAwareMutexLocker; |
660 friend class SafePointBarrier; | 671 friend class SafePointBarrier; |
661 friend class SafePointScope; | 672 friend class SafePointScope; |
662 | 673 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 }; | 746 }; |
736 | 747 |
737 template<> class ThreadStateFor<AnyThread> { | 748 template<> class ThreadStateFor<AnyThread> { |
738 public: | 749 public: |
739 static ThreadState* state() { return ThreadState::current(); } | 750 static ThreadState* state() { return ThreadState::current(); } |
740 }; | 751 }; |
741 | 752 |
742 } // namespace blink | 753 } // namespace blink |
743 | 754 |
744 #endif // ThreadState_h | 755 #endif // ThreadState_h |
OLD | NEW |