| 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // Pointers are marked and pushed on the marking stack by calling the | 471 // Pointers are marked and pushed on the marking stack by calling the |
| 472 // |mark| method with the pointer as an argument. | 472 // |mark| method with the pointer as an argument. |
| 473 // | 473 // |
| 474 // Pointers within objects are traced by calling the |trace| methods | 474 // Pointers within objects are traced by calling the |trace| methods |
| 475 // with the object as an argument. Tracing objects will mark all of the | 475 // with the object as an argument. Tracing objects will mark all of the |
| 476 // contained pointers and push them on the marking stack. | 476 // contained pointers and push them on the marking stack. |
| 477 class PLATFORM_EXPORT Visitor : public VisitorHelper<Visitor> { | 477 class PLATFORM_EXPORT Visitor : public VisitorHelper<Visitor> { |
| 478 public: | 478 public: |
| 479 friend class VisitorHelper<Visitor>; | 479 friend class VisitorHelper<Visitor>; |
| 480 | 480 |
| 481 enum VisitorType { |
| 482 GlobalMarkingVisitorType, |
| 483 GenericVisitorType, |
| 484 }; |
| 485 |
| 481 virtual ~Visitor() { } | 486 virtual ~Visitor() { } |
| 482 | 487 |
| 483 // FIXME: This is a temporary hack to cheat old Blink GC plugin checks. | 488 // FIXME: This is a temporary hack to cheat old Blink GC plugin checks. |
| 484 // Old GC Plugin doesn't accept calling VisitorHelper<Visitor>::trace | 489 // Old GC Plugin doesn't accept calling VisitorHelper<Visitor>::trace |
| 485 // as a valid mark. This manual redirect worksaround the issue by | 490 // as a valid mark. This manual redirect worksaround the issue by |
| 486 // making the method declaration on Visitor class. | 491 // making the method declaration on Visitor class. |
| 487 template<typename T> | 492 template<typename T> |
| 488 void trace(const T& t) | 493 void trace(const T& t) |
| 489 { | 494 { |
| 490 VisitorHelper<Visitor>::trace(t); | 495 VisitorHelper<Visitor>::trace(t); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 { | 567 { |
| 563 m_hostObject = object; | 568 m_hostObject = object; |
| 564 m_hostName = name; | 569 m_hostName = name; |
| 565 } | 570 } |
| 566 #endif | 571 #endif |
| 567 | 572 |
| 568 inline bool canTraceEagerly() const { return m_traceDepth < kMaxEagerTraceDe
pth; } | 573 inline bool canTraceEagerly() const { return m_traceDepth < kMaxEagerTraceDe
pth; } |
| 569 inline void incrementTraceDepth() { m_traceDepth++; } | 574 inline void incrementTraceDepth() { m_traceDepth++; } |
| 570 inline void decrementTraceDepth() { ASSERT(m_traceDepth > 0); m_traceDepth--
; } | 575 inline void decrementTraceDepth() { ASSERT(m_traceDepth > 0); m_traceDepth--
; } |
| 571 | 576 |
| 577 inline bool isGlobalMarkingVisitor() const { return m_isGlobalMarkingVisitor
; } |
| 578 |
| 572 protected: | 579 protected: |
| 573 Visitor() | 580 explicit Visitor(VisitorType type) |
| 574 : m_traceDepth(0) | 581 : m_traceDepth(0) |
| 582 , m_isGlobalMarkingVisitor(type == GlobalMarkingVisitorType) |
| 575 { | 583 { |
| 576 } | 584 } |
| 577 | 585 |
| 578 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; | 586 virtual void registerWeakCellWithCallback(void**, WeakPointerCallback) = 0; |
| 579 #if ENABLE(GC_PROFILE_MARKING) | 587 #if ENABLE(GC_PROFILE_MARKING) |
| 580 void* m_hostObject; | 588 void* m_hostObject; |
| 581 String m_hostName; | 589 String m_hostName; |
| 582 #endif | 590 #endif |
| 583 | 591 |
| 584 private: | 592 private: |
| 585 // The maximum depth of eager, unrolled trace() calls that is | 593 // The maximum depth of eager, unrolled trace() calls that is |
| 586 // considered safe and allowed. | 594 // considered safe and allowed. |
| 587 const int kMaxEagerTraceDepth = 100; | 595 const int kMaxEagerTraceDepth = 100; |
| 588 | 596 |
| 589 int m_traceDepth; | 597 int m_traceDepth; |
| 598 bool m_isGlobalMarkingVisitor; |
| 590 }; | 599 }; |
| 591 | 600 |
| 592 // We trace vectors by using the trace trait on each element, which means you | 601 // We trace vectors by using the trace trait on each element, which means you |
| 593 // can have vectors of general objects (not just pointers to objects) that can | 602 // can have vectors of general objects (not just pointers to objects) that can |
| 594 // be traced. | 603 // be traced. |
| 595 template<typename T, size_t N> | 604 template<typename T, size_t N> |
| 596 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { | 605 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { |
| 597 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; | 606 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; |
| 598 | 607 |
| 599 static void trace(Visitor* visitor, const Vector& vector) | 608 static void trace(Visitor* visitor, const Vector& vector) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 struct GCInfoTrait { | 822 struct GCInfoTrait { |
| 814 static const GCInfo* get() | 823 static const GCInfo* get() |
| 815 { | 824 { |
| 816 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 825 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
| 817 } | 826 } |
| 818 }; | 827 }; |
| 819 | 828 |
| 820 } | 829 } |
| 821 | 830 |
| 822 #endif | 831 #endif |
| OLD | NEW |