| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 333     // | 327     // | 
| 334     // Notes: | 328     // Notes: | 
| 335     // - We stop the world between 1) and 5). | 329     // - We stop the world between 1) and 5). | 
| 336     // - isInGC() returns true between 2) and 4). | 330     // - isInGC() returns true between 2) and 4). | 
| 337     // - isSweepingInProgress() returns true between 6) and 7). | 331     // - isSweepingInProgress() returns true between 6) and 7). | 
| 338     // - It is valid that the next GC is scheduled while some thread | 332     // - It is valid that the next GC is scheduled while some thread | 
| 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 makeConsistentForSweeping() | 335     //   Specifically, preGC() of the next GC calls makeConsistentForSweeping() | 
| 342     //   and it marks all not-yet-swept objets as dead. | 336     //   and it marks all not-yet-swept objets as dead. | 
| 343     void makeConsistentForSweeping(GCType); | 337     void makeConsistentForSweeping(); | 
| 344     void preGC(GCType); | 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 | 343 | 
| 350     // Support for disallowing allocation. Mainly used for sanity | 344     // Support for disallowing allocation. Mainly used for sanity | 
| 351     // checks asserts. | 345     // checks asserts. | 
| 352     bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
     nCount; } | 346     bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
     nCount; } | 
| 353     void enterNoAllocationScope() { m_noAllocationCount++; } | 347     void enterNoAllocationScope() { m_noAllocationCount++; } | 
| 354     void leaveNoAllocationScope() { m_noAllocationCount--; } | 348     void leaveNoAllocationScope() { m_noAllocationCount--; } | 
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 649     // to sweep away any objects that are left on this heap. | 643     // to sweep away any objects that are left on this heap. | 
| 650     // We assert that nothing must remain after this cleanup. | 644     // We assert that nothing must remain after this cleanup. | 
| 651     // If assertion does not hold we crash as we are potentially | 645     // If assertion does not hold we crash as we are potentially | 
| 652     // in the dangling pointer situation. | 646     // in the dangling pointer situation. | 
| 653     void cleanup(); | 647     void cleanup(); | 
| 654     void cleanupPages(); | 648     void cleanupPages(); | 
| 655 | 649 | 
| 656     void unregisterPreFinalizerInternal(void*); | 650     void unregisterPreFinalizerInternal(void*); | 
| 657     void invokePreFinalizers(Visitor&); | 651     void invokePreFinalizers(Visitor&); | 
| 658 | 652 | 
| 659     void takeSnapshot(); |  | 
| 660 #if ENABLE(GC_PROFILING) | 653 #if ENABLE(GC_PROFILING) | 
| 661     void snapshotFreeList(); | 654     void snapshotFreeList(); | 
| 662 #endif | 655 #endif | 
| 663     void clearHeapAges(); | 656     void clearHeapAges(); | 
| 664     int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
     apIndex); | 657     int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
     apIndex); | 
| 665 | 658 | 
| 666     friend class SafePointAwareMutexLocker; | 659     friend class SafePointAwareMutexLocker; | 
| 667     friend class SafePointBarrier; | 660     friend class SafePointBarrier; | 
| 668     friend class SafePointScope; | 661     friend class SafePointScope; | 
| 669 | 662 | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 742 }; | 735 }; | 
| 743 | 736 | 
| 744 template<> class ThreadStateFor<AnyThread> { | 737 template<> class ThreadStateFor<AnyThread> { | 
| 745 public: | 738 public: | 
| 746     static ThreadState* state() { return ThreadState::current(); } | 739     static ThreadState* state() { return ThreadState::current(); } | 
| 747 }; | 740 }; | 
| 748 | 741 | 
| 749 } // namespace blink | 742 } // namespace blink | 
| 750 | 743 | 
| 751 #endif // ThreadState_h | 744 #endif // ThreadState_h | 
| OLD | NEW | 
|---|