| 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 28 matching lines...) Expand all Loading... |
| 39 #include "platform/heap/TraceTraits.h" | 39 #include "platform/heap/TraceTraits.h" |
| 40 #include "platform/heap/Visitor.h" | 40 #include "platform/heap/Visitor.h" |
| 41 #include "wtf/Functional.h" | 41 #include "wtf/Functional.h" |
| 42 #include "wtf/HashFunctions.h" | 42 #include "wtf/HashFunctions.h" |
| 43 #include "wtf/Locker.h" | 43 #include "wtf/Locker.h" |
| 44 #include "wtf/MainThread.h" | 44 #include "wtf/MainThread.h" |
| 45 #include "wtf/RawPtr.h" | 45 #include "wtf/RawPtr.h" |
| 46 #include "wtf/RefCounted.h" | 46 #include "wtf/RefCounted.h" |
| 47 #include "wtf/TypeTraits.h" | 47 #include "wtf/TypeTraits.h" |
| 48 | 48 |
| 49 #if defined(LEAK_SANITIZER) |
| 50 #include "wtf/LeakAnnotations.h" |
| 51 #endif |
| 52 |
| 49 namespace blink { | 53 namespace blink { |
| 50 | 54 |
| 51 enum WeaknessPersistentConfiguration { | 55 enum WeaknessPersistentConfiguration { |
| 52 NonWeakPersistentConfiguration, | 56 NonWeakPersistentConfiguration, |
| 53 WeakPersistentConfiguration | 57 WeakPersistentConfiguration |
| 54 }; | 58 }; |
| 55 | 59 |
| 56 enum CrossThreadnessPersistentConfiguration { | 60 enum CrossThreadnessPersistentConfiguration { |
| 57 SingleThreadPersistentConfiguration, | 61 SingleThreadPersistentConfiguration, |
| 58 CrossThreadPersistentConfiguration | 62 CrossThreadPersistentConfiguration |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return *this; | 180 return *this; |
| 177 } | 181 } |
| 178 | 182 |
| 179 template<typename U> | 183 template<typename U> |
| 180 PersistentBase& operator=(const RawPtr<U>& other) | 184 PersistentBase& operator=(const RawPtr<U>& other) |
| 181 { | 185 { |
| 182 assign(other); | 186 assign(other); |
| 183 return *this; | 187 return *this; |
| 184 } | 188 } |
| 185 | 189 |
| 190 PersistentBase* registerAsStaticReference() |
| 191 { |
| 192 #if defined(LEAK_SANITIZER) |
| 193 if (m_persistentNode) { |
| 194 ThreadState::current()->registerStaticPersistentNode(m_persistentNod
e); |
| 195 WTF_ANNOTATE_LEAKING_OBJECT_PTR(this); |
| 196 } |
| 197 #endif |
| 198 return this; |
| 199 } |
| 186 | 200 |
| 187 private: | 201 private: |
| 188 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 202 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 189 void assign(T* ptr) | 203 void assign(T* ptr) |
| 190 { | 204 { |
| 191 m_raw = ptr; | 205 m_raw = ptr; |
| 192 checkPointer(); | 206 checkPointer(); |
| 193 if (m_raw) { | 207 if (m_raw) { |
| 194 if (!m_persistentNode) | 208 if (!m_persistentNode) |
| 195 initialize(); | 209 initialize(); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 uninitialize(); | 552 uninitialize(); |
| 539 } | 553 } |
| 540 | 554 |
| 541 template<typename VisitorDispatcher> | 555 template<typename VisitorDispatcher> |
| 542 void trace(VisitorDispatcher visitor) | 556 void trace(VisitorDispatcher visitor) |
| 543 { | 557 { |
| 544 static_assert(sizeof(Collection), "Collection must be fully defined"); | 558 static_assert(sizeof(Collection), "Collection must be fully defined"); |
| 545 visitor->trace(*static_cast<Collection*>(this)); | 559 visitor->trace(*static_cast<Collection*>(this)); |
| 546 } | 560 } |
| 547 | 561 |
| 562 PersistentHeapCollectionBase* registerAsStaticReference() |
| 563 { |
| 564 #if defined(LEAK_SANITIZER) |
| 565 if (m_persistentNode) { |
| 566 ThreadState::current()->registerStaticPersistentNode(m_persistentNod
e); |
| 567 WTF_ANNOTATE_LEAKING_OBJECT_PTR(this); |
| 568 } |
| 569 #endif |
| 570 return this; |
| 571 } |
| 572 |
| 548 private: | 573 private: |
| 574 |
| 549 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 575 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 550 void initialize() | 576 void initialize() |
| 551 { | 577 { |
| 552 // FIXME: Derive affinity based on the collection. | 578 // FIXME: Derive affinity based on the collection. |
| 553 ThreadState* state = ThreadState::current(); | 579 ThreadState* state = ThreadState::current(); |
| 554 ASSERT(state->checkThread()); | 580 ASSERT(state->checkThread()); |
| 555 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi
s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap
CollectionBase<Collection>::trace>::trampoline); | 581 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi
s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap
CollectionBase<Collection>::trace>::trampoline); |
| 556 #if ENABLE(ASSERT) | 582 #if ENABLE(ASSERT) |
| 557 m_state = state; | 583 m_state = state; |
| 558 #endif | 584 #endif |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 return ptr; | 1086 return ptr; |
| 1061 } | 1087 } |
| 1062 | 1088 |
| 1063 #define USING_FAST_MALLOC_WILL_BE_REMOVED(type) // do nothing when oilpan is ena
bled. | 1089 #define USING_FAST_MALLOC_WILL_BE_REMOVED(type) // do nothing when oilpan is ena
bled. |
| 1064 #define USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(type) | 1090 #define USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(type) |
| 1065 #define DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing | 1091 #define DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing |
| 1066 #define DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing | 1092 #define DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing |
| 1067 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing | 1093 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing |
| 1068 | 1094 |
| 1069 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ | 1095 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ |
| 1070 static type* name = (new Persistent<type>(arguments))->get(); | 1096 static type* name = *(new Persistent<type>(arguments))->registerAsStaticRefe
rence(); |
| 1071 | 1097 |
| 1072 #else // !ENABLE(OILPAN) | 1098 #else // !ENABLE(OILPAN) |
| 1073 | 1099 |
| 1074 #define PassRefPtrWillBeRawPtr WTF::PassRefPtr | 1100 #define PassRefPtrWillBeRawPtr WTF::PassRefPtr |
| 1075 #define RefCountedWillBeGarbageCollected WTF::RefCounted | 1101 #define RefCountedWillBeGarbageCollected WTF::RefCounted |
| 1076 #define RefCountedWillBeGarbageCollectedFinalized WTF::RefCounted | 1102 #define RefCountedWillBeGarbageCollectedFinalized WTF::RefCounted |
| 1077 #define RefCountedWillBeRefCountedGarbageCollected WTF::RefCounted | 1103 #define RefCountedWillBeRefCountedGarbageCollected WTF::RefCounted |
| 1078 #define RefCountedGarbageCollectedWillBeGarbageCollectedFinalized blink::RefCoun
tedGarbageCollected | 1104 #define RefCountedGarbageCollectedWillBeGarbageCollectedFinalized blink::RefCoun
tedGarbageCollected |
| 1079 #define RefCountedWillBeNoBase WTF::RefCounted | 1105 #define RefCountedWillBeNoBase WTF::RefCounted |
| 1080 #define RefCountedGarbageCollectedWillBeNoBase blink::RefCountedGarbageCollected | 1106 #define RefCountedGarbageCollectedWillBeNoBase blink::RefCountedGarbageCollected |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C
rossThread)WeakPersistent. | 1533 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C
rossThread)WeakPersistent. |
| 1508 static T* unwrap(const StorageType& value) { return value.get(); } | 1534 static T* unwrap(const StorageType& value) { return value.get(); } |
| 1509 }; | 1535 }; |
| 1510 | 1536 |
| 1511 template<typename T> | 1537 template<typename T> |
| 1512 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1538 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
| 1513 | 1539 |
| 1514 } // namespace WTF | 1540 } // namespace WTF |
| 1515 | 1541 |
| 1516 #endif | 1542 #endif |
| OLD | NEW |