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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // the argument to get the TraceTrait. By default, the mark method | 336 // the argument to get the TraceTrait. By default, the mark method |
337 // of the TraceTrait just calls the virtual two-argument mark method on this | 337 // of the TraceTrait just calls the virtual two-argument mark method on this |
338 // visitor, where the second argument is the static trace method of the trai
t. | 338 // visitor, where the second argument is the static trace method of the trai
t. |
339 template<typename T> | 339 template<typename T> |
340 void mark(T* t) | 340 void mark(T* t) |
341 { | 341 { |
342 if (!t) | 342 if (!t) |
343 return; | 343 return; |
344 #if ENABLE(ASSERT) | 344 #if ENABLE(ASSERT) |
345 TraceTrait<T>::checkGCInfo(t); | 345 TraceTrait<T>::checkGCInfo(t); |
| 346 Derived::fromHelper(this)->checkIsMarkingAllowed(); |
346 #endif | 347 #endif |
347 TraceTrait<T>::mark(Derived::fromHelper(this), t); | 348 TraceTrait<T>::mark(Derived::fromHelper(this), t); |
348 | 349 |
349 STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, "attempted to mark non garbage col
lected object"); | 350 STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, "attempted to mark non garbage col
lected object"); |
350 } | 351 } |
351 | 352 |
352 // Member version of the one-argument templated trace method. | 353 // Member version of the one-argument templated trace method. |
353 template<typename T> | 354 template<typename T> |
354 void trace(const Member<T>& t) | 355 void trace(const Member<T>& t) |
355 { | 356 { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 m_hostName = name; | 625 m_hostName = name; |
625 } | 626 } |
626 #endif | 627 #endif |
627 | 628 |
628 inline bool canTraceEagerly() const { return m_traceDepth < kMaxEagerTraceDe
pth; } | 629 inline bool canTraceEagerly() const { return m_traceDepth < kMaxEagerTraceDe
pth; } |
629 inline void incrementTraceDepth() { m_traceDepth++; } | 630 inline void incrementTraceDepth() { m_traceDepth++; } |
630 inline void decrementTraceDepth() { ASSERT(m_traceDepth > 0); m_traceDepth--
; } | 631 inline void decrementTraceDepth() { ASSERT(m_traceDepth > 0); m_traceDepth--
; } |
631 | 632 |
632 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor
; } | 633 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor
; } |
633 | 634 |
| 635 #if ENABLE(ASSERT) |
| 636 virtual void setAllowTraceForHashTableWeakProcessing(bool) { } |
| 637 #endif |
| 638 |
634 protected: | 639 protected: |
635 explicit Visitor(VisitorType type) | 640 explicit Visitor(VisitorType type) |
636 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) | 641 : m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) |
637 { | 642 { |
638 m_traceDepth = 0; | 643 m_traceDepth = 0; |
639 } | 644 } |
640 | 645 |
641 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; | 646 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; |
642 #if ENABLE(GC_PROFILE_MARKING) | 647 #if ENABLE(GC_PROFILE_MARKING) |
643 virtual void recordObjectGraphEdge(const void*) | 648 virtual void recordObjectGraphEdge(const void*) |
644 { | 649 { |
645 ASSERT_NOT_REACHED(); | 650 ASSERT_NOT_REACHED(); |
646 } | 651 } |
647 | 652 |
648 void* m_hostObject; | 653 void* m_hostObject; |
649 String m_hostName; | 654 String m_hostName; |
650 #endif | 655 #endif |
651 | 656 |
| 657 #if ENABLE(ASSERT) |
| 658 virtual void checkIsMarkingAllowed() { } |
| 659 #endif |
| 660 |
652 private: | 661 private: |
653 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { return static_c
ast<Visitor*>(helper); } | 662 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { return static_c
ast<Visitor*>(helper); } |
654 | 663 |
655 // The maximum depth of eager, unrolled trace() calls that is | 664 // The maximum depth of eager, unrolled trace() calls that is |
656 // considered safe and allowed. | 665 // considered safe and allowed. |
657 const int kMaxEagerTraceDepth = 100; | 666 const int kMaxEagerTraceDepth = 100; |
658 | 667 |
659 static int m_traceDepth; | 668 static int m_traceDepth; |
660 bool m_isGlobalMarkingVisitor; | 669 bool m_isGlobalMarkingVisitor; |
661 }; | 670 }; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 struct GCInfoTrait { | 929 struct GCInfoTrait { |
921 static size_t index() | 930 static size_t index() |
922 { | 931 { |
923 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); | 932 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); |
924 } | 933 } |
925 }; | 934 }; |
926 | 935 |
927 } | 936 } |
928 | 937 |
929 #endif | 938 #endif |
OLD | NEW |