src/share/vm/memory/allocation.cpp

Print this page




 546   while( k != _chunk) {         // Whilst have Chunks in a row
 547     sum += k->length();         // Total size of this Chunk
 548     k = k->next();              // Bump along to next Chunk
 549   }
 550   return sum;                   // Return total consumed space.
 551 }
 552 
 553 void Arena::signal_out_of_memory(size_t sz, const char* whence) const {
 554   vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, whence);
 555 }
 556 
 557 // Grow a new Chunk
 558 void* Arena::grow(size_t x, AllocFailType alloc_failmode) {
 559   // Get minimal required size.  Either real big, or even bigger for giant objs
 560   size_t len = MAX2(x, (size_t) Chunk::size);
 561 
 562   Chunk *k = _chunk;            // Get filled-up chunk address
 563   _chunk = new (alloc_failmode, len) Chunk(len);
 564 
 565   if (_chunk == NULL) {

 566     return NULL;
 567   }
 568   if (k) k->set_next(_chunk);   // Append new chunk to end of linked list
 569   else _first = _chunk;
 570   _hwm  = _chunk->bottom();     // Save the cached hwm, max
 571   _max =  _chunk->top();
 572   set_size_in_bytes(size_in_bytes() + len);
 573   void* result = _hwm;
 574   _hwm += x;
 575   return result;
 576 }
 577 
 578 
 579 
 580 // Reallocate storage in Arena.
 581 void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {
 582   assert(new_size >= 0, "bad size");
 583   if (new_size == 0) return NULL;
 584 #ifdef ASSERT
 585   if (UseMallocOnly) {




 546   while( k != _chunk) {         // Whilst have Chunks in a row
 547     sum += k->length();         // Total size of this Chunk
 548     k = k->next();              // Bump along to next Chunk
 549   }
 550   return sum;                   // Return total consumed space.
 551 }
 552 
 553 void Arena::signal_out_of_memory(size_t sz, const char* whence) const {
 554   vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, whence);
 555 }
 556 
 557 // Grow a new Chunk
 558 void* Arena::grow(size_t x, AllocFailType alloc_failmode) {
 559   // Get minimal required size.  Either real big, or even bigger for giant objs
 560   size_t len = MAX2(x, (size_t) Chunk::size);
 561 
 562   Chunk *k = _chunk;            // Get filled-up chunk address
 563   _chunk = new (alloc_failmode, len) Chunk(len);
 564 
 565   if (_chunk == NULL) {
 566     _chunk = k;                 // restore the value of _chunk
 567     return NULL;
 568   }
 569   if (k) k->set_next(_chunk);   // Append new chunk to end of linked list
 570   else _first = _chunk;
 571   _hwm  = _chunk->bottom();     // Save the cached hwm, max
 572   _max =  _chunk->top();
 573   set_size_in_bytes(size_in_bytes() + len);
 574   void* result = _hwm;
 575   _hwm += x;
 576   return result;
 577 }
 578 
 579 
 580 
 581 // Reallocate storage in Arena.
 582 void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {
 583   assert(new_size >= 0, "bad size");
 584   if (new_size == 0) return NULL;
 585 #ifdef ASSERT
 586   if (UseMallocOnly) {