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

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

Issue 2204183002: Prepare CompositorWorker for per thread heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 3 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Persistent_h 5 #ifndef Persistent_h
6 #define Persistent_h 6 #define Persistent_h
7 7
8 #include "platform/heap/Heap.h" 8 #include "platform/heap/Heap.h"
9 #include "platform/heap/Member.h" 9 #include "platform/heap/Member.h"
10 #include "platform/heap/PersistentNode.h" 10 #include "platform/heap/PersistentNode.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 assign(nullptr); 107 assign(nullptr);
108 return result; 108 return result;
109 } 109 }
110 110
111 void clear() { assign(nullptr); } 111 void clear() { assign(nullptr); }
112 T& operator*() const { return *m_raw; } 112 T& operator*() const { return *m_raw; }
113 explicit operator bool() const { return m_raw; } 113 explicit operator bool() const { return m_raw; }
114 operator T*() const { return m_raw; } 114 operator T*() const { return m_raw; }
115 T* operator->() const { return *this; } 115 T* operator->() const { return *this; }
116 T* get() const { return m_raw; } 116 T* get() const { return m_raw; }
117 T* getInternal() const { return m_raw; }
117 118
118 template<typename U> 119 template<typename U>
119 PersistentBase& operator=(U* other) 120 PersistentBase& operator=(U* other)
120 { 121 {
121 assign(other); 122 assign(other);
122 return *this; 123 return *this;
123 } 124 }
124 125
125 PersistentBase& operator=(std::nullptr_t) 126 PersistentBase& operator=(std::nullptr_t)
126 { 127 {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { } 431 CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { }
431 CrossThreadPersistent(T* raw) : Parent(raw) { } 432 CrossThreadPersistent(T* raw) : Parent(raw) { }
432 CrossThreadPersistent(T& raw) : Parent(raw) { } 433 CrossThreadPersistent(T& raw) : Parent(raw) { }
433 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { } 434 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { }
434 template<typename U> 435 template<typename U>
435 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { } 436 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
436 template<typename U> 437 template<typename U>
437 CrossThreadPersistent(const Member<U>& other) : Parent(other) { } 438 CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
438 CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { } 439 CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
439 440
440 T* atomicGet() { return Parent::atomicGet(); }
441
442 template<typename U> 441 template<typename U>
443 CrossThreadPersistent& operator=(U* other) 442 CrossThreadPersistent& operator=(U* other)
444 { 443 {
445 Parent::operator=(other); 444 Parent::operator=(other);
446 return *this; 445 return *this;
447 } 446 }
448 447
449 CrossThreadPersistent& operator=(std::nullptr_t) 448 CrossThreadPersistent& operator=(std::nullptr_t)
450 { 449 {
451 Parent::operator=(nullptr); 450 Parent::operator=(nullptr);
(...skipping 12 matching lines...) Expand all
464 Parent::operator=(other); 463 Parent::operator=(other);
465 return *this; 464 return *this;
466 } 465 }
467 466
468 template<typename U> 467 template<typename U>
469 CrossThreadPersistent& operator=(const Member<U>& other) 468 CrossThreadPersistent& operator=(const Member<U>& other)
470 { 469 {
471 Parent::operator=(other); 470 Parent::operator=(other);
472 return *this; 471 return *this;
473 } 472 }
473
474 template<typename U>
475 static CrossThreadPersistent<U> protectWeak(const PersistentBase<U, WeakPers istentConfiguration, CrossThreadPersistentConfiguration>& other)
476 {
477 CrossThreadPersistentRegion::LockScope persistentLock(ProcessHeap::cross ThreadPersistentRegion());
478 return CrossThreadPersistent<U>(other.getInternal());
479 }
474 }; 480 };
475 481
476 // Combines the behavior of CrossThreadPersistent and WeakPersistent. 482 // Combines the behavior of CrossThreadPersistent and WeakPersistent.
477 template<typename T> 483 template<typename T>
478 class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfigu ration, CrossThreadPersistentConfiguration> { 484 class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfigu ration, CrossThreadPersistentConfiguration> {
479 typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistent Configuration> Parent; 485 typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistent Configuration> Parent;
480 public: 486 public:
481 CrossThreadWeakPersistent() : Parent() { } 487 CrossThreadWeakPersistent() : Parent() { }
482 CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { } 488 CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { }
483 CrossThreadWeakPersistent(T* raw) : Parent(raw) { } 489 CrossThreadWeakPersistent(T* raw) : Parent(raw) { }
(...skipping 29 matching lines...) Expand all
513 Parent::operator=(other); 519 Parent::operator=(other);
514 return *this; 520 return *this;
515 } 521 }
516 522
517 template<typename U> 523 template<typename U>
518 CrossThreadWeakPersistent& operator=(const Member<U>& other) 524 CrossThreadWeakPersistent& operator=(const Member<U>& other)
519 { 525 {
520 Parent::operator=(other); 526 Parent::operator=(other);
521 return *this; 527 return *this;
522 } 528 }
529
530 T* atomicGet() { return Parent::atomicGet(); }
531
532 T& operator*() const
533 {
534 DCHECK(!Parent::get() || !ThreadState::current() || !ThreadState::curren t()->perThreadHeapEnabled() || &ThreadState::fromObject(Parent::get())->heap() = = &ThreadState::current()->heap());
haraken 2016/09/02 09:39:18 Should we drop the '|| !ThreadState::current()->pe
keishi 2016/09/07 10:14:42 Done.
535 return Parent::operator*();
536 }
537 explicit operator bool() const
538 {
539 DCHECK(!Parent::get() || !ThreadState::current() || !ThreadState::curren t()->perThreadHeapEnabled() || &ThreadState::fromObject(Parent::get())->heap() = = &ThreadState::current()->heap());
540 return Parent::operator bool();
541 }
542 operator T*() const
543 {
544 DCHECK(!Parent::get() || !ThreadState::current() || !ThreadState::curren t()->perThreadHeapEnabled() || &ThreadState::fromObject(Parent::get())->heap() = = &ThreadState::current()->heap());
545 return Parent::operator T*();
546 }
547 T* operator->() const
548 {
549 DCHECK(!Parent::get() || !ThreadState::current() || !ThreadState::curren t()->perThreadHeapEnabled() || &ThreadState::fromObject(Parent::get())->heap() = = &ThreadState::current()->heap());
550 return Parent::operator->();
551 }
552 T* get() const
553 {
554 DCHECK(!Parent::get() || !ThreadState::current() || !ThreadState::curren t()->perThreadHeapEnabled() || &ThreadState::fromObject(Parent::get())->heap() = = &ThreadState::current()->heap());
555 return Parent::get();
556 }
523 }; 557 };
524 558
525 template<typename Collection> 559 template<typename Collection>
526 class PersistentHeapCollectionBase : public Collection { 560 class PersistentHeapCollectionBase : public Collection {
527 // We overload the various new and delete operators with using the WTF Parti tionAllocator to ensure persistent 561 // We overload the various new and delete operators with using the WTF Parti tionAllocator to ensure persistent
528 // heap collections are always allocated off-heap. This allows persistent co llections to be used in 562 // heap collections are always allocated off-heap. This allows persistent co llections to be used in
529 // DEFINE_STATIC_LOCAL et. al. 563 // DEFINE_STATIC_LOCAL et. al.
530 WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::PartitionAllocator); 564 WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::PartitionAllocator);
531 IS_PERSISTENT_REFERENCE_TYPE(); 565 IS_PERSISTENT_REFERENCE_TYPE();
532 public: 566 public:
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 796
763 template <typename T> 797 template <typename T>
764 struct IsWeakReceiver<blink::WeakPersistent<T>> : std::true_type {}; 798 struct IsWeakReceiver<blink::WeakPersistent<T>> : std::true_type {};
765 799
766 template <typename T> 800 template <typename T>
767 struct IsWeakReceiver<blink::CrossThreadWeakPersistent<T>> : std::true_type {}; 801 struct IsWeakReceiver<blink::CrossThreadWeakPersistent<T>> : std::true_type {};
768 802
769 } 803 }
770 804
771 #endif // Persistent_h 805 #endif // Persistent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698