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

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

Issue 2028433003: Revert of Allow CrossThreadPersistent in collections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef HeapAllocator_h 5 #ifndef HeapAllocator_h
6 #define HeapAllocator_h 6 #define HeapAllocator_h
7 7
8 #include "platform/heap/Heap.h" 8 #include "platform/heap/Heap.h"
9 #include "platform/heap/Persistent.h"
10 #include "platform/heap/TraceTraits.h" 9 #include "platform/heap/TraceTraits.h"
11 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
12 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
13 #include "wtf/Deque.h" 12 #include "wtf/Deque.h"
14 #include "wtf/HashCountedSet.h" 13 #include "wtf/HashCountedSet.h"
15 #include "wtf/HashMap.h" 14 #include "wtf/HashMap.h"
16 #include "wtf/HashSet.h" 15 #include "wtf/HashSet.h"
17 #include "wtf/HashTable.h" 16 #include "wtf/HashTable.h"
18 #include "wtf/LinkedHashSet.h" 17 #include "wtf/LinkedHashSet.h"
19 #include "wtf/ListHashSet.h" 18 #include "wtf/ListHashSet.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 }; 415 };
417 416
418 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai tsBase<blink::UntracedMember<T>> { 417 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai tsBase<blink::UntracedMember<T>> {
419 STATIC_ONLY(VectorTraits); 418 STATIC_ONLY(VectorTraits);
420 static const bool needsDestruction = false; 419 static const bool needsDestruction = false;
421 static const bool canInitializeWithMemset = true; 420 static const bool canInitializeWithMemset = true;
422 static const bool canClearUnusedSlotsWithMemset = true; 421 static const bool canClearUnusedSlotsWithMemset = true;
423 static const bool canMoveWithMemcpy = true; 422 static const bool canMoveWithMemcpy = true;
424 }; 423 };
425 424
426 template <typename T, blink::WeaknessPersistentConfiguration weaknessConfigurati on, blink::CrossThreadnessPersistentConfiguration crossThreadnessConfiguration>
427 struct VectorTraits<blink::PersistentBase<T, weaknessConfiguration, crossThreadn essConfiguration>>
428 : VectorTraitsBase<blink::PersistentBase<T, weaknessConfiguration, crossThre adnessConfiguration>> {
429 STATIC_ONLY(VectorTraits);
430 static const bool needsDestruction = true;
431 static const bool canInitializeWithMemset = true;
432 static const bool canClearUnusedSlotsWithMemset = false;
433 static const bool canMoveWithMemcpy = true;
434 };
435
436 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait sBase<blink::HeapVector<T, 0>> { 425 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait sBase<blink::HeapVector<T, 0>> {
437 STATIC_ONLY(VectorTraits); 426 STATIC_ONLY(VectorTraits);
438 static const bool needsDestruction = false; 427 static const bool needsDestruction = false;
439 static const bool canInitializeWithMemset = true; 428 static const bool canInitializeWithMemset = true;
440 static const bool canClearUnusedSlotsWithMemset = true; 429 static const bool canClearUnusedSlotsWithMemset = true;
441 static const bool canMoveWithMemcpy = true; 430 static const bool canMoveWithMemcpy = true;
442 }; 431 };
443 432
444 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits Base<blink::HeapDeque<T, 0>> { 433 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits Base<blink::HeapDeque<T, 0>> {
445 STATIC_ONLY(VectorTraits); 434 STATIC_ONLY(VectorTraits);
(...skipping 12 matching lines...) Expand all
458 }; 447 };
459 448
460 template <typename T, size_t inlineCapacity> struct VectorTraits<blink::HeapDequ e<T, inlineCapacity>> : VectorTraitsBase<blink::HeapDeque<T, inlineCapacity>> { 449 template <typename T, size_t inlineCapacity> struct VectorTraits<blink::HeapDequ e<T, inlineCapacity>> : VectorTraitsBase<blink::HeapDeque<T, inlineCapacity>> {
461 STATIC_ONLY(VectorTraits); 450 STATIC_ONLY(VectorTraits);
462 static const bool needsDestruction = VectorTraits<T>::needsDestruction; 451 static const bool needsDestruction = VectorTraits<T>::needsDestruction;
463 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi thMemset; 452 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi thMemset;
464 static const bool canClearUnusedSlotsWithMemset = VectorTraits<T>::canClearU nusedSlotsWithMemset; 453 static const bool canClearUnusedSlotsWithMemset = VectorTraits<T>::canClearU nusedSlotsWithMemset;
465 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy; 454 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy;
466 }; 455 };
467 456
468 template<typename T, typename H> struct HandleHashTraits : SimpleClassHashTraits <H> { 457 template<typename T> struct HashTraits<blink::Member<T>> : SimpleClassHashTraits <blink::Member<T>> {
469 STATIC_ONLY(HandleHashTraits); 458 STATIC_ONLY(HashTraits);
470 // TODO: The distinction between PeekInType and PassInType is there for 459 // FIXME: The distinction between PeekInType and PassInType is there for
471 // the sake of the reference counting handles. When they are gone the two 460 // the sake of the reference counting handles. When they are gone the two
472 // types can be merged into PassInType. 461 // types can be merged into PassInType.
473 // TODO: Implement proper const'ness for iterator types. Requires support 462 // FIXME: Implement proper const'ness for iterator types. Requires support
474 // in the marking Visitor. 463 // in the marking Visitor.
475 using PeekInType = T*; 464 using PeekInType = T*;
476 using PassInType = T*; 465 using PassInType = T*;
477 using IteratorGetType = H*; 466 using IteratorGetType = blink::Member<T>*;
478 using IteratorConstGetType = const H*; 467 using IteratorConstGetType = const blink::Member<T>*;
479 using IteratorReferenceType = H&; 468 using IteratorReferenceType = blink::Member<T>&;
480 using IteratorConstReferenceType = const H&; 469 using IteratorConstReferenceType = const blink::Member<T>&;
481 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; } 470 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; }
482 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; } 471 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; }
483 472
484 using PeekOutType = T*; 473 using PeekOutType = T*;
485 474
486 template<typename U> 475 template<typename U>
487 static void store(const U& value, H& storage) { storage = value; } 476 static void store(const U& value, blink::Member<T>& storage) { storage = val ue; }
488 477
489 static PeekOutType peek(const H& value) { return value; } 478 static PeekOutType peek(const blink::Member<T>& value) { return value; }
490 }; 479 };
491 480
492 template<typename T> struct HashTraits<blink::Member<T>> : HandleHashTraits<T, b link::Member<T>> { }; 481 template<typename T> struct HashTraits<blink::WeakMember<T>> : SimpleClassHashTr aits<blink::WeakMember<T>> {
493
494 template<typename T> struct HashTraits<blink::WeakMember<T>> : HandleHashTraits< T, blink::WeakMember<T>> {
495 STATIC_ONLY(HashTraits); 482 STATIC_ONLY(HashTraits);
496 static const bool needsDestruction = false; 483 static const bool needsDestruction = false;
484 // FIXME: The distinction between PeekInType and PassInType is there for
485 // the sake of the reference counting handles. When they are gone the two
486 // types can be merged into PassInType.
487 // FIXME: Implement proper const'ness for iterator types. Requires support
488 // in the marking Visitor.
489 using PeekInType = T*;
490 using PassInType = T*;
491 using IteratorGetType = blink::WeakMember<T>*;
492 using IteratorConstGetType = const blink::WeakMember<T>*;
493 using IteratorReferenceType = blink::WeakMember<T>&;
494 using IteratorConstReferenceType = const blink::WeakMember<T>&;
495 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; }
496 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; }
497
498 using PeekOutType = T*;
499
500 template<typename U>
501 static void store(const U& value, blink::WeakMember<T>& storage) { storage = value; }
502
503 static PeekOutType peek(const blink::WeakMember<T>& value) { return value; }
497 504
498 template<typename VisitorDispatcher> 505 template<typename VisitorDispatcher>
499 static bool traceInCollection(VisitorDispatcher visitor, blink::WeakMember<T >& weakMember, ShouldWeakPointersBeMarkedStrongly strongify) 506 static bool traceInCollection(VisitorDispatcher visitor, blink::WeakMember<T >& weakMember, ShouldWeakPointersBeMarkedStrongly strongify)
500 { 507 {
501 if (strongify == WeakPointersActStrong) { 508 if (strongify == WeakPointersActStrong) {
502 visitor->trace(weakMember.get()); // Strongified visit. 509 visitor->trace(weakMember.get()); // Strongified visit.
503 return false; 510 return false;
504 } 511 }
505 return !blink::ThreadHeap::isHeapObjectAlive(weakMember); 512 return !blink::ThreadHeap::isHeapObjectAlive(weakMember);
506 } 513 }
507 }; 514 };
508 515
509 template<typename T> struct HashTraits<blink::UntracedMember<T>> : HandleHashTra its<T, blink::UntracedMember<T>> { 516 template<typename T> struct HashTraits<blink::UntracedMember<T>> : SimpleClassHa shTraits<blink::UntracedMember<T>> {
510 STATIC_ONLY(HashTraits); 517 STATIC_ONLY(HashTraits);
511 static const bool needsDestruction = false; 518 static const bool needsDestruction = false;
519 // FIXME: The distinction between PeekInType and PassInType is there for
520 // the sake of the reference counting handles. When they are gone the two
521 // types can be merged into PassInType.
522 // FIXME: Implement proper const'ness for iterator types.
523 using PeekInType = T*;
524 using PassInType = T*;
525 using IteratorGetType = blink::UntracedMember<T>*;
526 using IteratorConstGetType = const blink::UntracedMember<T>*;
527 using IteratorReferenceType = blink::UntracedMember<T>&;
528 using IteratorConstReferenceType = const blink::UntracedMember<T>&;
529 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; }
530 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; }
531 using PeekOutType = T*;
532
533 template<typename U>
534 static void store(const U& value, blink::UntracedMember<T>& storage) { stora ge = value; }
535
536 static PeekOutType peek(const blink::UntracedMember<T>& value) { return valu e; }
512 }; 537 };
513 538
514 template<typename T, size_t inlineCapacity> 539 template<typename T, size_t inlineCapacity>
515 struct NeedsTracing<ListHashSetNode<T, blink::HeapListHashSetAllocator<T, inline Capacity>> *> { 540 struct NeedsTracing<ListHashSetNode<T, blink::HeapListHashSetAllocator<T, inline Capacity>> *> {
516 STATIC_ONLY(NeedsTracing); 541 STATIC_ONLY(NeedsTracing);
517 static_assert(sizeof(T), "T must be fully defined"); 542 static_assert(sizeof(T), "T must be fully defined");
518 // All heap allocated node pointers need visiting to keep the nodes alive, 543 // All heap allocated node pointers need visiting to keep the nodes alive,
519 // regardless of whether they contain pointers to other heap allocated 544 // regardless of whether they contain pointers to other heap allocated
520 // objects. 545 // objects.
521 static const bool value = true; 546 static const bool value = true;
522 }; 547 };
523 548
524 template<typename T, size_t inlineCapacity> 549 template<typename T, size_t inlineCapacity>
525 struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator <T, inlineCapacity>>> { 550 struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator <T, inlineCapacity>>> {
526 static const bool value = true; 551 static const bool value = true;
527 }; 552 };
528 553
529 template<typename T> struct HashTraits<blink::Persistent<T>> : HandleHashTraits< T, blink::Persistent<T>> { };
530
531 template<typename T> struct HashTraits<blink::CrossThreadPersistent<T>> : Handle HashTraits<T, blink::CrossThreadPersistent<T>> { };
532
533 } // namespace WTF 554 } // namespace WTF
534 555
535 #endif 556 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698