| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 ASSERT(m_state->m_sweepForbidden); | 166 ASSERT(m_state->m_sweepForbidden); |
| 167 m_state->m_sweepForbidden = false; | 167 m_state->m_sweepForbidden = false; |
| 168 } | 168 } |
| 169 private: | 169 private: |
| 170 ThreadState* m_state; | 170 ThreadState* m_state; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 void lockThreadAttachMutex(); | 173 void lockThreadAttachMutex(); |
| 174 void unlockThreadAttachMutex(); | 174 void unlockThreadAttachMutex(); |
| 175 | 175 |
| 176 bool perThreadHeapEnabled() const { return m_perThreadHeapEnabled; } | |
| 177 | |
| 178 bool isTerminating() { return m_isTerminating; } | 176 bool isTerminating() { return m_isTerminating; } |
| 179 | 177 |
| 180 static void attachMainThread(); | 178 static void attachMainThread(); |
| 181 static void detachMainThread(); | 179 static void detachMainThread(); |
| 182 void cleanupMainThread(); | 180 void cleanupMainThread(); |
| 183 | 181 |
| 184 // Associate ThreadState object with the current thread. After this | 182 // Associate ThreadState object with the current thread. After this |
| 185 // call thread can start using the garbage collected heap infrastructure. | 183 // call thread can start using the garbage collected heap infrastructure. |
| 186 // It also has to periodically check for safepoints. | 184 // It also has to periodically check for safepoints. |
| 187 static void attachCurrentThread(bool perThreadHeapEnabled); | 185 static void attachCurrentThread(); |
| 188 | 186 |
| 189 // Disassociate attached ThreadState from the current thread. The thread | 187 // Disassociate attached ThreadState from the current thread. The thread |
| 190 // can no longer use the garbage collected heap after this call. | 188 // can no longer use the garbage collected heap after this call. |
| 191 static void detachCurrentThread(); | 189 static void detachCurrentThread(); |
| 192 | 190 |
| 193 static ThreadState* current() | 191 static ThreadState* current() |
| 194 { | 192 { |
| 195 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) | 193 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) |
| 196 // TLS lookup is fast in these platforms. | 194 // TLS lookup is fast in these platforms. |
| 197 return **s_threadSpecific; | 195 return **s_threadSpecific; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 void increaseMarkedObjectSize(size_t); | 520 void increaseMarkedObjectSize(size_t); |
| 523 | 521 |
| 524 void callThreadShutdownHooks(); | 522 void callThreadShutdownHooks(); |
| 525 | 523 |
| 526 private: | 524 private: |
| 527 enum SnapshotType { | 525 enum SnapshotType { |
| 528 HeapSnapshot, | 526 HeapSnapshot, |
| 529 FreelistSnapshot | 527 FreelistSnapshot |
| 530 }; | 528 }; |
| 531 | 529 |
| 532 ThreadState(bool perThreadHeapEnabled); | 530 ThreadState(); |
| 533 ~ThreadState(); | 531 ~ThreadState(); |
| 534 | 532 |
| 535 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); | 533 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); |
| 536 void clearSafePointScopeMarker() | 534 void clearSafePointScopeMarker() |
| 537 { | 535 { |
| 538 m_safePointStackCopy.clear(); | 536 m_safePointStackCopy.clear(); |
| 539 m_safePointScopeMarker = nullptr; | 537 m_safePointScopeMarker = nullptr; |
| 540 } | 538 } |
| 541 | 539 |
| 542 // shouldSchedule{Precise,Idle}GC and shouldForceConservativeGC | 540 // shouldSchedule{Precise,Idle}GC and shouldForceConservativeGC |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 bool m_sweepForbidden; | 630 bool m_sweepForbidden; |
| 633 size_t m_noAllocationCount; | 631 size_t m_noAllocationCount; |
| 634 size_t m_gcForbiddenCount; | 632 size_t m_gcForbiddenCount; |
| 635 double m_accumulatedSweepingTime; | 633 double m_accumulatedSweepingTime; |
| 636 | 634 |
| 637 BaseArena* m_arenas[BlinkGC::NumberOfArenas]; | 635 BaseArena* m_arenas[BlinkGC::NumberOfArenas]; |
| 638 int m_vectorBackingArenaIndex; | 636 int m_vectorBackingArenaIndex; |
| 639 size_t m_arenaAges[BlinkGC::NumberOfArenas]; | 637 size_t m_arenaAges[BlinkGC::NumberOfArenas]; |
| 640 size_t m_currentArenaAges; | 638 size_t m_currentArenaAges; |
| 641 | 639 |
| 642 bool m_perThreadHeapEnabled; | |
| 643 bool m_isTerminating; | 640 bool m_isTerminating; |
| 644 GarbageCollectedMixinConstructorMarker* m_gcMixinMarker; | 641 GarbageCollectedMixinConstructorMarker* m_gcMixinMarker; |
| 645 | 642 |
| 646 bool m_shouldFlushHeapDoesNotContainCache; | 643 bool m_shouldFlushHeapDoesNotContainCache; |
| 647 GCState m_gcState; | 644 GCState m_gcState; |
| 648 | 645 |
| 649 CallbackStack* m_threadLocalWeakCallbackStack; | 646 CallbackStack* m_threadLocalWeakCallbackStack; |
| 650 | 647 |
| 651 // Pre-finalizers are called in the reverse order in which they are | 648 // Pre-finalizers are called in the reverse order in which they are |
| 652 // registered by the constructors (including constructors of Mixin objects) | 649 // registered by the constructors (including constructors of Mixin objects) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 699 |
| 703 template<> class ThreadStateFor<AnyThread> { | 700 template<> class ThreadStateFor<AnyThread> { |
| 704 STATIC_ONLY(ThreadStateFor); | 701 STATIC_ONLY(ThreadStateFor); |
| 705 public: | 702 public: |
| 706 static ThreadState* state() { return ThreadState::current(); } | 703 static ThreadState* state() { return ThreadState::current(); } |
| 707 }; | 704 }; |
| 708 | 705 |
| 709 } // namespace blink | 706 } // namespace blink |
| 710 | 707 |
| 711 #endif // ThreadState_h | 708 #endif // ThreadState_h |
| OLD | NEW |