| 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 14 matching lines...) Expand all Loading... |
| 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" |
| 35 #include "platform/heap/ThreadState.h" | 36 #include "platform/heap/ThreadState.h" |
| 36 #include "wtf/Assertions.h" | 37 #include "wtf/Assertions.h" |
| 37 #include "wtf/Deque.h" | 38 #include "wtf/Deque.h" |
| 38 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 39 #include "wtf/HashMap.h" | 40 #include "wtf/HashMap.h" |
| 40 #include "wtf/HashTraits.h" | 41 #include "wtf/HashTraits.h" |
| 41 #include "wtf/InstanceCounter.h" | 42 #include "wtf/InstanceCounter.h" |
| 42 #include "wtf/OwnPtr.h" | 43 #include "wtf/OwnPtr.h" |
| 43 #include "wtf/RefPtr.h" | 44 #include "wtf/RefPtr.h" |
| 44 #include "wtf/TypeTraits.h" | 45 #include "wtf/TypeTraits.h" |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 virtual bool ensureMarked(const void*) = 0; | 608 virtual bool ensureMarked(const void*) = 0; |
| 608 | 609 |
| 609 #if ENABLE(GC_PROFILE_MARKING) | 610 #if ENABLE(GC_PROFILE_MARKING) |
| 610 void setHostInfo(void* object, const String& name) | 611 void setHostInfo(void* object, const String& name) |
| 611 { | 612 { |
| 612 m_hostObject = object; | 613 m_hostObject = object; |
| 613 m_hostName = name; | 614 m_hostName = name; |
| 614 } | 615 } |
| 615 #endif | 616 #endif |
| 616 | 617 |
| 617 inline bool canTraceEagerly() const { return m_traceDepth < kMaxEagerTraceDe
pth; } | 618 inline bool canTraceEagerly() const |
| 618 inline void incrementTraceDepth() { m_traceDepth++; } | 619 { |
| 619 inline void decrementTraceDepth() { ASSERT(m_traceDepth > 0); m_traceDepth--
; } | 620 ASSERT(m_traceDepth); |
| 621 return m_traceDepth->isSafeToRecurse(); |
| 622 } |
| 623 |
| 624 inline void incrementTraceDepth() |
| 625 { |
| 626 ASSERT(m_traceDepth); |
| 627 m_traceDepth->increment(); |
| 628 } |
| 629 |
| 630 inline void decrementTraceDepth() |
| 631 { |
| 632 ASSERT(m_traceDepth); |
| 633 m_traceDepth->decrement(); |
| 634 } |
| 635 |
| 636 inline void configureEagerTraceLimit() |
| 637 { |
| 638 if (!m_traceDepth) |
| 639 m_traceDepth = new StackFrameDepth; |
| 640 m_traceDepth->configureLimit(); |
| 641 } |
| 620 | 642 |
| 621 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor
; } | 643 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor
; } |
| 622 | 644 |
| 623 protected: | 645 protected: |
| 624 explicit Visitor(VisitorType type) | 646 explicit Visitor(VisitorType type) |
| 625 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) | 647 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) |
| 626 { | 648 { } |
| 627 m_traceDepth = 0; | |
| 628 } | |
| 629 | 649 |
| 630 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; | 650 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; |
| 631 #if ENABLE(GC_PROFILE_MARKING) | 651 #if ENABLE(GC_PROFILE_MARKING) |
| 632 virtual void recordObjectGraphEdge(const void*) | 652 virtual void recordObjectGraphEdge(const void*) |
| 633 { | 653 { |
| 634 ASSERT_NOT_REACHED(); | 654 ASSERT_NOT_REACHED(); |
| 635 } | 655 } |
| 636 | 656 |
| 637 void* m_hostObject; | 657 void* m_hostObject; |
| 638 String m_hostName; | 658 String m_hostName; |
| 639 #endif | 659 #endif |
| 640 | 660 |
| 641 private: | 661 private: |
| 642 // The maximum depth of eager, unrolled trace() calls that is | 662 static StackFrameDepth* m_traceDepth; |
| 643 // considered safe and allowed. | |
| 644 const int kMaxEagerTraceDepth = 100; | |
| 645 | |
| 646 static int m_traceDepth; | |
| 647 bool m_isGlobalMarkingVisitor; | 663 bool m_isGlobalMarkingVisitor; |
| 648 }; | 664 }; |
| 649 | 665 |
| 650 // We trace vectors by using the trace trait on each element, which means you | 666 // We trace vectors by using the trace trait on each element, which means you |
| 651 // can have vectors of general objects (not just pointers to objects) that can | 667 // can have vectors of general objects (not just pointers to objects) that can |
| 652 // be traced. | 668 // be traced. |
| 653 template<typename T, size_t N> | 669 template<typename T, size_t N> |
| 654 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { | 670 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { |
| 655 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; | 671 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; |
| 656 | 672 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 struct GCInfoTrait { | 906 struct GCInfoTrait { |
| 891 static size_t index() | 907 static size_t index() |
| 892 { | 908 { |
| 893 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); | 909 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); |
| 894 } | 910 } |
| 895 }; | 911 }; |
| 896 | 912 |
| 897 } | 913 } |
| 898 | 914 |
| 899 #endif | 915 #endif |
| OLD | NEW |