| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ContiguousContainer_h | 5 #ifndef ContiguousContainer_h |
| 6 #define ContiguousContainer_h | 6 #define ContiguousContainer_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Alignment.h" | 9 #include "wtf/Alignment.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 Vector<void*> m_elements; | 63 Vector<void*> m_elements; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 class Buffer; | 66 class Buffer; |
| 67 | 67 |
| 68 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); | 68 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); |
| 69 | 69 |
| 70 Vector<OwnPtr<Buffer>> m_buffers; | 70 Vector<OwnPtr<Buffer>> m_buffers; |
| 71 unsigned m_endIndex; | 71 unsigned m_endIndex; |
| 72 size_t m_maxObjectSize; | 72 size_t m_maxObjectSize; |
| 73 | |
| 74 // Makes Buffer accessible when clearing m_buffers. Fixes MSVC build. | |
| 75 friend struct WTF::OwnedPtrDeleter<Buffer>; | |
| 76 }; | 73 }; |
| 77 | 74 |
| 78 // For most cases, no alignment stricter than pointer alignment is required. If | 75 // For most cases, no alignment stricter than pointer alignment is required. If |
| 79 // one of the derived classes has stronger alignment requirements (and the | 76 // one of the derived classes has stronger alignment requirements (and the |
| 80 // static_assert fires), set alignment to the LCM of the derived class | 77 // static_assert fires), set alignment to the LCM of the derived class |
| 81 // alignments. For small structs without pointers, it may be possible to reduce | 78 // alignments. For small structs without pointers, it may be possible to reduce |
| 82 // alignment for tighter packing. | 79 // alignment for tighter packing. |
| 83 | 80 |
| 84 template <class BaseElementType, unsigned alignment = sizeof(void*)> | 81 template <class BaseElementType, unsigned alignment = sizeof(void*)> |
| 85 class ContiguousContainer : public ContiguousContainerBase { | 82 class ContiguousContainer : public ContiguousContainerBase { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 ASSERT(alignedSize % alignment == 0); | 211 ASSERT(alignedSize % alignment == 0); |
| 215 ASSERT(alignedSize >= size); | 212 ASSERT(alignedSize >= size); |
| 216 ASSERT(alignedSize < size + alignment); | 213 ASSERT(alignedSize < size + alignment); |
| 217 return alignedSize; | 214 return alignedSize; |
| 218 } | 215 } |
| 219 }; | 216 }; |
| 220 | 217 |
| 221 } // namespace blink | 218 } // namespace blink |
| 222 | 219 |
| 223 #endif // ContiguousContainer_h | 220 #endif // ContiguousContainer_h |
| OLD | NEW |