Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: third_party/WebKit/Source/platform/heap/Handle.h

Issue 1505003003: Revert of Release Oilpan heap singletons prior to LSan leak detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
53 namespace blink { 49 namespace blink {
54 50
55 enum WeaknessPersistentConfiguration { 51 enum WeaknessPersistentConfiguration {
56 NonWeakPersistentConfiguration, 52 NonWeakPersistentConfiguration,
57 WeakPersistentConfiguration 53 WeakPersistentConfiguration
58 }; 54 };
59 55
60 enum CrossThreadnessPersistentConfiguration { 56 enum CrossThreadnessPersistentConfiguration {
61 SingleThreadPersistentConfiguration, 57 SingleThreadPersistentConfiguration,
62 CrossThreadPersistentConfiguration 58 CrossThreadPersistentConfiguration
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return *this; 176 return *this;
181 } 177 }
182 178
183 template<typename U> 179 template<typename U>
184 PersistentBase& operator=(const RawPtr<U>& other) 180 PersistentBase& operator=(const RawPtr<U>& other)
185 { 181 {
186 assign(other); 182 assign(other);
187 return *this; 183 return *this;
188 } 184 }
189 185
190 #if defined(LEAK_SANITIZER)
191 PersistentBase* registerAsStaticReference()
192 {
193 if (m_persistentNode) {
194 ASSERT(ThreadState::current());
195 ThreadState::current()->registerStaticPersistentNode(m_persistentNod e);
196 LEAK_SANITIZER_IGNORE_OBJECT(this);
197 }
198 return this;
199 }
200 #endif
201 186
202 private: 187 private:
203 NO_LAZY_SWEEP_SANITIZE_ADDRESS 188 NO_LAZY_SWEEP_SANITIZE_ADDRESS
204 void assign(T* ptr) 189 void assign(T* ptr)
205 { 190 {
206 m_raw = ptr; 191 m_raw = ptr;
207 checkPointer(); 192 checkPointer();
208 if (m_raw) { 193 if (m_raw) {
209 if (!m_persistentNode) 194 if (!m_persistentNode)
210 initialize(); 195 initialize();
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 uninitialize(); 538 uninitialize();
554 } 539 }
555 540
556 template<typename VisitorDispatcher> 541 template<typename VisitorDispatcher>
557 void trace(VisitorDispatcher visitor) 542 void trace(VisitorDispatcher visitor)
558 { 543 {
559 static_assert(sizeof(Collection), "Collection must be fully defined"); 544 static_assert(sizeof(Collection), "Collection must be fully defined");
560 visitor->trace(*static_cast<Collection*>(this)); 545 visitor->trace(*static_cast<Collection*>(this));
561 } 546 }
562 547
563 #if defined(LEAK_SANITIZER)
564 PersistentHeapCollectionBase* registerAsStaticReference()
565 {
566 if (m_persistentNode) {
567 ASSERT(ThreadState::current());
568 ThreadState::current()->registerStaticPersistentNode(m_persistentNod e);
569 LEAK_SANITIZER_IGNORE_OBJECT(this);
570 }
571 return this;
572 }
573 #endif
574
575 private: 548 private:
576
577 NO_LAZY_SWEEP_SANITIZE_ADDRESS 549 NO_LAZY_SWEEP_SANITIZE_ADDRESS
578 void initialize() 550 void initialize()
579 { 551 {
580 // FIXME: Derive affinity based on the collection. 552 // FIXME: Derive affinity based on the collection.
581 ThreadState* state = ThreadState::current(); 553 ThreadState* state = ThreadState::current();
582 ASSERT(state->checkThread()); 554 ASSERT(state->checkThread());
583 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap CollectionBase<Collection>::trace>::trampoline); 555 m_persistentNode = state->persistentRegion()->allocatePersistentNode(thi s, TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, &PersistentHeap CollectionBase<Collection>::trace>::trampoline);
584 #if ENABLE(ASSERT) 556 #if ENABLE(ASSERT)
585 m_state = state; 557 m_state = state;
586 #endif 558 #endif
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 return ptr; 1060 return ptr;
1089 } 1061 }
1090 1062
1091 #define USING_FAST_MALLOC_WILL_BE_REMOVED(type) // do nothing when oilpan is ena bled. 1063 #define USING_FAST_MALLOC_WILL_BE_REMOVED(type) // do nothing when oilpan is ena bled.
1092 #define USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(type) 1064 #define USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(type)
1093 #define DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing 1065 #define DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing
1094 #define DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing 1066 #define DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing
1095 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing 1067 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing
1096 1068
1097 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ 1069 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \
1098 static type* name = *(new Persistent<type>(arguments))->registerAsStaticRefe rence(); 1070 static type* name = (new Persistent<type>(arguments))->get();
1099 1071
1100 #else // !ENABLE(OILPAN) 1072 #else // !ENABLE(OILPAN)
1101 1073
1102 #define PassRefPtrWillBeRawPtr WTF::PassRefPtr 1074 #define PassRefPtrWillBeRawPtr WTF::PassRefPtr
1103 #define RefCountedWillBeGarbageCollected WTF::RefCounted 1075 #define RefCountedWillBeGarbageCollected WTF::RefCounted
1104 #define RefCountedWillBeGarbageCollectedFinalized WTF::RefCounted 1076 #define RefCountedWillBeGarbageCollectedFinalized WTF::RefCounted
1105 #define RefCountedWillBeRefCountedGarbageCollected WTF::RefCounted 1077 #define RefCountedWillBeRefCountedGarbageCollected WTF::RefCounted
1106 #define RefCountedGarbageCollectedWillBeGarbageCollectedFinalized blink::RefCoun tedGarbageCollected 1078 #define RefCountedGarbageCollectedWillBeGarbageCollectedFinalized blink::RefCoun tedGarbageCollected
1107 #define RefCountedWillBeNoBase WTF::RefCounted 1079 #define RefCountedWillBeNoBase WTF::RefCounted
1108 #define RefCountedGarbageCollectedWillBeNoBase blink::RefCountedGarbageCollected 1080 #define RefCountedGarbageCollectedWillBeNoBase blink::RefCountedGarbageCollected
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 template<typename T> 1259 template<typename T>
1288 class AllowCrossThreadWeakPersistent { 1260 class AllowCrossThreadWeakPersistent {
1289 STACK_ALLOCATED(); 1261 STACK_ALLOCATED();
1290 public: 1262 public:
1291 explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { } 1263 explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { }
1292 CrossThreadWeakPersistent<T> value() const { return m_value; } 1264 CrossThreadWeakPersistent<T> value() const { return m_value; }
1293 private: 1265 private:
1294 CrossThreadWeakPersistent<T> m_value; 1266 CrossThreadWeakPersistent<T> m_value;
1295 }; 1267 };
1296 1268
1297 // LEAK_SANITIZER_DISABLED_SCOPE: all allocations made in the current scope
1298 // will be exempted from LSan consideration.
1299 //
1300 // TODO(sof): move this to wtf/LeakAnnotations.h (LeakSanitizer.h?) once
1301 // wtf/ can freely call upon Oilpan functionality.
1302 #if defined(LEAK_SANITIZER)
1303 class LeakSanitizerDisableScope {
1304 STACK_ALLOCATED();
1305 WTF_MAKE_NONCOPYABLE(LeakSanitizerDisableScope);
1306 public:
1307 LeakSanitizerDisableScope()
1308 {
1309 __lsan_disable();
1310 if (ThreadState::current())
1311 ThreadState::current()->enterStaticReferenceRegistrationDisabledScop e();
1312 }
1313
1314 ~LeakSanitizerDisableScope()
1315 {
1316 __lsan_enable();
1317 if (ThreadState::current())
1318 ThreadState::current()->leaveStaticReferenceRegistrationDisabledScop e();
1319 }
1320 };
1321 #define LEAK_SANITIZER_DISABLED_SCOPE LeakSanitizerDisableScope lsanDisabledScop e
1322 #else
1323 #define LEAK_SANITIZER_DISABLED_SCOPE
1324 #endif
1325
1326 } // namespace blink 1269 } // namespace blink
1327 1270
1328 namespace WTF { 1271 namespace WTF {
1329 1272
1330 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b link::Member<T>> { 1273 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b link::Member<T>> {
1331 static const bool needsDestruction = false; 1274 static const bool needsDestruction = false;
1332 static const bool canInitializeWithMemset = true; 1275 static const bool canInitializeWithMemset = true;
1333 static const bool canClearUnusedSlotsWithMemset = true; 1276 static const bool canClearUnusedSlotsWithMemset = true;
1334 static const bool canMoveWithMemcpy = true; 1277 static const bool canMoveWithMemcpy = true;
1335 }; 1278 };
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent. 1507 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent.
1565 static T* unwrap(const StorageType& value) { return value.get(); } 1508 static T* unwrap(const StorageType& value) { return value.get(); }
1566 }; 1509 };
1567 1510
1568 template<typename T> 1511 template<typename T>
1569 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1512 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1570 1513
1571 } // namespace WTF 1514 } // namespace WTF
1572 1515
1573 #endif 1516 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp ('k') | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698