| 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 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 }; | 1341 }; |
| 1342 #define LEAK_SANITIZER_DISABLED_SCOPE LeakSanitizerDisableScope lsanDisabledScop
e | 1342 #define LEAK_SANITIZER_DISABLED_SCOPE LeakSanitizerDisableScope lsanDisabledScop
e |
| 1343 #else | 1343 #else |
| 1344 #define LEAK_SANITIZER_DISABLED_SCOPE | 1344 #define LEAK_SANITIZER_DISABLED_SCOPE |
| 1345 #endif | 1345 #endif |
| 1346 | 1346 |
| 1347 } // namespace blink | 1347 } // namespace blink |
| 1348 | 1348 |
| 1349 namespace WTF { | 1349 namespace WTF { |
| 1350 | 1350 |
| 1351 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b
link::Member<T>> { | |
| 1352 static const bool needsDestruction = false; | |
| 1353 static const bool canInitializeWithMemset = true; | |
| 1354 static const bool canClearUnusedSlotsWithMemset = true; | |
| 1355 static const bool canMoveWithMemcpy = true; | |
| 1356 }; | |
| 1357 | |
| 1358 template <typename T> struct VectorTraits<blink::WeakMember<T>> : VectorTraitsBa
se<blink::WeakMember<T>> { | |
| 1359 static const bool needsDestruction = false; | |
| 1360 static const bool canInitializeWithMemset = true; | |
| 1361 static const bool canClearUnusedSlotsWithMemset = true; | |
| 1362 static const bool canMoveWithMemcpy = true; | |
| 1363 }; | |
| 1364 | |
| 1365 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai
tsBase<blink::UntracedMember<T>> { | |
| 1366 static const bool needsDestruction = false; | |
| 1367 static const bool canInitializeWithMemset = true; | |
| 1368 static const bool canClearUnusedSlotsWithMemset = true; | |
| 1369 static const bool canMoveWithMemcpy = true; | |
| 1370 }; | |
| 1371 | |
| 1372 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait
sBase<blink::HeapVector<T, 0>> { | |
| 1373 static const bool needsDestruction = false; | |
| 1374 static const bool canInitializeWithMemset = true; | |
| 1375 static const bool canClearUnusedSlotsWithMemset = true; | |
| 1376 static const bool canMoveWithMemcpy = true; | |
| 1377 }; | |
| 1378 | |
| 1379 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits
Base<blink::HeapDeque<T, 0>> { | |
| 1380 static const bool needsDestruction = false; | |
| 1381 static const bool canInitializeWithMemset = true; | |
| 1382 static const bool canClearUnusedSlotsWithMemset = true; | |
| 1383 static const bool canMoveWithMemcpy = true; | |
| 1384 }; | |
| 1385 | |
| 1386 template <typename T, size_t inlineCapacity> struct VectorTraits<blink::HeapVect
or<T, inlineCapacity>> : VectorTraitsBase<blink::HeapVector<T, inlineCapacity>>
{ | |
| 1387 static const bool needsDestruction = VectorTraits<T>::needsDestruction; | |
| 1388 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi
thMemset; | |
| 1389 static const bool canClearUnusedSlotsWithMemset = VectorTraits<T>::canClearU
nusedSlotsWithMemset; | |
| 1390 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy; | |
| 1391 }; | |
| 1392 | |
| 1393 template <typename T, size_t inlineCapacity> struct VectorTraits<blink::HeapDequ
e<T, inlineCapacity>> : VectorTraitsBase<blink::HeapDeque<T, inlineCapacity>> { | |
| 1394 static const bool needsDestruction = VectorTraits<T>::needsDestruction; | |
| 1395 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi
thMemset; | |
| 1396 static const bool canClearUnusedSlotsWithMemset = VectorTraits<T>::canClearU
nusedSlotsWithMemset; | |
| 1397 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy; | |
| 1398 }; | |
| 1399 | |
| 1400 template<typename T> struct HashTraits<blink::Member<T>> : SimpleClassHashTraits
<blink::Member<T>> { | |
| 1401 // FIXME: The distinction between PeekInType and PassInType is there for | |
| 1402 // the sake of the reference counting handles. When they are gone the two | |
| 1403 // types can be merged into PassInType. | |
| 1404 // FIXME: Implement proper const'ness for iterator types. Requires support | |
| 1405 // in the marking Visitor. | |
| 1406 using PeekInType = RawPtr<T>; | |
| 1407 using PassInType = RawPtr<T>; | |
| 1408 using IteratorGetType = blink::Member<T>*; | |
| 1409 using IteratorConstGetType = const blink::Member<T>*; | |
| 1410 using IteratorReferenceType = blink::Member<T>&; | |
| 1411 using IteratorConstReferenceType = const blink::Member<T>&; | |
| 1412 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r
eturn *x; } | |
| 1413 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons
tGetType x) { return *x; } | |
| 1414 // FIXME: Similarly, there is no need for a distinction between PeekOutType | |
| 1415 // and PassOutType without reference counting. | |
| 1416 using PeekOutType = T*; | |
| 1417 using PassOutType = T*; | |
| 1418 | |
| 1419 template<typename U> | |
| 1420 static void store(const U& value, blink::Member<T>& storage) { storage = val
ue; } | |
| 1421 | |
| 1422 static PeekOutType peek(const blink::Member<T>& value) { return value; } | |
| 1423 static PassOutType passOut(const blink::Member<T>& value) { return value; } | |
| 1424 }; | |
| 1425 | |
| 1426 template<typename T> struct HashTraits<blink::WeakMember<T>> : SimpleClassHashTr
aits<blink::WeakMember<T>> { | |
| 1427 static const bool needsDestruction = false; | |
| 1428 // FIXME: The distinction between PeekInType and PassInType is there for | |
| 1429 // the sake of the reference counting handles. When they are gone the two | |
| 1430 // types can be merged into PassInType. | |
| 1431 // FIXME: Implement proper const'ness for iterator types. Requires support | |
| 1432 // in the marking Visitor. | |
| 1433 using PeekInType = RawPtr<T>; | |
| 1434 using PassInType = RawPtr<T>; | |
| 1435 using IteratorGetType = blink::WeakMember<T>*; | |
| 1436 using IteratorConstGetType = const blink::WeakMember<T>*; | |
| 1437 using IteratorReferenceType = blink::WeakMember<T>&; | |
| 1438 using IteratorConstReferenceType = const blink::WeakMember<T>&; | |
| 1439 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r
eturn *x; } | |
| 1440 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons
tGetType x) { return *x; } | |
| 1441 // FIXME: Similarly, there is no need for a distinction between PeekOutType | |
| 1442 // and PassOutType without reference counting. | |
| 1443 using PeekOutType = T*; | |
| 1444 using PassOutType = T*; | |
| 1445 | |
| 1446 template<typename U> | |
| 1447 static void store(const U& value, blink::WeakMember<T>& storage) { storage =
value; } | |
| 1448 | |
| 1449 static PeekOutType peek(const blink::WeakMember<T>& value) { return value; } | |
| 1450 static PassOutType passOut(const blink::WeakMember<T>& value) { return value
; } | |
| 1451 | |
| 1452 template<typename VisitorDispatcher> | |
| 1453 static bool traceInCollection(VisitorDispatcher visitor, blink::WeakMember<T
>& weakMember, ShouldWeakPointersBeMarkedStrongly strongify) | |
| 1454 { | |
| 1455 if (strongify == WeakPointersActStrong) { | |
| 1456 visitor->trace(weakMember.get()); // Strongified visit. | |
| 1457 return false; | |
| 1458 } | |
| 1459 return !blink::Heap::isHeapObjectAlive(weakMember); | |
| 1460 } | |
| 1461 }; | |
| 1462 | |
| 1463 template<typename T> struct HashTraits<blink::UntracedMember<T>> : SimpleClassHa
shTraits<blink::UntracedMember<T>> { | |
| 1464 static const bool needsDestruction = false; | |
| 1465 // FIXME: The distinction between PeekInType and PassInType is there for | |
| 1466 // the sake of the reference counting handles. When they are gone the two | |
| 1467 // types can be merged into PassInType. | |
| 1468 // FIXME: Implement proper const'ness for iterator types. | |
| 1469 using PeekInType = RawPtr<T>; | |
| 1470 using PassInType = RawPtr<T>; | |
| 1471 using IteratorGetType = blink::UntracedMember<T>*; | |
| 1472 using IteratorConstGetType = const blink::UntracedMember<T>*; | |
| 1473 using IteratorReferenceType = blink::UntracedMember<T>&; | |
| 1474 using IteratorConstReferenceType = const blink::UntracedMember<T>&; | |
| 1475 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r
eturn *x; } | |
| 1476 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons
tGetType x) { return *x; } | |
| 1477 // FIXME: Similarly, there is no need for a distinction between PeekOutType | |
| 1478 // and PassOutType without reference counting. | |
| 1479 using PeekOutType = T*; | |
| 1480 using PassOutType = T*; | |
| 1481 | |
| 1482 template<typename U> | |
| 1483 static void store(const U& value, blink::UntracedMember<T>& storage) { stora
ge = value; } | |
| 1484 | |
| 1485 static PeekOutType peek(const blink::UntracedMember<T>& value) { return valu
e; } | |
| 1486 static PassOutType passOut(const blink::UntracedMember<T>& value) { return v
alue; } | |
| 1487 }; | |
| 1488 | |
| 1489 template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> { | 1351 template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> { |
| 1490 template<typename U> | 1352 template<typename U> |
| 1491 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } | 1353 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } |
| 1492 static bool equal(T* a, const blink::Member<T>& b) { return a == b; } | 1354 static bool equal(T* a, const blink::Member<T>& b) { return a == b; } |
| 1493 static bool equal(const blink::Member<T>& a, T* b) { return a == b; } | 1355 static bool equal(const blink::Member<T>& a, T* b) { return a == b; } |
| 1494 template<typename U, typename V> | 1356 template<typename U, typename V> |
| 1495 static bool equal(const U& a, const V& b) { return a == b; } | 1357 static bool equal(const U& a, const V& b) { return a == b; } |
| 1496 }; | 1358 }; |
| 1497 | 1359 |
| 1498 template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Membe
r<T>> { | 1360 template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Membe
r<T>> { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1527 template<typename T> inline T* getPtr(const blink::Member<T>& p) | 1389 template<typename T> inline T* getPtr(const blink::Member<T>& p) |
| 1528 { | 1390 { |
| 1529 return p.get(); | 1391 return p.get(); |
| 1530 } | 1392 } |
| 1531 | 1393 |
| 1532 template<typename T> inline T* getPtr(const blink::Persistent<T>& p) | 1394 template<typename T> inline T* getPtr(const blink::Persistent<T>& p) |
| 1533 { | 1395 { |
| 1534 return p.get(); | 1396 return p.get(); |
| 1535 } | 1397 } |
| 1536 | 1398 |
| 1537 template<typename T, size_t inlineCapacity> | |
| 1538 struct NeedsTracing<ListHashSetNode<T, blink::HeapListHashSetAllocator<T, inline
Capacity>> *> { | |
| 1539 static_assert(sizeof(T), "T must be fully defined"); | |
| 1540 // All heap allocated node pointers need visiting to keep the nodes alive, | |
| 1541 // regardless of whether they contain pointers to other heap allocated | |
| 1542 // objects. | |
| 1543 static const bool value = true; | |
| 1544 }; | |
| 1545 | |
| 1546 // For wtf/Functional.h | 1399 // For wtf/Functional.h |
| 1547 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; | 1400 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; |
| 1548 | 1401 |
| 1549 template<typename T> | 1402 template<typename T> |
| 1550 struct PointerParamStorageTraits<T*, false> { | 1403 struct PointerParamStorageTraits<T*, false> { |
| 1551 static_assert(sizeof(T), "T must be fully defined"); | 1404 static_assert(sizeof(T), "T must be fully defined"); |
| 1552 using StorageType = T*; | 1405 using StorageType = T*; |
| 1553 | 1406 |
| 1554 static StorageType wrap(T* value) { return value; } | 1407 static StorageType wrap(T* value) { return value; } |
| 1555 static T* unwrap(const StorageType& value) { return value; } | 1408 static T* unwrap(const StorageType& value) { return value; } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1582 static StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T>
& value) { return value.value(); } | 1435 static StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T>
& value) { return value.value(); } |
| 1583 | 1436 |
| 1584 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent | 1437 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent |
| 1585 // into it. | 1438 // into it. |
| 1586 // | 1439 // |
| 1587 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like | 1440 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like |
| 1588 // CrossThreadWeakPersistent<>. | 1441 // CrossThreadWeakPersistent<>. |
| 1589 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } | 1442 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } |
| 1590 }; | 1443 }; |
| 1591 | 1444 |
| 1592 // Adoption is not needed nor wanted for RefCountedGarbageCollected<>-derived ty
pes. | |
| 1593 template<typename T> | |
| 1594 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | |
| 1595 | |
| 1596 } // namespace WTF | 1445 } // namespace WTF |
| 1597 | 1446 |
| 1598 #endif | 1447 #endif |
| OLD | NEW |