| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 ASSERT(m_state->m_sweepForbidden); | 167 ASSERT(m_state->m_sweepForbidden); |
| 168 m_state->m_sweepForbidden = false; | 168 m_state->m_sweepForbidden = false; |
| 169 } | 169 } |
| 170 private: | 170 private: |
| 171 ThreadState* m_state; | 171 ThreadState* m_state; |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 void lockThreadAttachMutex(); | 174 void lockThreadAttachMutex(); |
| 175 void unlockThreadAttachMutex(); | 175 void unlockThreadAttachMutex(); |
| 176 | 176 |
| 177 bool perThreadHeapEnabled() const { return m_perThreadHeapEnabled; } | 177 BlinkGC::ThreadHeapMode threadHeapMode() const { return m_threadHeapMode; } |
| 178 | 178 |
| 179 bool isTerminating() { return m_isTerminating; } | 179 bool isTerminating() { return m_isTerminating; } |
| 180 | 180 |
| 181 static void attachMainThread(); | 181 static void attachMainThread(); |
| 182 static void detachMainThread(); | 182 static void detachMainThread(); |
| 183 void cleanupMainThread(); | 183 void cleanupMainThread(); |
| 184 | 184 |
| 185 // Associate ThreadState object with the current thread. After this | 185 // Associate ThreadState object with the current thread. After this |
| 186 // call thread can start using the garbage collected heap infrastructure. | 186 // call thread can start using the garbage collected heap infrastructure. |
| 187 // It also has to periodically check for safepoints. | 187 // It also has to periodically check for safepoints. |
| 188 static void attachCurrentThread(bool perThreadHeapEnabled); | 188 static void attachCurrentThread(BlinkGC::ThreadHeapMode); |
| 189 | 189 |
| 190 // Disassociate attached ThreadState from the current thread. The thread | 190 // Disassociate attached ThreadState from the current thread. The thread |
| 191 // can no longer use the garbage collected heap after this call. | 191 // can no longer use the garbage collected heap after this call. |
| 192 static void detachCurrentThread(); | 192 static void detachCurrentThread(); |
| 193 | 193 |
| 194 static ThreadState* current() | 194 static ThreadState* current() |
| 195 { | 195 { |
| 196 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) | 196 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) |
| 197 // TLS lookup is fast in these platforms. | 197 // TLS lookup is fast in these platforms. |
| 198 return **s_threadSpecific; | 198 return **s_threadSpecific; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason)
; | 533 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason)
; |
| 534 void collectGarbageForTerminatingThread(); | 534 void collectGarbageForTerminatingThread(); |
| 535 void collectAllGarbage(); | 535 void collectAllGarbage(); |
| 536 | 536 |
| 537 private: | 537 private: |
| 538 enum SnapshotType { | 538 enum SnapshotType { |
| 539 HeapSnapshot, | 539 HeapSnapshot, |
| 540 FreelistSnapshot | 540 FreelistSnapshot |
| 541 }; | 541 }; |
| 542 | 542 |
| 543 ThreadState(bool perThreadHeapEnabled); | 543 explicit ThreadState(BlinkGC::ThreadHeapMode); |
| 544 ~ThreadState(); | 544 ~ThreadState(); |
| 545 | 545 |
| 546 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); | 546 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); |
| 547 void clearSafePointScopeMarker() | 547 void clearSafePointScopeMarker() |
| 548 { | 548 { |
| 549 m_safePointStackCopy.clear(); | 549 m_safePointStackCopy.clear(); |
| 550 m_safePointScopeMarker = nullptr; | 550 m_safePointScopeMarker = nullptr; |
| 551 } | 551 } |
| 552 | 552 |
| 553 // shouldSchedule{Precise,Idle}GC and shouldForceConservativeGC | 553 // shouldSchedule{Precise,Idle}GC and shouldForceConservativeGC |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 bool m_sweepForbidden; | 643 bool m_sweepForbidden; |
| 644 size_t m_noAllocationCount; | 644 size_t m_noAllocationCount; |
| 645 size_t m_gcForbiddenCount; | 645 size_t m_gcForbiddenCount; |
| 646 double m_accumulatedSweepingTime; | 646 double m_accumulatedSweepingTime; |
| 647 | 647 |
| 648 BaseArena* m_arenas[BlinkGC::NumberOfArenas]; | 648 BaseArena* m_arenas[BlinkGC::NumberOfArenas]; |
| 649 int m_vectorBackingArenaIndex; | 649 int m_vectorBackingArenaIndex; |
| 650 size_t m_arenaAges[BlinkGC::NumberOfArenas]; | 650 size_t m_arenaAges[BlinkGC::NumberOfArenas]; |
| 651 size_t m_currentArenaAges; | 651 size_t m_currentArenaAges; |
| 652 | 652 |
| 653 bool m_perThreadHeapEnabled; | 653 const BlinkGC::ThreadHeapMode m_threadHeapMode; |
| 654 bool m_isTerminating; | 654 bool m_isTerminating; |
| 655 GarbageCollectedMixinConstructorMarker* m_gcMixinMarker; | 655 GarbageCollectedMixinConstructorMarker* m_gcMixinMarker; |
| 656 | 656 |
| 657 bool m_shouldFlushHeapDoesNotContainCache; | 657 bool m_shouldFlushHeapDoesNotContainCache; |
| 658 GCState m_gcState; | 658 GCState m_gcState; |
| 659 | 659 |
| 660 std::unique_ptr<CallbackStack> m_threadLocalWeakCallbackStack; | 660 std::unique_ptr<CallbackStack> m_threadLocalWeakCallbackStack; |
| 661 | 661 |
| 662 // Pre-finalizers are called in the reverse order in which they are | 662 // Pre-finalizers are called in the reverse order in which they are |
| 663 // registered by the constructors (including constructors of Mixin objects) | 663 // registered by the constructors (including constructors of Mixin objects) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 | 713 |
| 714 template<> class ThreadStateFor<AnyThread> { | 714 template<> class ThreadStateFor<AnyThread> { |
| 715 STATIC_ONLY(ThreadStateFor); | 715 STATIC_ONLY(ThreadStateFor); |
| 716 public: | 716 public: |
| 717 static ThreadState* state() { return ThreadState::current(); } | 717 static ThreadState* state() { return ThreadState::current(); } |
| 718 }; | 718 }; |
| 719 | 719 |
| 720 } // namespace blink | 720 } // namespace blink |
| 721 | 721 |
| 722 #endif // ThreadState_h | 722 #endif // ThreadState_h |
| OLD | NEW |