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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 GCWithSweep, // Sweeping is completed in Heap::collectGarbage(). | 181 GCWithSweep, // Sweeping is completed in Heap::collectGarbage(). |
182 GCWithoutSweep, // Lazy sweeping is scheduled. | 182 GCWithoutSweep, // Lazy sweeping is scheduled. |
183 }; | 183 }; |
184 | 184 |
185 // See setGCState() for possible state transitions. | 185 // See setGCState() for possible state transitions. |
186 enum GCState { | 186 enum GCState { |
187 NoGCScheduled, | 187 NoGCScheduled, |
188 IdleGCScheduled, | 188 IdleGCScheduled, |
189 PreciseGCScheduled, | 189 PreciseGCScheduled, |
190 FullGCScheduled, | 190 FullGCScheduled, |
191 StoppingOtherThreads, | |
192 GCRunning, | 191 GCRunning, |
193 EagerSweepScheduled, | 192 EagerSweepScheduled, |
194 LazySweepScheduled, | 193 LazySweepScheduled, |
195 Sweeping, | 194 Sweeping, |
196 SweepingAndIdleGCScheduled, | 195 SweepingAndIdleGCScheduled, |
197 SweepingAndPreciseGCScheduled, | 196 SweepingAndPreciseGCScheduled, |
198 }; | 197 }; |
199 | 198 |
200 // The NoAllocationScope class is used in debug mode to catch unwanted | 199 // The NoAllocationScope class is used in debug mode to catch unwanted |
201 // allocations. E.g. allocations during GC. | 200 // allocations. E.g. allocations during GC. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 void completeSweep(); | 340 void completeSweep(); |
342 void postSweep(); | 341 void postSweep(); |
343 | 342 |
344 // Support for disallowing allocation. Mainly used for sanity | 343 // Support for disallowing allocation. Mainly used for sanity |
345 // checks asserts. | 344 // checks asserts. |
346 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } | 345 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio
nCount; } |
347 void enterNoAllocationScope() { m_noAllocationCount++; } | 346 void enterNoAllocationScope() { m_noAllocationCount++; } |
348 void leaveNoAllocationScope() { m_noAllocationCount--; } | 347 void leaveNoAllocationScope() { m_noAllocationCount--; } |
349 bool isGCForbidden() const { return m_gcForbiddenCount; } | 348 bool isGCForbidden() const { return m_gcForbiddenCount; } |
350 void enterGCForbiddenScope() { m_gcForbiddenCount++; } | 349 void enterGCForbiddenScope() { m_gcForbiddenCount++; } |
351 void leaveGCForbiddenScope() { m_gcForbiddenCount--; } | 350 void leaveGCForbiddenScope() |
| 351 { |
| 352 ASSERT(m_gcForbiddenCount > 0); |
| 353 m_gcForbiddenCount--; |
| 354 } |
352 bool sweepForbidden() const { return m_sweepForbidden; } | 355 bool sweepForbidden() const { return m_sweepForbidden; } |
353 | 356 |
354 void prepareRegionTree(); | 357 void prepareRegionTree(); |
355 void flushHeapDoesNotContainCacheIfNeeded(); | 358 void flushHeapDoesNotContainCacheIfNeeded(); |
356 | 359 |
357 // Safepoint related functionality. | 360 // Safepoint related functionality. |
358 // | 361 // |
359 // When a thread attempts to perform GC it needs to stop all other threads | 362 // When a thread attempts to perform GC it needs to stop all other threads |
360 // that use the heap or at least guarantee that they will not touch any | 363 // that use the heap or at least guarantee that they will not touch any |
361 // heap allocated object until GC is complete. | 364 // heap allocated object until GC is complete. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // constructed. | 551 // constructed. |
549 void enterGCForbiddenScopeIfNeeded(GarbageCollectedMixinConstructorMarker* g
cMixinMarker) | 552 void enterGCForbiddenScopeIfNeeded(GarbageCollectedMixinConstructorMarker* g
cMixinMarker) |
550 { | 553 { |
551 if (!m_gcMixinMarker) { | 554 if (!m_gcMixinMarker) { |
552 enterGCForbiddenScope(); | 555 enterGCForbiddenScope(); |
553 m_gcMixinMarker = gcMixinMarker; | 556 m_gcMixinMarker = gcMixinMarker; |
554 } | 557 } |
555 } | 558 } |
556 void leaveGCForbiddenScopeIfNeeded(GarbageCollectedMixinConstructorMarker* g
cMixinMarker) | 559 void leaveGCForbiddenScopeIfNeeded(GarbageCollectedMixinConstructorMarker* g
cMixinMarker) |
557 { | 560 { |
558 ASSERT(m_gcForbiddenCount > 0); | |
559 if (m_gcMixinMarker == gcMixinMarker) { | 561 if (m_gcMixinMarker == gcMixinMarker) { |
560 leaveGCForbiddenScope(); | 562 leaveGCForbiddenScope(); |
561 m_gcMixinMarker = nullptr; | 563 m_gcMixinMarker = nullptr; |
562 } | 564 } |
563 } | 565 } |
564 | 566 |
565 // vectorBackingHeap() returns a heap that the vector allocation should use. | 567 // vectorBackingHeap() returns a heap that the vector allocation should use. |
566 // We have four vector heaps and want to choose the best heap here. | 568 // We have four vector heaps and want to choose the best heap here. |
567 // | 569 // |
568 // The goal is to improve the succession rate where expand and | 570 // The goal is to improve the succession rate where expand and |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 }; | 737 }; |
736 | 738 |
737 template<> class ThreadStateFor<AnyThread> { | 739 template<> class ThreadStateFor<AnyThread> { |
738 public: | 740 public: |
739 static ThreadState* state() { return ThreadState::current(); } | 741 static ThreadState* state() { return ThreadState::current(); } |
740 }; | 742 }; |
741 | 743 |
742 } // namespace blink | 744 } // namespace blink |
743 | 745 |
744 #endif // ThreadState_h | 746 #endif // ThreadState_h |
OLD | NEW |