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

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

Issue 1412083007: Remove FastAllocBase.h (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
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"
9 #include "wtf/Partitions.h"
8 #include "wtf/StdLibExtras.h" 10 #include "wtf/StdLibExtras.h"
9 11
10 namespace WTF { 12 namespace WTF {
11 13
12 // Classes that contain references to garbage-collected objects but aren't 14 // Classes that contain references to garbage-collected objects but aren't
13 // themselves garbaged allocated, have some extra macros available which 15 // themselves garbaged allocated, have some extra macros available which
14 // 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
15 // 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
16 // non-garbage-collected objects to avoid unintended allocations. 18 // non-garbage-collected objects to avoid unintended allocations.
17 // 19 //
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 private: \ 64 private: \
63 __attribute__((annotate("blink_stack_allocated"))) \ 65 __attribute__((annotate("blink_stack_allocated"))) \
64 void* operator new(size_t) = delete; \ 66 void* operator new(size_t) = delete; \
65 void* operator new(size_t, NotNullTag, void*) = delete; \ 67 void* operator new(size_t, NotNullTag, void*) = delete; \
66 void* operator new(size_t, void*) = delete; \ 68 void* operator new(size_t, void*) = delete; \
67 public: 69 public:
68 #else 70 #else
69 #define STACK_ALLOCATED() DISALLOW_ALLOCATION() 71 #define STACK_ALLOCATED() DISALLOW_ALLOCATION()
70 #endif 72 #endif
71 73
74 // Provides customizable overrides of fastMalloc/fastFree and operator new/delet e
75 //
76 // Provided functionality:
77 // Macro: WTF_MAKE_FAST_ALLOCATED
78 //
79 // Example usage:
80 // class Widget {
81 // WTF_MAKE_FAST_ALLOCATED(Widget)
82 // ...
83 // };
84 //
85 // struct Data {
86 // WTF_MAKE_FAST_ALLOCATED(Data)
87 // public:
88 // ...
89 // };
90 //
91
92 #define WTF_MAKE_FAST_ALLOCATED(type) \
93 public: \
94 void* operator new(size_t, void* p) { return p; } \
95 void* operator new[](size_t, void* p) { return p; } \
96 \
97 void* operator new(size_t size) \
98 { \
99 return ::WTF::Partitions::fastMalloc(size); \
100 } \
101 \
102 void operator delete(void* p) \
103 { \
104 ::WTF::Partitions::fastFree(p); \
105 } \
106 \
107 void* operator new[](size_t size) \
108 { \
109 return ::WTF::Partitions::fastMalloc(size); \
110 } \
111 \
112 void operator delete[](void* p) \
113 { \
114 ::WTF::Partitions::fastFree(p); \
115 } \
116 void* operator new(size_t, NotNullTag, void* location) \
117 { \
118 ASSERT(location); \
119 return location; \
120 } \
121 static const char* classNameForAllocator() \
122 { \
123 return #type; \
124 } \
125 private: \
126 typedef int __thisIsHereToForceASemicolonAfterThisMacro
127
72 } // namespace WTF 128 } // namespace WTF
73 129
74 #endif /* WTF_Allocator_h */ 130 #endif /* WTF_Allocator_h */
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebHelperPluginImpl.h ('k') | third_party/WebKit/Source/wtf/DefaultAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698