Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 #ifndef NDEBUG | 46 #ifndef NDEBUG |
| 47 #define DEBUG_ONLY(x) x | 47 #define DEBUG_ONLY(x) x |
| 48 #else | 48 #else |
| 49 #define DEBUG_ONLY(x) | 49 #define DEBUG_ONLY(x) |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 namespace WebCore { | 52 namespace WebCore { |
| 53 | 53 |
| 54 class FinalizedHeapObjectHeader; | 54 class FinalizedHeapObjectHeader; |
| 55 template<typename T> class GarbageCollected; | |
| 55 template<typename T> class GarbageCollectedFinalized; | 56 template<typename T> class GarbageCollectedFinalized; |
| 56 class HeapObjectHeader; | 57 class HeapObjectHeader; |
| 57 template<typename T> class Member; | 58 template<typename T> class Member; |
| 58 template<typename T> class WeakMember; | 59 template<typename T> class WeakMember; |
| 59 class Visitor; | 60 class Visitor; |
| 60 | 61 |
| 61 template<bool needsTracing, bool isWeak, bool markWeakMembersStrongly, typename T, typename Traits> struct CollectionBackingTraceTrait; | 62 template<bool needsTracing, bool isWeak, bool markWeakMembersStrongly, typename T, typename Traits> struct CollectionBackingTraceTrait; |
| 62 | 63 |
| 63 typedef void (*FinalizationCallback)(void*); | 64 typedef void (*FinalizationCallback)(void*); |
| 64 typedef void (*VisitorCallback)(Visitor*, void* self); | 65 typedef void (*VisitorCallback)(Visitor*, void* self); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 85 // inherits from GarbageCollected or GarbageCollectedFinalized. | 86 // inherits from GarbageCollected or GarbageCollectedFinalized. |
| 86 struct GCInfo { | 87 struct GCInfo { |
| 87 bool hasFinalizer() const { return m_nonTrivialFinalizer; } | 88 bool hasFinalizer() const { return m_nonTrivialFinalizer; } |
| 88 const char* m_typeMarker; | 89 const char* m_typeMarker; |
| 89 TraceCallback m_trace; | 90 TraceCallback m_trace; |
| 90 FinalizationCallback m_finalize; | 91 FinalizationCallback m_finalize; |
| 91 bool m_nonTrivialFinalizer; | 92 bool m_nonTrivialFinalizer; |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 // Template struct to detect whether type T inherits from | 95 // Template struct to detect whether type T inherits from |
| 96 // GarbageCollected. | |
| 97 template<typename T> | |
| 98 struct IsGarbageCollected { | |
|
Mads Ager (chromium)
2014/02/18 06:50:50
Can we use WTF::IsSubclassOfTemplate here?
WTF::I
Vyacheslav Egorov (Chromium)
2014/02/18 09:37:44
Done.
| |
| 99 typedef char TrueType; | |
| 100 struct FalseType { | |
| 101 char dummy[2]; | |
| 102 }; | |
| 103 template<typename U> static TrueType has(GarbageCollected<U>*); | |
| 104 static FalseType has(...); | |
| 105 static bool const value = sizeof(has(static_cast<T*>(0))) == sizeof(TrueType ); | |
| 106 }; | |
| 107 | |
| 108 | |
| 109 // Template struct to detect whether type T inherits from | |
| 95 // GarbageCollectedFinalized. | 110 // GarbageCollectedFinalized. |
| 96 template<typename T> | 111 template<typename T> |
| 97 struct IsGarbageCollectedFinalized { | 112 struct IsGarbageCollectedFinalized { |
|
Mads Ager (chromium)
2014/02/18 06:50:50
I think we can get rid of this one as well and use
| |
| 98 typedef char TrueType; | 113 typedef char TrueType; |
| 99 struct FalseType { | 114 struct FalseType { |
| 100 char dummy[2]; | 115 char dummy[2]; |
| 101 }; | 116 }; |
| 102 template<typename U> static TrueType has(GarbageCollectedFinalized<U>*); | 117 template<typename U> static TrueType has(GarbageCollectedFinalized<U>*); |
| 103 static FalseType has(...); | 118 static FalseType has(...); |
| 104 static bool const value = sizeof(has(static_cast<T*>(0))) == sizeof(TrueType ); | 119 static bool const value = sizeof(has(static_cast<T*>(0))) == sizeof(TrueType ); |
| 105 }; | 120 }; |
| 106 | 121 |
| 107 // The FinalizerTraitImpl specifies how to finalize objects. Object | 122 // The FinalizerTraitImpl specifies how to finalize objects. Object |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 return visitor->isMarked(obj); | 556 return visitor->isMarked(obj); |
| 542 } | 557 } |
| 543 template<typename T> bool ObjectAliveTrait<Member<T> >::isAlive(Visitor* visitor , const Member<T>& obj) | 558 template<typename T> bool ObjectAliveTrait<Member<T> >::isAlive(Visitor* visitor , const Member<T>& obj) |
| 544 { | 559 { |
| 545 return visitor->isMarked(obj.get()); | 560 return visitor->isMarked(obj.get()); |
| 546 } | 561 } |
| 547 | 562 |
| 548 } | 563 } |
| 549 | 564 |
| 550 #endif | 565 #endif |
| OLD | NEW |