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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 typedef T value_type; | 770 typedef T value_type; |
771 | 771 |
772 typedef T* iterator; | 772 typedef T* iterator; |
773 typedef const T* const_iterator; | 773 typedef const T* const_iterator; |
774 typedef std::reverse_iterator<iterator> reverse_iterator; | 774 typedef std::reverse_iterator<iterator> reverse_iterator; |
775 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 775 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
776 | 776 |
777 Vector() | 777 Vector() |
778 { | 778 { |
779 static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canIni
tializeWithMemset, "Cannot initialize with memset if there is a vtable"); | 779 static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canIni
tializeWithMemset, "Cannot initialize with memset if there is a vtable"); |
780 #if ENABLE(OILPAN) | |
781 static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T
>::value || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_N
EW objects that have trace methods into an off-heap Vector"); | 780 static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T
>::value || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_N
EW objects that have trace methods into an off-heap Vector"); |
782 #endif | |
783 static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollec
tedType<T>::value, "Cannot put raw pointers to garbage-collected classes into an
off-heap Vector. Use HeapVector<Member<T>> instead."); | 781 static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollec
tedType<T>::value, "Cannot put raw pointers to garbage-collected classes into an
off-heap Vector. Use HeapVector<Member<T>> instead."); |
784 | 782 |
785 ANNOTATE_NEW_BUFFER(begin(), capacity(), 0); | 783 ANNOTATE_NEW_BUFFER(begin(), capacity(), 0); |
786 m_size = 0; | 784 m_size = 0; |
787 } | 785 } |
788 | 786 |
789 explicit Vector(size_t size) | 787 explicit Vector(size_t size) |
790 : Base(size) | 788 : Base(size) |
791 { | 789 { |
792 static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canIni
tializeWithMemset, "Cannot initialize with memset if there is a vtable"); | 790 static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canIni
tializeWithMemset, "Cannot initialize with memset if there is a vtable"); |
793 #if ENABLE(OILPAN) | |
794 static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T
>::value || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_N
EW objects that have trace methods into an off-heap Vector"); | 791 static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T
>::value || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_N
EW objects that have trace methods into an off-heap Vector"); |
795 #endif | |
796 static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollec
tedType<T>::value, "Cannot put raw pointers to garbage-collected classes into an
off-heap Vector. Use HeapVector<Member<T>> instead."); | 792 static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollec
tedType<T>::value, "Cannot put raw pointers to garbage-collected classes into an
off-heap Vector. Use HeapVector<Member<T>> instead."); |
797 | 793 |
798 ANNOTATE_NEW_BUFFER(begin(), capacity(), size); | 794 ANNOTATE_NEW_BUFFER(begin(), capacity(), size); |
799 m_size = size; | 795 m_size = size; |
800 TypeOperations::initialize(begin(), end()); | 796 TypeOperations::initialize(begin(), end()); |
801 } | 797 } |
802 | 798 |
803 // Off-GC-heap vectors: Destructor should be called. | 799 // Off-GC-heap vectors: Destructor should be called. |
804 // On-GC-heap vectors: Destructor should be called for inline buffers (if | 800 // On-GC-heap vectors: Destructor should be called for inline buffers (if |
805 // any) but destructor shouldn't be called for vector backing since it is | 801 // any) but destructor shouldn't be called for vector backing since it is |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 } | 1491 } |
1496 const T* bufferBegin = buffer(); | 1492 const T* bufferBegin = buffer(); |
1497 const T* bufferEnd = buffer() + size(); | 1493 const T* bufferEnd = buffer() + size(); |
1498 if (NeedsTracingTrait<VectorTraits<T>>::value) { | 1494 if (NeedsTracingTrait<VectorTraits<T>>::value) { |
1499 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; buffe
rEntry++) | 1495 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; buffe
rEntry++) |
1500 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>(vis
itor, *const_cast<T*>(bufferEntry)); | 1496 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>(vis
itor, *const_cast<T*>(bufferEntry)); |
1501 checkUnusedSlots(buffer() + size(), buffer() + capacity()); | 1497 checkUnusedSlots(buffer() + size(), buffer() + capacity()); |
1502 } | 1498 } |
1503 } | 1499 } |
1504 | 1500 |
1505 #if !ENABLE(OILPAN) | |
1506 template <typename T, size_t N> | |
1507 struct NeedsTracing<Vector<T, N>> { | |
1508 STATIC_ONLY(NeedsTracing); | |
1509 static const bool value = false; | |
1510 }; | |
1511 #endif | |
1512 | |
1513 } // namespace WTF | 1501 } // namespace WTF |
1514 | 1502 |
1515 using WTF::Vector; | 1503 using WTF::Vector; |
1516 | 1504 |
1517 #endif // WTF_Vector_h | 1505 #endif // WTF_Vector_h |
OLD | NEW |