allocation.hpp revision 4573
0N/A/*
2120N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_MEMORY_ALLOCATION_HPP
1879N/A#define SHARE_VM_MEMORY_ALLOCATION_HPP
1879N/A
1879N/A#include "runtime/globals.hpp"
1879N/A#include "utilities/globalDefinitions.hpp"
1879N/A#ifdef COMPILER1
1879N/A#include "c1/c1_globals.hpp"
1879N/A#endif
1879N/A#ifdef COMPILER2
0N/A#include "opto/c2_globals.hpp"
0N/A#endif
0N/A
0N/A#include <new>
0N/A
0N/A#define ARENA_ALIGN_M1 (((size_t)(ARENA_AMALLOC_ALIGNMENT)) - 1)
0N/A#define ARENA_ALIGN_MASK (~((size_t)ARENA_ALIGN_M1))
0N/A#define ARENA_ALIGN(x) ((((size_t)(x)) + ARENA_ALIGN_M1) & ARENA_ALIGN_MASK)
1172N/A
0N/A
0N/A// noinline attribute
0N/A#ifdef _WINDOWS
0N/A #define _NOINLINE_ __declspec(noinline)
0N/A#else
0N/A #if __GNUC__ < 3 // gcc 2.x does not support noinline attribute
0N/A #define _NOINLINE_
0N/A #else
0N/A #define _NOINLINE_ __attribute__ ((noinline))
0N/A #endif
0N/A#endif
0N/A
0N/A// All classes in the virtual machine must be subclassed
0N/A// by one of the following allocation classes:
0N/A//
0N/A// For objects allocated in the resource area (see resourceArea.hpp).
0N/A// - ResourceObj
0N/A//
0N/A// For objects allocated in the C-heap (managed by: free & malloc).
0N/A// - CHeapObj
0N/A//
0N/A// For objects allocated on the stack.
0N/A// - StackObj
0N/A//
0N/A// For embedded objects.
0N/A// - ValueObj
0N/A//
0N/A// For classes used as name spaces.
0N/A// - AllStatic
0N/A//
0N/A// The printable subclasses are used for debugging and define virtual
0N/A// member functions for printing. Classes that avoid allocating the
0N/A// vtbl entries in the objects should therefore not be the printable
0N/A// subclasses.
0N/A//
0N/A// The following macros and function should be used to allocate memory
0N/A// directly in the resource area or in the C-heap:
0N/A//
0N/A// NEW_RESOURCE_ARRAY(type,size)
0N/A// NEW_RESOURCE_OBJ(type)
0N/A// NEW_C_HEAP_ARRAY(type,size)
0N/A// NEW_C_HEAP_OBJ(type)
0N/A// char* AllocateHeap(size_t size, const char* name);
0N/A// void FreeHeap(void* p);
0N/A//
0N/A// C-heap allocation can be traced using +PrintHeapAllocation.
0N/A// malloc and free should therefore never called directly.
0N/A
0N/A// Base class for objects allocated in the C-heap.
0N/A
0N/A// In non product mode we introduce a super class for all allocation classes
0N/A// that supports printing.
0N/A// We avoid the superclass in product mode since some C++ compilers add
0N/A// a word overhead for empty super classes.
0N/A
0N/A#ifdef PRODUCT
0N/A#define ALLOCATION_SUPER_CLASS_SPEC
0N/A#else
0N/A#define ALLOCATION_SUPER_CLASS_SPEC : public AllocatedObj
0N/Aclass AllocatedObj {
0N/A public:
0N/A // Printing support
0N/A void print() const;
0N/A void print_value() const;
0N/A
0N/A virtual void print_on(outputStream* st) const;
0N/A virtual void print_value_on(outputStream* st) const;
0N/A};
0N/A#endif
0N/A
0N/A
0N/A/*
0N/A * MemoryType bitmap layout:
0N/A * | 16 15 14 13 12 11 10 09 | 08 07 06 05 | 04 03 02 01 |
0N/A * | memory type | object | reserved |
0N/A * | | type | |
0N/A */
0N/Aenum MemoryType {
0N/A // Memory type by sub systems. It occupies lower byte.
0N/A mtNone = 0x0000, // undefined
0N/A mtClass = 0x0100, // memory class for Java classes
0N/A mtThread = 0x0200, // memory for thread objects
0N/A mtThreadStack = 0x0300,
0N/A mtCode = 0x0400, // memory for generated code
0N/A mtGC = 0x0500, // memory for GC
0N/A mtCompiler = 0x0600, // memory for compiler
0N/A mtInternal = 0x0700, // memory used by VM, but does not belong to
0N/A // any of above categories, and not used for
0N/A // native memory tracking
0N/A mtOther = 0x0800, // memory not used by VM
0N/A mtSymbol = 0x0900, // symbol
0N/A mtNMT = 0x0A00, // memory used by native memory tracking
0N/A mtChunk = 0x0B00, // chunk that holds content of arenas
0N/A mtJavaHeap = 0x0C00, // Java heap
0N/A mtClassShared = 0x0D00, // class data sharing
0N/A mtTest = 0x0E00, // Test type for verifying NMT
0N/A mtTracing = 0x0F00, // memory used for Tracing
0N/A mt_number_of_types = 0x000F, // number of memory types (mtDontTrack
0N/A // is not included as validate type)
0N/A mtDontTrack = 0x1000, // memory we do not or cannot track
0N/A mt_masks = 0x7F00,
0N/A
0N/A // object type mask
0N/A otArena = 0x0010, // an arena object
0N/A otNMTRecorder = 0x0020, // memory recorder object
0N/A ot_masks = 0x00F0
0N/A};
0N/A
0N/A#define IS_MEMORY_TYPE(flags, type) ((flags & mt_masks) == type)
0N/A#define HAS_VALID_MEMORY_TYPE(flags)((flags & mt_masks) != mtNone)
0N/A#define FLAGS_TO_MEMORY_TYPE(flags) (flags & mt_masks)
0N/A
0N/A#define IS_ARENA_OBJ(flags) ((flags & ot_masks) == otArena)
0N/A#define IS_NMT_RECORDER(flags) ((flags & ot_masks) == otNMTRecorder)
0N/A#define NMT_CAN_TRACK(flags) (!IS_NMT_RECORDER(flags) && !(IS_MEMORY_TYPE(flags, mtDontTrack)))
0N/A
0N/Atypedef unsigned short MEMFLAGS;
0N/A
0N/Aextern bool NMT_track_callsite;
0N/A
0N/A// debug build does not inline
0N/A#if defined(_DEBUG_)
0N/A #define CURRENT_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0)
0N/A #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
0N/A #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(3) : 0)
0N/A#else
0N/A #define CURRENT_PC (NMT_track_callsite? os::get_caller_pc(0) : 0)
0N/A #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0)
0N/A #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
0N/A#endif
0N/A
0N/A
0N/A
0N/Atemplate <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
0N/A public:
0N/A _NOINLINE_ void* operator new(size_t size, address caller_pc = 0);
0N/A _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
0N/A address caller_pc = 0);
0N/A
0N/A void operator delete(void* p);
0N/A};
0N/A
0N/A// Base class for objects allocated on the stack only.
0N/A// Calling new or delete will result in fatal error.
0N/A
0N/Aclass StackObj ALLOCATION_SUPER_CLASS_SPEC {
0N/A public:
0N/A void* operator new(size_t size);
0N/A void operator delete(void* p);
0N/A};
0N/A
0N/A// Base class for objects used as value objects.
0N/A// Calling new or delete will result in fatal error.
0N/A//
0N/A// Portability note: Certain compilers (e.g. gcc) will
0N/A// always make classes bigger if it has a superclass, even
0N/A// if the superclass does not have any virtual methods or
0N/A// instance fields. The HotSpot implementation relies on this
0N/A// not to happen. So never make a ValueObj class a direct subclass
0N/A// of this object, but use the VALUE_OBJ_CLASS_SPEC class instead, e.g.,
0N/A// like this:
0N/A//
367N/A// class A VALUE_OBJ_CLASS_SPEC {
367N/A// ...
0N/A// }
0N/A//
0N/A// With gcc and possible other compilers the VALUE_OBJ_CLASS_SPEC can
0N/A// be defined as a an empty string "".
0N/A//
0N/Aclass _ValueObj {
0N/A public:
0N/A void* operator new(size_t size);
0N/A void operator delete(void* p);
0N/A};
0N/A
0N/A// Base class for classes that constitute name spaces.
0N/A
0N/Aclass AllStatic {
0N/A public:
0N/A AllStatic() { ShouldNotCallThis(); }
0N/A ~AllStatic() { ShouldNotCallThis(); }
0N/A};
0N/A
0N/A
0N/A//------------------------------Chunk------------------------------------------
0N/A// Linked list of raw memory chunks
0N/Aclass Chunk: CHeapObj<mtChunk> {
0N/A friend class VMStructs;
0N/A
0N/A protected:
0N/A Chunk* _next; // Next Chunk in list
0N/A const size_t _len; // Size of this Chunk
0N/A public:
0N/A void* operator new(size_t size, size_t length);
0N/A void operator delete(void* p);
0N/A Chunk(size_t length);
0N/A
0N/A enum {
0N/A // default sizes; make them slightly smaller than 2**k to guard against
0N/A // buddy-system style malloc implementations
0N/A#ifdef _LP64
0N/A slack = 40, // [RGV] Not sure if this is right, but make it
0N/A // a multiple of 8.
0N/A#else
0N/A slack = 20, // suspected sizeof(Chunk) + internal malloc headers
0N/A#endif
0N/A
0N/A init_size = 1*K - slack, // Size of first chunk
0N/A medium_size= 10*K - slack, // Size of medium-sized chunk
0N/A size = 32*K - slack, // Default size of an Arena chunk (following the first)
0N/A non_pool_size = init_size + 32 // An initial size which is not one of above
0N/A };
0N/A
0N/A void chop(); // Chop this chunk
0N/A void next_chop(); // Chop next chunk
0N/A static size_t aligned_overhead_size(void) { return ARENA_ALIGN(sizeof(Chunk)); }
0N/A
0N/A size_t length() const { return _len; }
0N/A Chunk* next() const { return _next; }
0N/A void set_next(Chunk* n) { _next = n; }
0N/A // Boundaries of data area (possibly unused)
0N/A char* bottom() const { return ((char*) this) + aligned_overhead_size(); }
0N/A char* top() const { return bottom() + _len; }
0N/A bool contains(char* p) const { return bottom() <= p && p <= top(); }
0N/A
0N/A // Start the chunk_pool cleaner task
0N/A static void start_chunk_pool_cleaner_task();
0N/A
0N/A static void clean_chunk_pool();
0N/A};
0N/A
0N/A//------------------------------Arena------------------------------------------
0N/A// Fast allocation of memory
0N/Aclass Arena : public CHeapObj<mtNone|otArena> {
0N/Aprotected:
0N/A friend class ResourceMark;
0N/A friend class HandleMark;
0N/A friend class NoHandleMark;
0N/A friend class VMStructs;
0N/A
0N/A Chunk *_first; // First chunk
0N/A Chunk *_chunk; // current chunk
0N/A char *_hwm, *_max; // High water mark and max in current chunk
0N/A void* grow(size_t x); // Get a new Chunk of at least size x
0N/A size_t _size_in_bytes; // Size of arena (used for native memory tracking)
0N/A
0N/A NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start
0N/A friend class AllocStats;
0N/A debug_only(void* malloc(size_t size);)
0N/A debug_only(void* internal_malloc_4(size_t x);)
0N/A NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
0N/A
0N/A void signal_out_of_memory(size_t request, const char* whence) const;
0N/A
0N/A void check_for_overflow(size_t request, const char* whence) const {
0N/A if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
0N/A signal_out_of_memory(request, whence);
0N/A }
0N/A }
0N/A
0N/A public:
39N/A Arena();
39N/A Arena(size_t init_size);
0N/A ~Arena();
0N/A void destruct_contents();
0N/A char* hwm() const { return _hwm; }
0N/A
0N/A // new operators
0N/A void* operator new (size_t size);
39N/A void* operator new (size_t size, const std::nothrow_t& nothrow_constant);
0N/A
0N/A // dynamic memory type tagging
0N/A void* operator new(size_t size, MEMFLAGS flags);
0N/A void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags);
0N/A void operator delete(void* p);
0N/A
0N/A // Fast allocate in the arena. Common case is: pointer test + increment.
0N/A void* Amalloc(size_t x) {
0N/A assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
0N/A x = ARENA_ALIGN(x);
0N/A debug_only(if (UseMallocOnly) return malloc(x);)
0N/A check_for_overflow(x, "Arena::Amalloc");
0N/A NOT_PRODUCT(inc_bytes_allocated(x);)
0N/A if (_hwm + x > _max) {
0N/A return grow(x);
0N/A } else {
0N/A char *old = _hwm;
0N/A _hwm += x;
0N/A return old;
0N/A }
0N/A }
0N/A // Further assume size is padded out to words
0N/A void *Amalloc_4(size_t x) {
0N/A assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
0N/A debug_only(if (UseMallocOnly) return malloc(x);)
1172N/A check_for_overflow(x, "Arena::Amalloc_4");
1172N/A NOT_PRODUCT(inc_bytes_allocated(x);)
1172N/A if (_hwm + x > _max) {
1172N/A return grow(x);
401N/A } else {
401N/A char *old = _hwm;
401N/A _hwm += x;
401N/A return old;
0N/A }
401N/A }
401N/A
401N/A // Allocate with 'double' alignment. It is 8 bytes on sparc.
0N/A // In other cases Amalloc_D() should be the same as Amalloc_4().
0N/A void* Amalloc_D(size_t x) {
0N/A assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
0N/A debug_only(if (UseMallocOnly) return malloc(x);)
0N/A#if defined(SPARC) && !defined(_LP64)
0N/A#define DALIGN_M1 7
0N/A size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm;
0N/A x += delta;
0N/A#endif
0N/A check_for_overflow(x, "Arena::Amalloc_D");
0N/A NOT_PRODUCT(inc_bytes_allocated(x);)
0N/A if (_hwm + x > _max) {
0N/A return grow(x); // grow() returns a result aligned >= 8 bytes.
0N/A } else {
0N/A char *old = _hwm;
0N/A _hwm += x;
0N/A#if defined(SPARC) && !defined(_LP64)
0N/A old += delta; // align to 8-bytes
0N/A#endif
0N/A return old;
0N/A }
0N/A }
0N/A
0N/A // Fast delete in area. Common case is: NOP (except for storage reclaimed)
0N/A void Afree(void *ptr, size_t size) {
0N/A#ifdef ASSERT
0N/A if (ZapResourceArea) memset(ptr, badResourceValue, size); // zap freed memory
0N/A if (UseMallocOnly) return;
0N/A#endif
0N/A if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr;
0N/A }
0N/A
0N/A void *Arealloc( void *old_ptr, size_t old_size, size_t new_size );
0N/A
0N/A // Move contents of this arena into an empty arena
0N/A Arena *move_contents(Arena *empty_arena);
0N/A
0N/A // Determine if pointer belongs to this Arena or not.
0N/A bool contains( const void *ptr ) const;
0N/A
0N/A // Total of all chunks in use (not thread-safe)
0N/A size_t used() const;
0N/A
0N/A // Total # of bytes used
0N/A size_t size_in_bytes() const { return _size_in_bytes; };
0N/A void set_size_in_bytes(size_t size);
0N/A
0N/A static void free_malloced_objects(Chunk* chunk, char* hwm, char* max, char* hwm2) PRODUCT_RETURN;
0N/A static void free_all(char** start, char** end) PRODUCT_RETURN;
0N/A
0N/A // how many arena instances
0N/A NOT_PRODUCT(static volatile jint _instance_count;)
0N/Aprivate:
0N/A // Reset this Arena to empty, access will trigger grow if necessary
0N/A void reset(void) {
0N/A _first = _chunk = NULL;
0N/A _hwm = _max = NULL;
605N/A set_size_in_bytes(0);
0N/A }
0N/A};
0N/A
0N/A// One of the following macros must be used when allocating
1172N/A// an array or object from an arena
1172N/A#define NEW_ARENA_ARRAY(arena, type, size) \
1172N/A (type*) (arena)->Amalloc((size) * sizeof(type))
0N/A
0N/A#define REALLOC_ARENA_ARRAY(arena, type, old, old_size, new_size) \
0N/A (type*) (arena)->Arealloc((char*)(old), (old_size) * sizeof(type), \
0N/A (new_size) * sizeof(type) )
0N/A
0N/A#define FREE_ARENA_ARRAY(arena, type, old, size) \
0N/A (arena)->Afree((char*)(old), (size) * sizeof(type))
0N/A
605N/A#define NEW_ARENA_OBJ(arena, type) \
0N/A NEW_ARENA_ARRAY(arena, type, 1)
0N/A
0N/A
0N/A//%note allocation_1
0N/Aextern char* resource_allocate_bytes(size_t size);
0N/Aextern char* resource_allocate_bytes(Thread* thread, size_t size);
0N/Aextern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size);
0N/Aextern void resource_free_bytes( char *old, size_t size );
0N/A
0N/A//----------------------------------------------------------------------
0N/A// Base class for objects allocated in the resource area per default.
0N/A// Optionally, objects may be allocated on the C heap with
0N/A// new(ResourceObj::C_HEAP) Foo(...) or in an Arena with new (&arena)
0N/A// ResourceObj's can be allocated within other objects, but don't use
0N/A// new or delete (allocation_type is unknown). If new is used to allocate,
0N/A// use delete to deallocate.
0N/Aclass ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
0N/A public:
0N/A enum allocation_type { STACK_OR_EMBEDDED = 0, RESOURCE_AREA, C_HEAP, ARENA, allocation_mask = 0x3 };
0N/A static void set_allocation_type(address res, allocation_type type) NOT_DEBUG_RETURN;
0N/A#ifdef ASSERT
0N/A private:
0N/A // When this object is allocated on stack the new() operator is not
0N/A // called but garbage on stack may look like a valid allocation_type.
0N/A // Store negated 'this' pointer when new() is called to distinguish cases.
0N/A // Use second array's element for verification value to distinguish garbage.
0N/A uintptr_t _allocation_t[2];
0N/A bool is_type_set() const;
0N/A public:
0N/A allocation_type get_allocation_type() const;
0N/A bool allocated_on_stack() const { return get_allocation_type() == STACK_OR_EMBEDDED; }
0N/A bool allocated_on_res_area() const { return get_allocation_type() == RESOURCE_AREA; }
0N/A bool allocated_on_C_heap() const { return get_allocation_type() == C_HEAP; }
0N/A bool allocated_on_arena() const { return get_allocation_type() == ARENA; }
0N/A ResourceObj(); // default construtor
0N/A ResourceObj(const ResourceObj& r); // default copy construtor
0N/A ResourceObj& operator=(const ResourceObj& r); // default copy assignment
0N/A ~ResourceObj();
921N/A#endif // ASSERT
921N/A
921N/A public:
0N/A void* operator new(size_t size, allocation_type type, MEMFLAGS flags);
0N/A void* operator new(size_t size, Arena *arena) {
0N/A address res = (address)arena->Amalloc(size);
0N/A DEBUG_ONLY(set_allocation_type(res, ARENA);)
0N/A return res;
0N/A }
0N/A void* operator new(size_t size) {
0N/A address res = (address)resource_allocate_bytes(size);
0N/A DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
0N/A return res;
0N/A }
0N/A void operator delete(void* p);
0N/A};
0N/A
0N/A// One of the following macros must be used when allocating an array
0N/A// or object to determine whether it should reside in the C heap on in
0N/A// the resource area.
0N/A
0N/A#define NEW_RESOURCE_ARRAY(type, size)\
0N/A (type*) resource_allocate_bytes((size) * sizeof(type))
0N/A
0N/A#define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
0N/A (type*) resource_allocate_bytes(thread, (size) * sizeof(type))
0N/A
0N/A#define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\
0N/A (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type) )
0N/A
0N/A#define FREE_RESOURCE_ARRAY(type, old, size)\
0N/A resource_free_bytes((char*)(old), (size) * sizeof(type))
0N/A
0N/A#define FREE_FAST(old)\
0N/A /* nop */
0N/A
0N/A#define NEW_RESOURCE_OBJ(type)\
0N/A NEW_RESOURCE_ARRAY(type, 1)
0N/A
0N/A#define NEW_C_HEAP_ARRAY(type, size, memflags)\
0N/A (type*) (AllocateHeap((size) * sizeof(type), memflags))
0N/A
0N/A#define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
0N/A (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags))
0N/A
0N/A#define FREE_C_HEAP_ARRAY(type,old,memflags) \
0N/A FreeHeap((char*)(old), memflags)
0N/A
0N/A#define NEW_C_HEAP_OBJ(type, memflags)\
0N/A NEW_C_HEAP_ARRAY(type, 1, memflags)
0N/A
0N/A
0N/A#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
0N/A (type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
0N/A
0N/A#define REALLOC_C_HEAP_ARRAY2(type, old, size, memflags, pc)\
0N/A (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, pc))
0N/A
921N/A#define NEW_C_HEAP_OBJ2(type, memflags, pc)\
921N/A NEW_C_HEAP_ARRAY2(type, 1, memflags, pc)
921N/A
921N/A
921N/Aextern bool warn_new_operator;
921N/A
0N/A// for statistics
0N/A#ifndef PRODUCT
0N/Aclass AllocStats : StackObj {
0N/A julong start_mallocs, start_frees;
0N/A julong start_malloc_bytes, start_mfree_bytes, start_res_bytes;
0N/A public:
0N/A AllocStats();
0N/A
0N/A julong num_mallocs(); // since creation of receiver
0N/A julong alloc_bytes();
0N/A julong num_frees();
0N/A julong free_bytes();
0N/A julong resource_bytes();
0N/A void print();
921N/A};
0N/A#endif
0N/A
0N/A
0N/A//------------------------------ReallocMark---------------------------------
0N/A// Code which uses REALLOC_RESOURCE_ARRAY should check an associated
0N/A// ReallocMark, which is declared in the same scope as the reallocated
0N/A// pointer. Any operation that could __potentially__ cause a reallocation
0N/A// should check the ReallocMark.
0N/Aclass ReallocMark: public StackObj {
0N/Aprotected:
0N/A NOT_PRODUCT(int _nesting;)
0N/A
0N/Apublic:
0N/A ReallocMark() PRODUCT_RETURN;
0N/A void check() PRODUCT_RETURN;
0N/A};
0N/A
0N/A// Helper class to allocate arrays that may become large.
0N/A// Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
0N/A// and uses mapped memory for larger allocations.
0N/A// Most OS mallocs do something similar but Solaris malloc does not revert
0N/A// to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
0N/A// is set so that we always use malloc except for Solaris where we set the
0N/A// limit to get mapped memory.
0N/Atemplate <class E, MEMFLAGS F>
0N/Aclass ArrayAllocator VALUE_OBJ_CLASS_SPEC {
0N/A char* _addr;
0N/A bool _use_malloc;
0N/A size_t _size;
0N/A bool _free_in_destructor;
0N/A public:
0N/A ArrayAllocator(bool free_in_destructor = true) :
0N/A _addr(NULL), _use_malloc(false), _size(0), _free_in_destructor(free_in_destructor) { }
0N/A
0N/A ~ArrayAllocator() {
0N/A if (_free_in_destructor) {
0N/A free();
0N/A }
0N/A }
0N/A
0N/A E* allocate(size_t length);
0N/A void free();
0N/A};
0N/A
0N/A#endif // SHARE_VM_MEMORY_ALLOCATION_HPP
0N/A