Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: Source/platform/heap/ThreadState.h

Issue 618353004: Revert "Oilpan: Replace the positive heap-contains cache with a binary search tree of memory region… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #if ENABLE(GC_PROFILE_HEAP) 45 #if ENABLE(GC_PROFILE_HEAP)
46 #include "wtf/HashMap.h" 46 #include "wtf/HashMap.h"
47 #endif 47 #endif
48 48
49 namespace blink { 49 namespace blink {
50 50
51 class BaseHeap; 51 class BaseHeap;
52 class BaseHeapPage; 52 class BaseHeapPage;
53 class FinalizedHeapObjectHeader; 53 class FinalizedHeapObjectHeader;
54 struct GCInfo; 54 struct GCInfo;
55 class HeapContainsCache;
55 class HeapObjectHeader; 56 class HeapObjectHeader;
56 class PageMemory; 57 class PageMemory;
57 class PersistentNode; 58 class PersistentNode;
58 class WrapperPersistentRegion; 59 class WrapperPersistentRegion;
59 class Visitor; 60 class Visitor;
60 class SafePointBarrier; 61 class SafePointBarrier;
61 class SafePointAwareMutexLocker; 62 class SafePointAwareMutexLocker;
62 template<typename Header> class ThreadHeap; 63 template<typename Header> class ThreadHeap;
63 class CallbackStack; 64 class CallbackStack;
64 class PageMemoryRegion;
65 65
66 typedef uint8_t* Address; 66 typedef uint8_t* Address;
67 67
68 typedef void (*FinalizationCallback)(void*); 68 typedef void (*FinalizationCallback)(void*);
69 typedef void (*VisitorCallback)(Visitor*, void* self); 69 typedef void (*VisitorCallback)(Visitor*, void* self);
70 typedef VisitorCallback TraceCallback; 70 typedef VisitorCallback TraceCallback;
71 typedef VisitorCallback WeakPointerCallback; 71 typedef VisitorCallback WeakPointerCallback;
72 typedef VisitorCallback EphemeronCallback; 72 typedef VisitorCallback EphemeronCallback;
73 73
74 // ThreadAffinity indicates which threads objects can be used on. We 74 // ThreadAffinity indicates which threads objects can be used on. We
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // Get one of the heap structures for this thread. 541 // Get one of the heap structures for this thread.
542 // 542 //
543 // The heap is split into multiple heap parts based on object 543 // The heap is split into multiple heap parts based on object
544 // types. To get the index for a given type, use 544 // types. To get the index for a given type, use
545 // HeapTypeTrait<Type>::index. 545 // HeapTypeTrait<Type>::index.
546 BaseHeap* heap(int index) const { return m_heaps[index]; } 546 BaseHeap* heap(int index) const { return m_heaps[index]; }
547 547
548 // Infrastructure to determine if an address is within one of the 548 // Infrastructure to determine if an address is within one of the
549 // address ranges for the Blink heap. If the address is in the Blink 549 // address ranges for the Blink heap. If the address is in the Blink
550 // heap the containing heap page is returned. 550 // heap the containing heap page is returned.
551 HeapContainsCache* heapContainsCache() { return m_heapContainsCache.get(); }
551 BaseHeapPage* contains(Address address) { return heapPageFromAddress(address ); } 552 BaseHeapPage* contains(Address address) { return heapPageFromAddress(address ); }
552 BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Add ress>(pointer)); } 553 BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Add ress>(pointer)); }
553 BaseHeapPage* contains(const void* pointer) { return contains(const_cast<voi d*>(pointer)); } 554 BaseHeapPage* contains(const void* pointer) { return contains(const_cast<voi d*>(pointer)); }
554 555
555 WrapperPersistentRegion* wrapperRoots() const 556 WrapperPersistentRegion* wrapperRoots() const
556 { 557 {
557 ASSERT(m_liveWrapperPersistents); 558 ASSERT(m_liveWrapperPersistents);
558 return m_liveWrapperPersistents; 559 return m_liveWrapperPersistents;
559 } 560 }
560 WrapperPersistentRegion* takeWrapperPersistentRegion(); 561 WrapperPersistentRegion* takeWrapperPersistentRegion();
(...skipping 10 matching lines...) Expand all
571 // Visit local thread stack and trace all pointers conservatively. 572 // Visit local thread stack and trace all pointers conservatively.
572 void visitStack(Visitor*); 573 void visitStack(Visitor*);
573 574
574 // Visit the asan fake stack frame corresponding to a slot on the 575 // Visit the asan fake stack frame corresponding to a slot on the
575 // real machine stack if there is one. 576 // real machine stack if there is one.
576 void visitAsanFakeStackForPointer(Visitor*, Address); 577 void visitAsanFakeStackForPointer(Visitor*, Address);
577 578
578 // Visit all persistents allocated on this thread. 579 // Visit all persistents allocated on this thread.
579 void visitPersistents(Visitor*); 580 void visitPersistents(Visitor*);
580 581
582 // Checks a given address and if a pointer into the oilpan heap marks
583 // the object to which it points.
584 bool checkAndMarkPointer(Visitor*, Address);
585
581 #if ENABLE(GC_PROFILE_MARKING) 586 #if ENABLE(GC_PROFILE_MARKING)
582 const GCInfo* findGCInfo(Address); 587 const GCInfo* findGCInfo(Address);
583 static const GCInfo* findGCInfoFromAllThreads(Address); 588 static const GCInfo* findGCInfoFromAllThreads(Address);
584 #endif 589 #endif
585 590
586 #if ENABLE(GC_PROFILE_HEAP) 591 #if ENABLE(GC_PROFILE_HEAP)
587 struct SnapshotInfo { 592 struct SnapshotInfo {
588 ThreadState* state; 593 ThreadState* state;
589 594
590 size_t freeSize; 595 size_t freeSize;
(...skipping 28 matching lines...) Expand all
619 HeapStats& stats() { return m_stats; } 624 HeapStats& stats() { return m_stats; }
620 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; } 625 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; }
621 626
622 void setupHeapsForTermination(); 627 void setupHeapsForTermination();
623 628
624 void registerSweepingTask(); 629 void registerSweepingTask();
625 void unregisterSweepingTask(); 630 void unregisterSweepingTask();
626 631
627 Mutex& sweepMutex() { return m_sweepMutex; } 632 Mutex& sweepMutex() { return m_sweepMutex; }
628 633
629 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate dRegionsSinceLastGC; }
630
631 private: 634 private:
632 explicit ThreadState(); 635 explicit ThreadState();
633 ~ThreadState(); 636 ~ThreadState();
634 637
635 friend class SafePointBarrier; 638 friend class SafePointBarrier;
636 friend class SafePointAwareMutexLocker; 639 friend class SafePointAwareMutexLocker;
637 640
638 void enterSafePoint(StackState, void*); 641 void enterSafePoint(StackState, void*);
639 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); 642 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
640 void clearSafePointScopeMarker() 643 void clearSafePointScopeMarker()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 Vector<Address> m_safePointStackCopy; 696 Vector<Address> m_safePointStackCopy;
694 bool m_atSafePoint; 697 bool m_atSafePoint;
695 Vector<Interruptor*> m_interruptors; 698 Vector<Interruptor*> m_interruptors;
696 bool m_gcRequested; 699 bool m_gcRequested;
697 bool m_forcePreciseGCForTesting; 700 bool m_forcePreciseGCForTesting;
698 volatile int m_sweepRequested; 701 volatile int m_sweepRequested;
699 bool m_sweepInProgress; 702 bool m_sweepInProgress;
700 size_t m_noAllocationCount; 703 size_t m_noAllocationCount;
701 bool m_inGC; 704 bool m_inGC;
702 BaseHeap* m_heaps[NumberOfHeaps]; 705 BaseHeap* m_heaps[NumberOfHeaps];
706 OwnPtr<HeapContainsCache> m_heapContainsCache;
703 HeapStats m_stats; 707 HeapStats m_stats;
704 HeapStats m_statsAfterLastGC; 708 HeapStats m_statsAfterLastGC;
705 709
706 Vector<OwnPtr<CleanupTask> > m_cleanupTasks; 710 Vector<OwnPtr<CleanupTask> > m_cleanupTasks;
707 bool m_isTerminating; 711 bool m_isTerminating;
708 712
709 bool m_lowCollectionRate; 713 bool m_lowCollectionRate;
710 714
711 OwnPtr<blink::WebThread> m_sweeperThread; 715 OwnPtr<blink::WebThread> m_sweeperThread;
712 int m_numberOfSweeperTasks; 716 int m_numberOfSweeperTasks;
713 Mutex m_sweepMutex; 717 Mutex m_sweepMutex;
714 ThreadCondition m_sweepThreadCondition; 718 ThreadCondition m_sweepThreadCondition;
715 719
716 CallbackStack* m_weakCallbackStack; 720 CallbackStack* m_weakCallbackStack;
717 721
718 #if defined(ADDRESS_SANITIZER) 722 #if defined(ADDRESS_SANITIZER)
719 void* m_asanFakeStack; 723 void* m_asanFakeStack;
720 #endif 724 #endif
721
722 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC;
723 }; 725 };
724 726
725 template<ThreadAffinity affinity> class ThreadStateFor; 727 template<ThreadAffinity affinity> class ThreadStateFor;
726 728
727 template<> class ThreadStateFor<MainThreadOnly> { 729 template<> class ThreadStateFor<MainThreadOnly> {
728 public: 730 public:
729 static ThreadState* state() 731 static ThreadState* state()
730 { 732 {
731 // This specialization must only be used from the main thread. 733 // This specialization must only be used from the main thread.
732 ASSERT(ThreadState::current()->isMainThread()); 734 ASSERT(ThreadState::current()->isMainThread());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 815
814 #if ENABLE(GC_PROFILE_MARKING) 816 #if ENABLE(GC_PROFILE_MARKING)
815 virtual const GCInfo* findGCInfo(Address) = 0; 817 virtual const GCInfo* findGCInfo(Address) = 0;
816 #endif 818 #endif
817 819
818 Address address() { return reinterpret_cast<Address>(this); } 820 Address address() { return reinterpret_cast<Address>(this); }
819 PageMemory* storage() const { return m_storage; } 821 PageMemory* storage() const { return m_storage; }
820 ThreadState* threadState() const { return m_threadState; } 822 ThreadState* threadState() const { return m_threadState; }
821 const GCInfo* gcInfo() { return m_gcInfo; } 823 const GCInfo* gcInfo() { return m_gcInfo; }
822 virtual bool isLargeObject() { return false; } 824 virtual bool isLargeObject() { return false; }
823 virtual void markOrphaned(); 825 virtual void markOrphaned()
826 {
827 m_threadState = 0;
828 m_gcInfo = 0;
829 m_terminating = false;
830 m_tracedAfterOrphaned = false;
831 }
824 bool orphaned() { return !m_threadState; } 832 bool orphaned() { return !m_threadState; }
825 bool terminating() { return m_terminating; } 833 bool terminating() { return m_terminating; }
826 void setTerminating() { m_terminating = true; } 834 void setTerminating() { m_terminating = true; }
827 bool tracedAfterOrphaned() { return m_tracedAfterOrphaned; } 835 bool tracedAfterOrphaned() { return m_tracedAfterOrphaned; }
828 void setTracedAfterOrphaned() { m_tracedAfterOrphaned = true; } 836 void setTracedAfterOrphaned() { m_tracedAfterOrphaned = true; }
829 size_t promptlyFreedSize() { return m_promptlyFreedSize; } 837 size_t promptlyFreedSize() { return m_promptlyFreedSize; }
830 void resetPromptlyFreedSize() { m_promptlyFreedSize = 0; } 838 void resetPromptlyFreedSize() { m_promptlyFreedSize = 0; }
831 void addToPromptlyFreedSize(size_t size) { m_promptlyFreedSize += size; } 839 void addToPromptlyFreedSize(size_t size) { m_promptlyFreedSize += size; }
832 840
833 private: 841 private:
834 PageMemory* m_storage; 842 PageMemory* m_storage;
835 const GCInfo* m_gcInfo; 843 const GCInfo* m_gcInfo;
836 ThreadState* m_threadState; 844 ThreadState* m_threadState;
837 // Pointer sized integer to ensure proper alignment of the 845 // Pointer sized integer to ensure proper alignment of the
838 // HeapPage header. We use some of the bits to determine 846 // HeapPage header. We use some of the bits to determine
839 // whether the page is part of a terminting thread or 847 // whether the page is part of a terminting thread or
840 // if the page is traced after being terminated (orphaned). 848 // if the page is traced after being terminated (orphaned).
841 uintptr_t m_terminating : 1; 849 uintptr_t m_terminating : 1;
842 uintptr_t m_tracedAfterOrphaned : 1; 850 uintptr_t m_tracedAfterOrphaned : 1;
843 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2 851 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2
844 }; 852 };
845 853
846 } 854 }
847 855
848 #endif // ThreadState_h 856 #endif // ThreadState_h
OLDNEW
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698