| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 template<size_t> struct F; | 62 template<size_t> struct F; |
| 63 template<typename U> static TrueType hasAdjustAndMark(F<sizeof(&U::adjustAnd
Mark)>*); | 63 template<typename U> static TrueType hasAdjustAndMark(F<sizeof(&U::adjustAnd
Mark)>*); |
| 64 template<typename U> static TrueType hasIsAlive(F<sizeof(&U::isAlive)>*); | 64 template<typename U> static TrueType hasIsAlive(F<sizeof(&U::isAlive)>*); |
| 65 #endif | 65 #endif |
| 66 template<typename U> static FalseType hasIsAlive(...); | 66 template<typename U> static FalseType hasIsAlive(...); |
| 67 template<typename U> static FalseType hasAdjustAndMark(...); | 67 template<typename U> static FalseType hasAdjustAndMark(...); |
| 68 | 68 |
| 69 static bool const value = (sizeof(TrueType) == sizeof(hasAdjustAndMark<T>(0)
)) && (sizeof(TrueType) == sizeof(hasIsAlive<T>(0))); | 69 static bool const value = (sizeof(TrueType) == sizeof(hasAdjustAndMark<T>(0)
)) && (sizeof(TrueType) == sizeof(hasIsAlive<T>(0))); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 #define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage)
\ | 72 template <typename T> |
| 73 do {
\ | 73 struct IsGarbageCollectedType { |
| 74 typedef typename WTF::RemoveConst<T>::Type NonConstType;
\ | 74 typedef typename WTF::RemoveConst<T>::Type NonConstType; |
| 75 typedef WTF::IsSubclassOfTemplate<NonConstType, GarbageCollected> Garbag
eCollectedSubclass; \ | 75 typedef WTF::IsSubclassOfTemplate<NonConstType, GarbageCollected> GarbageCol
lectedSubclass; |
| 76 typedef IsGarbageCollectedMixin<NonConstType> GarbageCollectedMixinSubcl
ass; \ | 76 typedef IsGarbageCollectedMixin<NonConstType> GarbageCollectedMixinSubclass; |
| 77 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashSet> HeapHashSe
tSubclass; \ | 77 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashSet> HeapHashSetSub
class; |
| 78 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapLinkedHashSet> Heap
LinkedHashSetSubclass; \ | 78 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapLinkedHashSet> HeapLink
edHashSetSubclass; |
| 79 typedef WTF::IsSubclassOfTemplateTypenameSizeTypename<NonConstType, Heap
ListHashSet> HeapListHashSetSubclass; \ | 79 typedef WTF::IsSubclassOfTemplateTypenameSizeTypename<NonConstType, HeapList
HashSet> HeapListHashSetSubclass; |
| 80 typedef WTF::IsSubclassOfTemplate5<NonConstType, HeapHashMap> HeapHashMa
pSubclass; \ | 80 typedef WTF::IsSubclassOfTemplate5<NonConstType, HeapHashMap> HeapHashMapSub
class; |
| 81 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapVector>
HeapVectorSubclass; \ | 81 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapVector> Heap
VectorSubclass; |
| 82 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapDeque> H
eapDequeSubclass; \ | 82 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapDeque> HeapD
equeSubclass; |
| 83 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashCountedSet> Hea
pHashCountedSetSubclass; \ | 83 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashCountedSet> HeapHas
hCountedSetSubclass; |
| 84 typedef WTF::IsSubclassOfTemplate<NonConstType, HeapTerminatedArray> Hea
pTerminatedArraySubclass; \ | 84 typedef WTF::IsSubclassOfTemplate<NonConstType, HeapTerminatedArray> HeapTer
minatedArraySubclass; |
| 85 COMPILE_ASSERT(GarbageCollectedSubclass::value ||
\ | 85 static const bool value = |
| 86 GarbageCollectedMixinSubclass::value ||
\ | 86 GarbageCollectedSubclass::value |
| 87 HeapHashSetSubclass::value ||
\ | 87 || GarbageCollectedMixinSubclass::value |
| 88 HeapLinkedHashSetSubclass::value ||
\ | 88 || HeapHashSetSubclass::value |
| 89 HeapListHashSetSubclass::value ||
\ | 89 || HeapLinkedHashSetSubclass::value |
| 90 HeapHashMapSubclass::value ||
\ | 90 || HeapListHashSetSubclass::value |
| 91 HeapVectorSubclass::value ||
\ | 91 || HeapHashMapSubclass::value |
| 92 HeapDequeSubclass::value ||
\ | 92 || HeapVectorSubclass::value |
| 93 HeapHashCountedSetSubclass::value ||
\ | 93 || HeapDequeSubclass::value |
| 94 HeapTerminatedArraySubclass::value,
\ | 94 || HeapHashCountedSetSubclass::value |
| 95 ErrorMessage);
\ | 95 || HeapTerminatedArraySubclass::value; |
| 96 } while (0) | 96 }; |
| 97 |
| 98 #define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \ |
| 99 COMPILE_ASSERT(IsGarbageCollectedType<T>::value, ErrorMessage) |
| 97 | 100 |
| 98 template<typename T> class Member; | 101 template<typename T> class Member; |
| 99 | 102 |
| 100 class PersistentNode { | 103 class PersistentNode { |
| 101 public: | 104 public: |
| 102 explicit PersistentNode(TraceCallback trace) | 105 explicit PersistentNode(TraceCallback trace) |
| 103 : m_trace(trace) | 106 : m_trace(trace) |
| 104 { | 107 { |
| 105 } | 108 } |
| 106 | 109 |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 struct NeedsTracing<ListHashSetNode<T, WebCore::HeapListHashSetAllocator<T, inli
neCapacity> > *> { | 1156 struct NeedsTracing<ListHashSetNode<T, WebCore::HeapListHashSetAllocator<T, inli
neCapacity> > *> { |
| 1154 // All heap allocated node pointers need visiting to keep the nodes alive, | 1157 // All heap allocated node pointers need visiting to keep the nodes alive, |
| 1155 // regardless of whether they contain pointers to other heap allocated | 1158 // regardless of whether they contain pointers to other heap allocated |
| 1156 // objects. | 1159 // objects. |
| 1157 static const bool value = true; | 1160 static const bool value = true; |
| 1158 }; | 1161 }; |
| 1159 | 1162 |
| 1160 // For wtf/Functional.h | 1163 // For wtf/Functional.h |
| 1161 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; | 1164 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; |
| 1162 | 1165 |
| 1163 template<typename T> struct PointerParamStorageTraits<T*, false> { | 1166 template<typename T> |
| 1167 struct PointerParamStorageTraits<T*, false> { |
| 1164 typedef T* StorageType; | 1168 typedef T* StorageType; |
| 1165 | 1169 |
| 1166 static StorageType wrap(T* value) { return value; } | 1170 static StorageType wrap(T* value) { return value; } |
| 1167 static T* unwrap(const StorageType& value) { return value; } | 1171 static T* unwrap(const StorageType& value) { return value; } |
| 1168 }; | 1172 }; |
| 1169 | 1173 |
| 1170 template<typename T> struct PointerParamStorageTraits<T*, true> { | 1174 template<typename T> |
| 1175 struct PointerParamStorageTraits<T*, true> { |
| 1171 typedef WebCore::CrossThreadPersistent<T> StorageType; | 1176 typedef WebCore::CrossThreadPersistent<T> StorageType; |
| 1172 | 1177 |
| 1173 static StorageType wrap(T* value) { return value; } | 1178 static StorageType wrap(T* value) { return value; } |
| 1174 static T* unwrap(const StorageType& value) { return value.get(); } | 1179 static T* unwrap(const StorageType& value) { return value.get(); } |
| 1175 }; | 1180 }; |
| 1176 | 1181 |
| 1177 // FIXME: This doesn't support collections and const types. See | 1182 template<typename T> |
| 1178 // COMPILE_ASSERT_IS_GARBAGE_COLLECTED. | 1183 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is
GarbageCollectedType<T>::value> { |
| 1179 template<typename T> struct ParamStorageTraits<T*> : public PointerParamStorageT
raits<T*, WTF::IsSubclassOfTemplate<T, WebCore::GarbageCollected>::value || WebC
ore::IsGarbageCollectedMixin<T>::value> { | |
| 1180 }; | 1184 }; |
| 1181 | 1185 |
| 1182 // We assume RawPtr<T> is used only for garbage-collected types. | 1186 template<typename T> |
| 1183 template<typename T> struct ParamStorageTraits<RawPtr<T> > { | 1187 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web
Core::IsGarbageCollectedType<T>::value> { |
| 1184 typedef WebCore::CrossThreadPersistent<T> StorageType; | |
| 1185 | |
| 1186 static StorageType wrap(RawPtr<T> value) { return value.get(); } | |
| 1187 static T* unwrap(const StorageType& value) { return value.get(); } | |
| 1188 }; | 1188 }; |
| 1189 | 1189 |
| 1190 } // namespace WTF | 1190 } // namespace WTF |
| 1191 | 1191 |
| 1192 #endif | 1192 #endif |
| OLD | NEW |