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

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

Issue 1406923009: Rename DISALLOW_ALLOCATION and ALLOW_ONLY_INLINE_ALLOCATION (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/web/TextFinder.h ('k') | third_party/WebKit/Source/wtf/Deque.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"
11 11
12 namespace WTF { 12 namespace WTF {
13 13
14 // Classes that contain references to garbage-collected objects but aren't 14 // Classes that contain references to garbage-collected objects but aren't
15 // themselves garbaged allocated, have some extra macros available which 15 // themselves garbaged allocated, have some extra macros available which
16 // allows their use to be restricted to cases where the garbage collector 16 // allows their use to be restricted to cases where the garbage collector
17 // is able to discover their references. These macros will be useful for 17 // is able to discover their references. These macros will be useful for
18 // non-garbage-collected objects to avoid unintended allocations. 18 // non-garbage-collected objects to avoid unintended allocations.
19 // 19 //
20 // STACK_ALLOCATED(): Use if the object is only stack allocated. 20 // STACK_ALLOCATED(): Use if the object is only stack allocated.
21 // Garbage-collected objects should be in Members but you do not need the 21 // Garbage-collected objects should be in Members but you do not need the
22 // trace method as they are on the stack. (Down the line these might turn 22 // trace method as they are on the stack. (Down the line these might turn
23 // in to raw pointers, but for now Members indicate that we have thought 23 // in to raw pointers, but for now Members indicate that we have thought
24 // about them and explicitly taken care of them.) 24 // about them and explicitly taken care of them.)
25 // 25 //
26 // DISALLOW_ALLOCATION(): 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 // ALLOW_ONLY_INLINE_ALLOCATION(): Allows only placement new operator. This 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_ALLOCATION() \ 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 public:
42 42
43 #define ALLOW_ONLY_INLINE_ALLOCATION() \ 43 #define DISALLOW_NEW_EXCEPT_PLACEMENT_NEW() \
44 public: \ 44 public: \
45 using IsAllowOnlyInlineAllocation = int; \ 45 using IsAllowOnlyInlineAllocation = int; \
46 void* operator new(size_t, NotNullTag, void* location) { return location ; } \ 46 void* operator new(size_t, NotNullTag, void* location) { return location ; } \
47 void* operator new(size_t, void* location) { return location; } \ 47 void* operator new(size_t, void* location) { return location; } \
48 private: \ 48 private: \
49 void* operator new(size_t) = delete; \ 49 void* operator new(size_t) = delete; \
50 public: 50 public:
51 51
52 #define STATIC_ONLY(Type) \ 52 #define STATIC_ONLY(Type) \
53 private: \ 53 private: \
54 Type() = delete; \ 54 Type() = delete; \
55 Type(const Type&) = delete; \ 55 Type(const Type&) = delete; \
56 Type& operator=(const Type&) = delete; \ 56 Type& operator=(const Type&) = delete; \
57 void* operator new(size_t) = delete; \ 57 void* operator new(size_t) = delete; \
58 void* operator new(size_t, NotNullTag, void*) = delete; \ 58 void* operator new(size_t, NotNullTag, void*) = delete; \
59 void* operator new(size_t, void*) = delete; \ 59 void* operator new(size_t, void*) = delete; \
60 public: 60 public:
61 61
62 #if COMPILER(CLANG) 62 #if COMPILER(CLANG)
63 #define STACK_ALLOCATED() \ 63 #define STACK_ALLOCATED() \
64 private: \ 64 private: \
65 __attribute__((annotate("blink_stack_allocated"))) \ 65 __attribute__((annotate("blink_stack_allocated"))) \
66 void* operator new(size_t) = delete; \ 66 void* operator new(size_t) = delete; \
67 void* operator new(size_t, NotNullTag, void*) = delete; \ 67 void* operator new(size_t, NotNullTag, void*) = delete; \
68 void* operator new(size_t, void*) = delete; \ 68 void* operator new(size_t, void*) = delete; \
69 public: 69 public:
70 #else 70 #else
71 #define STACK_ALLOCATED() DISALLOW_ALLOCATION() 71 #define STACK_ALLOCATED() DISALLOW_NEW()
72 #endif 72 #endif
73 73
74 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e 74 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e
75 // 75 //
76 // Provided functionality: 76 // Provided functionality:
77 // Macro: USING_FAST_MALLOC 77 // Macro: USING_FAST_MALLOC
78 // 78 //
79 // Example usage: 79 // Example usage:
80 // class Widget { 80 // class Widget {
81 // USING_FAST_MALLOC(Widget) 81 // USING_FAST_MALLOC(Widget)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 static const char* classNameForAllocator() \ 121 static const char* classNameForAllocator() \
122 { \ 122 { \
123 return #type; \ 123 return #type; \
124 } \ 124 } \
125 private: \ 125 private: \
126 typedef int __thisIsHereToForceASemicolonAfterThisMacro 126 typedef int __thisIsHereToForceASemicolonAfterThisMacro
127 127
128 } // namespace WTF 128 } // namespace WTF
129 129
130 #endif /* WTF_Allocator_h */ 130 #endif /* WTF_Allocator_h */
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/TextFinder.h ('k') | third_party/WebKit/Source/wtf/Deque.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698