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

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

Issue 1397073002: [Oilpan] Create UnsafePtr to store on-heap pointers in Vector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support hash collections Created 5 years, 2 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 30 matching lines...) Expand all
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 namespace blink { 49 namespace blink {
50 50
51 template<typename T> class Member;
52 template<typename T> class UntracedMember;
53
51 enum WeaknessPersistentConfiguration { 54 enum WeaknessPersistentConfiguration {
52 NonWeakPersistentConfiguration, 55 NonWeakPersistentConfiguration,
53 WeakPersistentConfiguration 56 WeakPersistentConfiguration
54 }; 57 };
55 58
56 enum CrossThreadnessPersistentConfiguration { 59 enum CrossThreadnessPersistentConfiguration {
57 SingleThreadPersistentConfiguration, 60 SingleThreadPersistentConfiguration,
58 CrossThreadPersistentConfiguration 61 CrossThreadPersistentConfiguration
59 }; 62 };
60 63
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 97
95 template<typename U> 98 template<typename U>
96 PersistentBase(const PersistentBase<U, weaknessConfiguration, crossThreadnes sConfiguration>& other) : m_raw(other) 99 PersistentBase(const PersistentBase<U, weaknessConfiguration, crossThreadnes sConfiguration>& other) : m_raw(other)
97 { 100 {
98 initialize(); 101 initialize();
99 checkPointer(); 102 checkPointer();
100 recordBacktrace(); 103 recordBacktrace();
101 } 104 }
102 105
103 template<typename U> 106 template<typename U>
107 PersistentBase(const UntracedMember<U>& other) : m_raw(other)
haraken 2015/10/15 03:55:39 Now that UntracedMember inherits from Member, this
peria 2015/10/15 05:11:58 Done.
108 {
109 initialize();
110 checkPointer();
111 recordBacktrace();
112 }
113
114 template<typename U>
104 PersistentBase(const Member<U>& other) : m_raw(other) 115 PersistentBase(const Member<U>& other) : m_raw(other)
105 { 116 {
106 initialize(); 117 initialize();
107 checkPointer(); 118 checkPointer();
108 recordBacktrace(); 119 recordBacktrace();
109 } 120 }
110 121
111 template<typename U> 122 template<typename U>
112 PersistentBase(const RawPtr<U>& other) : m_raw(other.get()) 123 PersistentBase(const RawPtr<U>& other) : m_raw(other.get())
113 { 124 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 180 }
170 181
171 template<typename U> 182 template<typename U>
172 PersistentBase& operator=(const PersistentBase<U, weaknessConfiguration, cro ssThreadnessConfiguration>& other) 183 PersistentBase& operator=(const PersistentBase<U, weaknessConfiguration, cro ssThreadnessConfiguration>& other)
173 { 184 {
174 assign(other); 185 assign(other);
175 return *this; 186 return *this;
176 } 187 }
177 188
178 template<typename U> 189 template<typename U>
190 PersistentBase& operator=(const UntracedMember<U>& other)
191 {
192 assign(other);
193 return *this;
194 }
195
196 template<typename U>
179 PersistentBase& operator=(const Member<U>& other) 197 PersistentBase& operator=(const Member<U>& other)
180 { 198 {
181 assign(other); 199 assign(other);
182 return *this; 200 return *this;
183 } 201 }
184 202
185 template<typename U> 203 template<typename U>
186 PersistentBase& operator=(const RawPtr<U>& other) 204 PersistentBase& operator=(const RawPtr<U>& other)
187 { 205 {
188 assign(other); 206 assign(other);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 typedef PersistentBase<T, NonWeakPersistentConfiguration, SingleThreadPersis tentConfiguration> Parent; 309 typedef PersistentBase<T, NonWeakPersistentConfiguration, SingleThreadPersis tentConfiguration> Parent;
292 public: 310 public:
293 Persistent() : Parent() { } 311 Persistent() : Parent() { }
294 Persistent(std::nullptr_t) : Parent(nullptr) { } 312 Persistent(std::nullptr_t) : Parent(nullptr) { }
295 Persistent(T* raw) : Parent(raw) { } 313 Persistent(T* raw) : Parent(raw) { }
296 Persistent(T& raw) : Parent(raw) { } 314 Persistent(T& raw) : Parent(raw) { }
297 Persistent(const Persistent& other) : Parent(other) { } 315 Persistent(const Persistent& other) : Parent(other) { }
298 template<typename U> 316 template<typename U>
299 Persistent(const Persistent<U>& other) : Parent(other) { } 317 Persistent(const Persistent<U>& other) : Parent(other) { }
300 template<typename U> 318 template<typename U>
319 Persistent(const UntracedMember<U>& other) : Parent(other) { }
320 template<typename U>
301 Persistent(const Member<U>& other) : Parent(other) { } 321 Persistent(const Member<U>& other) : Parent(other) { }
302 template<typename U> 322 template<typename U>
303 Persistent(const RawPtr<U>& other) : Parent(other.get()) { } 323 Persistent(const RawPtr<U>& other) : Parent(other.get()) { }
304 324
305 template<typename U> 325 template<typename U>
306 Persistent& operator=(U* other) 326 Persistent& operator=(U* other)
307 { 327 {
308 Parent::operator=(other); 328 Parent::operator=(other);
309 return *this; 329 return *this;
310 } 330 }
(...skipping 11 matching lines...) Expand all
322 } 342 }
323 343
324 template<typename U> 344 template<typename U>
325 Persistent& operator=(const Persistent<U>& other) 345 Persistent& operator=(const Persistent<U>& other)
326 { 346 {
327 Parent::operator=(other); 347 Parent::operator=(other);
328 return *this; 348 return *this;
329 } 349 }
330 350
331 template<typename U> 351 template<typename U>
352 Persistent& operator=(const UntracedMember<U>& other)
353 {
354 Parent::operator=(other);
355 return *this;
356 }
357
358 template<typename U>
332 Persistent& operator=(const Member<U>& other) 359 Persistent& operator=(const Member<U>& other)
333 { 360 {
334 Parent::operator=(other); 361 Parent::operator=(other);
335 return *this; 362 return *this;
336 } 363 }
337 364
338 template<typename U> 365 template<typename U>
339 Persistent& operator=(const RawPtr<U>& other) 366 Persistent& operator=(const RawPtr<U>& other)
340 { 367 {
341 Parent::operator=(other); 368 Parent::operator=(other);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 typedef PersistentBase<T, NonWeakPersistentConfiguration, CrossThreadPersist entConfiguration> Parent; 445 typedef PersistentBase<T, NonWeakPersistentConfiguration, CrossThreadPersist entConfiguration> Parent;
419 public: 446 public:
420 CrossThreadPersistent() : Parent() { } 447 CrossThreadPersistent() : Parent() { }
421 CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { } 448 CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { }
422 CrossThreadPersistent(T* raw) : Parent(raw) { } 449 CrossThreadPersistent(T* raw) : Parent(raw) { }
423 CrossThreadPersistent(T& raw) : Parent(raw) { } 450 CrossThreadPersistent(T& raw) : Parent(raw) { }
424 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { } 451 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { }
425 template<typename U> 452 template<typename U>
426 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { } 453 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
427 template<typename U> 454 template<typename U>
455 CrossThreadPersistent(const UntracedMember<U>& other) : Parent(other) { }
456 template<typename U>
428 CrossThreadPersistent(const Member<U>& other) : Parent(other) { } 457 CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
429 template<typename U> 458 template<typename U>
430 CrossThreadPersistent(const RawPtr<U>& other) : Parent(other.get()) { } 459 CrossThreadPersistent(const RawPtr<U>& other) : Parent(other.get()) { }
431 460
432 template<typename U> 461 template<typename U>
433 CrossThreadPersistent& operator=(U* other) 462 CrossThreadPersistent& operator=(U* other)
434 { 463 {
435 Parent::operator=(other); 464 Parent::operator=(other);
436 return *this; 465 return *this;
437 } 466 }
(...skipping 11 matching lines...) Expand all
449 } 478 }
450 479
451 template<typename U> 480 template<typename U>
452 CrossThreadPersistent& operator=(const CrossThreadPersistent<U>& other) 481 CrossThreadPersistent& operator=(const CrossThreadPersistent<U>& other)
453 { 482 {
454 Parent::operator=(other); 483 Parent::operator=(other);
455 return *this; 484 return *this;
456 } 485 }
457 486
458 template<typename U> 487 template<typename U>
488 CrossThreadPersistent& operator=(const UntracedMember<U>& other)
489 {
490 Parent::operator=(other);
491 return *this;
492 }
493
494 template<typename U>
459 CrossThreadPersistent& operator=(const Member<U>& other) 495 CrossThreadPersistent& operator=(const Member<U>& other)
460 { 496 {
461 Parent::operator=(other); 497 Parent::operator=(other);
462 return *this; 498 return *this;
463 } 499 }
464 500
465 template<typename U> 501 template<typename U>
466 CrossThreadPersistent& operator=(const RawPtr<U>& other) 502 CrossThreadPersistent& operator=(const RawPtr<U>& other)
467 { 503 {
468 Parent::operator=(other); 504 Parent::operator=(other);
469 return *this; 505 return *this;
470 } 506 }
471 }; 507 };
472 508
473 // Combines the behavior of CrossThreadPersistent and WeakPersistent. 509 // Combines the behavior of CrossThreadPersistent and WeakPersistent.
474 template<typename T> 510 template<typename T>
475 class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfigu ration, CrossThreadPersistentConfiguration> { 511 class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfigu ration, CrossThreadPersistentConfiguration> {
476 typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistent Configuration> Parent; 512 typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistent Configuration> Parent;
477 public: 513 public:
478 CrossThreadWeakPersistent() : Parent() { } 514 CrossThreadWeakPersistent() : Parent() { }
479 CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { } 515 CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { }
480 CrossThreadWeakPersistent(T* raw) : Parent(raw) { } 516 CrossThreadWeakPersistent(T* raw) : Parent(raw) { }
481 CrossThreadWeakPersistent(T& raw) : Parent(raw) { } 517 CrossThreadWeakPersistent(T& raw) : Parent(raw) { }
482 CrossThreadWeakPersistent(const CrossThreadWeakPersistent& other) : Parent(o ther) { } 518 CrossThreadWeakPersistent(const CrossThreadWeakPersistent& other) : Parent(o ther) { }
483 template<typename U> 519 template<typename U>
484 CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Paren t(other) { } 520 CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Paren t(other) { }
485 template<typename U> 521 template<typename U>
522 CrossThreadWeakPersistent(const UntracedMember<U>& other) : Parent(other) { }
523 template<typename U>
486 CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { } 524 CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { }
487 template<typename U> 525 template<typename U>
488 CrossThreadWeakPersistent(const RawPtr<U>& other) : Parent(other.get()) { } 526 CrossThreadWeakPersistent(const RawPtr<U>& other) : Parent(other.get()) { }
489 527
490 template<typename U> 528 template<typename U>
491 CrossThreadWeakPersistent& operator=(U* other) 529 CrossThreadWeakPersistent& operator=(U* other)
492 { 530 {
493 Parent::operator=(other); 531 Parent::operator=(other);
494 return *this; 532 return *this;
495 } 533 }
(...skipping 11 matching lines...) Expand all
507 } 545 }
508 546
509 template<typename U> 547 template<typename U>
510 CrossThreadWeakPersistent& operator=(const CrossThreadWeakPersistent<U>& oth er) 548 CrossThreadWeakPersistent& operator=(const CrossThreadWeakPersistent<U>& oth er)
511 { 549 {
512 Parent::operator=(other); 550 Parent::operator=(other);
513 return *this; 551 return *this;
514 } 552 }
515 553
516 template<typename U> 554 template<typename U>
555 CrossThreadWeakPersistent& operator=(const UntracedMember<U>& other)
556 {
557 Parent::operator=(other);
558 return *this;
559 }
560
561 template<typename U>
517 CrossThreadWeakPersistent& operator=(const Member<U>& other) 562 CrossThreadWeakPersistent& operator=(const Member<U>& other)
518 { 563 {
519 Parent::operator=(other); 564 Parent::operator=(other);
520 return *this; 565 return *this;
521 } 566 }
522 567
523 template<typename U> 568 template<typename U>
524 CrossThreadWeakPersistent& operator=(const RawPtr<U>& other) 569 CrossThreadWeakPersistent& operator=(const RawPtr<U>& other)
525 { 570 {
526 Parent::operator=(other); 571 Parent::operator=(other);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 729 }
685 730
686 bool isHashTableDeletedValue() const { return m_raw == reinterpret_cast<T*>( -1); } 731 bool isHashTableDeletedValue() const { return m_raw == reinterpret_cast<T*>( -1); }
687 732
688 template<typename U> 733 template<typename U>
689 Member(const Persistent<U>& other) : m_raw(other) 734 Member(const Persistent<U>& other) : m_raw(other)
690 { 735 {
691 checkPointer(); 736 checkPointer();
692 } 737 }
693 738
739 template<typename U>
740 Member(const UntracedMember<U>& other) : m_raw(other)
741 {
742 checkPointer();
743 }
744
694 Member(const Member& other) : m_raw(other) 745 Member(const Member& other) : m_raw(other)
695 { 746 {
696 checkPointer(); 747 checkPointer();
697 } 748 }
698 749
699 template<typename U> 750 template<typename U>
700 Member(const Member<U>& other) : m_raw(other) 751 Member(const Member<U>& other) : m_raw(other)
701 { 752 {
702 checkPointer(); 753 checkPointer();
703 } 754 }
(...skipping 24 matching lines...) Expand all
728 779
729 template<typename U> 780 template<typename U>
730 Member& operator=(const Member<U>& other) 781 Member& operator=(const Member<U>& other)
731 { 782 {
732 m_raw = other; 783 m_raw = other;
733 checkPointer(); 784 checkPointer();
734 return *this; 785 return *this;
735 } 786 }
736 787
737 template<typename U> 788 template<typename U>
789 Member& operator=(const UntracedMember<U>& other)
790 {
791 m_raw = other;
792 checkPointer();
793 return *this;
794 }
795
796 template<typename U>
738 Member& operator=(U* other) 797 Member& operator=(U* other)
739 { 798 {
740 m_raw = other; 799 m_raw = other;
741 checkPointer(); 800 checkPointer();
742 return *this; 801 return *this;
743 } 802 }
744 803
745 template<typename U> 804 template<typename U>
746 Member& operator=(RawPtr<U> other) 805 Member& operator=(RawPtr<U> other)
747 { 806 {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 WeakMember(std::nullptr_t) : Member<T>(nullptr) { } 875 WeakMember(std::nullptr_t) : Member<T>(nullptr) { }
817 876
818 WeakMember(T* raw) : Member<T>(raw) { } 877 WeakMember(T* raw) : Member<T>(raw) { }
819 878
820 WeakMember(WTF::HashTableDeletedValueType x) : Member<T>(x) { } 879 WeakMember(WTF::HashTableDeletedValueType x) : Member<T>(x) { }
821 880
822 template<typename U> 881 template<typename U>
823 WeakMember(const Persistent<U>& other) : Member<T>(other) { } 882 WeakMember(const Persistent<U>& other) : Member<T>(other) { }
824 883
825 template<typename U> 884 template<typename U>
885 WeakMember(const UntracedMember<U>& other) : Member<T>(other) { }
886
887 template<typename U>
826 WeakMember(const Member<U>& other) : Member<T>(other) { } 888 WeakMember(const Member<U>& other) : Member<T>(other) { }
827 889
828 template<typename U> 890 template<typename U>
829 WeakMember& operator=(const Persistent<U>& other) 891 WeakMember& operator=(const Persistent<U>& other)
830 { 892 {
831 this->m_raw = other; 893 this->m_raw = other;
832 this->checkPointer(); 894 this->checkPointer();
833 return *this; 895 return *this;
834 } 896 }
835 897
836 template<typename U> 898 template<typename U>
837 WeakMember& operator=(const Member<U>& other) 899 WeakMember& operator=(const Member<U>& other)
838 { 900 {
839 this->m_raw = other; 901 this->m_raw = other;
840 this->checkPointer(); 902 this->checkPointer();
841 return *this; 903 return *this;
842 } 904 }
843 905
844 template<typename U> 906 template<typename U>
907 WeakMember& operator=(const UntracedMember<U>& other)
908 {
909 this->m_raw = other;
910 this->checkPointer();
911 return *this;
912 }
913
914 template<typename U>
845 WeakMember& operator=(U* other) 915 WeakMember& operator=(U* other)
846 { 916 {
847 this->m_raw = other; 917 this->m_raw = other;
848 this->checkPointer(); 918 this->checkPointer();
849 return *this; 919 return *this;
850 } 920 }
851 921
852 template<typename U> 922 template<typename U>
853 WeakMember& operator=(const RawPtr<U>& other) 923 WeakMember& operator=(const RawPtr<U>& other)
854 { 924 {
855 this->m_raw = other; 925 this->m_raw = other;
856 this->checkPointer(); 926 this->checkPointer();
857 return *this; 927 return *this;
858 } 928 }
859 929
860 WeakMember& operator=(std::nullptr_t) 930 WeakMember& operator=(std::nullptr_t)
861 { 931 {
862 this->m_raw = nullptr; 932 this->m_raw = nullptr;
863 return *this; 933 return *this;
864 } 934 }
865 935
866 private: 936 private:
867 T** cell() const { return const_cast<T**>(&this->m_raw); } 937 T** cell() const { return const_cast<T**>(&this->m_raw); }
868 938
869 template<typename Derived> friend class VisitorHelper; 939 template<typename Derived> friend class VisitorHelper;
870 }; 940 };
871 941
872 // Comparison operators between (Weak)Members and Persistents 942 // UntracedMember is actually a raw pointer.
943 // It is allowed to store a pointer to an object on oilpan heap,
944 // and it is also allowed to store UntracedMember in off heap collections.
945 // UntracedMember does not keep the pointee object alive, so if you use
946 // UntracedMember, you must guarantee that the pointee object is alive in
947 // some reason.
948 template<typename T>
949 class UntracedMember : public Member<T> {
950 public:
951 UntracedMember() : Member<T>() { }
952
953 UntracedMember(std::nullptr_t) : Member<T>(nullptr) { }
954
955 UntracedMember(const UntracedMember& other) : Member<T>(other) { }
956
957 template<typename U>
958 UntracedMember(const UntracedMember<U>& other) : Member<T>(other) { }
959
960 UntracedMember(T* raw) : Member<T>(raw) { }
961
962 template<typename U>
963 UntracedMember(const RawPtr<U>& other) : Member<T>(other) { }
964
965 template<typename U>
966 UntracedMember(const Persistent<U>& other) : Member<T>(other) { }
967
968 template<typename U>
969 UntracedMember(const Member<U>& other) : Member<T>(other) { }
970
971 UntracedMember(WTF::HashTableDeletedValueType x) : Member<T>(x) { }
972 };
973
974 // Comparison operators between (Weak)Members, Persistents, and UntracedMembers.
873 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Member<U>& b) { return a.get() == b.get(); } 975 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Member<U>& b) { return a.get() == b.get(); }
874 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Member<U>& b) { return a.get() != b.get(); } 976 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Member<U>& b) { return a.get() != b.get(); }
977 template<typename T, typename U> inline bool operator==(const UntracedMember<T>& a, const UntracedMember<U>& b) { return a.get() == b.get(); }
978 template<typename T, typename U> inline bool operator!=(const UntracedMember<T>& a, const UntracedMember<U>& b) { return a.get() != b.get(); }
979 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); }
980 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); }
981
875 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Persistent<U>& b) { return a.get() == b.get(); } 982 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Persistent<U>& b) { return a.get() == b.get(); }
876 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Persistent<U>& b) { return a.get() != b.get(); } 983 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Persistent<U>& b) { return a.get() != b.get(); }
877 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Member<U>& b) { return a.get() == b.get(); } 984 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Member<U>& b) { return a.get() == b.get(); }
878 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Member<U>& b) { return a.get() != b.get(); } 985 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Member<U>& b) { return a.get() != b.get(); }
879 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); } 986 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t UntracedMember<U>& b) { return a.get() == b.get(); }
880 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); } 987 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t UntracedMember<U>& b) { return a.get() != b.get(); }
988 template<typename T, typename U> inline bool operator==(const UntracedMember<T>& a, const Member<U>& b) { return a.get() == b.get(); }
989 template<typename T, typename U> inline bool operator!=(const UntracedMember<T>& a, const Member<U>& b) { return a.get() != b.get(); }
990 template<typename T, typename U> inline bool operator==(const UntracedMember<T>& a, const Persistent<U>& b) { return a.get() == b.get(); }
991 template<typename T, typename U> inline bool operator!=(const UntracedMember<T>& a, const Persistent<U>& b) { return a.get() != b.get(); }
992 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const UntracedMember<U>& b) { return a.get() == b.get(); }
993 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const UntracedMember<U>& b) { return a.get() != b.get(); }
881 994
882 template<typename T> 995 template<typename T>
883 class DummyBase { 996 class DummyBase {
884 public: 997 public:
885 DummyBase() { } 998 DummyBase() { }
886 ~DummyBase() { } 999 ~DummyBase() { }
887 }; 1000 };
888 1001
889 // CPP-defined type names for the transition period where we want to 1002 // CPP-defined type names for the transition period where we want to
890 // support both reference counting and garbage collection based on a 1003 // support both reference counting and garbage collection based on a
(...skipping 27 matching lines...) Expand all
918 #define RefPtrWillBePersistent blink::Persistent 1031 #define RefPtrWillBePersistent blink::Persistent
919 #define RefPtrWillBeRawPtr WTF::RawPtr 1032 #define RefPtrWillBeRawPtr WTF::RawPtr
920 #define RefPtrWillBeMember blink::Member 1033 #define RefPtrWillBeMember blink::Member
921 #define RefPtrWillBeWeakMember blink::WeakMember 1034 #define RefPtrWillBeWeakMember blink::WeakMember
922 #define RefPtrWillBeWeakPersistent blink::WeakPersistent 1035 #define RefPtrWillBeWeakPersistent blink::WeakPersistent
923 #define RefPtrWillBeCrossThreadPersistent blink::CrossThreadPersistent 1036 #define RefPtrWillBeCrossThreadPersistent blink::CrossThreadPersistent
924 #define RawPtrWillBeMember blink::Member 1037 #define RawPtrWillBeMember blink::Member
925 #define RawPtrWillBePersistent blink::Persistent 1038 #define RawPtrWillBePersistent blink::Persistent
926 #define RawPtrWillBeWeakMember blink::WeakMember 1039 #define RawPtrWillBeWeakMember blink::WeakMember
927 #define RawPtrWillBeWeakPersistent blink::WeakPersistent 1040 #define RawPtrWillBeWeakPersistent blink::WeakPersistent
1041 #define RawPtrWillBeUntracedMember blink::UntracedMember
928 #define OwnPtrWillBeCrossThreadPersistent blink::CrossThreadPersistent 1042 #define OwnPtrWillBeCrossThreadPersistent blink::CrossThreadPersistent
929 #define OwnPtrWillBeMember blink::Member 1043 #define OwnPtrWillBeMember blink::Member
930 #define OwnPtrWillBePersistent blink::Persistent 1044 #define OwnPtrWillBePersistent blink::Persistent
931 #define OwnPtrWillBeRawPtr WTF::RawPtr 1045 #define OwnPtrWillBeRawPtr WTF::RawPtr
932 #define PassOwnPtrWillBeRawPtr WTF::RawPtr 1046 #define PassOwnPtrWillBeRawPtr WTF::RawPtr
933 #define WeakPtrWillBeCrossThreadWeakPersistent blink::CrossThreadWeakPersistent 1047 #define WeakPtrWillBeCrossThreadWeakPersistent blink::CrossThreadWeakPersistent
934 #define WeakPtrWillBeMember blink::Member 1048 #define WeakPtrWillBeMember blink::Member
935 #define WeakPtrWillBeRawPtr WTF::RawPtr 1049 #define WeakPtrWillBeRawPtr WTF::RawPtr
936 #define WeakPtrWillBeWeakMember blink::WeakMember 1050 #define WeakPtrWillBeWeakMember blink::WeakMember
937 #define WeakPtrWillBeWeakPersistent blink::WeakPersistent 1051 #define WeakPtrWillBeWeakPersistent blink::WeakPersistent
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 #define RefPtrWillBePersistent WTF::RefPtr 1115 #define RefPtrWillBePersistent WTF::RefPtr
1002 #define RefPtrWillBeRawPtr WTF::RefPtr 1116 #define RefPtrWillBeRawPtr WTF::RefPtr
1003 #define RefPtrWillBeMember WTF::RefPtr 1117 #define RefPtrWillBeMember WTF::RefPtr
1004 #define RefPtrWillBeWeakMember WTF::RefPtr 1118 #define RefPtrWillBeWeakMember WTF::RefPtr
1005 #define RefPtrWillBeWeakPersistent WTF::RefPtr 1119 #define RefPtrWillBeWeakPersistent WTF::RefPtr
1006 #define RefPtrWillBeCrossThreadPersistent WTF::RefPtr 1120 #define RefPtrWillBeCrossThreadPersistent WTF::RefPtr
1007 #define RawPtrWillBeMember WTF::RawPtr 1121 #define RawPtrWillBeMember WTF::RawPtr
1008 #define RawPtrWillBePersistent WTF::RawPtr 1122 #define RawPtrWillBePersistent WTF::RawPtr
1009 #define RawPtrWillBeWeakMember WTF::RawPtr 1123 #define RawPtrWillBeWeakMember WTF::RawPtr
1010 #define RawPtrWillBeWeakPersistent WTF::RawPtr 1124 #define RawPtrWillBeWeakPersistent WTF::RawPtr
1125 #define RawPtrWillBeUntracedMember WTF::RawPtr
1011 #define OwnPtrWillBeCrossThreadPersistent WTF::OwnPtr 1126 #define OwnPtrWillBeCrossThreadPersistent WTF::OwnPtr
1012 #define OwnPtrWillBeMember WTF::OwnPtr 1127 #define OwnPtrWillBeMember WTF::OwnPtr
1013 #define OwnPtrWillBePersistent WTF::OwnPtr 1128 #define OwnPtrWillBePersistent WTF::OwnPtr
1014 #define OwnPtrWillBeRawPtr WTF::OwnPtr 1129 #define OwnPtrWillBeRawPtr WTF::OwnPtr
1015 #define PassOwnPtrWillBeRawPtr WTF::PassOwnPtr 1130 #define PassOwnPtrWillBeRawPtr WTF::PassOwnPtr
1016 #define WeakPtrWillBeCrossThreadWeakPersistent WTF::WeakPtr 1131 #define WeakPtrWillBeCrossThreadWeakPersistent WTF::WeakPtr
1017 #define WeakPtrWillBeMember WTF::WeakPtr 1132 #define WeakPtrWillBeMember WTF::WeakPtr
1018 #define WeakPtrWillBeRawPtr WTF::WeakPtr 1133 #define WeakPtrWillBeRawPtr WTF::WeakPtr
1019 #define WeakPtrWillBeWeakMember WTF::WeakPtr 1134 #define WeakPtrWillBeWeakMember WTF::WeakPtr
1020 #define WeakPtrWillBeWeakPersistent WTF::WeakPtr 1135 #define WeakPtrWillBeWeakPersistent WTF::WeakPtr
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 static const bool canMoveWithMemcpy = true; 1306 static const bool canMoveWithMemcpy = true;
1192 }; 1307 };
1193 1308
1194 template <typename T> struct VectorTraits<blink::WeakMember<T>> : VectorTraitsBa se<blink::WeakMember<T>> { 1309 template <typename T> struct VectorTraits<blink::WeakMember<T>> : VectorTraitsBa se<blink::WeakMember<T>> {
1195 static const bool needsDestruction = false; 1310 static const bool needsDestruction = false;
1196 static const bool canInitializeWithMemset = true; 1311 static const bool canInitializeWithMemset = true;
1197 static const bool canClearUnusedSlotsWithMemset = true; 1312 static const bool canClearUnusedSlotsWithMemset = true;
1198 static const bool canMoveWithMemcpy = true; 1313 static const bool canMoveWithMemcpy = true;
1199 }; 1314 };
1200 1315
1316 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai tsBase<blink::UntracedMember<T>> {
1317 static const bool needsDestruction = false;
1318 static const bool canInitializeWithMemset = true;
1319 static const bool canClearUnusedSlotsWithMemset = true;
1320 static const bool canMoveWithMemcpy = true;
1321 };
1322
1201 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait sBase<blink::HeapVector<T, 0>> { 1323 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait sBase<blink::HeapVector<T, 0>> {
1202 static const bool needsDestruction = false; 1324 static const bool needsDestruction = false;
1203 static const bool canInitializeWithMemset = true; 1325 static const bool canInitializeWithMemset = true;
1204 static const bool canClearUnusedSlotsWithMemset = true; 1326 static const bool canClearUnusedSlotsWithMemset = true;
1205 static const bool canMoveWithMemcpy = true; 1327 static const bool canMoveWithMemcpy = true;
1206 }; 1328 };
1207 1329
1208 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits Base<blink::HeapDeque<T, 0>> { 1330 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits Base<blink::HeapDeque<T, 0>> {
1209 static const bool needsDestruction = false; 1331 static const bool needsDestruction = false;
1210 static const bool canInitializeWithMemset = true; 1332 static const bool canInitializeWithMemset = true;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 static bool traceInCollection(VisitorDispatcher visitor, blink::WeakMember<T >& weakMember, ShouldWeakPointersBeMarkedStrongly strongify) 1404 static bool traceInCollection(VisitorDispatcher visitor, blink::WeakMember<T >& weakMember, ShouldWeakPointersBeMarkedStrongly strongify)
1283 { 1405 {
1284 if (strongify == WeakPointersActStrong) { 1406 if (strongify == WeakPointersActStrong) {
1285 visitor->trace(weakMember.get()); // Strongified visit. 1407 visitor->trace(weakMember.get()); // Strongified visit.
1286 return false; 1408 return false;
1287 } 1409 }
1288 return !blink::Heap::isHeapObjectAlive(weakMember); 1410 return !blink::Heap::isHeapObjectAlive(weakMember);
1289 } 1411 }
1290 }; 1412 };
1291 1413
1414 template<typename T> struct HashTraits<blink::UntracedMember<T>> : SimpleClassHa shTraits<blink::UntracedMember<T>> {
1415 static const bool needsDestruction = false;
1416 // FIXME: The distinction between PeekInType and PassInType is there for
1417 // the sake of the reference counting handles. When they are gone the two
1418 // types can be merged into PassInType.
1419 // FIXME: Implement proper const'ness for iterator types.
1420 using PeekInType = RawPtr<T>;
1421 using PassInType = RawPtr<T>;
1422 using IteratorGetType = blink::UntracedMember<T>*;
1423 using IteratorConstGetType = const blink::UntracedMember<T>*;
1424 using IteratorReferenceType = blink::UntracedMember<T>&;
1425 using IteratorConstReferenceType = const blink::UntracedMember<T>&;
1426 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; }
1427 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; }
1428 // FIXME: Similarly, there is no need for a distinction between PeekOutType
1429 // and PassOutType without reference counting.
1430 using PeekOutType = T*;
1431 using PassOutType = T*;
1432
1433 template<typename U>
1434 static void store(const U& value, blink::UntracedMember<T>& storage) { stora ge = value; }
1435
1436 static PeekOutType peek(const blink::UntracedMember<T>& value) { return valu e; }
1437 static PassOutType passOut(const blink::UntracedMember<T>& value) { return v alue; }
1438 };
1439
1292 template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> { 1440 template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> {
1293 template<typename U> 1441 template<typename U>
1294 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } 1442 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); }
1295 static bool equal(T* a, const blink::Member<T>& b) { return a == b; } 1443 static bool equal(T* a, const blink::Member<T>& b) { return a == b; }
1296 static bool equal(const blink::Member<T>& a, T* b) { return a == b; } 1444 static bool equal(const blink::Member<T>& a, T* b) { return a == b; }
1297 template<typename U, typename V> 1445 template<typename U, typename V>
1298 static bool equal(const U& a, const V& b) { return a == b; } 1446 static bool equal(const U& a, const V& b) { return a == b; }
1299 }; 1447 };
1300 1448
1301 template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Membe r<T>> { 1449 template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Membe r<T>> {
1302 }; 1450 };
1303 1451
1452 template<typename T> struct PtrHash<blink::UntracedMember<T>> : PtrHash<blink::M ember<T>> {
1453 };
1454
1304 // PtrHash is the default hash for hash tables with members. 1455 // PtrHash is the default hash for hash tables with members.
1305 template<typename T> struct DefaultHash<blink::Member<T>> { 1456 template<typename T> struct DefaultHash<blink::Member<T>> {
1306 using Hash = PtrHash<blink::Member<T>>; 1457 using Hash = PtrHash<blink::Member<T>>;
1307 }; 1458 };
1308 1459
1309 template<typename T> struct DefaultHash<blink::WeakMember<T>> { 1460 template<typename T> struct DefaultHash<blink::WeakMember<T>> {
1310 using Hash = PtrHash<blink::WeakMember<T>>; 1461 using Hash = PtrHash<blink::WeakMember<T>>;
1311 }; 1462 };
1312 1463
1464 template<typename T> struct DefaultHash<blink::UntracedMember<T>> {
1465 using Hash = PtrHash<blink::UntracedMember<T>>;
1466 };
1467
1313 template<typename T> 1468 template<typename T>
1314 struct NeedsTracing<blink::Member<T>> { 1469 struct NeedsTracing<blink::Member<T>> {
1315 static const bool value = true; 1470 static const bool value = true;
1316 }; 1471 };
1317 1472
1318 template<typename T> 1473 template<typename T>
1319 struct IsWeak<blink::WeakMember<T>> { 1474 struct IsWeak<blink::WeakMember<T>> {
1320 static const bool value = true; 1475 static const bool value = true;
1321 }; 1476 };
1322 1477
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent. 1536 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent.
1382 static T* unwrap(const StorageType& value) { return value.get(); } 1537 static T* unwrap(const StorageType& value) { return value.get(); }
1383 }; 1538 };
1384 1539
1385 template<typename T> 1540 template<typename T>
1386 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1541 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1387 1542
1388 } // namespace WTF 1543 } // namespace WTF
1389 1544
1390 #endif 1545 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | third_party/WebKit/Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698