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

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

Issue 851563003: Revert of Oilpan: Query stack frame register instead of manual bookkeeping (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « Source/platform/heap/StackFrameDepth.cpp ('k') | Source/platform/heap/Visitor.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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef Visitor_h 31 #ifndef Visitor_h
32 #define Visitor_h 32 #define Visitor_h
33 33
34 #include "platform/PlatformExport.h" 34 #include "platform/PlatformExport.h"
35 #include "platform/heap/StackFrameDepth.h"
36 #include "platform/heap/ThreadState.h" 35 #include "platform/heap/ThreadState.h"
37 #include "wtf/Assertions.h" 36 #include "wtf/Assertions.h"
38 #include "wtf/Deque.h" 37 #include "wtf/Deque.h"
39 #include "wtf/Forward.h" 38 #include "wtf/Forward.h"
40 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
41 #include "wtf/HashTraits.h" 40 #include "wtf/HashTraits.h"
42 #include "wtf/InstanceCounter.h" 41 #include "wtf/InstanceCounter.h"
43 #include "wtf/OwnPtr.h" 42 #include "wtf/OwnPtr.h"
44 #include "wtf/RefPtr.h" 43 #include "wtf/RefPtr.h"
45 #include "wtf/TypeTraits.h" 44 #include "wtf/TypeTraits.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 virtual bool ensureMarked(const void*) = 0; 605 virtual bool ensureMarked(const void*) = 0;
607 606
608 #if ENABLE(GC_PROFILE_MARKING) 607 #if ENABLE(GC_PROFILE_MARKING)
609 void setHostInfo(void* object, const String& name) 608 void setHostInfo(void* object, const String& name)
610 { 609 {
611 m_hostObject = object; 610 m_hostObject = object;
612 m_hostName = name; 611 m_hostName = name;
613 } 612 }
614 #endif 613 #endif
615 614
616 inline bool canTraceEagerly() const 615 inline bool canTraceEagerly() const { return m_traceDepth < kMaxEagerTraceDe pth; }
617 { 616 inline void incrementTraceDepth() { m_traceDepth++; }
618 ASSERT(m_stackFrameDepth); 617 inline void decrementTraceDepth() { ASSERT(m_traceDepth > 0); m_traceDepth-- ; }
619 return m_stackFrameDepth->isSafeToRecurse();
620 }
621
622 inline void configureEagerTraceLimit()
623 {
624 if (!m_stackFrameDepth)
625 m_stackFrameDepth = new StackFrameDepth;
626 m_stackFrameDepth->configureLimit();
627 }
628 618
629 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor ; } 619 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor ; }
630 620
631 protected: 621 protected:
632 explicit Visitor(VisitorType type) 622 explicit Visitor(VisitorType type)
633 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) 623 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType)
634 { } 624 {
625 m_traceDepth = 0;
626 }
635 627
636 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; 628 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0;
637 #if ENABLE(GC_PROFILE_MARKING) 629 #if ENABLE(GC_PROFILE_MARKING)
638 virtual void recordObjectGraphEdge(const void*) 630 virtual void recordObjectGraphEdge(const void*)
639 { 631 {
640 ASSERT_NOT_REACHED(); 632 ASSERT_NOT_REACHED();
641 } 633 }
642 634
643 void* m_hostObject; 635 void* m_hostObject;
644 String m_hostName; 636 String m_hostName;
645 #endif 637 #endif
646 638
647 private: 639 private:
648 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { return static_c ast<Visitor*>(helper); } 640 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { return static_c ast<Visitor*>(helper); }
649 static StackFrameDepth* m_stackFrameDepth;
650 641
642 // The maximum depth of eager, unrolled trace() calls that is
643 // considered safe and allowed.
644 const int kMaxEagerTraceDepth = 100;
645
646 static int m_traceDepth;
651 bool m_isGlobalMarkingVisitor; 647 bool m_isGlobalMarkingVisitor;
652 }; 648 };
653 649
654 // We trace vectors by using the trace trait on each element, which means you 650 // We trace vectors by using the trace trait on each element, which means you
655 // can have vectors of general objects (not just pointers to objects) that can 651 // can have vectors of general objects (not just pointers to objects) that can
656 // be traced. 652 // be traced.
657 template<typename T, size_t N> 653 template<typename T, size_t N>
658 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { 654 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > {
659 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; 655 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector;
660 656
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (TraceEagerlyTrait<T>::value) { 703 if (TraceEagerlyTrait<T>::value) {
708 // Protect against too deep trace call chains, and the 704 // Protect against too deep trace call chains, and the
709 // unbounded system stack usage they can bring about. 705 // unbounded system stack usage they can bring about.
710 // 706 //
711 // Assert against deep stacks so as to flush them out, 707 // Assert against deep stacks so as to flush them out,
712 // but test and appropriately handle them should they occur 708 // but test and appropriately handle them should they occur
713 // in release builds. 709 // in release builds.
714 ASSERT(visitor->canTraceEagerly()); 710 ASSERT(visitor->canTraceEagerly());
715 if (LIKELY(visitor->canTraceEagerly())) { 711 if (LIKELY(visitor->canTraceEagerly())) {
716 if (visitor->ensureMarked(t)) { 712 if (visitor->ensureMarked(t)) {
713 visitor->incrementTraceDepth();
717 TraceTrait<T>::trace(visitor, const_cast<T*>(t)); 714 TraceTrait<T>::trace(visitor, const_cast<T*>(t));
715 visitor->decrementTraceDepth();
718 } 716 }
719 return; 717 return;
720 } 718 }
721 } 719 }
722 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); 720 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace);
723 } 721 }
724 722
725 #if ENABLE(ASSERT) 723 #if ENABLE(ASSERT)
726 static void checkGCInfo(const T* t) 724 static void checkGCInfo(const T* t)
727 { 725 {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 struct GCInfoTrait { 906 struct GCInfoTrait {
909 static size_t index() 907 static size_t index()
910 { 908 {
911 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); 909 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index();
912 } 910 }
913 }; 911 };
914 912
915 } 913 }
916 914
917 #endif 915 #endif
OLDNEW
« no previous file with comments | « Source/platform/heap/StackFrameDepth.cpp ('k') | Source/platform/heap/Visitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698