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

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

Issue 616483002: Oilpan: Replace the positive heap-contains cache with a binary search tree of memory regions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove ThreadState::checkAndMarkPointer 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
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;
56 class HeapObjectHeader; 55 class HeapObjectHeader;
57 class PageMemory; 56 class PageMemory;
58 class PersistentNode; 57 class PersistentNode;
59 class WrapperPersistentRegion; 58 class WrapperPersistentRegion;
60 class Visitor; 59 class Visitor;
61 class SafePointBarrier; 60 class SafePointBarrier;
62 class SafePointAwareMutexLocker; 61 class SafePointAwareMutexLocker;
63 template<typename Header> class ThreadHeap; 62 template<typename Header> class ThreadHeap;
64 class CallbackStack; 63 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(); }
552 BaseHeapPage* contains(Address address) { return heapPageFromAddress(address ); } 551 BaseHeapPage* contains(Address address) { return heapPageFromAddress(address ); }
553 BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Add ress>(pointer)); } 552 BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Add ress>(pointer)); }
554 BaseHeapPage* contains(const void* pointer) { return contains(const_cast<voi d*>(pointer)); } 553 BaseHeapPage* contains(const void* pointer) { return contains(const_cast<voi d*>(pointer)); }
555 554
556 WrapperPersistentRegion* wrapperRoots() const 555 WrapperPersistentRegion* wrapperRoots() const
557 { 556 {
558 ASSERT(m_liveWrapperPersistents); 557 ASSERT(m_liveWrapperPersistents);
559 return m_liveWrapperPersistents; 558 return m_liveWrapperPersistents;
560 } 559 }
561 WrapperPersistentRegion* takeWrapperPersistentRegion(); 560 WrapperPersistentRegion* takeWrapperPersistentRegion();
(...skipping 10 matching lines...) Expand all
572 // Visit local thread stack and trace all pointers conservatively. 571 // Visit local thread stack and trace all pointers conservatively.
573 void visitStack(Visitor*); 572 void visitStack(Visitor*);
574 573
575 // Visit the asan fake stack frame corresponding to a slot on the 574 // Visit the asan fake stack frame corresponding to a slot on the
576 // real machine stack if there is one. 575 // real machine stack if there is one.
577 void visitAsanFakeStackForPointer(Visitor*, Address); 576 void visitAsanFakeStackForPointer(Visitor*, Address);
578 577
579 // Visit all persistents allocated on this thread. 578 // Visit all persistents allocated on this thread.
580 void visitPersistents(Visitor*); 579 void visitPersistents(Visitor*);
581 580
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
586 #if ENABLE(GC_PROFILE_MARKING) 581 #if ENABLE(GC_PROFILE_MARKING)
587 const GCInfo* findGCInfo(Address); 582 const GCInfo* findGCInfo(Address);
588 static const GCInfo* findGCInfoFromAllThreads(Address); 583 static const GCInfo* findGCInfoFromAllThreads(Address);
589 #endif 584 #endif
590 585
591 #if ENABLE(GC_PROFILE_HEAP) 586 #if ENABLE(GC_PROFILE_HEAP)
592 struct SnapshotInfo { 587 struct SnapshotInfo {
593 ThreadState* state; 588 ThreadState* state;
594 589
595 size_t freeSize; 590 size_t freeSize;
(...skipping 28 matching lines...) Expand all
624 HeapStats& stats() { return m_stats; } 619 HeapStats& stats() { return m_stats; }
625 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; } 620 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; }
626 621
627 void setupHeapsForTermination(); 622 void setupHeapsForTermination();
628 623
629 void registerSweepingTask(); 624 void registerSweepingTask();
630 void unregisterSweepingTask(); 625 void unregisterSweepingTask();
631 626
632 Mutex& sweepMutex() { return m_sweepMutex; } 627 Mutex& sweepMutex() { return m_sweepMutex; }
633 628
629 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate dRegionsSinceLastGC; }
630
634 private: 631 private:
635 explicit ThreadState(); 632 explicit ThreadState();
636 ~ThreadState(); 633 ~ThreadState();
637 634
638 friend class SafePointBarrier; 635 friend class SafePointBarrier;
639 friend class SafePointAwareMutexLocker; 636 friend class SafePointAwareMutexLocker;
640 637
641 void enterSafePoint(StackState, void*); 638 void enterSafePoint(StackState, void*);
642 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); 639 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
643 void clearSafePointScopeMarker() 640 void clearSafePointScopeMarker()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 Vector<Address> m_safePointStackCopy; 693 Vector<Address> m_safePointStackCopy;
697 bool m_atSafePoint; 694 bool m_atSafePoint;
698 Vector<Interruptor*> m_interruptors; 695 Vector<Interruptor*> m_interruptors;
699 bool m_gcRequested; 696 bool m_gcRequested;
700 bool m_forcePreciseGCForTesting; 697 bool m_forcePreciseGCForTesting;
701 volatile int m_sweepRequested; 698 volatile int m_sweepRequested;
702 bool m_sweepInProgress; 699 bool m_sweepInProgress;
703 size_t m_noAllocationCount; 700 size_t m_noAllocationCount;
704 bool m_inGC; 701 bool m_inGC;
705 BaseHeap* m_heaps[NumberOfHeaps]; 702 BaseHeap* m_heaps[NumberOfHeaps];
706 OwnPtr<HeapContainsCache> m_heapContainsCache;
707 HeapStats m_stats; 703 HeapStats m_stats;
708 HeapStats m_statsAfterLastGC; 704 HeapStats m_statsAfterLastGC;
709 705
710 Vector<OwnPtr<CleanupTask> > m_cleanupTasks; 706 Vector<OwnPtr<CleanupTask> > m_cleanupTasks;
711 bool m_isTerminating; 707 bool m_isTerminating;
712 708
713 bool m_lowCollectionRate; 709 bool m_lowCollectionRate;
714 710
715 OwnPtr<blink::WebThread> m_sweeperThread; 711 OwnPtr<blink::WebThread> m_sweeperThread;
716 int m_numberOfSweeperTasks; 712 int m_numberOfSweeperTasks;
717 Mutex m_sweepMutex; 713 Mutex m_sweepMutex;
718 ThreadCondition m_sweepThreadCondition; 714 ThreadCondition m_sweepThreadCondition;
719 715
720 CallbackStack* m_weakCallbackStack; 716 CallbackStack* m_weakCallbackStack;
721 717
722 #if defined(ADDRESS_SANITIZER) 718 #if defined(ADDRESS_SANITIZER)
723 void* m_asanFakeStack; 719 void* m_asanFakeStack;
724 #endif 720 #endif
721
722 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC;
725 }; 723 };
726 724
727 template<ThreadAffinity affinity> class ThreadStateFor; 725 template<ThreadAffinity affinity> class ThreadStateFor;
728 726
729 template<> class ThreadStateFor<MainThreadOnly> { 727 template<> class ThreadStateFor<MainThreadOnly> {
730 public: 728 public:
731 static ThreadState* state() 729 static ThreadState* state()
732 { 730 {
733 // This specialization must only be used from the main thread. 731 // This specialization must only be used from the main thread.
734 ASSERT(ThreadState::current()->isMainThread()); 732 ASSERT(ThreadState::current()->isMainThread());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 // whether the page is part of a terminting thread or 845 // whether the page is part of a terminting thread or
848 // if the page is traced after being terminated (orphaned). 846 // if the page is traced after being terminated (orphaned).
849 uintptr_t m_terminating : 1; 847 uintptr_t m_terminating : 1;
850 uintptr_t m_tracedAfterOrphaned : 1; 848 uintptr_t m_tracedAfterOrphaned : 1;
851 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2 849 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2
852 }; 850 };
853 851
854 } 852 }
855 853
856 #endif // ThreadState_h 854 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698