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 29 matching lines...) Expand all Loading... |
40 #include "wtf/HashMap.h" | 40 #include "wtf/HashMap.h" |
41 #include "wtf/HashSet.h" | 41 #include "wtf/HashSet.h" |
42 #include "wtf/HashTraits.h" | 42 #include "wtf/HashTraits.h" |
43 #include "wtf/InstanceCounter.h" | 43 #include "wtf/InstanceCounter.h" |
44 #include "wtf/LinkedHashSet.h" | 44 #include "wtf/LinkedHashSet.h" |
45 #include "wtf/ListHashSet.h" | 45 #include "wtf/ListHashSet.h" |
46 #include "wtf/OwnPtr.h" | 46 #include "wtf/OwnPtr.h" |
47 #include "wtf/RefPtr.h" | 47 #include "wtf/RefPtr.h" |
48 #include "wtf/TypeTraits.h" | 48 #include "wtf/TypeTraits.h" |
49 #include "wtf/WeakPtr.h" | 49 #include "wtf/WeakPtr.h" |
50 #if ENABLE(GC_TRACING) | 50 #if GC_PROFILE_DEFINE_CLASSNAME |
51 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #ifndef NDEBUG | 54 #ifndef NDEBUG |
55 #define DEBUG_ONLY(x) x | 55 #define DEBUG_ONLY(x) x |
56 #else | 56 #else |
57 #define DEBUG_ONLY(x) | 57 #define DEBUG_ONLY(x) |
58 #endif | 58 #endif |
59 | 59 |
60 namespace WebCore { | 60 namespace WebCore { |
(...skipping 25 matching lines...) Expand all Loading... |
86 // the garbage collector determines that the object is no longer | 86 // the garbage collector determines that the object is no longer |
87 // reachable. There is a GCInfo struct for each class that directly | 87 // reachable. There is a GCInfo struct for each class that directly |
88 // inherits from GarbageCollected or GarbageCollectedFinalized. | 88 // inherits from GarbageCollected or GarbageCollectedFinalized. |
89 struct GCInfo { | 89 struct GCInfo { |
90 bool hasFinalizer() const { return m_nonTrivialFinalizer; } | 90 bool hasFinalizer() const { return m_nonTrivialFinalizer; } |
91 bool hasVTable() const { return m_hasVTable; } | 91 bool hasVTable() const { return m_hasVTable; } |
92 TraceCallback m_trace; | 92 TraceCallback m_trace; |
93 FinalizationCallback m_finalize; | 93 FinalizationCallback m_finalize; |
94 bool m_nonTrivialFinalizer; | 94 bool m_nonTrivialFinalizer; |
95 bool m_hasVTable; | 95 bool m_hasVTable; |
96 #if ENABLE(GC_TRACING) | 96 #if GC_PROFILE_DEFINE_CLASSNAME |
97 // |m_className| is held as a reference to prevent dtor being called at exit
. | 97 // |m_className| is held as a reference to prevent dtor being called at exit
. |
98 const String& m_className; | 98 const String& m_className; |
99 #endif | 99 #endif |
100 }; | 100 }; |
101 | 101 |
102 // The FinalizerTraitImpl specifies how to finalize objects. Object | 102 // The FinalizerTraitImpl specifies how to finalize objects. Object |
103 // that inherit from GarbageCollectedFinalized are finalized by | 103 // that inherit from GarbageCollectedFinalized are finalized by |
104 // calling their 'finalize' method which by default will call the | 104 // calling their 'finalize' method which by default will call the |
105 // destructor on the object. | 105 // destructor on the object. |
106 template<typename T, bool isGarbageCollectedFinalized> | 106 template<typename T, bool isGarbageCollectedFinalized> |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 419 |
420 // Macro to declare methods needed for each typed heap. | 420 // Macro to declare methods needed for each typed heap. |
421 #define DECLARE_VISITOR_METHODS(Type) \ | 421 #define DECLARE_VISITOR_METHODS(Type) \ |
422 DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \ | 422 DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \ |
423 virtual void mark(const Type*, TraceCallback) = 0; \ | 423 virtual void mark(const Type*, TraceCallback) = 0; \ |
424 virtual bool isMarked(const Type*) = 0; | 424 virtual bool isMarked(const Type*) = 0; |
425 | 425 |
426 FOR_EACH_TYPED_HEAP(DECLARE_VISITOR_METHODS) | 426 FOR_EACH_TYPED_HEAP(DECLARE_VISITOR_METHODS) |
427 #undef DECLARE_VISITOR_METHODS | 427 #undef DECLARE_VISITOR_METHODS |
428 | 428 |
429 #if ENABLE(GC_TRACING) | 429 #if GC_PROFILE_MARKING |
430 void setHostInfo(void* object, const String& name) | 430 void setHostInfo(void* object, const String& name) |
431 { | 431 { |
432 m_hostObject = object; | 432 m_hostObject = object; |
433 m_hostName = name; | 433 m_hostName = name; |
434 } | 434 } |
435 #endif | 435 #endif |
436 | 436 |
437 protected: | 437 protected: |
438 virtual void registerWeakCell(void**, WeakPointerCallback) = 0; | 438 virtual void registerWeakCell(void**, WeakPointerCallback) = 0; |
439 #if ENABLE(GC_TRACING) | 439 #if GC_PROFILE_MARKING |
440 void* m_hostObject; | 440 void* m_hostObject; |
441 String m_hostName; | 441 String m_hostName; |
442 #endif | 442 #endif |
443 | 443 |
444 private: | 444 private: |
445 template<typename T> | 445 template<typename T> |
446 static void handleWeakCell(Visitor* self, void* obj) | 446 static void handleWeakCell(Visitor* self, void* obj) |
447 { | 447 { |
448 T** cell = reinterpret_cast<T**>(obj); | 448 T** cell = reinterpret_cast<T**>(obj); |
449 if (*cell && !self->isAlive(*cell)) | 449 if (*cell && !self->isAlive(*cell)) |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 return visitor->isAlive(this); \ | 668 return visitor->isAlive(this); \ |
669 } \ | 669 } \ |
670 private: | 670 private: |
671 | 671 |
672 #if ENABLE(OILPAN) | 672 #if ENABLE(OILPAN) |
673 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI
N(TYPE) | 673 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI
N(TYPE) |
674 #else | 674 #else |
675 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) | 675 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) |
676 #endif | 676 #endif |
677 | 677 |
678 #if ENABLE(GC_TRACING) | 678 #if GC_PROFILE_DEFINE_CLASSNAME |
679 template<typename T> | 679 template<typename T> |
680 struct TypenameStringTrait { | 680 struct TypenameStringTrait { |
681 static const String& get() | 681 static const String& get() |
682 { | 682 { |
683 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun
ctionName(WTF::extractNameFunction<T>()))); | 683 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun
ctionName(WTF::extractNameFunction<T>()))); |
684 return typenameString; | 684 return typenameString; |
685 } | 685 } |
686 }; | 686 }; |
687 #endif | 687 #endif |
688 | 688 |
689 template<typename T> | 689 template<typename T> |
690 struct GCInfoAtBase { | 690 struct GCInfoAtBase { |
691 static const GCInfo* get() | 691 static const GCInfo* get() |
692 { | 692 { |
693 static const GCInfo gcInfo = { | 693 static const GCInfo gcInfo = { |
694 TraceTrait<T>::trace, | 694 TraceTrait<T>::trace, |
695 FinalizerTrait<T>::finalize, | 695 FinalizerTrait<T>::finalize, |
696 FinalizerTrait<T>::nonTrivialFinalizer, | 696 FinalizerTrait<T>::nonTrivialFinalizer, |
697 WTF::IsPolymorphic<T>::value, | 697 WTF::IsPolymorphic<T>::value, |
698 #if ENABLE(GC_TRACING) | 698 #if GC_PROFILE_DEFINE_CLASSNAME |
699 TypenameStringTrait<T>::get() | 699 TypenameStringTrait<T>::get() |
700 #endif | 700 #endif |
701 }; | 701 }; |
702 return &gcInfo; | 702 return &gcInfo; |
703 } | 703 } |
704 }; | 704 }; |
705 | 705 |
706 template<typename T> class GarbageCollected; | 706 template<typename T> class GarbageCollected; |
707 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<
T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; | 707 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<
T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; |
708 | 708 |
(...skipping 11 matching lines...) Expand all Loading... |
720 struct GCInfoTrait { | 720 struct GCInfoTrait { |
721 static const GCInfo* get() | 721 static const GCInfo* get() |
722 { | 722 { |
723 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 723 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
724 } | 724 } |
725 }; | 725 }; |
726 | 726 |
727 } | 727 } |
728 | 728 |
729 #endif | 729 #endif |
OLD | NEW |