Mercurial > hg > truffle
annotate src/share/vm/memory/allocation.hpp @ 2831:f072013daba9
Added lookup method.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Tue, 31 May 2011 11:32:48 +0200 |
parents | 4a9604cd7c5f |
children | 2a3da7eaf4a6 |
rev | line source |
---|---|
0 | 1 /* |
2250 | 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
342
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
342
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
342
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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 | |
0 | 37 #define ARENA_ALIGN_M1 (((size_t)(ARENA_AMALLOC_ALIGNMENT)) - 1) |
38 #define ARENA_ALIGN_MASK (~((size_t)ARENA_ALIGN_M1)) | |
39 #define ARENA_ALIGN(x) ((((size_t)(x)) + ARENA_ALIGN_M1) & ARENA_ALIGN_MASK) | |
40 | |
41 // All classes in the virtual machine must be subclassed | |
42 // by one of the following allocation classes: | |
43 // | |
44 // For objects allocated in the resource area (see resourceArea.hpp). | |
45 // - ResourceObj | |
46 // | |
47 // For objects allocated in the C-heap (managed by: free & malloc). | |
48 // - CHeapObj | |
49 // | |
50 // For objects allocated on the stack. | |
51 // - StackObj | |
52 // | |
53 // For embedded objects. | |
54 // - ValueObj | |
55 // | |
56 // For classes used as name spaces. | |
57 // - AllStatic | |
58 // | |
59 // The printable subclasses are used for debugging and define virtual | |
60 // member functions for printing. Classes that avoid allocating the | |
61 // vtbl entries in the objects should therefore not be the printable | |
62 // subclasses. | |
63 // | |
64 // The following macros and function should be used to allocate memory | |
65 // directly in the resource area or in the C-heap: | |
66 // | |
67 // NEW_RESOURCE_ARRAY(type,size) | |
68 // NEW_RESOURCE_OBJ(type) | |
69 // NEW_C_HEAP_ARRAY(type,size) | |
70 // NEW_C_HEAP_OBJ(type) | |
71 // char* AllocateHeap(size_t size, const char* name); | |
72 // void FreeHeap(void* p); | |
73 // | |
74 // C-heap allocation can be traced using +PrintHeapAllocation. | |
75 // malloc and free should therefore never called directly. | |
76 | |
77 // Base class for objects allocated in the C-heap. | |
78 | |
79 // In non product mode we introduce a super class for all allocation classes | |
80 // that supports printing. | |
81 // We avoid the superclass in product mode since some C++ compilers add | |
82 // a word overhead for empty super classes. | |
83 | |
84 #ifdef PRODUCT | |
85 #define ALLOCATION_SUPER_CLASS_SPEC | |
86 #else | |
87 #define ALLOCATION_SUPER_CLASS_SPEC : public AllocatedObj | |
88 class AllocatedObj { | |
89 public: | |
90 // Printing support | |
91 void print() const; | |
92 void print_value() const; | |
93 | |
94 virtual void print_on(outputStream* st) const; | |
95 virtual void print_value_on(outputStream* st) const; | |
96 }; | |
97 #endif | |
98 | |
99 class CHeapObj ALLOCATION_SUPER_CLASS_SPEC { | |
100 public: | |
101 void* operator new(size_t size); | |
102 void operator delete(void* p); | |
103 void* new_array(size_t size); | |
104 }; | |
105 | |
106 // Base class for objects allocated on the stack only. | |
107 // Calling new or delete will result in fatal error. | |
108 | |
109 class StackObj ALLOCATION_SUPER_CLASS_SPEC { | |
110 public: | |
111 void* operator new(size_t size); | |
112 void operator delete(void* p); | |
113 }; | |
114 | |
115 // Base class for objects used as value objects. | |
116 // Calling new or delete will result in fatal error. | |
117 // | |
118 // Portability note: Certain compilers (e.g. gcc) will | |
119 // always make classes bigger if it has a superclass, even | |
120 // if the superclass does not have any virtual methods or | |
121 // instance fields. The HotSpot implementation relies on this | |
122 // not to happen. So never make a ValueObj class a direct subclass | |
123 // of this object, but use the VALUE_OBJ_CLASS_SPEC class instead, e.g., | |
124 // like this: | |
125 // | |
126 // class A VALUE_OBJ_CLASS_SPEC { | |
127 // ... | |
128 // } | |
129 // | |
130 // With gcc and possible other compilers the VALUE_OBJ_CLASS_SPEC can | |
131 // be defined as a an empty string "". | |
132 // | |
133 class _ValueObj { | |
134 public: | |
135 void* operator new(size_t size); | |
136 void operator delete(void* p); | |
137 }; | |
138 | |
139 // Base class for classes that constitute name spaces. | |
140 | |
141 class AllStatic { | |
142 public: | |
143 AllStatic() { ShouldNotCallThis(); } | |
144 ~AllStatic() { ShouldNotCallThis(); } | |
145 }; | |
146 | |
147 | |
148 //------------------------------Chunk------------------------------------------ | |
149 // Linked list of raw memory chunks | |
150 class Chunk: public CHeapObj { | |
151 protected: | |
152 Chunk* _next; // Next Chunk in list | |
153 const size_t _len; // Size of this Chunk | |
154 public: | |
155 void* operator new(size_t size, size_t length); | |
156 void operator delete(void* p); | |
157 Chunk(size_t length); | |
158 | |
159 enum { | |
160 // default sizes; make them slightly smaller than 2**k to guard against | |
161 // buddy-system style malloc implementations | |
162 #ifdef _LP64 | |
163 slack = 40, // [RGV] Not sure if this is right, but make it | |
164 // a multiple of 8. | |
165 #else | |
166 slack = 20, // suspected sizeof(Chunk) + internal malloc headers | |
167 #endif | |
168 | |
169 init_size = 1*K - slack, // Size of first chunk | |
170 medium_size= 10*K - slack, // Size of medium-sized chunk | |
171 size = 32*K - slack, // Default size of an Arena chunk (following the first) | |
172 non_pool_size = init_size + 32 // An initial size which is not one of above | |
173 }; | |
174 | |
175 void chop(); // Chop this chunk | |
176 void next_chop(); // Chop next chunk | |
177 static size_t aligned_overhead_size(void) { return ARENA_ALIGN(sizeof(Chunk)); } | |
178 | |
179 size_t length() const { return _len; } | |
180 Chunk* next() const { return _next; } | |
181 void set_next(Chunk* n) { _next = n; } | |
182 // Boundaries of data area (possibly unused) | |
183 char* bottom() const { return ((char*) this) + aligned_overhead_size(); } | |
184 char* top() const { return bottom() + _len; } | |
185 bool contains(char* p) const { return bottom() <= p && p <= top(); } | |
186 | |
187 // Start the chunk_pool cleaner task | |
188 static void start_chunk_pool_cleaner_task(); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
189 |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
190 static void clean_chunk_pool(); |
0 | 191 }; |
192 | |
193 //------------------------------Arena------------------------------------------ | |
194 // Fast allocation of memory | |
195 class Arena: public CHeapObj { | |
196 protected: | |
197 friend class ResourceMark; | |
198 friend class HandleMark; | |
199 friend class NoHandleMark; | |
200 Chunk *_first; // First chunk | |
201 Chunk *_chunk; // current chunk | |
202 char *_hwm, *_max; // High water mark and max in current chunk | |
203 void* grow(size_t x); // Get a new Chunk of at least size x | |
204 NOT_PRODUCT(size_t _size_in_bytes;) // Size of arena (used for memory usage tracing) | |
2250 | 205 NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start |
0 | 206 friend class AllocStats; |
207 debug_only(void* malloc(size_t size);) | |
208 debug_only(void* internal_malloc_4(size_t x);) | |
2250 | 209 NOT_PRODUCT(void inc_bytes_allocated(size_t x);) |
2307
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
210 |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
211 void signal_out_of_memory(size_t request, const char* whence) const; |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
212 |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
213 void check_for_overflow(size_t request, const char* whence) const { |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
214 if (UINTPTR_MAX - request < (uintptr_t)_hwm) { |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
215 signal_out_of_memory(request, whence); |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
216 } |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
217 } |
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
218 |
0 | 219 public: |
220 Arena(); | |
221 Arena(size_t init_size); | |
222 Arena(Arena *old); | |
223 ~Arena(); | |
224 void destruct_contents(); | |
225 char* hwm() const { return _hwm; } | |
226 | |
227 // Fast allocate in the arena. Common case is: pointer test + increment. | |
228 void* Amalloc(size_t x) { | |
229 assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2"); | |
230 x = ARENA_ALIGN(x); | |
231 debug_only(if (UseMallocOnly) return malloc(x);) | |
2307
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
232 check_for_overflow(x, "Arena::Amalloc"); |
2250 | 233 NOT_PRODUCT(inc_bytes_allocated(x);) |
0 | 234 if (_hwm + x > _max) { |
235 return grow(x); | |
236 } else { | |
237 char *old = _hwm; | |
238 _hwm += x; | |
239 return old; | |
240 } | |
241 } | |
242 // Further assume size is padded out to words | |
243 void *Amalloc_4(size_t x) { | |
244 assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); | |
245 debug_only(if (UseMallocOnly) return malloc(x);) | |
2307
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
246 check_for_overflow(x, "Arena::Amalloc_4"); |
2250 | 247 NOT_PRODUCT(inc_bytes_allocated(x);) |
0 | 248 if (_hwm + x > _max) { |
249 return grow(x); | |
250 } else { | |
251 char *old = _hwm; | |
252 _hwm += x; | |
253 return old; | |
254 } | |
255 } | |
256 | |
257 // Allocate with 'double' alignment. It is 8 bytes on sparc. | |
258 // In other cases Amalloc_D() should be the same as Amalloc_4(). | |
259 void* Amalloc_D(size_t x) { | |
260 assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); | |
261 debug_only(if (UseMallocOnly) return malloc(x);) | |
262 #if defined(SPARC) && !defined(_LP64) | |
263 #define DALIGN_M1 7 | |
264 size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm; | |
265 x += delta; | |
266 #endif | |
2307
4a9604cd7c5f
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
2250
diff
changeset
|
267 check_for_overflow(x, "Arena::Amalloc_D"); |
2250 | 268 NOT_PRODUCT(inc_bytes_allocated(x);) |
0 | 269 if (_hwm + x > _max) { |
270 return grow(x); // grow() returns a result aligned >= 8 bytes. | |
271 } else { | |
272 char *old = _hwm; | |
273 _hwm += x; | |
274 #if defined(SPARC) && !defined(_LP64) | |
275 old += delta; // align to 8-bytes | |
276 #endif | |
277 return old; | |
278 } | |
279 } | |
280 | |
281 // Fast delete in area. Common case is: NOP (except for storage reclaimed) | |
282 void Afree(void *ptr, size_t size) { | |
283 #ifdef ASSERT | |
284 if (ZapResourceArea) memset(ptr, badResourceValue, size); // zap freed memory | |
285 if (UseMallocOnly) return; | |
286 #endif | |
287 if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr; | |
288 } | |
289 | |
290 void *Arealloc( void *old_ptr, size_t old_size, size_t new_size ); | |
291 | |
292 // Move contents of this arena into an empty arena | |
293 Arena *move_contents(Arena *empty_arena); | |
294 | |
295 // Determine if pointer belongs to this Arena or not. | |
296 bool contains( const void *ptr ) const; | |
297 | |
298 // Total of all chunks in use (not thread-safe) | |
299 size_t used() const; | |
300 | |
301 // Total # of bytes used | |
302 size_t size_in_bytes() const NOT_PRODUCT({ return _size_in_bytes; }) PRODUCT_RETURN0; | |
303 void set_size_in_bytes(size_t size) NOT_PRODUCT({ _size_in_bytes = size; }) PRODUCT_RETURN; | |
304 static void free_malloced_objects(Chunk* chunk, char* hwm, char* max, char* hwm2) PRODUCT_RETURN; | |
305 static void free_all(char** start, char** end) PRODUCT_RETURN; | |
306 | |
307 private: | |
308 // Reset this Arena to empty, access will trigger grow if necessary | |
309 void reset(void) { | |
310 _first = _chunk = NULL; | |
311 _hwm = _max = NULL; | |
312 } | |
313 }; | |
314 | |
315 // One of the following macros must be used when allocating | |
316 // an array or object from an arena | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
317 #define NEW_ARENA_ARRAY(arena, type, size) \ |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
318 (type*) (arena)->Amalloc((size) * sizeof(type)) |
0 | 319 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
320 #define REALLOC_ARENA_ARRAY(arena, type, old, old_size, new_size) \ |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
321 (type*) (arena)->Arealloc((char*)(old), (old_size) * sizeof(type), \ |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
322 (new_size) * sizeof(type) ) |
0 | 323 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
324 #define FREE_ARENA_ARRAY(arena, type, old, size) \ |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
325 (arena)->Afree((char*)(old), (size) * sizeof(type)) |
0 | 326 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1689
diff
changeset
|
327 #define NEW_ARENA_OBJ(arena, type) \ |
0 | 328 NEW_ARENA_ARRAY(arena, type, 1) |
329 | |
330 | |
331 //%note allocation_1 | |
332 extern char* resource_allocate_bytes(size_t size); | |
333 extern char* resource_allocate_bytes(Thread* thread, size_t size); | |
334 extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size); | |
335 extern void resource_free_bytes( char *old, size_t size ); | |
336 | |
337 //---------------------------------------------------------------------- | |
338 // Base class for objects allocated in the resource area per default. | |
339 // Optionally, objects may be allocated on the C heap with | |
340 // new(ResourceObj::C_HEAP) Foo(...) or in an Arena with new (&arena) | |
341 // ResourceObj's can be allocated within other objects, but don't use | |
342 // new or delete (allocation_type is unknown). If new is used to allocate, | |
343 // use delete to deallocate. | |
344 class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { | |
345 public: | |
1685 | 346 enum allocation_type { STACK_OR_EMBEDDED = 0, RESOURCE_AREA, C_HEAP, ARENA, allocation_mask = 0x3 }; |
1688
2dfd013a7465
6975078: assert(allocated_on_res_area() || allocated_on_C_heap() || allocated_on_arena()
kvn
parents:
1685
diff
changeset
|
347 static void set_allocation_type(address res, allocation_type type) NOT_DEBUG_RETURN; |
0 | 348 #ifdef ASSERT |
349 private: | |
1685 | 350 // When this object is allocated on stack the new() operator is not |
351 // called but garbage on stack may look like a valid allocation_type. | |
352 // Store negated 'this' pointer when new() is called to distinguish cases. | |
2015
79d8657be916
6993125: runThese crashes with assert(Thread::current()->on_local_stack((address)this))
kvn
parents:
1972
diff
changeset
|
353 // Use second array's element for verification value to distinguish garbage. |
79d8657be916
6993125: runThese crashes with assert(Thread::current()->on_local_stack((address)this))
kvn
parents:
1972
diff
changeset
|
354 uintptr_t _allocation_t[2]; |
79d8657be916
6993125: runThese crashes with assert(Thread::current()->on_local_stack((address)this))
kvn
parents:
1972
diff
changeset
|
355 bool is_type_set() const; |
0 | 356 public: |
1688
2dfd013a7465
6975078: assert(allocated_on_res_area() || allocated_on_C_heap() || allocated_on_arena()
kvn
parents:
1685
diff
changeset
|
357 allocation_type get_allocation_type() const; |
2dfd013a7465
6975078: assert(allocated_on_res_area() || allocated_on_C_heap() || allocated_on_arena()
kvn
parents:
1685
diff
changeset
|
358 bool allocated_on_stack() const { return get_allocation_type() == STACK_OR_EMBEDDED; } |
2dfd013a7465
6975078: assert(allocated_on_res_area() || allocated_on_C_heap() || allocated_on_arena()
kvn
parents:
1685
diff
changeset
|
359 bool allocated_on_res_area() const { return get_allocation_type() == RESOURCE_AREA; } |
2dfd013a7465
6975078: assert(allocated_on_res_area() || allocated_on_C_heap() || allocated_on_arena()
kvn
parents:
1685
diff
changeset
|
360 bool allocated_on_C_heap() const { return get_allocation_type() == C_HEAP; } |
2dfd013a7465
6975078: assert(allocated_on_res_area() || allocated_on_C_heap() || allocated_on_arena()
kvn
parents:
1685
diff
changeset
|
361 bool allocated_on_arena() const { return get_allocation_type() == ARENA; } |
1685 | 362 ResourceObj(); // default construtor |
363 ResourceObj(const ResourceObj& r); // default copy construtor | |
364 ResourceObj& operator=(const ResourceObj& r); // default copy assignment | |
365 ~ResourceObj(); | |
0 | 366 #endif // ASSERT |
367 | |
368 public: | |
369 void* operator new(size_t size, allocation_type type); | |
370 void* operator new(size_t size, Arena *arena) { | |
371 address res = (address)arena->Amalloc(size); | |
1685 | 372 DEBUG_ONLY(set_allocation_type(res, ARENA);) |
0 | 373 return res; |
374 } | |
375 void* operator new(size_t size) { | |
376 address res = (address)resource_allocate_bytes(size); | |
1685 | 377 DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) |
0 | 378 return res; |
379 } | |
380 void operator delete(void* p); | |
381 }; | |
382 | |
383 // One of the following macros must be used when allocating an array | |
384 // or object to determine whether it should reside in the C heap on in | |
385 // the resource area. | |
386 | |
387 #define NEW_RESOURCE_ARRAY(type, size)\ | |
388 (type*) resource_allocate_bytes((size) * sizeof(type)) | |
389 | |
390 #define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\ | |
391 (type*) resource_allocate_bytes(thread, (size) * sizeof(type)) | |
392 | |
393 #define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\ | |
394 (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type) ) | |
395 | |
396 #define FREE_RESOURCE_ARRAY(type, old, size)\ | |
397 resource_free_bytes((char*)(old), (size) * sizeof(type)) | |
398 | |
399 #define FREE_FAST(old)\ | |
400 /* nop */ | |
401 | |
402 #define NEW_RESOURCE_OBJ(type)\ | |
403 NEW_RESOURCE_ARRAY(type, 1) | |
404 | |
405 #define NEW_C_HEAP_ARRAY(type, size)\ | |
406 (type*) (AllocateHeap((size) * sizeof(type), XSTR(type) " in " __FILE__)) | |
407 | |
408 #define REALLOC_C_HEAP_ARRAY(type, old, size)\ | |
409 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), XSTR(type) " in " __FILE__)) | |
410 | |
411 #define FREE_C_HEAP_ARRAY(type,old) \ | |
412 FreeHeap((char*)(old)) | |
413 | |
414 #define NEW_C_HEAP_OBJ(type)\ | |
415 NEW_C_HEAP_ARRAY(type, 1) | |
416 | |
417 extern bool warn_new_operator; | |
418 | |
419 // for statistics | |
420 #ifndef PRODUCT | |
421 class AllocStats : StackObj { | |
2250 | 422 julong start_mallocs, start_frees; |
423 julong start_malloc_bytes, start_mfree_bytes, start_res_bytes; | |
0 | 424 public: |
425 AllocStats(); | |
426 | |
2250 | 427 julong num_mallocs(); // since creation of receiver |
428 julong alloc_bytes(); | |
429 julong num_frees(); | |
430 julong free_bytes(); | |
431 julong resource_bytes(); | |
0 | 432 void print(); |
433 }; | |
434 #endif | |
435 | |
436 | |
437 //------------------------------ReallocMark--------------------------------- | |
438 // Code which uses REALLOC_RESOURCE_ARRAY should check an associated | |
439 // ReallocMark, which is declared in the same scope as the reallocated | |
440 // pointer. Any operation that could __potentially__ cause a reallocation | |
441 // should check the ReallocMark. | |
442 class ReallocMark: public StackObj { | |
443 protected: | |
444 NOT_PRODUCT(int _nesting;) | |
445 | |
446 public: | |
447 ReallocMark() PRODUCT_RETURN; | |
448 void check() PRODUCT_RETURN; | |
449 }; | |
1972 | 450 |
451 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP |