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

Side by Side Diff: Source/wtf/Vector.h

Issue 803443002: Introduce InlinedGlobalMarkingVisitor Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « Source/wtf/TypeTraits.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 template<typename Iterator> void appendRange(Iterator start, Iterator en d); 738 template<typename Iterator> void appendRange(Iterator start, Iterator en d);
739 739
740 void swap(Vector& other) 740 void swap(Vector& other)
741 { 741 {
742 Base::swapVectorBuffer(other); 742 Base::swapVectorBuffer(other);
743 std::swap(m_size, other.m_size); 743 std::swap(m_size, other.m_size);
744 } 744 }
745 745
746 void reverse(); 746 void reverse();
747 747
748 void trace(typename Allocator::Visitor*); 748 template<typename VisitorDispatcher> void trace(VisitorDispatcher visito r);
749 749
750 private: 750 private:
751 void expandCapacity(size_t newMinCapacity); 751 void expandCapacity(size_t newMinCapacity);
752 const T* expandCapacity(size_t newMinCapacity, const T*); 752 const T* expandCapacity(size_t newMinCapacity, const T*);
753 template<typename U> U* expandCapacity(size_t newMinCapacity, U*); 753 template<typename U> U* expandCapacity(size_t newMinCapacity, U*);
754 void shrinkCapacity(size_t newCapacity); 754 void shrinkCapacity(size_t newCapacity);
755 template<typename U> void appendSlowCase(const U&); 755 template<typename U> void appendSlowCase(const U&);
756 756
757 using Base::m_size; 757 using Base::m_size;
758 using Base::buffer; 758 using Base::buffer;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1203
1204 template<typename T, size_t inlineCapacityA, size_t inlineCapacityB, typenam e Allocator> 1204 template<typename T, size_t inlineCapacityA, size_t inlineCapacityB, typenam e Allocator>
1205 inline bool operator!=(const Vector<T, inlineCapacityA, Allocator>& a, const Vector<T, inlineCapacityB, Allocator>& b) 1205 inline bool operator!=(const Vector<T, inlineCapacityA, Allocator>& a, const Vector<T, inlineCapacityB, Allocator>& b)
1206 { 1206 {
1207 return !(a == b); 1207 return !(a == b);
1208 } 1208 }
1209 1209
1210 // This is only called if the allocator is a HeapAllocator. It is used when 1210 // This is only called if the allocator is a HeapAllocator. It is used when
1211 // visiting during a tracing GC. 1211 // visiting during a tracing GC.
1212 template<typename T, size_t inlineCapacity, typename Allocator> 1212 template<typename T, size_t inlineCapacity, typename Allocator>
1213 void Vector<T, inlineCapacity, Allocator>::trace(typename Allocator::Visitor * visitor) 1213 template<typename VisitorDispatcher>
1214 void Vector<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor)
1214 { 1215 {
1215 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab led. 1216 COMPILE_ASSERT(Allocator::isGarbageCollected, GarbageCollectorMustBeEnab led);
1216 const T* bufferBegin = buffer(); 1217 const T* bufferBegin = buffer();
1217 const T* bufferEnd = buffer() + size(); 1218 const T* bufferEnd = buffer() + size();
1218 if (ShouldBeTraced<VectorTraits<T> >::value) { 1219 if (ShouldBeTraced<VectorTraits<T> >::value) {
1219 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; b ufferEntry++) 1220 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; b ufferEntry++)
1220 Allocator::template trace<T, VectorTraits<T> >(visitor, *const_c ast<T*>(bufferEntry)); 1221 Allocator::template trace<T, VectorTraits<T> >(visitor, *const_c ast<T*>(bufferEntry));
1221 } 1222 }
1222 if (this->hasOutOfLineBuffer()) 1223 if (this->hasOutOfLineBuffer())
1223 Allocator::markNoTracing(visitor, buffer()); 1224 visitor->markNoTracing(buffer());
1224 } 1225 }
1225 1226
1226 #if !ENABLE(OILPAN) 1227 #if !ENABLE(OILPAN)
1227 template<typename T, size_t N> 1228 template<typename T, size_t N>
1228 struct NeedsTracing<Vector<T, N> > { 1229 struct NeedsTracing<Vector<T, N> > {
1229 static const bool value = false; 1230 static const bool value = false;
1230 }; 1231 };
1231 #endif 1232 #endif
1232 1233
1233 } // namespace WTF 1234 } // namespace WTF
1234 1235
1235 using WTF::Vector; 1236 using WTF::Vector;
1236 1237
1237 #endif // WTF_Vector_h 1238 #endif // WTF_Vector_h
OLDNEW
« no previous file with comments | « Source/wtf/TypeTraits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698