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