| 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 // Run a marking task and a sweeping task in Heap::collectGarbage(). | 181 GCWithSweep, // Sweeping is completed in Heap::collectGarbage(). |
| 182 GCWithSweep, | 182 GCWithoutSweep, // Lazy sweeping is scheduled. |
| 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, | |
| 189 }; | 183 }; |
| 190 | 184 |
| 191 // See setGCState() for possible state transitions. | 185 // See setGCState() for possible state transitions. |
| 192 enum GCState { | 186 enum GCState { |
| 193 NoGCScheduled, | 187 NoGCScheduled, |
| 194 IdleGCScheduled, | 188 IdleGCScheduled, |
| 195 PreciseGCScheduled, | 189 PreciseGCScheduled, |
| 196 FullGCScheduled, | 190 FullGCScheduled, |
| 197 StoppingOtherThreads, | 191 StoppingOtherThreads, |
| 198 GCRunning, | 192 GCRunning, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // has not yet completed its lazy sweeping of the last GC. | 333 // has not yet completed its lazy sweeping of the last GC. |
| 340 // In this case, the next GC just cancels the remaining lazy sweeping. | 334 // In this case, the next GC just cancels the remaining lazy sweeping. |
| 341 // Specifically, preGC() of the next GC calls makeConsistentForGC() | 335 // Specifically, preGC() of the next GC calls makeConsistentForGC() |
| 342 // and it marks all not-yet-swept objets as dead. | 336 // and it marks all not-yet-swept objets as dead. |
| 343 void makeConsistentForGC(); | 337 void makeConsistentForGC(); |
| 344 void preGC(); | 338 void preGC(); |
| 345 void postGC(GCType); | 339 void postGC(GCType); |
| 346 void preSweep(); | 340 void preSweep(); |
| 347 void completeSweep(); | 341 void completeSweep(); |
| 348 void postSweep(); | 342 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(); | |
| 353 | 343 |
| 354 // Support for disallowing allocation. Mainly used for sanity | 344 // Support for disallowing allocation. Mainly used for sanity |
| 355 // checks asserts. | 345 // checks asserts. |
| 356 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } | 346 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } |
| 357 void enterNoAllocationScope() { m_noAllocationCount++; } | 347 void enterNoAllocationScope() { m_noAllocationCount++; } |
| 358 void leaveNoAllocationScope() { m_noAllocationCount--; } | 348 void leaveNoAllocationScope() { m_noAllocationCount--; } |
| 359 bool isGCForbidden() const { return m_gcForbiddenCount; } | 349 bool isGCForbidden() const { return m_gcForbiddenCount; } |
| 360 void enterGCForbiddenScope() { m_gcForbiddenCount++; } | 350 void enterGCForbiddenScope() { m_gcForbiddenCount++; } |
| 361 void leaveGCForbiddenScope() { m_gcForbiddenCount--; } | 351 void leaveGCForbiddenScope() { m_gcForbiddenCount--; } |
| 362 bool sweepForbidden() const { return m_sweepForbidden; } | 352 bool sweepForbidden() const { return m_sweepForbidden; } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // to sweep away any objects that are left on this heap. | 643 // to sweep away any objects that are left on this heap. |
| 654 // We assert that nothing must remain after this cleanup. | 644 // We assert that nothing must remain after this cleanup. |
| 655 // If assertion does not hold we crash as we are potentially | 645 // If assertion does not hold we crash as we are potentially |
| 656 // in the dangling pointer situation. | 646 // in the dangling pointer situation. |
| 657 void cleanup(); | 647 void cleanup(); |
| 658 void cleanupPages(); | 648 void cleanupPages(); |
| 659 | 649 |
| 660 void unregisterPreFinalizerInternal(void*); | 650 void unregisterPreFinalizerInternal(void*); |
| 661 void invokePreFinalizers(Visitor&); | 651 void invokePreFinalizers(Visitor&); |
| 662 | 652 |
| 663 void takeSnapshot(); | |
| 664 #if ENABLE(GC_PROFILING) | 653 #if ENABLE(GC_PROFILING) |
| 665 void snapshotFreeList(); | 654 void snapshotFreeList(); |
| 666 #endif | 655 #endif |
| 667 void clearHeapAges(); | 656 void clearHeapAges(); |
| 668 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); | 657 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); |
| 669 | 658 |
| 670 friend class SafePointAwareMutexLocker; | 659 friend class SafePointAwareMutexLocker; |
| 671 friend class SafePointBarrier; | 660 friend class SafePointBarrier; |
| 672 friend class SafePointScope; | 661 friend class SafePointScope; |
| 673 | 662 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 }; | 735 }; |
| 747 | 736 |
| 748 template<> class ThreadStateFor<AnyThread> { | 737 template<> class ThreadStateFor<AnyThread> { |
| 749 public: | 738 public: |
| 750 static ThreadState* state() { return ThreadState::current(); } | 739 static ThreadState* state() { return ThreadState::current(); } |
| 751 }; | 740 }; |
| 752 | 741 |
| 753 } // namespace blink | 742 } // namespace blink |
| 754 | 743 |
| 755 #endif // ThreadState_h | 744 #endif // ThreadState_h |
| OLD | NEW |