hotspot/src/share/vm/memory/allocation.cpp
changeset 14120 7d298141c258
parent 14083 103054a71a30
child 14579 7f6ce6e3dd80
equal deleted inserted replaced
14117:6e2e697e310f 14120:7d298141c258
   431   _max = _chunk->top();
   431   _max = _chunk->top();
   432   set_size_in_bytes(Chunk::init_size);
   432   set_size_in_bytes(Chunk::init_size);
   433   NOT_PRODUCT(Atomic::inc(&_instance_count);)
   433   NOT_PRODUCT(Atomic::inc(&_instance_count);)
   434 }
   434 }
   435 
   435 
   436 Arena::Arena(Arena *a) : _chunk(a->_chunk), _hwm(a->_hwm), _max(a->_max), _first(a->_first) {
       
   437   set_size_in_bytes(a->size_in_bytes());
       
   438   NOT_PRODUCT(Atomic::inc(&_instance_count);)
       
   439 }
       
   440 
       
   441 
       
   442 Arena *Arena::move_contents(Arena *copy) {
   436 Arena *Arena::move_contents(Arena *copy) {
   443   copy->destruct_contents();
   437   copy->destruct_contents();
   444   copy->_chunk = _chunk;
   438   copy->_chunk = _chunk;
   445   copy->_hwm   = _hwm;
   439   copy->_hwm   = _hwm;
   446   copy->_max   = _max;
   440   copy->_max   = _max;
   447   copy->_first = _first;
   441   copy->_first = _first;
   448   copy->set_size_in_bytes(size_in_bytes());
   442 
       
   443   // workaround rare racing condition, which could double count
       
   444   // the arena size by native memory tracking
       
   445   size_t size = size_in_bytes();
       
   446   set_size_in_bytes(0);
       
   447   copy->set_size_in_bytes(size);
   449   // Destroy original arena
   448   // Destroy original arena
   450   reset();
   449   reset();
   451   return copy;            // Return Arena with contents
   450   return copy;            // Return Arena with contents
   452 }
   451 }
   453 
   452 
   495 void Arena::destruct_contents() {
   494 void Arena::destruct_contents() {
   496   if (UseMallocOnly && _first != NULL) {
   495   if (UseMallocOnly && _first != NULL) {
   497     char* end = _first->next() ? _first->top() : _hwm;
   496     char* end = _first->next() ? _first->top() : _hwm;
   498     free_malloced_objects(_first, _first->bottom(), end, _hwm);
   497     free_malloced_objects(_first, _first->bottom(), end, _hwm);
   499   }
   498   }
       
   499   // reset size before chop to avoid a rare racing condition
       
   500   // that can have total arena memory exceed total chunk memory
       
   501   set_size_in_bytes(0);
   500   _first->chop();
   502   _first->chop();
   501   reset();
   503   reset();
   502 }
   504 }
   503 
   505 
   504 // This is high traffic method, but many calls actually don't
   506 // This is high traffic method, but many calls actually don't