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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 ASSERT(!m_persistentNode); | 238 ASSERT(!m_persistentNode); |
239 if (!m_raw) | 239 if (!m_raw) |
240 return; | 240 return; |
241 | 241 |
242 TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weak
nessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessCon
figuration, crossThreadnessConfiguration>::trace>::trampoline; | 242 TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weak
nessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessCon
figuration, crossThreadnessConfiguration>::trace>::trampoline; |
243 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
{ | 243 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
{ |
244 m_persistentNode = Heap::crossThreadPersistentRegion().allocatePersi
stentNode(this, traceCallback); | 244 m_persistentNode = Heap::crossThreadPersistentRegion().allocatePersi
stentNode(this, traceCallback); |
245 } else { | 245 } else { |
246 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::st
ate(); | 246 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::st
ate(); |
247 ASSERT(state->checkThread()); | 247 ASSERT(state->checkThread()); |
248 m_persistentNode = state->persistentRegion()->allocatePersistentNode
(this, traceCallback); | 248 m_persistentNode = state->getPersistentRegion()->allocatePersistentN
ode(this, traceCallback); |
249 #if ENABLE(ASSERT) | 249 #if ENABLE(ASSERT) |
250 m_state = state; | 250 m_state = state; |
251 #endif | 251 #endif |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 void uninitialize() | 255 void uninitialize() |
256 { | 256 { |
257 if (!m_persistentNode) | 257 if (!m_persistentNode) |
258 return; | 258 return; |
259 | 259 |
260 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
{ | 260 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
{ |
261 Heap::crossThreadPersistentRegion().freePersistentNode(m_persistentN
ode); | 261 Heap::crossThreadPersistentRegion().freePersistentNode(m_persistentN
ode); |
262 } else { | 262 } else { |
263 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::st
ate(); | 263 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::st
ate(); |
264 ASSERT(state->checkThread()); | 264 ASSERT(state->checkThread()); |
265 // Persistent handle must be created and destructed in the same thre
ad. | 265 // Persistent handle must be created and destructed in the same thre
ad. |
266 ASSERT(m_state == state); | 266 ASSERT(m_state == state); |
267 state->persistentRegion()->freePersistentNode(m_persistentNode); | 267 state->getPersistentRegion()->freePersistentNode(m_persistentNode); |
268 } | 268 } |
269 m_persistentNode = nullptr; | 269 m_persistentNode = nullptr; |
270 } | 270 } |
271 | 271 |
272 void checkPointer() | 272 void checkPointer() |
273 { | 273 { |
274 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) | 274 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) |
275 if (!m_raw) | 275 if (!m_raw) |
276 return; | 276 return; |
277 | 277 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 #endif | 594 #endif |
595 | 595 |
596 private: | 596 private: |
597 | 597 |
598 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 598 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
599 void initialize() | 599 void initialize() |
600 { | 600 { |
601 // FIXME: Derive affinity based on the collection. | 601 // FIXME: Derive affinity based on the collection. |
602 ThreadState* state = ThreadState::current(); | 602 ThreadState* state = ThreadState::current(); |
603 ASSERT(state->checkThread()); | 603 ASSERT(state->checkThread()); |
604 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi
s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap
CollectionBase<Collection>::trace>::trampoline); | 604 m_persistentNode = state->getPersistentRegion()->allocatePersistentNode(
this, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentH
eapCollectionBase<Collection>::trace>::trampoline); |
605 #if ENABLE(ASSERT) | 605 #if ENABLE(ASSERT) |
606 m_state = state; | 606 m_state = state; |
607 #endif | 607 #endif |
608 } | 608 } |
609 | 609 |
610 void uninitialize() | 610 void uninitialize() |
611 { | 611 { |
612 ThreadState* state = ThreadState::current(); | 612 ThreadState* state = ThreadState::current(); |
613 ASSERT(state->checkThread()); | 613 ASSERT(state->checkThread()); |
614 // Persistent handle must be created and destructed in the same thread. | 614 // Persistent handle must be created and destructed in the same thread. |
615 ASSERT(m_state == state); | 615 ASSERT(m_state == state); |
616 state->persistentRegion()->freePersistentNode(m_persistentNode); | 616 state->getPersistentRegion()->freePersistentNode(m_persistentNode); |
617 } | 617 } |
618 | 618 |
619 PersistentNode* m_persistentNode; | 619 PersistentNode* m_persistentNode; |
620 #if ENABLE(ASSERT) | 620 #if ENABLE(ASSERT) |
621 ThreadState* m_state; | 621 ThreadState* m_state; |
622 #endif | 622 #endif |
623 }; | 623 }; |
624 | 624 |
625 template< | 625 template< |
626 typename KeyArg, | 626 typename KeyArg, |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 // into it. | 1492 // into it. |
1493 // | 1493 // |
1494 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like | 1494 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like |
1495 // CrossThreadWeakPersistent<>. | 1495 // CrossThreadWeakPersistent<>. |
1496 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } | 1496 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } |
1497 }; | 1497 }; |
1498 | 1498 |
1499 } // namespace WTF | 1499 } // namespace WTF |
1500 | 1500 |
1501 #endif | 1501 #endif |
OLD | NEW |