| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 // call onInterrupted on that thread once interruption | 438 // call onInterrupted on that thread once interruption |
| 439 // succeeds. | 439 // succeeds. |
| 440 virtual void requestInterrupt() = 0; | 440 virtual void requestInterrupt() = 0; |
| 441 | 441 |
| 442 protected: | 442 protected: |
| 443 // This method is called on the interrupted thread to | 443 // This method is called on the interrupted thread to |
| 444 // create a safepoint for a GC. | 444 // create a safepoint for a GC. |
| 445 void onInterrupted(); | 445 void onInterrupted(); |
| 446 }; | 446 }; |
| 447 | 447 |
| 448 void addInterruptor(Interruptor*); | 448 void addInterruptor(PassOwnPtr<Interruptor>); |
| 449 void removeInterruptor(Interruptor*); | 449 void removeInterruptor(Interruptor*); |
| 450 | 450 |
| 451 // Should only be called under protection of threadAttachMutex(). | |
| 452 const Vector<Interruptor*>& interruptors() const { return m_interruptors; } | |
| 453 | |
| 454 void recordStackEnd(intptr_t* endOfStack) | 451 void recordStackEnd(intptr_t* endOfStack) |
| 455 { | 452 { |
| 456 m_endOfStack = endOfStack; | 453 m_endOfStack = endOfStack; |
| 457 } | 454 } |
| 458 | 455 |
| 459 // Get one of the heap structures for this thread. | 456 // Get one of the heap structures for this thread. |
| 460 // The thread heap is split into multiple heap parts based on object types | 457 // The thread heap is split into multiple heap parts based on object types |
| 461 // and object sizes. | 458 // and object sizes. |
| 462 BaseHeap* heap(int heapIndex) const | 459 BaseHeap* heap(int heapIndex) const |
| 463 { | 460 { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 707 |
| 711 void invokePreFinalizers(); | 708 void invokePreFinalizers(); |
| 712 | 709 |
| 713 void takeSnapshot(SnapshotType); | 710 void takeSnapshot(SnapshotType); |
| 714 #if ENABLE(GC_PROFILING) | 711 #if ENABLE(GC_PROFILING) |
| 715 void snapshotFreeList(); | 712 void snapshotFreeList(); |
| 716 #endif | 713 #endif |
| 717 void clearHeapAges(); | 714 void clearHeapAges(); |
| 718 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); | 715 int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHe
apIndex); |
| 719 | 716 |
| 717 using InterruptorVector = Vector<OwnPtr<Interruptor>>; |
| 718 |
| 719 // Should only be called under protection of threadAttachMutex(). |
| 720 const InterruptorVector& interruptors() const { return m_interruptors; } |
| 721 |
| 720 friend class SafePointAwareMutexLocker; | 722 friend class SafePointAwareMutexLocker; |
| 721 friend class SafePointBarrier; | 723 friend class SafePointBarrier; |
| 722 friend class SafePointScope; | 724 friend class SafePointScope; |
| 723 | 725 |
| 724 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; | 726 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; |
| 725 static uintptr_t s_mainThreadStackStart; | 727 static uintptr_t s_mainThreadStackStart; |
| 726 static uintptr_t s_mainThreadUnderestimatedStackSize; | 728 static uintptr_t s_mainThreadUnderestimatedStackSize; |
| 727 static SafePointBarrier* s_safePointBarrier; | 729 static SafePointBarrier* s_safePointBarrier; |
| 728 | 730 |
| 729 // We can't create a static member of type ThreadState here | 731 // We can't create a static member of type ThreadState here |
| 730 // because it will introduce global constructor and destructor. | 732 // because it will introduce global constructor and destructor. |
| 731 // We would like to manage lifetime of the ThreadState attached | 733 // We would like to manage lifetime of the ThreadState attached |
| 732 // to the main thread explicitly instead and still use normal | 734 // to the main thread explicitly instead and still use normal |
| 733 // constructor and destructor for the ThreadState class. | 735 // constructor and destructor for the ThreadState class. |
| 734 // For this we reserve static storage for the main ThreadState | 736 // For this we reserve static storage for the main ThreadState |
| 735 // and lazily construct ThreadState in it using placement new. | 737 // and lazily construct ThreadState in it using placement new. |
| 736 static uint8_t s_mainThreadStateStorage[]; | 738 static uint8_t s_mainThreadStateStorage[]; |
| 737 | 739 |
| 738 ThreadIdentifier m_thread; | 740 ThreadIdentifier m_thread; |
| 739 OwnPtr<PersistentRegion> m_persistentRegion; | 741 OwnPtr<PersistentRegion> m_persistentRegion; |
| 740 StackState m_stackState; | 742 StackState m_stackState; |
| 741 intptr_t* m_startOfStack; | 743 intptr_t* m_startOfStack; |
| 742 intptr_t* m_endOfStack; | 744 intptr_t* m_endOfStack; |
| 743 void* m_safePointScopeMarker; | 745 void* m_safePointScopeMarker; |
| 744 Vector<Address> m_safePointStackCopy; | 746 Vector<Address> m_safePointStackCopy; |
| 745 bool m_atSafePoint; | 747 bool m_atSafePoint; |
| 746 Vector<Interruptor*> m_interruptors; | 748 InterruptorVector m_interruptors; |
| 747 bool m_sweepForbidden; | 749 bool m_sweepForbidden; |
| 748 size_t m_noAllocationCount; | 750 size_t m_noAllocationCount; |
| 749 size_t m_gcForbiddenCount; | 751 size_t m_gcForbiddenCount; |
| 750 int m_persistentAllocated; | 752 int m_persistentAllocated; |
| 751 int m_persistentFreed; | 753 int m_persistentFreed; |
| 752 BaseHeap* m_heaps[NumberOfHeaps]; | 754 BaseHeap* m_heaps[NumberOfHeaps]; |
| 753 | 755 |
| 754 int m_vectorBackingHeapIndex; | 756 int m_vectorBackingHeapIndex; |
| 755 size_t m_heapAges[NumberOfHeaps]; | 757 size_t m_heapAges[NumberOfHeaps]; |
| 756 size_t m_currentHeapAges; | 758 size_t m_currentHeapAges; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 }; | 802 }; |
| 801 | 803 |
| 802 template<> class ThreadStateFor<AnyThread> { | 804 template<> class ThreadStateFor<AnyThread> { |
| 803 public: | 805 public: |
| 804 static ThreadState* state() { return ThreadState::current(); } | 806 static ThreadState* state() { return ThreadState::current(); } |
| 805 }; | 807 }; |
| 806 | 808 |
| 807 } // namespace blink | 809 } // namespace blink |
| 808 | 810 |
| 809 #endif // ThreadState_h | 811 #endif // ThreadState_h |
| OLD | NEW |