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

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

Issue 2570483002: Revert of Simple BlinkGC heap compaction. (Closed)
Patch Set: Created 4 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 | « third_party/WebKit/Source/wtf/LinkedHashSet.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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 using Base::clearUnusedSlots; 486 using Base::clearUnusedSlots;
487 using Base::checkUnusedSlots; 487 using Base::checkUnusedSlots;
488 488
489 bool hasOutOfLineBuffer() const { 489 bool hasOutOfLineBuffer() const {
490 // When inlineCapacity is 0 we have an out of line buffer if we have a 490 // When inlineCapacity is 0 we have an out of line buffer if we have a
491 // buffer. 491 // buffer.
492 return buffer(); 492 return buffer();
493 } 493 }
494 494
495 T** bufferSlot() { return &m_buffer; }
496
497 protected: 495 protected:
498 using Base::m_size; 496 using Base::m_size;
499 497
500 private: 498 private:
501 using Base::m_buffer; 499 using Base::m_buffer;
502 using Base::m_capacity; 500 using Base::m_capacity;
503 }; 501 };
504 502
505 template <typename T, size_t inlineCapacity, typename Allocator> 503 template <typename T, size_t inlineCapacity, typename Allocator>
506 class VectorBuffer : protected VectorBufferBase<T, true, Allocator> { 504 class VectorBuffer : protected VectorBufferBase<T, true, Allocator> {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 Allocator::leaveGCForbiddenScope(); 764 Allocator::leaveGCForbiddenScope();
767 } 765 }
768 766
769 using Base::buffer; 767 using Base::buffer;
770 using Base::capacity; 768 using Base::capacity;
771 769
772 bool hasOutOfLineBuffer() const { 770 bool hasOutOfLineBuffer() const {
773 return buffer() && buffer() != inlineBuffer(); 771 return buffer() && buffer() != inlineBuffer();
774 } 772 }
775 773
776 T** bufferSlot() { return &m_buffer; }
777
778 protected: 774 protected:
779 using Base::m_size; 775 using Base::m_size;
780 776
781 private: 777 private:
782 using Base::m_buffer; 778 using Base::m_buffer;
783 using Base::m_capacity; 779 using Base::m_capacity;
784 780
785 static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T); 781 static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T);
786 T* inlineBuffer() { return reinterpret_cast_ptr<T*>(m_inlineBuffer.buffer); } 782 T* inlineBuffer() { return reinterpret_cast_ptr<T*>(m_inlineBuffer.buffer); }
787 const T* inlineBuffer() const { 783 const T* inlineBuffer() const {
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 if (!buffer()) 1596 if (!buffer())
1601 return; 1597 return;
1602 if (this->hasOutOfLineBuffer()) { 1598 if (this->hasOutOfLineBuffer()) {
1603 // This is a performance optimization for a case where the buffer has 1599 // This is a performance optimization for a case where the buffer has
1604 // been already traced by somewhere. This can happen if the conservative 1600 // been already traced by somewhere. This can happen if the conservative
1605 // scanning traced an on-stack (false-positive or real) pointer to the 1601 // scanning traced an on-stack (false-positive or real) pointer to the
1606 // HeapVector, and then visitor->trace() traces the HeapVector. 1602 // HeapVector, and then visitor->trace() traces the HeapVector.
1607 if (Allocator::isHeapObjectAlive(buffer())) 1603 if (Allocator::isHeapObjectAlive(buffer()))
1608 return; 1604 return;
1609 Allocator::markNoTracing(visitor, buffer()); 1605 Allocator::markNoTracing(visitor, buffer());
1610 Allocator::registerBackingStoreReference(visitor, Base::bufferSlot());
1611 } 1606 }
1612 const T* bufferBegin = buffer(); 1607 const T* bufferBegin = buffer();
1613 const T* bufferEnd = buffer() + size(); 1608 const T* bufferEnd = buffer() + size();
1614 if (IsTraceableInCollectionTrait<VectorTraits<T>>::value) { 1609 if (IsTraceableInCollectionTrait<VectorTraits<T>>::value) {
1615 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd; 1610 for (const T* bufferEntry = bufferBegin; bufferEntry != bufferEnd;
1616 bufferEntry++) 1611 bufferEntry++)
1617 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>( 1612 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>(
1618 visitor, *const_cast<T*>(bufferEntry)); 1613 visitor, *const_cast<T*>(bufferEntry));
1619 checkUnusedSlots(buffer() + size(), buffer() + capacity()); 1614 checkUnusedSlots(buffer() + size(), buffer() + capacity());
1620 } 1615 }
1621 } 1616 }
1622 1617
1623 } // namespace WTF 1618 } // namespace WTF
1624 1619
1625 using WTF::Vector; 1620 using WTF::Vector;
1626 1621
1627 #endif // WTF_Vector_h 1622 #endif // WTF_Vector_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/LinkedHashSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698