| 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 25 matching lines...) Expand all Loading... |
| 36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
| 37 #include "wtf/Deque.h" | 37 #include "wtf/Deque.h" |
| 38 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 39 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
| 40 #include "wtf/HashTraits.h" | 40 #include "wtf/HashTraits.h" |
| 41 #include "wtf/InstanceCounter.h" | 41 #include "wtf/InstanceCounter.h" |
| 42 #include "wtf/OwnPtr.h" | 42 #include "wtf/OwnPtr.h" |
| 43 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
| 44 #include "wtf/TypeTraits.h" | 44 #include "wtf/TypeTraits.h" |
| 45 #include "wtf/WeakPtr.h" | 45 #include "wtf/WeakPtr.h" |
| 46 #if ENABLE(GC_TRACING) | 46 #if ENABLE(GC_PROFILING) |
| 47 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if ENABLE(ASSERT) | 50 #if ENABLE(ASSERT) |
| 51 #define DEBUG_ONLY(x) x | 51 #define DEBUG_ONLY(x) x |
| 52 #else | 52 #else |
| 53 #define DEBUG_ONLY(x) | 53 #define DEBUG_ONLY(x) |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 namespace blink { | 56 namespace blink { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 82 // the garbage collector determines that the object is no longer | 82 // the garbage collector determines that the object is no longer |
| 83 // reachable. There is a GCInfo struct for each class that directly | 83 // reachable. There is a GCInfo struct for each class that directly |
| 84 // inherits from GarbageCollected or GarbageCollectedFinalized. | 84 // inherits from GarbageCollected or GarbageCollectedFinalized. |
| 85 struct GCInfo { | 85 struct GCInfo { |
| 86 bool hasFinalizer() const { return m_nonTrivialFinalizer; } | 86 bool hasFinalizer() const { return m_nonTrivialFinalizer; } |
| 87 bool hasVTable() const { return m_hasVTable; } | 87 bool hasVTable() const { return m_hasVTable; } |
| 88 TraceCallback m_trace; | 88 TraceCallback m_trace; |
| 89 FinalizationCallback m_finalize; | 89 FinalizationCallback m_finalize; |
| 90 bool m_nonTrivialFinalizer; | 90 bool m_nonTrivialFinalizer; |
| 91 bool m_hasVTable; | 91 bool m_hasVTable; |
| 92 #if ENABLE(GC_TRACING) | 92 #if ENABLE(GC_PROFILING) |
| 93 // |m_className| is held as a reference to prevent dtor being called at exit
. | 93 // |m_className| is held as a reference to prevent dtor being called at exit
. |
| 94 const String& m_className; | 94 const String& m_className; |
| 95 #endif | 95 #endif |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 // The FinalizerTraitImpl specifies how to finalize objects. Object | 98 // The FinalizerTraitImpl specifies how to finalize objects. Object |
| 99 // that inherit from GarbageCollectedFinalized are finalized by | 99 // that inherit from GarbageCollectedFinalized are finalized by |
| 100 // calling their 'finalize' method which by default will call the | 100 // calling their 'finalize' method which by default will call the |
| 101 // destructor on the object. | 101 // destructor on the object. |
| 102 template<typename T, bool isGarbageCollectedFinalized> | 102 template<typename T, bool isGarbageCollectedFinalized> |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 // Macro to declare methods needed for each typed heap. | 399 // Macro to declare methods needed for each typed heap. |
| 400 #define DECLARE_VISITOR_METHODS(Type) \ | 400 #define DECLARE_VISITOR_METHODS(Type) \ |
| 401 DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \ | 401 DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \ |
| 402 virtual void mark(const Type*, TraceCallback) = 0; \ | 402 virtual void mark(const Type*, TraceCallback) = 0; \ |
| 403 virtual bool isMarked(const Type*) = 0; | 403 virtual bool isMarked(const Type*) = 0; |
| 404 | 404 |
| 405 FOR_EACH_TYPED_HEAP(DECLARE_VISITOR_METHODS) | 405 FOR_EACH_TYPED_HEAP(DECLARE_VISITOR_METHODS) |
| 406 #undef DECLARE_VISITOR_METHODS | 406 #undef DECLARE_VISITOR_METHODS |
| 407 | 407 |
| 408 #if ENABLE(GC_TRACING) | 408 #if ENABLE(GC_PROFILE_MARKING) |
| 409 void setHostInfo(void* object, const String& name) | 409 void setHostInfo(void* object, const String& name) |
| 410 { | 410 { |
| 411 m_hostObject = object; | 411 m_hostObject = object; |
| 412 m_hostName = name; | 412 m_hostName = name; |
| 413 } | 413 } |
| 414 #endif | 414 #endif |
| 415 | 415 |
| 416 protected: | 416 protected: |
| 417 virtual void registerWeakCell(void**, WeakPointerCallback) = 0; | 417 virtual void registerWeakCell(void**, WeakPointerCallback) = 0; |
| 418 #if ENABLE(GC_TRACING) | 418 #if ENABLE(GC_PROFILE_MARKING) |
| 419 void* m_hostObject; | 419 void* m_hostObject; |
| 420 String m_hostName; | 420 String m_hostName; |
| 421 #endif | 421 #endif |
| 422 | 422 |
| 423 private: | 423 private: |
| 424 template<typename T> | 424 template<typename T> |
| 425 static void handleWeakCell(Visitor* self, void* obj) | 425 static void handleWeakCell(Visitor* self, void* obj) |
| 426 { | 426 { |
| 427 T** cell = reinterpret_cast<T**>(obj); | 427 T** cell = reinterpret_cast<T**>(obj); |
| 428 if (*cell && !self->isAlive(*cell)) | 428 if (*cell && !self->isAlive(*cell)) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return visitor->isAlive(this); \ | 578 return visitor->isAlive(this); \ |
| 579 } \ | 579 } \ |
| 580 private: | 580 private: |
| 581 | 581 |
| 582 #if ENABLE(OILPAN) | 582 #if ENABLE(OILPAN) |
| 583 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI
N(TYPE) | 583 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI
N(TYPE) |
| 584 #else | 584 #else |
| 585 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) | 585 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) |
| 586 #endif | 586 #endif |
| 587 | 587 |
| 588 #if ENABLE(GC_TRACING) | 588 #if ENABLE(GC_PROFILING) |
| 589 template<typename T> | 589 template<typename T> |
| 590 struct TypenameStringTrait { | 590 struct TypenameStringTrait { |
| 591 static const String& get() | 591 static const String& get() |
| 592 { | 592 { |
| 593 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun
ctionName(WTF::extractNameFunction<T>()))); | 593 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun
ctionName(WTF::extractNameFunction<T>()))); |
| 594 return typenameString; | 594 return typenameString; |
| 595 } | 595 } |
| 596 }; | 596 }; |
| 597 #endif | 597 #endif |
| 598 | 598 |
| 599 template<typename T> | 599 template<typename T> |
| 600 struct GCInfoAtBase { | 600 struct GCInfoAtBase { |
| 601 static const GCInfo* get() | 601 static const GCInfo* get() |
| 602 { | 602 { |
| 603 static const GCInfo gcInfo = { | 603 static const GCInfo gcInfo = { |
| 604 TraceTrait<T>::trace, | 604 TraceTrait<T>::trace, |
| 605 FinalizerTrait<T>::finalize, | 605 FinalizerTrait<T>::finalize, |
| 606 FinalizerTrait<T>::nonTrivialFinalizer, | 606 FinalizerTrait<T>::nonTrivialFinalizer, |
| 607 WTF::IsPolymorphic<T>::value, | 607 WTF::IsPolymorphic<T>::value, |
| 608 #if ENABLE(GC_TRACING) | 608 #if ENABLE(GC_PROFILING) |
| 609 TypenameStringTrait<T>::get() | 609 TypenameStringTrait<T>::get() |
| 610 #endif | 610 #endif |
| 611 }; | 611 }; |
| 612 return &gcInfo; | 612 return &gcInfo; |
| 613 } | 613 } |
| 614 }; | 614 }; |
| 615 | 615 |
| 616 template<typename T> class GarbageCollected; | 616 template<typename T> class GarbageCollected; |
| 617 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<
T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; | 617 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<
T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; |
| 618 | 618 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 630 struct GCInfoTrait { | 630 struct GCInfoTrait { |
| 631 static const GCInfo* get() | 631 static const GCInfo* get() |
| 632 { | 632 { |
| 633 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 633 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
| 634 } | 634 } |
| 635 }; | 635 }; |
| 636 | 636 |
| 637 } | 637 } |
| 638 | 638 |
| 639 #endif | 639 #endif |
| OLD | NEW |