OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #ifndef WTF_PartitionAllocator_h | 31 #ifndef WTF_PartitionAllocator_h |
32 #define WTF_PartitionAllocator_h | 32 #define WTF_PartitionAllocator_h |
33 | 33 |
34 // This is the allocator that is used for allocations that are not on the | 34 // This is the allocator that is used for allocations that are not on the |
35 // traced, garbage collected heap. It uses FastMalloc for collections, | 35 // traced, garbage collected heap. It uses FastMalloc for collections, |
36 // but uses the partition allocator for the backing store of the collections. | 36 // but uses the partition allocator for the backing store of the collections. |
37 | 37 |
38 #include "wtf/Allocator.h" | 38 #include "wtf/Allocator.h" |
39 #include "wtf/Assertions.h" | 39 #include "wtf/Assertions.h" |
40 #include "wtf/PartitionAlloc.h" | 40 #include "wtf/allocator/PartitionAlloc.h" |
41 #include "wtf/Partitions.h" | 41 #include "wtf/allocator/Partitions.h" |
42 | 42 |
43 #include <string.h> | 43 #include <string.h> |
44 | 44 |
45 namespace WTF { | 45 namespace WTF { |
46 | 46 |
47 class PartitionAllocatorDummyVisitor; | 47 class PartitionAllocatorDummyVisitor; |
48 | 48 |
49 class WTF_EXPORT PartitionAllocator { | 49 class WTF_EXPORT PartitionAllocator { |
50 public: | 50 public: |
51 typedef PartitionAllocatorDummyVisitor Visitor; | 51 typedef PartitionAllocatorDummyVisitor Visitor; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 public: | 190 public: |
191 template<typename T> inline bool isHeapObjectAlive(T obj) | 191 template<typename T> inline bool isHeapObjectAlive(T obj) |
192 { | 192 { |
193 ASSERT_NOT_REACHED(); | 193 ASSERT_NOT_REACHED(); |
194 return false; | 194 return false; |
195 } | 195 } |
196 }; | 196 }; |
197 | 197 |
198 // Specializations for heap profiling, so type profiling of |char| is possible | 198 // Specializations for heap profiling, so type profiling of |char| is possible |
199 // even in official builds (because |char| makes up a large portion of the heap.
) | 199 // even in official builds (because |char| makes up a large portion of the heap.
) |
200 template <> WTF_EXPORT char* PartitionAllocator::allocateVectorBacking<char>(siz
e_t size); | 200 template <> WTF_EXPORT char* PartitionAllocator::allocateVectorBacking<char>(siz
e_t); |
201 template <> WTF_EXPORT char* PartitionAllocator::allocateExpandedVectorBacking<c
har>(size_t size); | 201 template <> WTF_EXPORT char* PartitionAllocator::allocateExpandedVectorBacking<c
har>(size_t); |
202 | 202 |
203 } // namespace WTF | 203 } // namespace WTF |
204 | 204 |
205 #define WTF_USE_ALLOCATOR(ClassName, Allocator) \ | 205 #define WTF_USE_ALLOCATOR(ClassName, Allocator) \ |
206 public: \ | 206 public: \ |
207 void* operator new(size_t size) \ | 207 void* operator new(size_t size) \ |
208 { \ | 208 { \ |
209 return Allocator::template malloc<void*, ClassName>(size, WTF_HEAP_PROFI
LER_TYPE_NAME(ClassName)); \ | 209 return Allocator::template malloc<void*, ClassName>(size, WTF_HEAP_PROFI
LER_TYPE_NAME(ClassName)); \ |
210 } \ | 210 } \ |
211 void operator delete(void* p) { Allocator::free(p); } \ | 211 void operator delete(void* p) { Allocator::free(p); } \ |
212 void* operator new[](size_t size) { return Allocator::template newArray<Clas
sName>(size); } \ | 212 void* operator new[](size_t size) { return Allocator::template newArray<Clas
sName>(size); } \ |
213 void operator delete[](void* p) { Allocator::deleteArray(p); } \ | 213 void operator delete[](void* p) { Allocator::deleteArray(p); } \ |
214 void* operator new(size_t, NotNullTag, void* location) \ | 214 void* operator new(size_t, NotNullTag, void* location) \ |
215 { \ | 215 { \ |
216 ASSERT(location); \ | 216 ASSERT(location); \ |
217 return location; \ | 217 return location; \ |
218 } \ | 218 } \ |
219 private: \ | 219 private: \ |
220 typedef int __thisIsHereToForceASemicolonAfterThisMacro | 220 typedef int __thisIsHereToForceASemicolonAfterThisMacro |
221 | 221 |
222 using WTF::PartitionAllocator; | 222 using WTF::PartitionAllocator; |
223 | 223 |
224 #endif // WTF_PartitionAllocator_h | 224 #endif // WTF_PartitionAllocator_h |
OLD | NEW |