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

Side by Side Diff: third_party/WebKit/Source/wtf/Allocator.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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(size_t) = delete; \
71 void* operator new(size_t) = delete; \ 76 void* operator new(size_t, NotNullTag, void*) = delete; \
72 void* operator new(size_t, NotNullTag, void*) = delete; \ 77 void* operator new(size_t, void*) = delete; \
73 void* operator new(size_t, void*) = delete; \ 78 \
74 public: 79 public:
75 #else 80 #else
76 #define STACK_ALLOCATED() DISALLOW_NEW() 81 #define STACK_ALLOCATED() DISALLOW_NEW()
77 #endif 82 #endif
78 83
79 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e 84 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e
80 // 85 //
81 // Provided functionality: 86 // Provided functionality:
82 // Macro: USING_FAST_MALLOC 87 // Macro: USING_FAST_MALLOC
83 // 88 //
84 // Example usage: 89 // Example usage:
85 // class Widget { 90 // class Widget {
86 // USING_FAST_MALLOC(Widget) 91 // USING_FAST_MALLOC(Widget)
87 // ... 92 // ...
88 // }; 93 // };
89 // 94 //
90 // struct Data { 95 // struct Data {
91 // USING_FAST_MALLOC(Data) 96 // USING_FAST_MALLOC(Data)
92 // public: 97 // public:
93 // ... 98 // ...
94 // }; 99 // };
95 // 100 //
96 101
97 #define USING_FAST_MALLOC(type) \ 102 #define USING_FAST_MALLOC(type) \
98 public: \ 103 public: \
99 void* operator new(size_t, void* p) { return p; } \ 104 void* operator new(size_t, void* p) { return p; } \
100 void* operator new[](size_t, void* p) { return p; } \ 105 void* operator new[](size_t, void* p) { return p; } \
101 \ 106 \
102 void* operator new(size_t size) \ 107 void* operator new(size_t size) { \
103 { \ 108 return ::WTF::Partitions::fastMalloc(size); \
104 return ::WTF::Partitions::fastMalloc(size); \ 109 } \
105 } \ 110 \
106 \ 111 void operator delete(void* p) { \
107 void operator delete(void* p) \ 112 ::WTF::Partitions::fastFree(p); \
108 { \ 113 } \
109 ::WTF::Partitions::fastFree(p); \ 114 \
110 } \ 115 void* operator new[](size_t size) { \
111 \ 116 return ::WTF::Partitions::fastMalloc(size); \
112 void* operator new[](size_t size) \ 117 } \
113 { \ 118 \
114 return ::WTF::Partitions::fastMalloc(size); \ 119 void operator delete[](void* p) { \
115 } \ 120 ::WTF::Partitions::fastFree(p); \
116 \ 121 } \
117 void operator delete[](void* p) \ 122 void* operator new(size_t, NotNullTag, void* location) { \
118 { \ 123 ASSERT(location); \
119 ::WTF::Partitions::fastFree(p); \ 124 return location; \
120 } \ 125 } \
121 void* operator new(size_t, NotNullTag, void* location) \ 126 static const char* classNameForAllocator() { \
122 { \ 127 return #type; \
123 ASSERT(location); \ 128 } \
124 return location; \ 129 \
125 } \ 130 private: \
126 static const char* classNameForAllocator() \ 131 typedef int __thisIsHereToForceASemicolonAfterThisMacro
127 { \
128 return #type; \
129 } \
130 private: \
131 typedef int __thisIsHereToForceASemicolonAfterThisMacro
132 132
133 } // namespace WTF 133 } // namespace WTF
134 134
135 #endif /* WTF_Allocator_h */ 135 #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