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

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

Issue 827723002: Reland: Templatize visitor arguments for TraceTrait mark and trace methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 5 years, 11 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
« no previous file with comments | « Source/platform/heap/Visitor.h ('k') | Source/wtf/HashTable.h » ('j') | 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) 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void removeFirst(); 105 void removeFirst();
106 void removeLast(); 106 void removeLast();
107 void remove(iterator&); 107 void remove(iterator&);
108 void remove(const_iterator&); 108 void remove(const_iterator&);
109 109
110 void clear(); 110 void clear();
111 111
112 template<typename Predicate> 112 template<typename Predicate>
113 iterator findIf(Predicate&); 113 iterator findIf(Predicate&);
114 114
115 void trace(typename Allocator::Visitor*); 115 template<typename VisitorDispatcher> void trace(VisitorDispatcher);
116 116
117 private: 117 private:
118 friend class DequeIteratorBase<T, inlineCapacity, Allocator>; 118 friend class DequeIteratorBase<T, inlineCapacity, Allocator>;
119 119
120 typedef VectorBuffer<T, inlineCapacity, Allocator> Buffer; 120 typedef VectorBuffer<T, inlineCapacity, Allocator> Buffer;
121 typedef VectorTypeOperations<T> TypeOperations; 121 typedef VectorTypeOperations<T> TypeOperations;
122 typedef DequeIteratorBase<T, inlineCapacity, Allocator> IteratorBase; 122 typedef DequeIteratorBase<T, inlineCapacity, Allocator> IteratorBase;
123 123
124 void remove(size_t position); 124 void remove(size_t position);
125 void destroyAll(); 125 void destroyAll();
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 { 521 {
522 ASSERT(m_index != m_deque->m_start); 522 ASSERT(m_index != m_deque->m_start);
523 if (!m_index) 523 if (!m_index)
524 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1] ; 524 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1] ;
525 return &m_deque->m_buffer.buffer()[m_index - 1]; 525 return &m_deque->m_buffer.buffer()[m_index - 1];
526 } 526 }
527 527
528 // This is only called if the allocator is a HeapAllocator. It is used when 528 // This is only called if the allocator is a HeapAllocator. It is used when
529 // visiting during a tracing GC. 529 // visiting during a tracing GC.
530 template<typename T, size_t inlineCapacity, typename Allocator> 530 template<typename T, size_t inlineCapacity, typename Allocator>
531 void Deque<T, inlineCapacity, Allocator>::trace(typename Allocator::Visitor* visitor) 531 template<typename VisitorDispatcher>
532 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor)
532 { 533 {
533 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab led. 534 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enab led.
534 const T* bufferBegin = m_buffer.buffer(); 535 const T* bufferBegin = m_buffer.buffer();
535 const T* end = bufferBegin + m_end; 536 const T* end = bufferBegin + m_end;
536 if (ShouldBeTraced<VectorTraits<T> >::value) { 537 if (ShouldBeTraced<VectorTraits<T> >::value) {
537 if (m_start <= m_end) { 538 if (m_start <= m_end) {
538 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry ! = end; bufferEntry++) 539 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry ! = end; bufferEntry++)
539 Allocator::template trace<T, VectorTraits<T> >(visitor, *con st_cast<T*>(bufferEntry)); 540 Allocator::template trace<VisitorDispatcher, T, VectorTraits <T> >(visitor, *const_cast<T*>(bufferEntry));
540 } else { 541 } else {
541 for (const T* bufferEntry = bufferBegin; bufferEntry != end; buf ferEntry++) 542 for (const T* bufferEntry = bufferBegin; bufferEntry != end; buf ferEntry++)
542 Allocator::template trace<T, VectorTraits<T> >(visitor, *con st_cast<T*>(bufferEntry)); 543 Allocator::template trace<VisitorDispatcher, T, VectorTraits <T> >(visitor, *const_cast<T*>(bufferEntry));
543 const T* bufferEnd = m_buffer.buffer() + m_buffer.capacity(); 544 const T* bufferEnd = m_buffer.buffer() + m_buffer.capacity();
544 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry ! = bufferEnd; bufferEntry++) 545 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry ! = bufferEnd; bufferEntry++)
545 Allocator::template trace<T, VectorTraits<T> >(visitor, *con st_cast<T*>(bufferEntry)); 546 Allocator::template trace<VisitorDispatcher, T, VectorTraits <T> >(visitor, *const_cast<T*>(bufferEntry));
546 } 547 }
547 } 548 }
548 if (m_buffer.hasOutOfLineBuffer()) 549 if (m_buffer.hasOutOfLineBuffer())
549 Allocator::markNoTracing(visitor, m_buffer.buffer()); 550 Allocator::markNoTracing(visitor, m_buffer.buffer());
550 } 551 }
551 552
552 template<typename T, size_t inlineCapacity, typename Allocator> 553 template<typename T, size_t inlineCapacity, typename Allocator>
553 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapa city, Allocator>& b) 554 inline void swap(Deque<T, inlineCapacity, Allocator>& a, Deque<T, inlineCapa city, Allocator>& b)
554 { 555 {
555 a.swap(b); 556 a.swap(b);
556 } 557 }
557 558
558 #if !ENABLE(OILPAN) 559 #if !ENABLE(OILPAN)
559 template<typename T, size_t N> 560 template<typename T, size_t N>
560 struct NeedsTracing<Deque<T, N> > { 561 struct NeedsTracing<Deque<T, N> > {
561 static const bool value = false; 562 static const bool value = false;
562 }; 563 };
563 #endif 564 #endif
564 565
565 } // namespace WTF 566 } // namespace WTF
566 567
567 using WTF::Deque; 568 using WTF::Deque;
568 569
569 #endif // WTF_Deque_h 570 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « Source/platform/heap/Visitor.h ('k') | Source/wtf/HashTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698