| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 CrossThreadWeakPersistent(T& raw) : Parent(raw) { } | 350 CrossThreadWeakPersistent(T& raw) : Parent(raw) { } |
| 351 CrossThreadWeakPersistent(const CrossThreadWeakPersistent& other) : Parent(o
ther) { } | 351 CrossThreadWeakPersistent(const CrossThreadWeakPersistent& other) : Parent(o
ther) { } |
| 352 template<typename U> | 352 template<typename U> |
| 353 CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Paren
t(other) { } | 353 CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Paren
t(other) { } |
| 354 template<typename U> | 354 template<typename U> |
| 355 CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { } | 355 CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { } |
| 356 template<typename U> | 356 template<typename U> |
| 357 CrossThreadWeakPersistent(const RawPtr<U>& other) : Parent(other.get()) { } | 357 CrossThreadWeakPersistent(const RawPtr<U>& other) : Parent(other.get()) { } |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 // PersistentNode must be the left-most class to let the | |
| 361 // visitor->trace(static_cast<Collection*>(this)) trace the correct position. | |
| 362 // FIXME: derive affinity based on the collection. | |
| 363 template<typename Collection> | 360 template<typename Collection> |
| 364 class PersistentHeapCollectionBase : public Collection { | 361 class PersistentHeapCollectionBase : public Collection { |
| 365 // We overload the various new and delete operators with using the WTF Defau
ltAllocator to ensure persistent | 362 // We overload the various new and delete operators with using the WTF Defau
ltAllocator to ensure persistent |
| 366 // heap collections are always allocated off-heap. This allows persistent co
llections to be used in | 363 // heap collections are always allocated off-heap. This allows persistent co
llections to be used in |
| 367 // DEFINE_STATIC_LOCAL et. al. | 364 // DEFINE_STATIC_LOCAL et. al. |
| 368 WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::DefaultAllocator); | 365 WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::DefaultAllocator); |
| 369 public: | 366 public: |
| 370 PersistentHeapCollectionBase() | 367 PersistentHeapCollectionBase() |
| 371 { | 368 { |
| 372 initialize(); | 369 initialize(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 392 void trace(VisitorDispatcher visitor) | 389 void trace(VisitorDispatcher visitor) |
| 393 { | 390 { |
| 394 static_assert(sizeof(Collection), "Collection must be fully defined"); | 391 static_assert(sizeof(Collection), "Collection must be fully defined"); |
| 395 visitor->trace(*static_cast<Collection*>(this)); | 392 visitor->trace(*static_cast<Collection*>(this)); |
| 396 } | 393 } |
| 397 | 394 |
| 398 private: | 395 private: |
| 399 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 396 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 400 void initialize() | 397 void initialize() |
| 401 { | 398 { |
| 399 // FIXME: Derive affinity based on the collection. |
| 402 ThreadState* state = ThreadState::current(); | 400 ThreadState* state = ThreadState::current(); |
| 403 ASSERT(state->checkThread()); | 401 ASSERT(state->checkThread()); |
| 404 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi
s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap
CollectionBase<Collection>::trace>::trampoline); | 402 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi
s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap
CollectionBase<Collection>::trace>::trampoline); |
| 405 state->persistentAllocated(); | 403 state->persistentAllocated(); |
| 406 #if ENABLE(ASSERT) | 404 #if ENABLE(ASSERT) |
| 407 m_state = state; | 405 m_state = state; |
| 408 #endif | 406 #endif |
| 409 } | 407 } |
| 410 | 408 |
| 411 void uninitialize() | 409 void uninitialize() |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
k::IsGarbageCollectedType<T>::value> { | 1178 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
k::IsGarbageCollectedType<T>::value> { |
| 1181 static_assert(sizeof(T), "T must be fully defined"); | 1179 static_assert(sizeof(T), "T must be fully defined"); |
| 1182 }; | 1180 }; |
| 1183 | 1181 |
| 1184 template<typename T> | 1182 template<typename T> |
| 1185 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1183 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
| 1186 | 1184 |
| 1187 } // namespace WTF | 1185 } // namespace WTF |
| 1188 | 1186 |
| 1189 #endif | 1187 #endif |
| OLD | NEW |