src/share/vm/memory/allocation.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7088955 Sdiff src/share/vm/memory

src/share/vm/memory/allocation.hpp

Print this page




 134 // be defined as a an empty string "".
 135 //
 136 class _ValueObj {
 137  public:
 138   void* operator new(size_t size);
 139   void operator delete(void* p);
 140 };
 141 
 142 // Base class for classes that constitute name spaces.
 143 
 144 class AllStatic {
 145  public:
 146   AllStatic()  { ShouldNotCallThis(); }
 147   ~AllStatic() { ShouldNotCallThis(); }
 148 };
 149 
 150 
 151 //------------------------------Chunk------------------------------------------
 152 // Linked list of raw memory chunks
 153 class Chunk: public CHeapObj {


 154  protected:
 155   Chunk*       _next;     // Next Chunk in list
 156   const size_t _len;      // Size of this Chunk
 157  public:
 158   void* operator new(size_t size, size_t length);
 159   void  operator delete(void* p);
 160   Chunk(size_t length);
 161 
 162   enum {
 163     // default sizes; make them slightly smaller than 2**k to guard against
 164     // buddy-system style malloc implementations
 165 #ifdef _LP64
 166     slack      = 40,            // [RGV] Not sure if this is right, but make it
 167                                 //       a multiple of 8.
 168 #else
 169     slack      = 20,            // suspected sizeof(Chunk) + internal malloc headers
 170 #endif
 171 
 172     init_size  =  1*K  - slack, // Size of first chunk
 173     medium_size= 10*K  - slack, // Size of medium-sized chunk


 183   Chunk* next() const           { return _next;  }
 184   void set_next(Chunk* n)       { _next = n;  }
 185   // Boundaries of data area (possibly unused)
 186   char* bottom() const          { return ((char*) this) + aligned_overhead_size();  }
 187   char* top()    const          { return bottom() + _len; }
 188   bool contains(char* p) const  { return bottom() <= p && p <= top(); }
 189 
 190   // Start the chunk_pool cleaner task
 191   static void start_chunk_pool_cleaner_task();
 192 
 193   static void clean_chunk_pool();
 194 };
 195 
 196 //------------------------------Arena------------------------------------------
 197 // Fast allocation of memory
 198 class Arena: public CHeapObj {
 199 protected:
 200   friend class ResourceMark;
 201   friend class HandleMark;
 202   friend class NoHandleMark;


 203   Chunk *_first;                // First chunk
 204   Chunk *_chunk;                // current chunk
 205   char *_hwm, *_max;            // High water mark and max in current chunk
 206   void* grow(size_t x);         // Get a new Chunk of at least size x
 207   NOT_PRODUCT(size_t _size_in_bytes;) // Size of arena (used for memory usage tracing)
 208   NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start
 209   friend class AllocStats;
 210   debug_only(void* malloc(size_t size);)
 211   debug_only(void* internal_malloc_4(size_t x);)
 212   NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
 213 
 214   void signal_out_of_memory(size_t request, const char* whence) const;
 215 
 216   void check_for_overflow(size_t request, const char* whence) const {
 217     if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
 218       signal_out_of_memory(request, whence);
 219     }
 220  }
 221 
 222  public:




 134 // be defined as a an empty string "".
 135 //
 136 class _ValueObj {
 137  public:
 138   void* operator new(size_t size);
 139   void operator delete(void* p);
 140 };
 141 
 142 // Base class for classes that constitute name spaces.
 143 
 144 class AllStatic {
 145  public:
 146   AllStatic()  { ShouldNotCallThis(); }
 147   ~AllStatic() { ShouldNotCallThis(); }
 148 };
 149 
 150 
 151 //------------------------------Chunk------------------------------------------
 152 // Linked list of raw memory chunks
 153 class Chunk: public CHeapObj {
 154   friend class VMStructs;
 155 
 156  protected:
 157   Chunk*       _next;     // Next Chunk in list
 158   const size_t _len;      // Size of this Chunk
 159  public:
 160   void* operator new(size_t size, size_t length);
 161   void  operator delete(void* p);
 162   Chunk(size_t length);
 163 
 164   enum {
 165     // default sizes; make them slightly smaller than 2**k to guard against
 166     // buddy-system style malloc implementations
 167 #ifdef _LP64
 168     slack      = 40,            // [RGV] Not sure if this is right, but make it
 169                                 //       a multiple of 8.
 170 #else
 171     slack      = 20,            // suspected sizeof(Chunk) + internal malloc headers
 172 #endif
 173 
 174     init_size  =  1*K  - slack, // Size of first chunk
 175     medium_size= 10*K  - slack, // Size of medium-sized chunk


 185   Chunk* next() const           { return _next;  }
 186   void set_next(Chunk* n)       { _next = n;  }
 187   // Boundaries of data area (possibly unused)
 188   char* bottom() const          { return ((char*) this) + aligned_overhead_size();  }
 189   char* top()    const          { return bottom() + _len; }
 190   bool contains(char* p) const  { return bottom() <= p && p <= top(); }
 191 
 192   // Start the chunk_pool cleaner task
 193   static void start_chunk_pool_cleaner_task();
 194 
 195   static void clean_chunk_pool();
 196 };
 197 
 198 //------------------------------Arena------------------------------------------
 199 // Fast allocation of memory
 200 class Arena: public CHeapObj {
 201 protected:
 202   friend class ResourceMark;
 203   friend class HandleMark;
 204   friend class NoHandleMark;
 205   friend class VMStructs;
 206 
 207   Chunk *_first;                // First chunk
 208   Chunk *_chunk;                // current chunk
 209   char *_hwm, *_max;            // High water mark and max in current chunk
 210   void* grow(size_t x);         // Get a new Chunk of at least size x
 211   NOT_PRODUCT(size_t _size_in_bytes;) // Size of arena (used for memory usage tracing)
 212   NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start
 213   friend class AllocStats;
 214   debug_only(void* malloc(size_t size);)
 215   debug_only(void* internal_malloc_4(size_t x);)
 216   NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
 217 
 218   void signal_out_of_memory(size_t request, const char* whence) const;
 219 
 220   void check_for_overflow(size_t request, const char* whence) const {
 221     if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
 222       signal_out_of_memory(request, whence);
 223     }
 224  }
 225 
 226  public:


src/share/vm/memory/allocation.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File