| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // We have to construct and destruct Persistent in the same thread. | 217 // We have to construct and destruct Persistent in the same thread. |
| 218 template<typename T> | 218 template<typename T> |
| 219 class Persistent : public PersistentBase<ThreadLocalPersistents<ThreadingTrait<T
>::Affinity>, Persistent<T>> { | 219 class Persistent : public PersistentBase<ThreadLocalPersistents<ThreadingTrait<T
>::Affinity>, Persistent<T>> { |
| 220 public: | 220 public: |
| 221 Persistent() : m_raw(nullptr) { } | 221 Persistent() : m_raw(nullptr) { } |
| 222 | 222 |
| 223 Persistent(std::nullptr_t) : m_raw(nullptr) { } | 223 Persistent(std::nullptr_t) : m_raw(nullptr) { } |
| 224 | 224 |
| 225 Persistent(T* raw) : m_raw(raw) | 225 Persistent(T* raw) : m_raw(raw) |
| 226 { | 226 { |
| 227 ASSERT(!m_raw || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->f
indPageFromAddress(m_raw)); | 227 checkPointer(); |
| 228 recordBacktrace(); | 228 recordBacktrace(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 explicit Persistent(T& raw) : m_raw(&raw) | 231 explicit Persistent(T& raw) : m_raw(&raw) |
| 232 { | 232 { |
| 233 ASSERT(!m_raw || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->f
indPageFromAddress(m_raw)); | 233 checkPointer(); |
| 234 recordBacktrace(); | 234 recordBacktrace(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 Persistent(const Persistent& other) : m_raw(other) { recordBacktrace(); } | 237 Persistent(const Persistent& other) : m_raw(other) |
| 238 { |
| 239 checkPointer(); |
| 240 recordBacktrace(); |
| 241 } |
| 238 | 242 |
| 239 template<typename U> | 243 template<typename U> |
| 240 Persistent(const Persistent<U>& other) : m_raw(other) { recordBacktrace(); } | 244 Persistent(const Persistent<U>& other) : m_raw(other) |
| 245 { |
| 246 checkPointer(); |
| 247 recordBacktrace(); |
| 248 } |
| 241 | 249 |
| 242 template<typename U> | 250 template<typename U> |
| 243 Persistent(const Member<U>& other) : m_raw(other) { recordBacktrace(); } | 251 Persistent(const Member<U>& other) : m_raw(other) |
| 252 { |
| 253 checkPointer(); |
| 254 recordBacktrace(); |
| 255 } |
| 244 | 256 |
| 245 template<typename U> | 257 template<typename U> |
| 246 Persistent(const RawPtr<U>& other) : m_raw(other.get()) { recordBacktrace();
} | 258 Persistent(const RawPtr<U>& other) : m_raw(other.get()) |
| 247 | |
| 248 template<typename U> | |
| 249 Persistent& operator=(U* other) | |
| 250 { | 259 { |
| 251 m_raw = other; | 260 checkPointer(); |
| 252 recordBacktrace(); | 261 recordBacktrace(); |
| 253 return *this; | |
| 254 } | |
| 255 | |
| 256 Persistent& operator=(std::nullptr_t) | |
| 257 { | |
| 258 m_raw = nullptr; | |
| 259 return *this; | |
| 260 } | 262 } |
| 261 | 263 |
| 262 void clear() { m_raw = nullptr; } | 264 void clear() { m_raw = nullptr; } |
| 263 | 265 |
| 264 virtual ~Persistent() | 266 virtual ~Persistent() |
| 265 { | 267 { |
| 266 m_raw = nullptr; | 268 m_raw = nullptr; |
| 267 } | 269 } |
| 268 | 270 |
| 269 template<typename VisitorDispatcher> | 271 template<typename VisitorDispatcher> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 286 | 288 |
| 287 T& operator*() const { return *m_raw; } | 289 T& operator*() const { return *m_raw; } |
| 288 | 290 |
| 289 bool operator!() const { return !m_raw; } | 291 bool operator!() const { return !m_raw; } |
| 290 | 292 |
| 291 operator T*() const { return m_raw; } | 293 operator T*() const { return m_raw; } |
| 292 operator RawPtr<T>() const { return m_raw; } | 294 operator RawPtr<T>() const { return m_raw; } |
| 293 | 295 |
| 294 T* operator->() const { return *this; } | 296 T* operator->() const { return *this; } |
| 295 | 297 |
| 298 template<typename U> |
| 299 Persistent& operator=(U* other) |
| 300 { |
| 301 m_raw = other; |
| 302 checkPointer(); |
| 303 recordBacktrace(); |
| 304 return *this; |
| 305 } |
| 306 |
| 307 Persistent& operator=(std::nullptr_t) |
| 308 { |
| 309 m_raw = nullptr; |
| 310 return *this; |
| 311 } |
| 312 |
| 296 Persistent& operator=(const Persistent& other) | 313 Persistent& operator=(const Persistent& other) |
| 297 { | 314 { |
| 298 m_raw = other; | 315 m_raw = other; |
| 316 checkPointer(); |
| 299 recordBacktrace(); | 317 recordBacktrace(); |
| 300 return *this; | 318 return *this; |
| 301 } | 319 } |
| 302 | 320 |
| 303 template<typename U> | 321 template<typename U> |
| 304 Persistent& operator=(const Persistent<U>& other) | 322 Persistent& operator=(const Persistent<U>& other) |
| 305 { | 323 { |
| 306 m_raw = other; | 324 m_raw = other; |
| 325 checkPointer(); |
| 307 recordBacktrace(); | 326 recordBacktrace(); |
| 308 return *this; | 327 return *this; |
| 309 } | 328 } |
| 310 | 329 |
| 311 template<typename U> | 330 template<typename U> |
| 312 Persistent& operator=(const Member<U>& other) | 331 Persistent& operator=(const Member<U>& other) |
| 313 { | 332 { |
| 314 m_raw = other; | 333 m_raw = other; |
| 334 checkPointer(); |
| 315 recordBacktrace(); | 335 recordBacktrace(); |
| 316 return *this; | 336 return *this; |
| 317 } | 337 } |
| 318 | 338 |
| 319 template<typename U> | 339 template<typename U> |
| 320 Persistent& operator=(const RawPtr<U>& other) | 340 Persistent& operator=(const RawPtr<U>& other) |
| 321 { | 341 { |
| 322 m_raw = other; | 342 m_raw = other; |
| 343 checkPointer(); |
| 323 recordBacktrace(); | 344 recordBacktrace(); |
| 324 return *this; | 345 return *this; |
| 325 } | 346 } |
| 326 | 347 |
| 327 T* get() const { return m_raw; } | 348 T* get() const { return m_raw; } |
| 328 | 349 |
| 329 private: | 350 private: |
| 351 void checkPointer() |
| 352 { |
| 353 ASSERT(!m_raw || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->f
indPageFromAddress(m_raw)); |
| 354 } |
| 355 |
| 330 #if ENABLE(GC_PROFILING) | 356 #if ENABLE(GC_PROFILING) |
| 331 void recordBacktrace() | 357 void recordBacktrace() |
| 332 { | 358 { |
| 333 if (m_raw) | 359 if (m_raw) |
| 334 m_tracingName = Heap::createBacktraceString(); | 360 m_tracingName = Heap::createBacktraceString(); |
| 335 } | 361 } |
| 336 | 362 |
| 337 String m_tracingName; | 363 String m_tracingName; |
| 338 #else | 364 #else |
| 339 inline void recordBacktrace() const { } | 365 inline void recordBacktrace() const { } |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
k::IsGarbageCollectedType<T>::value> { | 1164 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
k::IsGarbageCollectedType<T>::value> { |
| 1139 static_assert(sizeof(T), "T must be fully defined"); | 1165 static_assert(sizeof(T), "T must be fully defined"); |
| 1140 }; | 1166 }; |
| 1141 | 1167 |
| 1142 template<typename T> | 1168 template<typename T> |
| 1143 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1169 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
| 1144 | 1170 |
| 1145 } // namespace WTF | 1171 } // namespace WTF |
| 1146 | 1172 |
| 1147 #endif | 1173 #endif |
| OLD | NEW |