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

Side by Side Diff: third_party/WebKit/Source/wtf/HashCountedSet.h

Issue 1652953002: Make copyToVector() robust against conservative GCs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary 'template' use Created 4 years, 10 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) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return; 123 return;
124 124
125 m_impl.remove(it); 125 m_impl.remove(it);
126 } 126 }
127 127
128 template <typename T, typename U, typename V, typename W, typename VectorType> 128 template <typename T, typename U, typename V, typename W, typename VectorType>
129 inline void copyToVector(const HashCountedSet<T, U, V, W>& collection, VectorTyp e& vector) 129 inline void copyToVector(const HashCountedSet<T, U, V, W>& collection, VectorTyp e& vector)
130 { 130 {
131 typedef typename HashCountedSet<T, U, V, W>::const_iterator iterator; 131 typedef typename HashCountedSet<T, U, V, W>::const_iterator iterator;
132 132
133 vector.resize(collection.size()); 133 {
134 // Disallow GC across resize allocation, see crbug.com/568173
135 typename VectorType::GCForbiddenScope scope;
136 vector.resize(collection.size());
137 }
134 138
135 iterator it = collection.begin(); 139 iterator it = collection.begin();
136 iterator end = collection.end(); 140 iterator end = collection.end();
137 for (unsigned i = 0; it != end; ++it, ++i) 141 for (unsigned i = 0; it != end; ++it, ++i)
138 vector[i] = *it; 142 vector[i] = *it;
139 } 143 }
140 144
141 template <typename Value, typename HashFunctions, typename Traits, typename Allo cator, size_t inlineCapacity, typename VectorAllocator> 145 template <typename Value, typename HashFunctions, typename Traits, typename Allo cator, size_t inlineCapacity, typename VectorAllocator>
142 inline void copyToVector(const HashCountedSet<Value, HashFunctions, Traits, Allo cator>& collection, Vector<Value, inlineCapacity, VectorAllocator>& vector) 146 inline void copyToVector(const HashCountedSet<Value, HashFunctions, Traits, Allo cator>& collection, Vector<Value, inlineCapacity, VectorAllocator>& vector)
143 { 147 {
144 typedef typename HashCountedSet<Value, HashFunctions, Traits, Allocator>::co nst_iterator iterator; 148 typedef typename HashCountedSet<Value, HashFunctions, Traits, Allocator>::co nst_iterator iterator;
145 149
146 vector.resize(collection.size()); 150 {
151 // Disallow GC across resize allocation, see crbug.com/568173
152 typename Vector<Value, inlineCapacity, VectorAllocator>::GCForbiddenScop e scope;
153 vector.resize(collection.size());
154 }
147 155
148 iterator it = collection.begin(); 156 iterator it = collection.begin();
149 iterator end = collection.end(); 157 iterator end = collection.end();
150 for (unsigned i = 0; it != end; ++it, ++i) 158 for (unsigned i = 0; it != end; ++it, ++i)
151 vector[i] = (*it).key; 159 vector[i] = (*it).key;
152 } 160 }
153 161
154 #if !ENABLE(OILPAN) 162 #if !ENABLE(OILPAN)
155 template <typename T, typename U, typename V> 163 template <typename T, typename U, typename V>
156 struct NeedsTracing<HashCountedSet<T, U, V>> { 164 struct NeedsTracing<HashCountedSet<T, U, V>> {
157 static const bool value = false; 165 static const bool value = false;
158 }; 166 };
159 #endif 167 #endif
160 168
161 } // namespace WTF 169 } // namespace WTF
162 170
163 using WTF::HashCountedSet; 171 using WTF::HashCountedSet;
164 172
165 #endif // WTF_HashCountedSet_h 173 #endif // WTF_HashCountedSet_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSFontSelector.cpp ('k') | third_party/WebKit/Source/wtf/HashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698