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

Side by Side Diff: third_party/WebKit/Source/wtf/allocator/PartitionAllocator.h

Issue 2657173002: Disallow sequences with lengths exceeding max allocation supported. (Closed)
Patch Set: add expected output Created 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 WTF_PartitionAllocator_h 5 #ifndef WTF_PartitionAllocator_h
6 #define WTF_PartitionAllocator_h 6 #define WTF_PartitionAllocator_h
7 7
8 // This is the allocator that is used for allocations that are not on the 8 // This is the allocator that is used for allocations that are not on the
9 // traced, garbage collected heap. It uses FastMalloc for collections, 9 // traced, garbage collected heap. It uses FastMalloc for collections,
10 // but uses the partition allocator for the backing store of the collections. 10 // but uses the partition allocator for the backing store of the collections.
11 11
12 #include "base/allocator/partition_allocator/partition_alloc.h" 12 #include "base/allocator/partition_allocator/partition_alloc.h"
13 #include "third_party/WebKit/Source/wtf/Allocator.h" 13 #include "third_party/WebKit/Source/wtf/Allocator.h"
14 #include "wtf/Assertions.h" 14 #include "wtf/Assertions.h"
15 #include "wtf/TypeTraits.h" 15 #include "wtf/TypeTraits.h"
16 #include "wtf/WTFExport.h" 16 #include "wtf/WTFExport.h"
17 #include <string.h> 17 #include <string.h>
18 18
19 namespace WTF { 19 namespace WTF {
20 20
21 class PartitionAllocatorDummyVisitor { 21 class PartitionAllocatorDummyVisitor {
22 DISALLOW_NEW(); 22 DISALLOW_NEW();
23 }; 23 };
24 24
25 class WTF_EXPORT PartitionAllocator { 25 class WTF_EXPORT PartitionAllocator {
26 public: 26 public:
27 typedef PartitionAllocatorDummyVisitor Visitor; 27 typedef PartitionAllocatorDummyVisitor Visitor;
28 static const bool isGarbageCollected = false; 28 static const bool isGarbageCollected = false;
29 29
30 template<typename T>
31 static size_t maxElementCountInBackingStore() {
32 return base::kGenericMaxDirectMapped / sizeof(T);
33 }
34
30 template <typename T> 35 template <typename T>
31 static size_t quantizedSize(size_t count) { 36 static size_t quantizedSize(size_t count) {
32 RELEASE_ASSERT(count <= base::kGenericMaxDirectMapped / sizeof(T)); 37 CHECK(count <= maxElementCountInBackingStore<T>());
Yuta Kitamura 2017/01/30 07:19:42 nit+optional: Use CHECK_LE?
sof 2017/01/31 21:01:43 Done.
33 return PartitionAllocActualSize(WTF::Partitions::bufferPartition(), 38 return PartitionAllocActualSize(WTF::Partitions::bufferPartition(),
34 count * sizeof(T)); 39 count * sizeof(T));
35 } 40 }
36 template <typename T> 41 template <typename T>
37 static T* allocateVectorBacking(size_t size) { 42 static T* allocateVectorBacking(size_t size) {
38 return reinterpret_cast<T*>( 43 return reinterpret_cast<T*>(
39 allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T))); 44 allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
40 } 45 }
41 template <typename T> 46 template <typename T>
42 static T* allocateExpandedVectorBacking(size_t size) { 47 static T* allocateExpandedVectorBacking(size_t size) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void* operator new(size_t, NotNullTag, void* location) { \ 135 void* operator new(size_t, NotNullTag, void* location) { \
131 DCHECK(location); \ 136 DCHECK(location); \
132 return location; \ 137 return location; \
133 } \ 138 } \
134 void* operator new(size_t, void* location) { return location; } \ 139 void* operator new(size_t, void* location) { return location; } \
135 \ 140 \
136 private: \ 141 private: \
137 typedef int __thisIsHereToForceASemicolonAfterThisMacro 142 typedef int __thisIsHereToForceASemicolonAfterThisMacro
138 143
139 #endif // WTF_PartitionAllocator_h 144 #endif // WTF_PartitionAllocator_h
OLDNEW
« third_party/WebKit/Source/wtf/Vector.h ('K') | « third_party/WebKit/Source/wtf/Vector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698