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