10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_ALLOCATION_HPP
26 #define SHARE_VM_MEMORY_ALLOCATION_HPP
27
28 #include "runtime/globals.hpp"
29 #include "utilities/globalDefinitions.hpp"
30 #ifdef COMPILER1
31 #include "c1/c1_globals.hpp"
32 #endif
33 #ifdef COMPILER2
34 #include "opto/c2_globals.hpp"
35 #endif
36
37 #include <new>
38
39 #define ARENA_ALIGN_M1 (((size_t)(ARENA_AMALLOC_ALIGNMENT)) - 1)
40 #define ARENA_ALIGN_MASK (~((size_t)ARENA_ALIGN_M1))
41 #define ARENA_ALIGN(x) ((((size_t)(x)) + ARENA_ALIGN_M1) & ARENA_ALIGN_MASK)
42
43
44 // noinline attribute
45 #ifdef _WINDOWS
46 #define _NOINLINE_ __declspec(noinline)
47 #else
48 #if __GNUC__ < 3 // gcc 2.x does not support noinline attribute
49 #define _NOINLINE_
130 mtGC = 0x0500, // memory for GC
131 mtCompiler = 0x0600, // memory for compiler
132 mtInternal = 0x0700, // memory used by VM, but does not belong to
133 // any of above categories, and not used for
134 // native memory tracking
135 mtOther = 0x0800, // memory not used by VM
136 mtSymbol = 0x0900, // symbol
137 mtNMT = 0x0A00, // memory used by native memory tracking
138 mtChunk = 0x0B00, // chunk that holds content of arenas
139 mtJavaHeap = 0x0C00, // Java heap
140 mtDontTrack = 0x0D00, // memory we donot or cannot track
141 mt_number_of_types = 0x000C, // number of memory types
142 mt_masks = 0x7F00,
143
144 // object type mask
145 otArena = 0x0010, // an arena object
146 otNMTRecorder = 0x0020, // memory recorder object
147 ot_masks = 0x00F0
148 };
149
150 #define IS_MEMORY_TYPE(flags, type) ((flags & mt_masks) == type)
151 #define HAS_VALID_MEMORY_TYPE(flags)((flags & mt_masks) != mtNone)
152 #define FLAGS_TO_MEMORY_TYPE(flags) (flags & mt_masks)
153
154 #define IS_ARENA_OBJ(flags) ((flags & ot_masks) == otArena)
155 #define IS_NMT_RECORDER(flags) ((flags & ot_masks) == otNMTRecorder)
156 #define NMT_CAN_TRACK(flags) (!IS_NMT_RECORDER(flags) && !(IS_MEMORY_TYPE(flags, mtDontTrack)))
157
158 typedef unsigned short MEMFLAGS;
159
160 extern bool NMT_track_callsite;
161
162 // debug build does not inline
163 #if defined(_DEBUG_)
164 #define CURRENT_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0)
165 #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
166 #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(3) : 0)
167 #else
168 #define CURRENT_PC (NMT_track_callsite? os::get_caller_pc(0) : 0)
169 #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0)
170 #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
171 #endif
172
173
174
175 template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
176 public:
177 _NOINLINE_ void* operator new(size_t size, address caller_pc = 0);
178 _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
179 address caller_pc = 0);
180
181 void operator delete(void* p);
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_ALLOCATION_HPP
26 #define SHARE_VM_MEMORY_ALLOCATION_HPP
27
28 #include "runtime/globals.hpp"
29 #include "utilities/globalDefinitions.hpp"
30 #include "utilities/macros.hpp"
31 #ifdef COMPILER1
32 #include "c1/c1_globals.hpp"
33 #endif
34 #ifdef COMPILER2
35 #include "opto/c2_globals.hpp"
36 #endif
37
38 #include <new>
39
40 #define ARENA_ALIGN_M1 (((size_t)(ARENA_AMALLOC_ALIGNMENT)) - 1)
41 #define ARENA_ALIGN_MASK (~((size_t)ARENA_ALIGN_M1))
42 #define ARENA_ALIGN(x) ((((size_t)(x)) + ARENA_ALIGN_M1) & ARENA_ALIGN_MASK)
43
44
45 // noinline attribute
46 #ifdef _WINDOWS
47 #define _NOINLINE_ __declspec(noinline)
48 #else
49 #if __GNUC__ < 3 // gcc 2.x does not support noinline attribute
50 #define _NOINLINE_
131 mtGC = 0x0500, // memory for GC
132 mtCompiler = 0x0600, // memory for compiler
133 mtInternal = 0x0700, // memory used by VM, but does not belong to
134 // any of above categories, and not used for
135 // native memory tracking
136 mtOther = 0x0800, // memory not used by VM
137 mtSymbol = 0x0900, // symbol
138 mtNMT = 0x0A00, // memory used by native memory tracking
139 mtChunk = 0x0B00, // chunk that holds content of arenas
140 mtJavaHeap = 0x0C00, // Java heap
141 mtDontTrack = 0x0D00, // memory we donot or cannot track
142 mt_number_of_types = 0x000C, // number of memory types
143 mt_masks = 0x7F00,
144
145 // object type mask
146 otArena = 0x0010, // an arena object
147 otNMTRecorder = 0x0020, // memory recorder object
148 ot_masks = 0x00F0
149 };
150
151 #if INCLUDE_NMT
152 #define IS_MEMORY_TYPE(flags, type) ((flags & mt_masks) == type)
153 #define HAS_VALID_MEMORY_TYPE(flags)((flags & mt_masks) != mtNone)
154 #define FLAGS_TO_MEMORY_TYPE(flags) (flags & mt_masks)
155
156 #define IS_ARENA_OBJ(flags) ((flags & ot_masks) == otArena)
157 #define IS_NMT_RECORDER(flags) ((flags & ot_masks) == otNMTRecorder)
158 #define NMT_CAN_TRACK(flags) (!IS_NMT_RECORDER(flags) && !(IS_MEMORY_TYPE(flags, mtDontTrack)))
159 #endif // INCLUDE_NMT
160
161 typedef unsigned short MEMFLAGS;
162
163 #if INCLUDE_NMT
164
165 extern bool NMT_track_callsite;
166
167 #else
168
169 const bool NMT_track_callsite = false;
170
171 #endif // INCLUDE_NMT
172
173 // debug build does not inline
174 #if defined(_DEBUG_)
175 #define CURRENT_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0)
176 #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
177 #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(3) : 0)
178 #else
179 #define CURRENT_PC (NMT_track_callsite? os::get_caller_pc(0) : 0)
180 #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0)
181 #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
182 #endif
183
184
185
186 template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
187 public:
188 _NOINLINE_ void* operator new(size_t size, address caller_pc = 0);
189 _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
190 address caller_pc = 0);
191
192 void operator delete(void* p);
|