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

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

Issue 1609943003: Make platform/heap to use USING_FAST_MALLOC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compile error Created 4 years, 11 months 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 20 matching lines...) Expand all
31 #ifndef Handle_h 31 #ifndef Handle_h
32 #define Handle_h 32 #define Handle_h
33 33
34 #include "platform/heap/Heap.h" 34 #include "platform/heap/Heap.h"
35 #include "platform/heap/HeapAllocator.h" 35 #include "platform/heap/HeapAllocator.h"
36 #include "platform/heap/InlinedGlobalMarkingVisitor.h" 36 #include "platform/heap/InlinedGlobalMarkingVisitor.h"
37 #include "platform/heap/PersistentNode.h" 37 #include "platform/heap/PersistentNode.h"
38 #include "platform/heap/ThreadState.h" 38 #include "platform/heap/ThreadState.h"
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/Allocator.h"
41 #include "wtf/Functional.h" 42 #include "wtf/Functional.h"
42 #include "wtf/HashFunctions.h" 43 #include "wtf/HashFunctions.h"
43 #include "wtf/Locker.h" 44 #include "wtf/Locker.h"
44 #include "wtf/MainThread.h" 45 #include "wtf/MainThread.h"
45 #include "wtf/RawPtr.h" 46 #include "wtf/RawPtr.h"
46 #include "wtf/RefCounted.h" 47 #include "wtf/RefCounted.h"
47 #include "wtf/TypeTraits.h" 48 #include "wtf/TypeTraits.h"
48 49
49 #if defined(LEAK_SANITIZER) 50 #if defined(LEAK_SANITIZER)
50 #include "wtf/LeakAnnotations.h" 51 #include "wtf/LeakAnnotations.h"
(...skipping 14 matching lines...) Expand all
65 WeakPersistentConfiguration 66 WeakPersistentConfiguration
66 }; 67 };
67 68
68 enum CrossThreadnessPersistentConfiguration { 69 enum CrossThreadnessPersistentConfiguration {
69 SingleThreadPersistentConfiguration, 70 SingleThreadPersistentConfiguration,
70 CrossThreadPersistentConfiguration 71 CrossThreadPersistentConfiguration
71 }; 72 };
72 73
73 template<typename T, WeaknessPersistentConfiguration weaknessConfiguration, Cros sThreadnessPersistentConfiguration crossThreadnessConfiguration> 74 template<typename T, WeaknessPersistentConfiguration weaknessConfiguration, Cros sThreadnessPersistentConfiguration crossThreadnessConfiguration>
74 class PersistentBase { 75 class PersistentBase {
76 USING_FAST_MALLOC(PersistentBase);
75 IS_PERSISTENT_REFERENCE_TYPE(); 77 IS_PERSISTENT_REFERENCE_TYPE();
76 public: 78 public:
77 PersistentBase() : m_raw(nullptr) 79 PersistentBase() : m_raw(nullptr)
78 { 80 {
79 initialize(); 81 initialize();
80 } 82 }
81 83
82 PersistentBase(std::nullptr_t) : m_raw(nullptr) 84 PersistentBase(std::nullptr_t) : m_raw(nullptr)
83 { 85 {
84 initialize(); 86 initialize();
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 696 }
695 }; 697 };
696 698
697 // Members are used in classes to contain strong pointers to other oilpan heap 699 // Members are used in classes to contain strong pointers to other oilpan heap
698 // allocated objects. 700 // allocated objects.
699 // All Member fields of a class must be traced in the class' trace method. 701 // All Member fields of a class must be traced in the class' trace method.
700 // During the mark phase of the GC all live objects are marked as live and 702 // During the mark phase of the GC all live objects are marked as live and
701 // all Member fields of a live object will be traced marked as live as well. 703 // all Member fields of a live object will be traced marked as live as well.
702 template<typename T> 704 template<typename T>
703 class Member { 705 class Member {
706 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
704 public: 707 public:
705 Member() : m_raw(nullptr) 708 Member() : m_raw(nullptr)
706 { 709 {
707 } 710 }
708 711
709 Member(std::nullptr_t) : m_raw(nullptr) 712 Member(std::nullptr_t) : m_raw(nullptr)
710 { 713 {
711 } 714 }
712 715
713 Member(T* raw) : m_raw(raw) 716 Member(T* raw) : m_raw(raw)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) \ 1194 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) \
1192 type::~type() { } 1195 type::~type() { }
1193 1196
1194 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ 1197 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \
1195 DEFINE_STATIC_REF(type, name, arguments) 1198 DEFINE_STATIC_REF(type, name, arguments)
1196 1199
1197 #endif // ENABLE(OILPAN) 1200 #endif // ENABLE(OILPAN)
1198 1201
1199 template<typename T, bool = IsGarbageCollectedType<T>::value> 1202 template<typename T, bool = IsGarbageCollectedType<T>::value>
1200 class RawPtrOrMemberTrait { 1203 class RawPtrOrMemberTrait {
1204 STATIC_ONLY(RawPtrOrMemberTrait)
1201 public: 1205 public:
1202 using Type = RawPtr<T>; 1206 using Type = RawPtr<T>;
1203 }; 1207 };
1204 1208
1205 template<typename T> 1209 template<typename T>
1206 class RawPtrOrMemberTrait<T, true> { 1210 class RawPtrOrMemberTrait<T, true> {
1211 STATIC_ONLY(RawPtrOrMemberTrait)
1207 public: 1212 public:
1208 using Type = Member<T>; 1213 using Type = Member<T>;
1209 }; 1214 };
1210 1215
1211 // Abstraction for injecting calls to an object's 'dispose()' method 1216 // Abstraction for injecting calls to an object's 'dispose()' method
1212 // on leaving a stack scope, ensuring earlier release of resources 1217 // on leaving a stack scope, ensuring earlier release of resources
1213 // than waiting until the object is eventually GCed. 1218 // than waiting until the object is eventually GCed.
1214 template<typename T, void (T::*Disposer)() = (&T::dispose)> 1219 template<typename T, void (T::*Disposer)() = (&T::dispose)>
1215 class ScopedDisposal { 1220 class ScopedDisposal {
1216 STACK_ALLOCATED(); 1221 STACK_ALLOCATED();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 // private: 1261 // private:
1257 // ... 1262 // ...
1258 // SelfKeepAlive m_keepAlive; 1263 // SelfKeepAlive m_keepAlive;
1259 // }; 1264 // };
1260 // 1265 //
1261 // The responsibility to call clear() in a timely fashion resides with the imple mentation 1266 // The responsibility to call clear() in a timely fashion resides with the imple mentation
1262 // of the object. 1267 // of the object.
1263 // 1268 //
1264 // 1269 //
1265 template<typename Self> 1270 template<typename Self>
1266 class SelfKeepAlive { 1271 class SelfKeepAlive final {
1272 DISALLOW_NEW();
1267 public: 1273 public:
1268 SelfKeepAlive() 1274 SelfKeepAlive()
1269 { 1275 {
1270 } 1276 }
1271 1277
1272 explicit SelfKeepAlive(Self* self) 1278 explicit SelfKeepAlive(Self* self)
1273 { 1279 {
1274 assign(self); 1280 assign(self);
1275 } 1281 }
1276 1282
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 #define LEAK_SANITIZER_DISABLED_SCOPE LeakSanitizerDisableScope lsanDisabledScop e 1348 #define LEAK_SANITIZER_DISABLED_SCOPE LeakSanitizerDisableScope lsanDisabledScop e
1343 #else 1349 #else
1344 #define LEAK_SANITIZER_DISABLED_SCOPE 1350 #define LEAK_SANITIZER_DISABLED_SCOPE
1345 #endif 1351 #endif
1346 1352
1347 } // namespace blink 1353 } // namespace blink
1348 1354
1349 namespace WTF { 1355 namespace WTF {
1350 1356
1351 template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> { 1357 template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> {
1358 STATIC_ONLY(PtrHash);
1352 template<typename U> 1359 template<typename U>
1353 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } 1360 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); }
1354 static bool equal(T* a, const blink::Member<T>& b) { return a == b; } 1361 static bool equal(T* a, const blink::Member<T>& b) { return a == b; }
1355 static bool equal(const blink::Member<T>& a, T* b) { return a == b; } 1362 static bool equal(const blink::Member<T>& a, T* b) { return a == b; }
1356 template<typename U, typename V> 1363 template<typename U, typename V>
1357 static bool equal(const U& a, const V& b) { return a == b; } 1364 static bool equal(const U& a, const V& b) { return a == b; }
1358 }; 1365 };
1359 1366
1360 template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Membe r<T>> { 1367 template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Membe r<T>> {
1368 STATIC_ONLY(PtrHash);
1361 }; 1369 };
1362 1370
1363 template<typename T> struct PtrHash<blink::UntracedMember<T>> : PtrHash<blink::M ember<T>> { 1371 template<typename T> struct PtrHash<blink::UntracedMember<T>> : PtrHash<blink::M ember<T>> {
1372 STATIC_ONLY(PtrHash);
1364 }; 1373 };
1365 1374
1366 // PtrHash is the default hash for hash tables with members. 1375 // PtrHash is the default hash for hash tables with members.
1367 template<typename T> struct DefaultHash<blink::Member<T>> { 1376 template<typename T> struct DefaultHash<blink::Member<T>> {
1377 STATIC_ONLY(DefaultHash);
1368 using Hash = PtrHash<blink::Member<T>>; 1378 using Hash = PtrHash<blink::Member<T>>;
1369 }; 1379 };
1370 1380
1371 template<typename T> struct DefaultHash<blink::WeakMember<T>> { 1381 template<typename T> struct DefaultHash<blink::WeakMember<T>> {
1382 STATIC_ONLY(DefaultHash);
1372 using Hash = PtrHash<blink::WeakMember<T>>; 1383 using Hash = PtrHash<blink::WeakMember<T>>;
1373 }; 1384 };
1374 1385
1375 template<typename T> struct DefaultHash<blink::UntracedMember<T>> { 1386 template<typename T> struct DefaultHash<blink::UntracedMember<T>> {
1387 STATIC_ONLY(DefaultHash);
1376 using Hash = PtrHash<blink::UntracedMember<T>>; 1388 using Hash = PtrHash<blink::UntracedMember<T>>;
1377 }; 1389 };
1378 1390
1379 template<typename T> 1391 template<typename T>
1380 struct NeedsTracing<blink::Member<T>> { 1392 struct NeedsTracing<blink::Member<T>> {
1393 STATIC_ONLY(NeedsTracing);
1381 static const bool value = true; 1394 static const bool value = true;
1382 }; 1395 };
1383 1396
1384 template<typename T> 1397 template<typename T>
1385 struct IsWeak<blink::WeakMember<T>> { 1398 struct IsWeak<blink::WeakMember<T>> {
1399 STATIC_ONLY(IsWeak);
1386 static const bool value = true; 1400 static const bool value = true;
1387 }; 1401 };
1388 1402
1389 template<typename T> inline T* getPtr(const blink::Member<T>& p) 1403 template<typename T> inline T* getPtr(const blink::Member<T>& p)
1390 { 1404 {
1391 return p.get(); 1405 return p.get();
1392 } 1406 }
1393 1407
1394 template<typename T> inline T* getPtr(const blink::Persistent<T>& p) 1408 template<typename T> inline T* getPtr(const blink::Persistent<T>& p)
1395 { 1409 {
1396 return p.get(); 1410 return p.get();
1397 } 1411 }
1398 1412
1399 // For wtf/Functional.h 1413 // For wtf/Functional.h
1400 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; 1414 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits;
1401 1415
1402 template<typename T> 1416 template<typename T>
1403 struct PointerParamStorageTraits<T*, false> { 1417 struct PointerParamStorageTraits<T*, false> {
1418 STATIC_ONLY(PointerParamStorageTraits);
1404 static_assert(sizeof(T), "T must be fully defined"); 1419 static_assert(sizeof(T), "T must be fully defined");
1405 using StorageType = T*; 1420 using StorageType = T*;
1406 1421
1407 static StorageType wrap(T* value) { return value; } 1422 static StorageType wrap(T* value) { return value; }
1408 static T* unwrap(const StorageType& value) { return value; } 1423 static T* unwrap(const StorageType& value) { return value; }
1409 }; 1424 };
1410 1425
1411 template<typename T> 1426 template<typename T>
1412 struct PointerParamStorageTraits<T*, true> { 1427 struct PointerParamStorageTraits<T*, true> {
1428 STATIC_ONLY(PointerParamStorageTraits);
1413 static_assert(sizeof(T), "T must be fully defined"); 1429 static_assert(sizeof(T), "T must be fully defined");
1414 using StorageType = blink::CrossThreadPersistent<T>; 1430 using StorageType = blink::CrossThreadPersistent<T>;
1415 1431
1416 static StorageType wrap(T* value) { return value; } 1432 static StorageType wrap(T* value) { return value; }
1417 static T* unwrap(const StorageType& value) { return value.get(); } 1433 static T* unwrap(const StorageType& value) { return value.get(); }
1418 }; 1434 };
1419 1435
1420 template<typename T> 1436 template<typename T>
1421 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> { 1437 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> {
1438 STATIC_ONLY(ParamStorageTraits);
1422 static_assert(sizeof(T), "T must be fully defined"); 1439 static_assert(sizeof(T), "T must be fully defined");
1423 }; 1440 };
1424 1441
1425 template<typename T> 1442 template<typename T>
1426 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { 1443 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> {
1444 STATIC_ONLY(ParamStorageTraits);
1427 static_assert(sizeof(T), "T must be fully defined"); 1445 static_assert(sizeof(T), "T must be fully defined");
1428 }; 1446 };
1429 1447
1430 template<typename T> 1448 template<typename T>
1431 struct ParamStorageTraits<blink::CrossThreadWeakPersistentThisPointer<T>> { 1449 struct ParamStorageTraits<blink::CrossThreadWeakPersistentThisPointer<T>> {
1450 STATIC_ONLY(ParamStorageTraits);
1432 static_assert(sizeof(T), "T must be fully defined"); 1451 static_assert(sizeof(T), "T must be fully defined");
1433 using StorageType = blink::CrossThreadWeakPersistent<T>; 1452 using StorageType = blink::CrossThreadWeakPersistent<T>;
1434 1453
1435 static StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T> & value) { return value.value(); } 1454 static StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T> & value) { return value.value(); }
1436 1455
1437 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent 1456 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent
1438 // into it. 1457 // into it.
1439 // 1458 //
1440 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like 1459 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like
1441 // CrossThreadWeakPersistent<>. 1460 // CrossThreadWeakPersistent<>.
1442 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } 1461 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); }
1443 }; 1462 };
1444 1463
1445 } // namespace WTF 1464 } // namespace WTF
1446 1465
1447 #endif 1466 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698