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 25 matching lines...) Expand all Loading... |
36 #include "public/platform/WebThread.h" | 36 #include "public/platform/WebThread.h" |
37 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
38 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
39 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
40 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
41 #include "wtf/ThreadSpecific.h" | 41 #include "wtf/ThreadSpecific.h" |
42 #include "wtf/Threading.h" | 42 #include "wtf/Threading.h" |
43 #include "wtf/ThreadingPrimitives.h" | 43 #include "wtf/ThreadingPrimitives.h" |
44 #include "wtf/Vector.h" | 44 #include "wtf/Vector.h" |
45 | 45 |
| 46 namespace v8 { |
| 47 class Isolate; |
| 48 }; |
| 49 |
46 namespace blink { | 50 namespace blink { |
47 | 51 |
48 class BaseHeap; | 52 class BaseHeap; |
49 class BaseHeapPage; | 53 class BaseHeapPage; |
50 class FinalizedHeapObjectHeader; | 54 class FinalizedHeapObjectHeader; |
51 struct GCInfo; | 55 struct GCInfo; |
52 class HeapObjectHeader; | 56 class HeapObjectHeader; |
53 class PageMemory; | 57 class PageMemory; |
54 class PersistentNode; | 58 class PersistentNode; |
55 class WrapperPersistentRegion; | |
56 class Visitor; | 59 class Visitor; |
57 class SafePointBarrier; | 60 class SafePointBarrier; |
58 class SafePointAwareMutexLocker; | 61 class SafePointAwareMutexLocker; |
59 template<typename Header> class ThreadHeap; | 62 template<typename Header> class ThreadHeap; |
60 class CallbackStack; | 63 class CallbackStack; |
61 class PageMemoryRegion; | 64 class PageMemoryRegion; |
62 | 65 |
63 typedef uint8_t* Address; | 66 typedef uint8_t* Address; |
64 | 67 |
65 typedef void (*FinalizationCallback)(void*); | 68 typedef void (*FinalizationCallback)(void*); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 // HeapTypeTrait<Type>::index. | 619 // HeapTypeTrait<Type>::index. |
617 BaseHeap* heap(int index) const { return m_heaps[index]; } | 620 BaseHeap* heap(int index) const { return m_heaps[index]; } |
618 | 621 |
619 // Infrastructure to determine if an address is within one of the | 622 // Infrastructure to determine if an address is within one of the |
620 // address ranges for the Blink heap. If the address is in the Blink | 623 // address ranges for the Blink heap. If the address is in the Blink |
621 // heap the containing heap page is returned. | 624 // heap the containing heap page is returned. |
622 BaseHeapPage* contains(Address address) { return heapPageFromAddress(address
); } | 625 BaseHeapPage* contains(Address address) { return heapPageFromAddress(address
); } |
623 BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Add
ress>(pointer)); } | 626 BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Add
ress>(pointer)); } |
624 BaseHeapPage* contains(const void* pointer) { return contains(const_cast<voi
d*>(pointer)); } | 627 BaseHeapPage* contains(const void* pointer) { return contains(const_cast<voi
d*>(pointer)); } |
625 | 628 |
626 WrapperPersistentRegion* wrapperRoots() const | |
627 { | |
628 ASSERT(m_liveWrapperPersistents); | |
629 return m_liveWrapperPersistents; | |
630 } | |
631 WrapperPersistentRegion* takeWrapperPersistentRegion(); | |
632 void freeWrapperPersistentRegion(WrapperPersistentRegion*); | |
633 | |
634 // List of persistent roots allocated on the given thread. | 629 // List of persistent roots allocated on the given thread. |
635 PersistentNode* roots() const { return m_persistents.get(); } | 630 PersistentNode* roots() const { return m_persistents.get(); } |
636 | 631 |
637 // List of global persistent roots not owned by any particular thread. | 632 // List of global persistent roots not owned by any particular thread. |
638 // globalRootsMutex must be acquired before any modifications. | 633 // globalRootsMutex must be acquired before any modifications. |
639 static PersistentNode* globalRoots(); | 634 static PersistentNode* globalRoots(); |
640 static Mutex& globalRootsMutex(); | 635 static Mutex& globalRootsMutex(); |
641 | 636 |
642 // Visit local thread stack and trace all pointers conservatively. | 637 // Visit local thread stack and trace all pointers conservatively. |
643 void visitStack(Visitor*); | 638 void visitStack(Visitor*); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 ASSERT(&T::invokePreFinalizer); | 712 ASSERT(&T::invokePreFinalizer); |
718 unregisterPreFinalizerInternal(&target); | 713 unregisterPreFinalizerInternal(&target); |
719 } | 714 } |
720 | 715 |
721 Mutex& sweepMutex() { return m_sweepMutex; } | 716 Mutex& sweepMutex() { return m_sweepMutex; } |
722 | 717 |
723 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate
dRegionsSinceLastGC; } | 718 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate
dRegionsSinceLastGC; } |
724 | 719 |
725 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC
ache = true; } | 720 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC
ache = true; } |
726 | 721 |
| 722 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers)
(v8::Isolate*, Visitor*)) |
| 723 { |
| 724 m_isolate = isolate; |
| 725 m_traceDOMWrappers = traceDOMWrappers; |
| 726 } |
| 727 |
727 private: | 728 private: |
728 explicit ThreadState(); | 729 explicit ThreadState(); |
729 ~ThreadState(); | 730 ~ThreadState(); |
730 | 731 |
731 friend class SafePointBarrier; | 732 friend class SafePointBarrier; |
732 friend class SafePointAwareMutexLocker; | 733 friend class SafePointAwareMutexLocker; |
733 | 734 |
734 void enterSafePoint(StackState, void*); | 735 void enterSafePoint(StackState, void*); |
735 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); | 736 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); |
736 void clearSafePointScopeMarker() | 737 void clearSafePointScopeMarker() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 // We can't create a static member of type ThreadState here | 777 // We can't create a static member of type ThreadState here |
777 // because it will introduce global constructor and destructor. | 778 // because it will introduce global constructor and destructor. |
778 // We would like to manage lifetime of the ThreadState attached | 779 // We would like to manage lifetime of the ThreadState attached |
779 // to the main thread explicitly instead and still use normal | 780 // to the main thread explicitly instead and still use normal |
780 // constructor and destructor for the ThreadState class. | 781 // constructor and destructor for the ThreadState class. |
781 // For this we reserve static storage for the main ThreadState | 782 // For this we reserve static storage for the main ThreadState |
782 // and lazily construct ThreadState in it using placement new. | 783 // and lazily construct ThreadState in it using placement new. |
783 static uint8_t s_mainThreadStateStorage[]; | 784 static uint8_t s_mainThreadStateStorage[]; |
784 | 785 |
785 ThreadIdentifier m_thread; | 786 ThreadIdentifier m_thread; |
786 WrapperPersistentRegion* m_liveWrapperPersistents; | |
787 WrapperPersistentRegion* m_pooledWrapperPersistents; | |
788 size_t m_pooledWrapperPersistentRegionCount; | |
789 OwnPtr<PersistentNode> m_persistents; | 787 OwnPtr<PersistentNode> m_persistents; |
790 StackState m_stackState; | 788 StackState m_stackState; |
791 intptr_t* m_startOfStack; | 789 intptr_t* m_startOfStack; |
792 intptr_t* m_endOfStack; | 790 intptr_t* m_endOfStack; |
793 void* m_safePointScopeMarker; | 791 void* m_safePointScopeMarker; |
794 Vector<Address> m_safePointStackCopy; | 792 Vector<Address> m_safePointStackCopy; |
795 bool m_atSafePoint; | 793 bool m_atSafePoint; |
796 Vector<Interruptor*> m_interruptors; | 794 Vector<Interruptor*> m_interruptors; |
797 bool m_gcRequested; | 795 bool m_gcRequested; |
798 bool m_forcePreciseGCForTesting; | 796 bool m_forcePreciseGCForTesting; |
(...skipping 12 matching lines...) Expand all Loading... |
811 bool m_lowCollectionRate; | 809 bool m_lowCollectionRate; |
812 | 810 |
813 OwnPtr<blink::WebThread> m_sweeperThread; | 811 OwnPtr<blink::WebThread> m_sweeperThread; |
814 int m_numberOfSweeperTasks; | 812 int m_numberOfSweeperTasks; |
815 Mutex m_sweepMutex; | 813 Mutex m_sweepMutex; |
816 ThreadCondition m_sweepThreadCondition; | 814 ThreadCondition m_sweepThreadCondition; |
817 | 815 |
818 CallbackStack* m_weakCallbackStack; | 816 CallbackStack* m_weakCallbackStack; |
819 HashMap<void*, bool (*)(void*, Visitor&)> m_preFinalizers; | 817 HashMap<void*, bool (*)(void*, Visitor&)> m_preFinalizers; |
820 | 818 |
| 819 v8::Isolate* m_isolate; |
| 820 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*); |
| 821 |
821 #if defined(ADDRESS_SANITIZER) | 822 #if defined(ADDRESS_SANITIZER) |
822 void* m_asanFakeStack; | 823 void* m_asanFakeStack; |
823 #endif | 824 #endif |
824 | 825 |
825 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC; | 826 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC; |
826 }; | 827 }; |
827 | 828 |
828 template<ThreadAffinity affinity> class ThreadStateFor; | 829 template<ThreadAffinity affinity> class ThreadStateFor; |
829 | 830 |
830 template<> class ThreadStateFor<MainThreadOnly> { | 831 template<> class ThreadStateFor<MainThreadOnly> { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 // whether the page is part of a terminting thread or | 943 // whether the page is part of a terminting thread or |
943 // if the page is traced after being terminated (orphaned). | 944 // if the page is traced after being terminated (orphaned). |
944 uintptr_t m_terminating : 1; | 945 uintptr_t m_terminating : 1; |
945 uintptr_t m_tracedAfterOrphaned : 1; | 946 uintptr_t m_tracedAfterOrphaned : 1; |
946 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2 | 947 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2 |
947 }; | 948 }; |
948 | 949 |
949 } | 950 } |
950 | 951 |
951 #endif // ThreadState_h | 952 #endif // ThreadState_h |
OLD | NEW |