Chromium Code Reviews| 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 configureEagerTraceLimit() | |
| 625 { | |
| 626 if (!m_traceDepth) | |
| 627 m_traceDepth = new StackFrameDepth; | |
| 628 m_traceDepth->configureLimit(); | |
| 629 } | |
| 620 | 630 |
| 621 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor ; } | 631 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor ; } |
| 622 | 632 |
| 623 protected: | 633 protected: |
| 624 explicit Visitor(VisitorType type) | 634 explicit Visitor(VisitorType type) |
| 625 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) | 635 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) |
| 626 { | 636 { } |
| 627 m_traceDepth = 0; | |
| 628 } | |
| 629 | 637 |
| 630 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; | 638 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; |
| 631 #if ENABLE(GC_PROFILE_MARKING) | 639 #if ENABLE(GC_PROFILE_MARKING) |
| 632 virtual void recordObjectGraphEdge(const void*) | 640 virtual void recordObjectGraphEdge(const void*) |
| 633 { | 641 { |
| 634 ASSERT_NOT_REACHED(); | 642 ASSERT_NOT_REACHED(); |
| 635 } | 643 } |
| 636 | 644 |
| 637 void* m_hostObject; | 645 void* m_hostObject; |
| 638 String m_hostName; | 646 String m_hostName; |
| 639 #endif | 647 #endif |
| 640 | 648 |
| 641 private: | 649 private: |
| 642 // The maximum depth of eager, unrolled trace() calls that is | 650 static StackFrameDepth* m_traceDepth; |
|
haraken
2015/01/08 01:14:23
m_traceDepth => m_stackFrameDepth
kouhei (in TOK)
2015/01/08 03:29:55
Done.
| |
| 643 // considered safe and allowed. | |
| 644 const int kMaxEagerTraceDepth = 100; | |
| 645 | |
| 646 static int m_traceDepth; | |
| 647 bool m_isGlobalMarkingVisitor; | 651 bool m_isGlobalMarkingVisitor; |
| 648 }; | 652 }; |
| 649 | 653 |
| 650 // We trace vectors by using the trace trait on each element, which means you | 654 // 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 | 655 // can have vectors of general objects (not just pointers to objects) that can |
| 652 // be traced. | 656 // be traced. |
| 653 template<typename T, size_t N> | 657 template<typename T, size_t N> |
| 654 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { | 658 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { |
| 655 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; | 659 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; |
| 656 | 660 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 if (TraceEagerlyTrait<T>::value) { | 707 if (TraceEagerlyTrait<T>::value) { |
| 704 // Protect against too deep trace call chains, and the | 708 // Protect against too deep trace call chains, and the |
| 705 // unbounded system stack usage they can bring about. | 709 // unbounded system stack usage they can bring about. |
| 706 // | 710 // |
| 707 // Assert against deep stacks so as to flush them out, | 711 // Assert against deep stacks so as to flush them out, |
| 708 // but test and appropriately handle them should they occur | 712 // but test and appropriately handle them should they occur |
| 709 // in release builds. | 713 // in release builds. |
| 710 ASSERT(visitor->canTraceEagerly()); | 714 ASSERT(visitor->canTraceEagerly()); |
| 711 if (LIKELY(visitor->canTraceEagerly())) { | 715 if (LIKELY(visitor->canTraceEagerly())) { |
| 712 if (visitor->ensureMarked(t)) { | 716 if (visitor->ensureMarked(t)) { |
| 713 visitor->incrementTraceDepth(); | |
| 714 TraceTrait<T>::trace(visitor, const_cast<T*>(t)); | 717 TraceTrait<T>::trace(visitor, const_cast<T*>(t)); |
| 715 visitor->decrementTraceDepth(); | |
| 716 } | 718 } |
| 717 return; | 719 return; |
| 718 } | 720 } |
| 719 } | 721 } |
| 720 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); | 722 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); |
| 721 } | 723 } |
| 722 | 724 |
| 723 #if ENABLE(ASSERT) | 725 #if ENABLE(ASSERT) |
| 724 static void checkGCInfo(const T* t) | 726 static void checkGCInfo(const T* t) |
| 725 { | 727 { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 struct GCInfoTrait { | 892 struct GCInfoTrait { |
| 891 static size_t index() | 893 static size_t index() |
| 892 { | 894 { |
| 893 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); | 895 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); |
| 894 } | 896 } |
| 895 }; | 897 }; |
| 896 | 898 |
| 897 } | 899 } |
| 898 | 900 |
| 899 #endif | 901 #endif |
| OLD | NEW |