| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void remove(const_iterator&); | 106 void remove(const_iterator&); |
| 107 | 107 |
| 108 void clear(); | 108 void clear(); |
| 109 | 109 |
| 110 template <typename Predicate> | 110 template <typename Predicate> |
| 111 iterator findIf(Predicate&); | 111 iterator findIf(Predicate&); |
| 112 | 112 |
| 113 template <typename VisitorDispatcher> void trace(VisitorDispatcher); | 113 template <typename VisitorDispatcher> void trace(VisitorDispatcher); |
| 114 | 114 |
| 115 static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canInitial
izeWithMemset, "Cannot initialize with memset if there is a vtable"); | 115 static_assert(!std::is_polymorphic<T>::value || !VectorTraits<T>::canInitial
izeWithMemset, "Cannot initialize with memset if there is a vtable"); |
| 116 static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T>::v
alue || !NeedsTracing<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW o
bjects that have trace methods into an off-heap Deque"); | 116 static_assert(Allocator::isGarbageCollected || !AllowsOnlyPlacementNew<T>::v
alue || !IsTraceable<T>::value, "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW ob
jects that have trace methods into an off-heap Deque"); |
| 117 static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollectedT
ype<T>::value, "Cannot put raw pointers to garbage-collected classes into a Dequ
e. Use HeapDeque<Member<T>> instead."); | 117 static_assert(Allocator::isGarbageCollected || !IsPointerToGarbageCollectedT
ype<T>::value, "Cannot put raw pointers to garbage-collected classes into a Dequ
e. Use HeapDeque<Member<T>> instead."); |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 friend class DequeIteratorBase<T, inlineCapacity, Allocator>; | 120 friend class DequeIteratorBase<T, inlineCapacity, Allocator>; |
| 121 | 121 |
| 122 class BackingBuffer : public VectorBuffer<T, INLINE_CAPACITY, Allocator> { | 122 class BackingBuffer : public VectorBuffer<T, INLINE_CAPACITY, Allocator> { |
| 123 WTF_MAKE_NONCOPYABLE(BackingBuffer); | 123 WTF_MAKE_NONCOPYABLE(BackingBuffer); |
| 124 private: | 124 private: |
| 125 using Base = VectorBuffer<T, INLINE_CAPACITY, Allocator>; | 125 using Base = VectorBuffer<T, INLINE_CAPACITY, Allocator>; |
| 126 using Base::m_size; | 126 using Base::m_size; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 // This is only called if the allocator is a HeapAllocator. It is used when | 590 // This is only called if the allocator is a HeapAllocator. It is used when |
| 591 // visiting during a tracing GC. | 591 // visiting during a tracing GC. |
| 592 template <typename T, size_t inlineCapacity, typename Allocator> | 592 template <typename T, size_t inlineCapacity, typename Allocator> |
| 593 template <typename VisitorDispatcher> | 593 template <typename VisitorDispatcher> |
| 594 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) | 594 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) |
| 595 { | 595 { |
| 596 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enabled. | 596 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enabled. |
| 597 const T* bufferBegin = m_buffer.buffer(); | 597 const T* bufferBegin = m_buffer.buffer(); |
| 598 const T* end = bufferBegin + m_end; | 598 const T* end = bufferBegin + m_end; |
| 599 if (NeedsTracingTrait<VectorTraits<T>>::value) { | 599 if (IsTraceableInCollectionTrait<VectorTraits<T>>::value) { |
| 600 if (m_start <= m_end) { | 600 if (m_start <= m_end) { |
| 601 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry != en
d; bufferEntry++) | 601 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry != en
d; bufferEntry++) |
| 602 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>
(visitor, *const_cast<T*>(bufferEntry)); | 602 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>
(visitor, *const_cast<T*>(bufferEntry)); |
| 603 } else { | 603 } else { |
| 604 for (const T* bufferEntry = bufferBegin; bufferEntry != end; bufferE
ntry++) | 604 for (const T* bufferEntry = bufferBegin; bufferEntry != end; bufferE
ntry++) |
| 605 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>
(visitor, *const_cast<T*>(bufferEntry)); | 605 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>
(visitor, *const_cast<T*>(bufferEntry)); |
| 606 const T* bufferEnd = m_buffer.buffer() + m_buffer.capacity(); | 606 const T* bufferEnd = m_buffer.buffer() + m_buffer.capacity(); |
| 607 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry != bu
fferEnd; bufferEntry++) | 607 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry != bu
fferEnd; bufferEntry++) |
| 608 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>
(visitor, *const_cast<T*>(bufferEntry)); | 608 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>
(visitor, *const_cast<T*>(bufferEntry)); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 if (m_buffer.hasOutOfLineBuffer()) | 611 if (m_buffer.hasOutOfLineBuffer()) |
| 612 Allocator::markNoTracing(visitor, m_buffer.buffer()); | 612 Allocator::markNoTracing(visitor, m_buffer.buffer()); |
| 613 } | 613 } |
| 614 | 614 |
| 615 template <typename T, size_t inlineCapacity, typename Allocator> | 615 template <typename T, size_t inlineCapacity, typename Allocator> |
| 616 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapacity
, Allocator>& b) | 616 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapacity
, Allocator>& b) |
| 617 { | 617 { |
| 618 a.swap(b); | 618 a.swap(b); |
| 619 } | 619 } |
| 620 | 620 |
| 621 } // namespace WTF | 621 } // namespace WTF |
| 622 | 622 |
| 623 using WTF::Deque; | 623 using WTF::Deque; |
| 624 | 624 |
| 625 #endif // WTF_Deque_h | 625 #endif // WTF_Deque_h |
| OLD | NEW |