Chromium Code Reviews| Index: third_party/WebKit/Source/platform/heap/Handle.h |
| diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h |
| index 9ef17dedb23ab35406e19a1e1e774f52269c40af..7cc5f242837abcd2e596f3f9fc79a36532bbec0e 100644 |
| --- a/third_party/WebKit/Source/platform/heap/Handle.h |
| +++ b/third_party/WebKit/Source/platform/heap/Handle.h |
| @@ -46,6 +46,10 @@ |
| #include "wtf/RefCounted.h" |
| #include "wtf/TypeTraits.h" |
| +#if defined(LEAK_SANITIZER) |
| +#include "wtf/LeakAnnotations.h" |
| +#endif |
| + |
| namespace blink { |
| enum WeaknessPersistentConfiguration { |
| @@ -183,6 +187,16 @@ public: |
| return *this; |
| } |
| +#if defined(LEAK_SANITIZER) |
| + PersistentBase* registerAsStaticReference() |
| + { |
| + if (m_persistentNode) { |
| + ThreadState::current()->registerStaticPersistentNode(m_persistentNode); |
| + WTF_ANNOTATE_LEAK_IGNORE_OBJECT(this); |
| + } |
| + return this; |
| + } |
| +#endif |
| private: |
| NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| @@ -545,7 +559,19 @@ public: |
| visitor->trace(*static_cast<Collection*>(this)); |
| } |
| +#if defined(LEAK_SANITIZER) |
| + PersistentHeapCollectionBase* registerAsStaticReference() |
| + { |
| + if (m_persistentNode) { |
| + ThreadState::current()->registerStaticPersistentNode(m_persistentNode); |
| + WTF_ANNOTATE_LEAK_IGNORE_OBJECT(this); |
| + } |
| + return this; |
| + } |
| +#endif |
| + |
| private: |
| + |
| NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| void initialize() |
| { |
| @@ -1067,7 +1093,7 @@ template<typename T> T* adoptPtrWillBeNoop(T* ptr) |
| #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing |
| #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ |
| - static type* name = (new Persistent<type>(arguments))->get(); |
| + static type* name = *(new Persistent<type>(arguments))->registerAsStaticReference(); |
| #else // !ENABLE(OILPAN) |
| @@ -1266,6 +1292,24 @@ private: |
| CrossThreadWeakPersistent<T> m_value; |
| }; |
| +#if defined(LEAK_SANITIZER) |
| +class StaticReferenceDisableScope { |
| +public: |
| + StaticReferenceDisableScope() |
| + { |
| + ThreadState::current()->enterDisabledStaticReferenceRegistrationScope(); |
|
haraken
2015/12/06 23:56:21
Can we add an if(ThreadState::current()) check? Th
sof
2015/12/07 07:18:19
Yes, that would be preferable. But wtf/LeakAnnotat
haraken
2015/12/07 07:23:36
Yeah, the dependency issue between platform/ and w
|
| + } |
| + |
| + ~StaticReferenceDisableScope() |
| + { |
| + ThreadState::current()->exitDisabledStaticReferenceRegistrationScope(); |
| + } |
| +}; |
| +#define LSAN_LEAK_SCOPE StaticReferenceDisableScope staticRefScope; WTF_ANNOTATE_LEAK_SCOPE |
| +#else |
| +#define LSAN_LEAK_SCOPE |
| +#endif |
| + |
| } // namespace blink |
| namespace WTF { |