Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1019 // The check is just a static hint for a compiler to indicate that | 1019 // The check is just a static hint for a compiler to indicate that |
| 1020 // Base::expandBuffer returns false if Allocator is a DefaultAllocator. | 1020 // Base::expandBuffer returns false if Allocator is a DefaultAllocator. |
| 1021 if (Allocator::isGarbageCollected && Base::expandBuffer(newCapacity)) { | 1021 if (Allocator::isGarbageCollected && Base::expandBuffer(newCapacity)) { |
| 1022 ANNOTATE_CHANGE_CAPACITY(begin(), oldCapacity, m_size, capacity()); | 1022 ANNOTATE_CHANGE_CAPACITY(begin(), oldCapacity, m_size, capacity()); |
| 1023 return; | 1023 return; |
| 1024 } | 1024 } |
| 1025 T* oldEnd = end(); | 1025 T* oldEnd = end(); |
| 1026 Base::allocateExpandedBuffer(newCapacity); | 1026 Base::allocateExpandedBuffer(newCapacity); |
| 1027 ANNOTATE_NEW_BUFFER(begin(), capacity(), m_size); | 1027 ANNOTATE_NEW_BUFFER(begin(), capacity(), m_size); |
| 1028 TypeOperations::move(oldBuffer, oldEnd, begin()); | 1028 TypeOperations::move(oldBuffer, oldEnd, begin()); |
| 1029 clearUnusedSlots(oldBuffer, oldEnd); | |
| 1029 ANNOTATE_DELETE_BUFFER(oldBuffer, oldCapacity, m_size); | 1030 ANNOTATE_DELETE_BUFFER(oldBuffer, oldCapacity, m_size); |
| 1030 Base::deallocateBuffer(oldBuffer); | 1031 Base::deallocateBuffer(oldBuffer); |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 template<typename T, size_t inlineCapacity, typename Allocator> | 1034 template<typename T, size_t inlineCapacity, typename Allocator> |
| 1034 inline void Vector<T, inlineCapacity, Allocator>::reserveInitialCapacity(siz e_t initialCapacity) | 1035 inline void Vector<T, inlineCapacity, Allocator>::reserveInitialCapacity(siz e_t initialCapacity) |
| 1035 { | 1036 { |
| 1036 ASSERT(!m_size); | 1037 ASSERT(!m_size); |
| 1037 ASSERT(capacity() == INLINE_CAPACITY); | 1038 ASSERT(capacity() == INLINE_CAPACITY); |
| 1038 if (initialCapacity > INLINE_CAPACITY) { | 1039 if (initialCapacity > INLINE_CAPACITY) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1059 if (Base::shrinkBuffer(newCapacity)) { | 1060 if (Base::shrinkBuffer(newCapacity)) { |
| 1060 ANNOTATE_CHANGE_CAPACITY(begin(), oldCapacity, m_size, capacity( )); | 1061 ANNOTATE_CHANGE_CAPACITY(begin(), oldCapacity, m_size, capacity( )); |
| 1061 return; | 1062 return; |
| 1062 } | 1063 } |
| 1063 | 1064 |
| 1064 T* oldEnd = end(); | 1065 T* oldEnd = end(); |
| 1065 Base::allocateBuffer(newCapacity); | 1066 Base::allocateBuffer(newCapacity); |
| 1066 if (begin() != oldBuffer) { | 1067 if (begin() != oldBuffer) { |
| 1067 ANNOTATE_NEW_BUFFER(begin(), capacity(), m_size); | 1068 ANNOTATE_NEW_BUFFER(begin(), capacity(), m_size); |
| 1068 TypeOperations::move(oldBuffer, oldEnd, begin()); | 1069 TypeOperations::move(oldBuffer, oldEnd, begin()); |
| 1070 clearUnusedSlots(oldBuffer, oldEnd); | |
| 1069 ANNOTATE_DELETE_BUFFER(oldBuffer, oldCapacity, m_size); | 1071 ANNOTATE_DELETE_BUFFER(oldBuffer, oldCapacity, m_size); |
| 1070 } | 1072 } |
| 1071 } else { | 1073 } else { |
| 1072 Base::resetBufferPointer(); | 1074 Base::resetBufferPointer(); |
| 1073 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | 1075 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 1074 if (oldBuffer != begin()) { | 1076 if (oldBuffer != begin()) { |
| 1075 ANNOTATE_NEW_BUFFER(begin(), capacity(), m_size); | 1077 ANNOTATE_NEW_BUFFER(begin(), capacity(), m_size); |
| 1076 ANNOTATE_DELETE_BUFFER(oldBuffer, oldCapacity, m_size); | 1078 ANNOTATE_DELETE_BUFFER(oldBuffer, oldCapacity, m_size); |
| 1077 } | 1079 } |
| 1078 #endif | 1080 #endif |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 // This is only called if the allocator is a HeapAllocator. It is used when | 1280 // This is only called if the allocator is a HeapAllocator. It is used when |
| 1279 // visiting during a tracing GC. | 1281 // visiting during a tracing GC. |
| 1280 template<typename T, size_t inlineCapacity, typename Allocator> | 1282 template<typename T, size_t inlineCapacity, typename Allocator> |
| 1281 template<typename VisitorDispatcher> | 1283 template<typename VisitorDispatcher> |
| 1282 void Vector<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) | 1284 void Vector<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) |
| 1283 { | 1285 { |
| 1284 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab led. | 1286 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab led. |
| 1285 const T* bufferBegin = buffer(); | 1287 const T* bufferBegin = buffer(); |
| 1286 const T* bufferEnd = buffer() + size(); | 1288 const T* bufferEnd = buffer() + size(); |
| 1287 if (ShouldBeTraced<VectorTraits<T>>::value) { | 1289 if (ShouldBeTraced<VectorTraits<T>>::value) { |
| 1288 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; b ufferEntry++) | 1290 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; b ufferEntry++) |
|
haraken
2015/04/18 23:48:47
Here would it be helpful to insert ASSERTs to veri
sof
2015/04/19 20:10:52
Excellent suggestion. Added & by doing so I came a
| |
| 1289 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>> (visitor, *const_cast<T*>(bufferEntry)); | 1291 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>> (visitor, *const_cast<T*>(bufferEntry)); |
| 1290 } | 1292 } |
| 1291 if (this->hasOutOfLineBuffer()) | 1293 if (this->hasOutOfLineBuffer()) |
| 1292 Allocator::markNoTracing(visitor, buffer()); | 1294 Allocator::markNoTracing(visitor, buffer()); |
| 1293 } | 1295 } |
| 1294 | 1296 |
| 1295 #if !ENABLE(OILPAN) | 1297 #if !ENABLE(OILPAN) |
| 1296 template<typename T, size_t N> | 1298 template<typename T, size_t N> |
| 1297 struct NeedsTracing<Vector<T, N>> { | 1299 struct NeedsTracing<Vector<T, N>> { |
| 1298 static const bool value = false; | 1300 static const bool value = false; |
| 1299 }; | 1301 }; |
| 1300 #endif | 1302 #endif |
| 1301 | 1303 |
| 1302 } // namespace WTF | 1304 } // namespace WTF |
| 1303 | 1305 |
| 1304 using WTF::Vector; | 1306 using WTF::Vector; |
| 1305 | 1307 |
| 1306 #endif // WTF_Vector_h | 1308 #endif // WTF_Vector_h |
| OLD | NEW |