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

Side by Side Diff: third_party/WebKit/Source/platform/heap/ThreadingTraits.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 // 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 ThreadingTraits_h 5 #ifndef ThreadingTraits_h
6 #define ThreadingTraits_h 6 #define ThreadingTraits_h
7 7
8 #include "wtf/Allocator.h"
8 #include "wtf/Deque.h" 9 #include "wtf/Deque.h"
9 #include "wtf/HashCountedSet.h" 10 #include "wtf/HashCountedSet.h"
10 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
11 #include "wtf/HashSet.h" 12 #include "wtf/HashSet.h"
12 #include "wtf/HashTable.h" 13 #include "wtf/HashTable.h"
13 #include "wtf/LinkedHashSet.h" 14 #include "wtf/LinkedHashSet.h"
14 #include "wtf/ListHashSet.h" 15 #include "wtf/ListHashSet.h"
15 #include "wtf/TypeTraits.h" 16 #include "wtf/TypeTraits.h"
16 #include "wtf/Vector.h" 17 #include "wtf/Vector.h"
17 18
(...skipping 15 matching lines...) Expand all
33 // Remove them. 34 // Remove them.
34 class Node; 35 class Node;
35 class NodeList; 36 class NodeList;
36 37
37 template<typename T, 38 template<typename T,
38 bool mainThreadOnly = WTF::IsSubclass<typename std::remove_const<T>::type, N ode>::value 39 bool mainThreadOnly = WTF::IsSubclass<typename std::remove_const<T>::type, N ode>::value
39 || WTF::IsSubclass<typename std::remove_const<T>::type, NodeList>::value > struct DefaultThreadingTrait; 40 || WTF::IsSubclass<typename std::remove_const<T>::type, NodeList>::value > struct DefaultThreadingTrait;
40 41
41 template<typename T> 42 template<typename T>
42 struct DefaultThreadingTrait<T, false> { 43 struct DefaultThreadingTrait<T, false> {
44 STATIC_ONLY(DefaultThreadingTrait);
43 static const ThreadAffinity Affinity = AnyThread; 45 static const ThreadAffinity Affinity = AnyThread;
44 }; 46 };
45 47
46 template<typename T> 48 template<typename T>
47 struct DefaultThreadingTrait<T, true> { 49 struct DefaultThreadingTrait<T, true> {
50 STATIC_ONLY(DefaultThreadingTrait);
48 static const ThreadAffinity Affinity = MainThreadOnly; 51 static const ThreadAffinity Affinity = MainThreadOnly;
49 }; 52 };
50 53
51 class HeapAllocator; 54 class HeapAllocator;
52 template<typename Table> class HeapHashTableBacking; 55 template<typename Table> class HeapHashTableBacking;
53 template<typename T, typename Traits> class HeapVectorBacking; 56 template<typename T, typename Traits> class HeapVectorBacking;
54 template<typename T> class Member; 57 template<typename T> class Member;
55 template<typename T> class WeakMember; 58 template<typename T> class WeakMember;
56 59
57 template<typename T> 60 template<typename T>
58 struct ThreadingTrait { 61 struct ThreadingTrait {
62 STATIC_ONLY(ThreadingTrait);
59 static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity; 63 static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity;
60 }; 64 };
61 65
62 template<typename U> class ThreadingTrait<const U> : public ThreadingTrait<U> { }; 66 template<typename U> class ThreadingTrait<const U> : public ThreadingTrait<U> { };
63 67
64 template<typename T> 68 template<typename T>
65 struct ThreadingTrait<Member<T>> { 69 struct ThreadingTrait<Member<T>> {
70 STATIC_ONLY(ThreadingTrait);
66 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 71 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
67 }; 72 };
68 73
69 template<typename T> 74 template<typename T>
70 struct ThreadingTrait<WeakMember<T>> { 75 struct ThreadingTrait<WeakMember<T>> {
76 STATIC_ONLY(ThreadingTrait);
71 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 77 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
72 }; 78 };
73 79
74 template<typename Key, typename Value, typename T, typename U, typename V> 80 template<typename Key, typename Value, typename T, typename U, typename V>
75 struct ThreadingTrait<HashMap<Key, Value, T, U, V, HeapAllocator>> { 81 struct ThreadingTrait<HashMap<Key, Value, T, U, V, HeapAllocator>> {
82 STATIC_ONLY(ThreadingTrait);
76 static const ThreadAffinity Affinity = 83 static const ThreadAffinity Affinity =
77 (ThreadingTrait<Key>::Affinity == MainThreadOnly) 84 (ThreadingTrait<Key>::Affinity == MainThreadOnly)
78 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread; 85 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
79 }; 86 };
80 87
81 template<typename First, typename Second> 88 template<typename First, typename Second>
82 struct ThreadingTrait<WTF::KeyValuePair<First, Second>> { 89 struct ThreadingTrait<WTF::KeyValuePair<First, Second>> {
90 STATIC_ONLY(ThreadingTrait);
83 static const ThreadAffinity Affinity = 91 static const ThreadAffinity Affinity =
84 (ThreadingTrait<First>::Affinity == MainThreadOnly) 92 (ThreadingTrait<First>::Affinity == MainThreadOnly)
85 && (ThreadingTrait<Second>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread; 93 && (ThreadingTrait<Second>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
86 }; 94 };
87 95
88 template<typename T, typename U, typename V> 96 template<typename T, typename U, typename V>
89 struct ThreadingTrait<HashSet<T, U, V, HeapAllocator>> { 97 struct ThreadingTrait<HashSet<T, U, V, HeapAllocator>> {
98 STATIC_ONLY(ThreadingTrait);
90 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 99 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
91 }; 100 };
92 101
93 template<typename T, size_t inlineCapacity> 102 template<typename T, size_t inlineCapacity>
94 struct ThreadingTrait<Vector<T, inlineCapacity, HeapAllocator>> { 103 struct ThreadingTrait<Vector<T, inlineCapacity, HeapAllocator>> {
104 STATIC_ONLY(ThreadingTrait);
95 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 105 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
96 }; 106 };
97 107
98 template<typename T, typename Traits> 108 template<typename T, typename Traits>
99 struct ThreadingTrait<HeapVectorBacking<T, Traits>> { 109 struct ThreadingTrait<HeapVectorBacking<T, Traits>> {
110 STATIC_ONLY(ThreadingTrait);
100 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 111 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
101 }; 112 };
102 113
103 template<typename T, size_t inlineCapacity> 114 template<typename T, size_t inlineCapacity>
104 struct ThreadingTrait<Deque<T, inlineCapacity, HeapAllocator>> { 115 struct ThreadingTrait<Deque<T, inlineCapacity, HeapAllocator>> {
116 STATIC_ONLY(ThreadingTrait);
105 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 117 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
106 }; 118 };
107 119
108 template<typename T, typename U, typename V> 120 template<typename T, typename U, typename V>
109 struct ThreadingTrait<HashCountedSet<T, U, V, HeapAllocator>> { 121 struct ThreadingTrait<HashCountedSet<T, U, V, HeapAllocator>> {
122 STATIC_ONLY(ThreadingTrait);
110 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 123 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
111 }; 124 };
112 125
113 template<typename Table> 126 template<typename Table>
114 struct ThreadingTrait<HeapHashTableBacking<Table>> { 127 struct ThreadingTrait<HeapHashTableBacking<Table>> {
128 STATIC_ONLY(ThreadingTrait);
115 using Key = typename Table::KeyType; 129 using Key = typename Table::KeyType;
116 using Value = typename Table::ValueType; 130 using Value = typename Table::ValueType;
117 static const ThreadAffinity Affinity = 131 static const ThreadAffinity Affinity =
118 (ThreadingTrait<Key>::Affinity == MainThreadOnly) 132 (ThreadingTrait<Key>::Affinity == MainThreadOnly)
119 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread; 133 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
120 }; 134 };
121 135
122 template<typename T, typename U, typename V, typename W, typename X> class HeapH ashMap; 136 template<typename T, typename U, typename V, typename W, typename X> class HeapH ashMap;
123 template<typename T, typename U, typename V> class HeapHashSet; 137 template<typename T, typename U, typename V> class HeapHashSet;
124 template<typename T, size_t inlineCapacity> class HeapVector; 138 template<typename T, size_t inlineCapacity> class HeapVector;
125 template<typename T, size_t inlineCapacity> class HeapDeque; 139 template<typename T, size_t inlineCapacity> class HeapDeque;
126 template<typename T, typename U, typename V> class HeapHashCountedSet; 140 template<typename T, typename U, typename V> class HeapHashCountedSet;
127 141
128 template<typename T, typename U, typename V, typename W, typename X> 142 template<typename T, typename U, typename V, typename W, typename X>
129 struct ThreadingTrait<HeapHashMap<T, U, V, W, X>> : public ThreadingTrait<HashMa p<T, U, V, W, X, HeapAllocator>> { }; 143 struct ThreadingTrait<HeapHashMap<T, U, V, W, X>> : public ThreadingTrait<HashMa p<T, U, V, W, X, HeapAllocator>> {
144 STATIC_ONLY(ThreadingTrait);
145 };
130 template<typename T, typename U, typename V> 146 template<typename T, typename U, typename V>
131 struct ThreadingTrait<HeapHashSet<T, U, V>> : public ThreadingTrait<HashSet<T, U , V, HeapAllocator>> { }; 147 struct ThreadingTrait<HeapHashSet<T, U, V>> : public ThreadingTrait<HashSet<T, U , V, HeapAllocator>> {
148 STATIC_ONLY(ThreadingTrait);
149 };
132 template<typename T, size_t inlineCapacity> 150 template<typename T, size_t inlineCapacity>
133 struct ThreadingTrait<HeapVector<T, inlineCapacity>> : public ThreadingTrait<Vec tor<T, inlineCapacity, HeapAllocator>> { }; 151 struct ThreadingTrait<HeapVector<T, inlineCapacity>> : public ThreadingTrait<Vec tor<T, inlineCapacity, HeapAllocator>> {
152 STATIC_ONLY(ThreadingTrait);
153 };
134 template<typename T, size_t inlineCapacity> 154 template<typename T, size_t inlineCapacity>
135 struct ThreadingTrait<HeapDeque<T, inlineCapacity>> : public ThreadingTrait<Dequ e<T, inlineCapacity, HeapAllocator>> { }; 155 struct ThreadingTrait<HeapDeque<T, inlineCapacity>> : public ThreadingTrait<Dequ e<T, inlineCapacity, HeapAllocator>> {
156 STATIC_ONLY(ThreadingTrait);
157 };
136 template<typename T, typename U, typename V> 158 template<typename T, typename U, typename V>
137 struct ThreadingTrait<HeapHashCountedSet<T, U, V>> : public ThreadingTrait<HashC ountedSet<T, U, V, HeapAllocator>> { }; 159 struct ThreadingTrait<HeapHashCountedSet<T, U, V>> : public ThreadingTrait<HashC ountedSet<T, U, V, HeapAllocator>> {
160 STATIC_ONLY(ThreadingTrait);
161 };
138 162
139 } // namespace blink 163 } // namespace blink
140 164
141 #endif 165 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698