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

Side by Side Diff: third_party/WebKit/Source/wtf/Allocator.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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/Alignment.h ('k') | third_party/WebKit/Source/wtf/ArrayBuffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 WTF_Allocator_h 5 #ifndef WTF_Allocator_h
6 #define WTF_Allocator_h 6 #define WTF_Allocator_h
7 7
8 #include "wtf/Assertions.h" 8 #include "wtf/Assertions.h"
9 #include "wtf/Partitions.h" 9 #include "wtf/Partitions.h"
10 #include "wtf/StdLibExtras.h" 10 #include "wtf/StdLibExtras.h"
(...skipping 15 matching lines...) Expand all
26 // DISALLOW_NEW(): Cannot be allocated with new operators but can be a 26 // DISALLOW_NEW(): Cannot be allocated with new operators but can be a
27 // part of object. If it has Members you need a trace method and the containing 27 // part of object. If it has Members you need a trace method and the containing
28 // object needs to call that trace method. 28 // object needs to call that trace method.
29 // 29 //
30 // DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(): Allows only placement new operator. Thi s 30 // DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(): Allows only placement new operator. Thi s
31 // disallows general allocation of this object but allows to put the object as a 31 // disallows general allocation of this object but allows to put the object as a
32 // value object in collections. If these have Members you need to have a trace 32 // value object in collections. If these have Members you need to have a trace
33 // method. That trace method will be called automatically by the on-heap 33 // method. That trace method will be called automatically by the on-heap
34 // collections. 34 // collections.
35 // 35 //
36 #define DISALLOW_NEW() \ 36 #define DISALLOW_NEW() \
37 private: \ 37 private: \
38 void* operator new(size_t) = delete; \ 38 void* operator new(size_t) = delete; \
39 void* operator new(size_t, NotNullTag, void*) = delete; \ 39 void* operator new(size_t, NotNullTag, void*) = delete; \
40 void* operator new(size_t, void*) = delete; \ 40 void* operator new(size_t, void*) = delete; \
41 public: 41 \
42 public:
42 43
43 #define DISALLOW_NEW_EXCEPT_PLACEMENT_NEW() \ 44 #define DISALLOW_NEW_EXCEPT_PLACEMENT_NEW() \
44 public: \ 45 public: \
45 using IsAllowOnlyPlacementNew = int; \ 46 using IsAllowOnlyPlacementNew = int; \
46 void* operator new(size_t, NotNullTag, void* location) { return location ; } \ 47 void* operator new(size_t, NotNullTag, void* location) { return location; } \
47 void* operator new(size_t, void* location) { return location; } \ 48 void* operator new(size_t, void* location) { return location; } \
48 private: \ 49 \
49 void* operator new(size_t) = delete; \ 50 private: \
50 public: 51 void* operator new(size_t) = delete; \
52 \
53 public:
51 54
52 #define STATIC_ONLY(Type) \ 55 #define STATIC_ONLY(Type) \
53 private: \ 56 private: \
54 Type() = delete; \ 57 Type() = delete; \
55 Type(const Type&) = delete; \ 58 Type(const Type&) = delete; \
56 Type& operator=(const Type&) = delete; \ 59 Type& operator=(const Type&) = delete; \
57 void* operator new(size_t) = delete; \ 60 void* operator new(size_t) = delete; \
58 void* operator new(size_t, NotNullTag, void*) = delete; \ 61 void* operator new(size_t, NotNullTag, void*) = delete; \
59 void* operator new(size_t, void*) = delete; \ 62 void* operator new(size_t, void*) = delete; \
60 public: 63 \
64 public:
61 65
62 #define IS_GARBAGE_COLLECTED_TYPE() \ 66 #define IS_GARBAGE_COLLECTED_TYPE() \
63 public: \ 67 public: \
64 using IsGarbageCollectedTypeMarker = int; \ 68 using IsGarbageCollectedTypeMarker = int; \
65 private: 69 \
70 private:
66 71
67 #if COMPILER(CLANG) 72 #if COMPILER(CLANG)
68 #define STACK_ALLOCATED() \ 73 #define STACK_ALLOCATED() \
69 private: \ 74 private: \
70 __attribute__((annotate("blink_stack_allocated"))) \ 75 __attribute__((annotate("blink_stack_allocated"))) void* operator new( \
71 void* operator new(size_t) = delete; \ 76 size_t) = delete; \
72 void* operator new(size_t, NotNullTag, void*) = delete; \ 77 void* operator new(size_t, NotNullTag, void*) = delete; \
73 void* operator new(size_t, void*) = delete; \ 78 void* operator new(size_t, void*) = delete; \
74 public: 79 \
80 public:
75 #else 81 #else
76 #define STACK_ALLOCATED() DISALLOW_NEW() 82 #define STACK_ALLOCATED() DISALLOW_NEW()
77 #endif 83 #endif
78 84
79 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e 85 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e
80 // 86 //
81 // Provided functionality: 87 // Provided functionality:
82 // Macro: USING_FAST_MALLOC 88 // Macro: USING_FAST_MALLOC
83 // 89 //
84 // Example usage: 90 // Example usage:
85 // class Widget { 91 // class Widget {
86 // USING_FAST_MALLOC(Widget) 92 // USING_FAST_MALLOC(Widget)
87 // ... 93 // ...
88 // }; 94 // };
89 // 95 //
90 // struct Data { 96 // struct Data {
91 // USING_FAST_MALLOC(Data) 97 // USING_FAST_MALLOC(Data)
92 // public: 98 // public:
93 // ... 99 // ...
94 // }; 100 // };
95 // 101 //
96 102
97 #define USING_FAST_MALLOC_INTERNAL(type, typeName) \ 103 #define USING_FAST_MALLOC_INTERNAL(type, typeName) \
98 public: \ 104 public: \
99 void* operator new(size_t, void* p) { return p; } \ 105 void* operator new(size_t, void* p) { return p; } \
100 void* operator new[](size_t, void* p) { return p; } \ 106 void* operator new[](size_t, void* p) { return p; } \
101 \ 107 \
102 void* operator new(size_t size) \ 108 void* operator new(size_t size) { \
103 { \ 109 return ::WTF::Partitions::fastMalloc(size, typeName); \
104 return ::WTF::Partitions::fastMalloc(size, typeName); \ 110 } \
105 } \ 111 \
106 \ 112 void operator delete(void* p) { ::WTF::Partitions::fastFree(p); } \
107 void operator delete(void* p) \ 113 \
108 { \ 114 void* operator new[](size_t size) { \
109 ::WTF::Partitions::fastFree(p); \ 115 return ::WTF::Partitions::fastMalloc(size, typeName); \
110 } \ 116 } \
111 \ 117 \
112 void* operator new[](size_t size) \ 118 void operator delete[](void* p) { ::WTF::Partitions::fastFree(p); } \
113 { \ 119 void* operator new(size_t, NotNullTag, void* location) { \
114 return ::WTF::Partitions::fastMalloc(size, typeName); \ 120 ASSERT(location); \
115 } \ 121 return location; \
116 \ 122 } \
117 void operator delete[](void* p) \ 123 static const char* classNameForAllocator() { return #type; } \
118 { \ 124 \
119 ::WTF::Partitions::fastFree(p); \ 125 private: \
120 } \ 126 typedef int __thisIsHereToForceASemicolonAfterThisMacro
121 void* operator new(size_t, NotNullTag, void* location) \
122 { \
123 ASSERT(location); \
124 return location; \
125 } \
126 static const char* classNameForAllocator() \
127 { \
128 return #type; \
129 } \
130 private: \
131 typedef int __thisIsHereToForceASemicolonAfterThisMacro
132 127
133 // Both of these macros enable fast malloc and provide type info to the heap 128 // Both of these macros enable fast malloc and provide type info to the heap
134 // profiler. The regular macro does not provide type info in official builds, 129 // profiler. The regular macro does not provide type info in official builds,
135 // to avoid bloating the binary with type name strings. The |WITH_TYPE_NAME| 130 // to avoid bloating the binary with type name strings. The |WITH_TYPE_NAME|
136 // variant provides type info unconditionally, so it should be used sparingly. 131 // variant provides type info unconditionally, so it should be used sparingly.
137 // Furthermore, the |WITH_TYPE_NAME| variant does not work if |type| is a 132 // Furthermore, the |WITH_TYPE_NAME| variant does not work if |type| is a
138 // template argument; |USING_FAST_MALLOC| does. 133 // template argument; |USING_FAST_MALLOC| does.
139 #define USING_FAST_MALLOC(type) USING_FAST_MALLOC_INTERNAL(type, WTF_HEAP_PROFIL ER_TYPE_NAME(type)) 134 #define USING_FAST_MALLOC(type) \
140 #define USING_FAST_MALLOC_WITH_TYPE_NAME(type) USING_FAST_MALLOC_INTERNAL(type, #type) 135 USING_FAST_MALLOC_INTERNAL(type, WTF_HEAP_PROFILER_TYPE_NAME(type))
136 #define USING_FAST_MALLOC_WITH_TYPE_NAME(type) \
137 USING_FAST_MALLOC_INTERNAL(type, #type)
141 138
142 } // namespace WTF 139 } // namespace WTF
143 140
144 #endif /* WTF_Allocator_h */ 141 #endif /* WTF_Allocator_h */
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Alignment.h ('k') | third_party/WebKit/Source/wtf/ArrayBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698