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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // When garbage collecting we need to know whether or not there | 185 // When garbage collecting we need to know whether or not there |
186 // can be pointers to Blink GC managed objects on the stack for | 186 // can be pointers to Blink GC managed objects on the stack for |
187 // each thread. When threads reach a safe point they record | 187 // each thread. When threads reach a safe point they record |
188 // whether or not they have pointers on the stack. | 188 // whether or not they have pointers on the stack. |
189 enum StackState { | 189 enum StackState { |
190 NoHeapPointersOnStack, | 190 NoHeapPointersOnStack, |
191 HeapPointersOnStack | 191 HeapPointersOnStack |
192 }; | 192 }; |
193 | 193 |
194 enum GCType { | 194 enum GCType { |
195 GCWithSweep, // Sweeping is completed in Heap::collectGarbage(). | 195 // Both of the marking task and the sweeping task run in |
196 GCWithoutSweep, // Lazy sweeping is scheduled. | 196 // Heap::collectGarbage(). |
197 ThreadTerminationGC, // A thread-local GC scheduled before the thread sh
utdown. | 197 GCWithSweep, |
| 198 // Only the marking task runs in Heap::collectGarbage(). |
| 199 // The sweeping task is split into chunks and scheduled lazily. |
| 200 GCWithoutSweep, |
| 201 // Only the marking task runs just to take a heap snapshot. |
| 202 // The sweeping task doesn't run. The marks added in the marking task |
| 203 // are just cleared. |
| 204 TakeSnapshot, |
| 205 // The marking task does not mark objects outside the heap of the GCing |
| 206 // thread. |
| 207 ThreadTerminationGC, |
198 }; | 208 }; |
199 | 209 |
200 // See setGCState() for possible state transitions. | 210 // See setGCState() for possible state transitions. |
201 enum GCState { | 211 enum GCState { |
202 NoGCScheduled, | 212 NoGCScheduled, |
203 IdleGCScheduled, | 213 IdleGCScheduled, |
204 PreciseGCScheduled, | 214 PreciseGCScheduled, |
205 FullGCScheduled, | 215 FullGCScheduled, |
206 GCRunning, | 216 GCRunning, |
207 EagerSweepScheduled, | 217 EagerSweepScheduled, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // has not yet completed its lazy sweeping of the last GC. | 357 // has not yet completed its lazy sweeping of the last GC. |
348 // In this case, the next GC just cancels the remaining lazy sweeping. | 358 // In this case, the next GC just cancels the remaining lazy sweeping. |
349 // Specifically, preGC() of the next GC calls makeConsistentForGC() | 359 // Specifically, preGC() of the next GC calls makeConsistentForGC() |
350 // and it marks all not-yet-swept objets as dead. | 360 // and it marks all not-yet-swept objets as dead. |
351 void makeConsistentForGC(); | 361 void makeConsistentForGC(); |
352 void preGC(); | 362 void preGC(); |
353 void postGC(GCType); | 363 void postGC(GCType); |
354 void preSweep(); | 364 void preSweep(); |
355 void completeSweep(); | 365 void completeSweep(); |
356 void postSweep(); | 366 void postSweep(); |
| 367 // makeConsistentForMutator() drops marks from marked objects and rebuild |
| 368 // free lists. This is called after taking a snapshot and before resuming |
| 369 // the executions of mutators. |
| 370 void makeConsistentForMutator(); |
357 | 371 |
358 // Support for disallowing allocation. Mainly used for sanity | 372 // Support for disallowing allocation. Mainly used for sanity |
359 // checks asserts. | 373 // checks asserts. |
360 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } | 374 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } |
361 void enterNoAllocationScope() { m_noAllocationCount++; } | 375 void enterNoAllocationScope() { m_noAllocationCount++; } |
362 void leaveNoAllocationScope() { m_noAllocationCount--; } | 376 void leaveNoAllocationScope() { m_noAllocationCount--; } |
363 bool isGCForbidden() const { return m_gcForbiddenCount; } | 377 bool isGCForbidden() const { return m_gcForbiddenCount; } |
364 void enterGCForbiddenScope() { m_gcForbiddenCount++; } | 378 void enterGCForbiddenScope() { m_gcForbiddenCount++; } |
365 void leaveGCForbiddenScope() | 379 void leaveGCForbiddenScope() |
366 { | 380 { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 // to sweep away any objects that are left on this heap. | 678 // to sweep away any objects that are left on this heap. |
665 // We assert that nothing must remain after this cleanup. | 679 // We assert that nothing must remain after this cleanup. |
666 // If assertion does not hold we crash as we are potentially | 680 // If assertion does not hold we crash as we are potentially |
667 // in the dangling pointer situation. | 681 // in the dangling pointer situation. |
668 void cleanup(); | 682 void cleanup(); |
669 void cleanupPages(); | 683 void cleanupPages(); |
670 | 684 |
671 void unregisterPreFinalizerInternal(void*); | 685 void unregisterPreFinalizerInternal(void*); |
672 void invokePreFinalizers(); | 686 void invokePreFinalizers(); |
673 | 687 |
| 688 void takeSnapshot(); |
674 #if ENABLE(GC_PROFILING) | 689 #if ENABLE(GC_PROFILING) |
675 void snapshotFreeList(); | 690 void snapshotFreeList(); |
676 #endif | 691 #endif |
677 void clearHeapAges(); | 692 void clearHeapAges(); |
678 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); | 693 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); |
679 | 694 |
680 friend class SafePointAwareMutexLocker; | 695 friend class SafePointAwareMutexLocker; |
681 friend class SafePointBarrier; | 696 friend class SafePointBarrier; |
682 friend class SafePointScope; | 697 friend class SafePointScope; |
683 | 698 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 }; | 771 }; |
757 | 772 |
758 template<> class ThreadStateFor<AnyThread> { | 773 template<> class ThreadStateFor<AnyThread> { |
759 public: | 774 public: |
760 static ThreadState* state() { return ThreadState::current(); } | 775 static ThreadState* state() { return ThreadState::current(); } |
761 }; | 776 }; |
762 | 777 |
763 } // namespace blink | 778 } // namespace blink |
764 | 779 |
765 #endif // ThreadState_h | 780 #endif // ThreadState_h |
OLD | NEW |