| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ASSERT(isAlive()); | 185 ASSERT(isAlive()); |
| 186 ASSERT(m_next->isAlive()); | 186 ASSERT(m_next->isAlive()); |
| 187 ASSERT(m_prev->isAlive()); | 187 ASSERT(m_prev->isAlive()); |
| 188 m_next->m_prev = m_prev; | 188 m_next->m_prev = m_prev; |
| 189 m_prev->m_next = m_next; | 189 m_prev->m_next = m_next; |
| 190 } | 190 } |
| 191 | 191 |
| 192 protected: | 192 protected: |
| 193 inline PersistentBase() | 193 inline PersistentBase() |
| 194 : PersistentNode(TraceMethodDelegate<Owner, &Owner::trace>::trampoline) | 194 : PersistentNode(TraceMethodDelegate<Owner, &Owner::trace>::trampoline) |
| 195 #ifndef NDEBUG | 195 #if ENABLE(ASSERT) |
| 196 , m_roots(RootsAccessor::roots()) | 196 , m_roots(RootsAccessor::roots()) |
| 197 #endif | 197 #endif |
| 198 { | 198 { |
| 199 typename RootsAccessor::Lock lock; | 199 typename RootsAccessor::Lock lock; |
| 200 m_prev = RootsAccessor::roots(); | 200 m_prev = RootsAccessor::roots(); |
| 201 m_next = m_prev->m_next; | 201 m_next = m_prev->m_next; |
| 202 m_prev->m_next = this; | 202 m_prev->m_next = this; |
| 203 m_next->m_prev = this; | 203 m_next->m_prev = this; |
| 204 } | 204 } |
| 205 | 205 |
| 206 inline explicit PersistentBase(const PersistentBase& otherref) | 206 inline explicit PersistentBase(const PersistentBase& otherref) |
| 207 : PersistentNode(otherref.m_trace) | 207 : PersistentNode(otherref.m_trace) |
| 208 #ifndef NDEBUG | 208 #if ENABLE(ASSERT) |
| 209 , m_roots(RootsAccessor::roots()) | 209 , m_roots(RootsAccessor::roots()) |
| 210 #endif | 210 #endif |
| 211 { | 211 { |
| 212 typename RootsAccessor::Lock lock; | 212 typename RootsAccessor::Lock lock; |
| 213 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same
list. | 213 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same
list. |
| 214 PersistentBase* other = const_cast<PersistentBase*>(&otherref); | 214 PersistentBase* other = const_cast<PersistentBase*>(&otherref); |
| 215 m_prev = other; | 215 m_prev = other; |
| 216 m_next = other->m_next; | 216 m_next = other->m_next; |
| 217 other->m_next = this; | 217 other->m_next = this; |
| 218 m_next->m_prev = this; | 218 m_next->m_prev = this; |
| 219 } | 219 } |
| 220 | 220 |
| 221 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t
his; } | 221 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t
his; } |
| 222 | 222 |
| 223 #ifndef NDEBUG | 223 #if ENABLE(ASSERT) |
| 224 private: | 224 private: |
| 225 PersistentNode* m_roots; | 225 PersistentNode* m_roots; |
| 226 #endif | 226 #endif |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 // A dummy Persistent handle that ensures the list of persistents is never null. | 229 // A dummy Persistent handle that ensures the list of persistents is never null. |
| 230 // This removes a test from a hot path. | 230 // This removes a test from a hot path. |
| 231 class PersistentAnchor : public PersistentNode { | 231 class PersistentAnchor : public PersistentNode { |
| 232 public: | 232 public: |
| 233 void trace(Visitor* visitor) | 233 void trace(Visitor* visitor) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 247 private: | 247 private: |
| 248 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P
ersistentAnchor::trace>::trampoline) | 248 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P
ersistentAnchor::trace>::trampoline) |
| 249 { | 249 { |
| 250 m_next = this; | 250 m_next = this; |
| 251 m_prev = this; | 251 m_prev = this; |
| 252 } | 252 } |
| 253 | 253 |
| 254 friend class ThreadState; | 254 friend class ThreadState; |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 #ifndef NDEBUG | 257 #if ENABLE(ASSERT) |
| 258 // For global persistent handles we cannot check that the | 258 // For global persistent handles we cannot check that the |
| 259 // pointer is in the heap because that would involve | 259 // pointer is in the heap because that would involve |
| 260 // inspecting the heap of running threads. | 260 // inspecting the heap of running threads. |
| 261 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) \ | 261 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) \ |
| 262 bool isGlobalPersistent = WTF::IsSubclass<RootsAccessor, GlobalPersistents>:
:value; \ | 262 bool isGlobalPersistent = WTF::IsSubclass<RootsAccessor, GlobalPersistents>:
:value; \ |
| 263 ASSERT(!pointer || isGlobalPersistent || ThreadStateFor<ThreadingTrait<T>::A
ffinity>::state()->contains(pointer)) | 263 ASSERT(!pointer || isGlobalPersistent || ThreadStateFor<ThreadingTrait<T>::A
ffinity>::state()->contains(pointer)) |
| 264 #else | 264 #else |
| 265 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) | 265 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) |
| 266 #endif | 266 #endif |
| 267 | 267 |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is
GarbageCollectedType<T>::value> { | 1163 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is
GarbageCollectedType<T>::value> { |
| 1164 }; | 1164 }; |
| 1165 | 1165 |
| 1166 template<typename T> | 1166 template<typename T> |
| 1167 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web
Core::IsGarbageCollectedType<T>::value> { | 1167 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web
Core::IsGarbageCollectedType<T>::value> { |
| 1168 }; | 1168 }; |
| 1169 | 1169 |
| 1170 } // namespace WTF | 1170 } // namespace WTF |
| 1171 | 1171 |
| 1172 #endif | 1172 #endif |
| OLD | NEW |