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

Unified Diff: third_party/WebKit/Source/wtf/PartitionAllocator.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/PartitionAllocator.h
diff --git a/third_party/WebKit/Source/wtf/PartitionAllocator.h b/third_party/WebKit/Source/wtf/PartitionAllocator.h
index e3b57e5e77e4392920865c5418ecfe60aa80f3a5..671c4c9c8f6a5fd0a4c90fc0b728afc3f238ec29 100644
--- a/third_party/WebKit/Source/wtf/PartitionAllocator.h
+++ b/third_party/WebKit/Source/wtf/PartitionAllocator.h
@@ -47,178 +47,164 @@ namespace WTF {
class PartitionAllocatorDummyVisitor;
class WTF_EXPORT PartitionAllocator {
-public:
- typedef PartitionAllocatorDummyVisitor Visitor;
- static const bool isGarbageCollected = false;
-
- template<typename T>
- static size_t quantizedSize(size_t count)
- {
- RELEASE_ASSERT(count <= kGenericMaxDirectMapped / sizeof(T));
- return partitionAllocActualSize(Partitions::bufferPartition(), count * sizeof(T));
- }
- template <typename T>
- static T* allocateVectorBacking(size_t size)
- {
- return reinterpret_cast<T*>(allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
- }
- template <typename T>
- static T* allocateExpandedVectorBacking(size_t size)
- {
- return reinterpret_cast<T*>(allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
- }
- static void freeVectorBacking(void* address);
- static inline bool expandVectorBacking(void*, size_t)
- {
- return false;
- }
- static inline bool shrinkVectorBacking(void* address, size_t quantizedCurrentSize, size_t quantizedShrunkSize)
- {
- // Optimization: if we're downsizing inside the same allocator bucket,
- // we can skip reallocation.
- return quantizedCurrentSize == quantizedShrunkSize;
- }
- template <typename T>
- static T* allocateInlineVectorBacking(size_t size) { return allocateVectorBacking<T>(size); }
- static inline void freeInlineVectorBacking(void* address) { freeVectorBacking(address); }
- static inline bool expandInlineVectorBacking(void*, size_t) { return false; }
- static inline bool shrinkInlineVectorBacking(void* address, size_t quantizedCurrentSize, size_t quantizedShrunkSize) { return shrinkVectorBacking(address, quantizedCurrentSize, quantizedShrunkSize); }
-
- template <typename T, typename HashTable>
- static T* allocateHashTableBacking(size_t size)
- {
- return reinterpret_cast<T*>(allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
- }
- template <typename T, typename HashTable>
- static T* allocateZeroedHashTableBacking(size_t size)
- {
- void* result = allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T));
- memset(result, 0, size);
- return reinterpret_cast<T*>(result);
- }
- static void freeHashTableBacking(void* address);
-
- template <typename Return, typename Metadata>
- static Return malloc(size_t size, const char* typeName)
- {
- return reinterpret_cast<Return>(Partitions::fastMalloc(size, typeName));
- }
-
- static inline bool expandHashTableBacking(void*, size_t)
- {
- return false;
- }
- static void free(void* address)
- {
- Partitions::fastFree(address);
- }
- template<typename T>
- static void* newArray(size_t bytes)
- {
- return malloc<void*, void>(bytes, WTF_HEAP_PROFILER_TYPE_NAME(T));
- }
- static void
- deleteArray(void* ptr)
- {
- free(ptr); // Not the system free, the one from this class.
- }
-
- static bool isAllocationAllowed() { return true; }
- template<typename T>
- static bool isHeapObjectAlive(T* object)
- {
- ASSERT_NOT_REACHED();
- return false;
- }
-
- static void markNoTracing(...)
- {
- ASSERT_NOT_REACHED();
- }
-
- static void registerDelayedMarkNoTracing(...)
- {
- ASSERT_NOT_REACHED();
- }
-
- static void registerWeakMembers(...)
- {
- ASSERT_NOT_REACHED();
- }
-
- static void registerWeakTable(...)
- {
- ASSERT_NOT_REACHED();
- }
+ public:
+ typedef PartitionAllocatorDummyVisitor Visitor;
+ static const bool isGarbageCollected = false;
+
+ template <typename T>
+ static size_t quantizedSize(size_t count) {
+ RELEASE_ASSERT(count <= kGenericMaxDirectMapped / sizeof(T));
+ return partitionAllocActualSize(Partitions::bufferPartition(),
+ count * sizeof(T));
+ }
+ template <typename T>
+ static T* allocateVectorBacking(size_t size) {
+ return reinterpret_cast<T*>(
+ allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
+ }
+ template <typename T>
+ static T* allocateExpandedVectorBacking(size_t size) {
+ return reinterpret_cast<T*>(
+ allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
+ }
+ static void freeVectorBacking(void* address);
+ static inline bool expandVectorBacking(void*, size_t) { return false; }
+ static inline bool shrinkVectorBacking(void* address,
+ size_t quantizedCurrentSize,
+ size_t quantizedShrunkSize) {
+ // Optimization: if we're downsizing inside the same allocator bucket,
+ // we can skip reallocation.
+ return quantizedCurrentSize == quantizedShrunkSize;
+ }
+ template <typename T>
+ static T* allocateInlineVectorBacking(size_t size) {
+ return allocateVectorBacking<T>(size);
+ }
+ static inline void freeInlineVectorBacking(void* address) {
+ freeVectorBacking(address);
+ }
+ static inline bool expandInlineVectorBacking(void*, size_t) { return false; }
+ static inline bool shrinkInlineVectorBacking(void* address,
+ size_t quantizedCurrentSize,
+ size_t quantizedShrunkSize) {
+ return shrinkVectorBacking(address, quantizedCurrentSize,
+ quantizedShrunkSize);
+ }
+
+ template <typename T, typename HashTable>
+ static T* allocateHashTableBacking(size_t size) {
+ return reinterpret_cast<T*>(
+ allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
+ }
+ template <typename T, typename HashTable>
+ static T* allocateZeroedHashTableBacking(size_t size) {
+ void* result = allocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T));
+ memset(result, 0, size);
+ return reinterpret_cast<T*>(result);
+ }
+ static void freeHashTableBacking(void* address);
+
+ template <typename Return, typename Metadata>
+ static Return malloc(size_t size, const char* typeName) {
+ return reinterpret_cast<Return>(Partitions::fastMalloc(size, typeName));
+ }
+
+ static inline bool expandHashTableBacking(void*, size_t) { return false; }
+ static void free(void* address) { Partitions::fastFree(address); }
+ template <typename T>
+ static void* newArray(size_t bytes) {
+ return malloc<void*, void>(bytes, WTF_HEAP_PROFILER_TYPE_NAME(T));
+ }
+ static void deleteArray(void* ptr) {
+ free(ptr); // Not the system free, the one from this class.
+ }
+
+ static bool isAllocationAllowed() { return true; }
+ template <typename T>
+ static bool isHeapObjectAlive(T* object) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ static void markNoTracing(...) { ASSERT_NOT_REACHED(); }
+
+ static void registerDelayedMarkNoTracing(...) { ASSERT_NOT_REACHED(); }
+
+ static void registerWeakMembers(...) { ASSERT_NOT_REACHED(); }
+
+ static void registerWeakTable(...) { ASSERT_NOT_REACHED(); }
#if ENABLE(ASSERT)
- static bool weakTableRegistered(...)
- {
- ASSERT_NOT_REACHED();
- return false;
- }
+ static bool weakTableRegistered(...) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
#endif
- template<typename T, typename Traits>
- static void trace(...)
- {
- ASSERT_NOT_REACHED();
- }
+ template <typename T, typename Traits>
+ static void trace(...) {
+ ASSERT_NOT_REACHED();
+ }
- template<typename T>
- struct OtherType {
- typedef T* Type;
- };
+ template <typename T>
+ struct OtherType {
+ typedef T* Type;
+ };
- template<typename T>
- static T& getOther(T* other)
- {
- return *other;
- }
+ template <typename T>
+ static T& getOther(T* other) {
+ return *other;
+ }
- static void enterGCForbiddenScope() { }
- static void leaveGCForbiddenScope() { }
+ static void enterGCForbiddenScope() {}
+ static void leaveGCForbiddenScope() {}
-private:
- static void* allocateBacking(size_t, const char* typeName);
+ private:
+ static void* allocateBacking(size_t, const char* typeName);
};
// The Windows compiler seems to be very eager to instantiate things it won't
// need, so unless we have this class we get compile errors.
class PartitionAllocatorDummyVisitor {
- DISALLOW_NEW();
-public:
- template<typename T> inline bool isHeapObjectAlive(T obj)
- {
- ASSERT_NOT_REACHED();
- return false;
- }
+ DISALLOW_NEW();
+
+ public:
+ template <typename T>
+ inline bool isHeapObjectAlive(T obj) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
};
// Specializations for heap profiling, so type profiling of |char| is possible
// even in official builds (because |char| makes up a large portion of the heap.)
-template <> WTF_EXPORT char* PartitionAllocator::allocateVectorBacking<char>(size_t size);
-template <> WTF_EXPORT char* PartitionAllocator::allocateExpandedVectorBacking<char>(size_t size);
-
-} // namespace WTF
-
-#define WTF_USE_ALLOCATOR(ClassName, Allocator) \
-public: \
- void* operator new(size_t size) \
- { \
- return Allocator::template malloc<void*, ClassName>(size, WTF_HEAP_PROFILER_TYPE_NAME(ClassName)); \
- } \
- void operator delete(void* p) { Allocator::free(p); } \
- void* operator new[](size_t size) { return Allocator::template newArray<ClassName>(size); } \
- void operator delete[](void* p) { Allocator::deleteArray(p); } \
- void* operator new(size_t, NotNullTag, void* location) \
- { \
- ASSERT(location); \
- return location; \
- } \
-private: \
-typedef int __thisIsHereToForceASemicolonAfterThisMacro
+template <>
+WTF_EXPORT char* PartitionAllocator::allocateVectorBacking<char>(size_t size);
+template <>
+WTF_EXPORT char* PartitionAllocator::allocateExpandedVectorBacking<char>(
+ size_t size);
+
+} // namespace WTF
+
+#define WTF_USE_ALLOCATOR(ClassName, Allocator) \
+ public: \
+ void* operator new(size_t size) { \
+ return Allocator::template malloc<void*, ClassName>( \
+ size, WTF_HEAP_PROFILER_TYPE_NAME(ClassName)); \
+ } \
+ void operator delete(void* p) { Allocator::free(p); } \
+ void* operator new[](size_t size) { \
+ return Allocator::template newArray<ClassName>(size); \
+ } \
+ void operator delete[](void* p) { Allocator::deleteArray(p); } \
+ void* operator new(size_t, NotNullTag, void* location) { \
+ ASSERT(location); \
+ return location; \
+ } \
+ \
+ private: \
+ typedef int __thisIsHereToForceASemicolonAfterThisMacro
using WTF::PartitionAllocator;
-#endif // WTF_PartitionAllocator_h
+#endif // WTF_PartitionAllocator_h
« no previous file with comments | « third_party/WebKit/Source/wtf/PartitionAllocTest.cpp ('k') | third_party/WebKit/Source/wtf/PartitionAllocator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698