示例#1
0
 // Allocate _preorders[] array
 void reallocate_preorders() {
   if ( _max_preorder < C->unique() ) {
     _preorders = REALLOC_RESOURCE_ARRAY(uint, _preorders, _max_preorder, C->unique());
     _max_preorder = C->unique();
   }
   memset(_preorders, 0, sizeof(uint) * _max_preorder);
 }
示例#2
0
int OopRecorder::allocate_index(jobject h) {
  assert(!_complete, "cannot allocate more elements after size query");
  if (_handles_arena == NULL)  _nesting.check();

  if (_handles_size == 0) {
    _handles_size = 100;
    if (_handles_arena == NULL)
      _handles = NEW_RESOURCE_ARRAY(jobject, _handles_size);
    else
      _handles = (jobject*) _handles_arena->Amalloc(_handles_size * sizeof(jobject));
  } else if (_handles_length == _handles_size) {
    // Expand
    int     new_handles_size = _handles_size * 2;
    if (_handles_arena == NULL)
      _handles = REALLOC_RESOURCE_ARRAY(jobject, _handles, _handles_size, new_handles_size);
    else
      _handles = (jobject*)_handles_arena->Arealloc(_handles, _handles_size * sizeof(jobject), new_handles_size * sizeof(jobject));
    _handles_size = new_handles_size;
  }

  assert(_handles_size > _handles_length, "There must be room for after expanding");
  _handles[_handles_length++] = h;
  // indexing uses 1 as an origin--0 means null
  return _handles_length;
}
示例#3
0
 // Check to grow _preorders[] array for the case when build_loop_tree_impl()
 // adds new nodes.
 void check_grow_preorders( ) {
   if ( _max_preorder < C->unique() ) {
     uint newsize = _max_preorder<<1;  // double size of array
     _preorders = REALLOC_RESOURCE_ARRAY(uint, _preorders, _max_preorder, newsize);
     memset(&_preorders[_max_preorder],0,sizeof(uint)*(newsize-_max_preorder));
     _max_preorder = newsize;
   }
 }
void UnionFind::extend( uint from_idx, uint to_idx ) {
  _nesting.check();
  if( from_idx >= _max ) {
    uint size = 16; 
    while( size <= from_idx ) size <<=1;
    _indices = REALLOC_RESOURCE_ARRAY( uint, _indices, _max, size );
    _max = size;
  }
  while( _cnt <= from_idx ) _indices[_cnt++] = 0;
  _indices[from_idx] = to_idx;
}
void ExceptionHandlerTable::add_entry(HandlerTableEntry entry) {
  _nesting.check();
  if (_length >= _size) {
    // not enough space => grow the table (amortized growth, double its size)
    guarantee(_size > 0, "no space allocated => cannot grow the table since it is part of nmethod");
    int new_size = _size * 2;
    _table = REALLOC_RESOURCE_ARRAY(HandlerTableEntry, _table, _size, new_size);
    _size = new_size;
  }
  assert(_length < _size, "sanity check");
  _table[_length++] = entry;
}
void ImplicitExceptionTable::append( uint exec_off, uint cont_off ) {
  assert( (sizeof(implicit_null_entry) >= 4) || (exec_off < 65535), "" );
  assert( (sizeof(implicit_null_entry) >= 4) || (cont_off < 65535), "" );
  uint l = len();
  if (l == _size) {
    uint old_size_in_elements = _size*2;
    if (_size == 0) _size = 4;
    _size *= 2;
    uint new_size_in_elements = _size*2;
    _data = REALLOC_RESOURCE_ARRAY(uint, _data, old_size_in_elements, new_size_in_elements);
  }
  *(adr(l)  ) = exec_off;
  *(adr(l)+1) = cont_off;
  _len = l+1;
};
address JvmtiClassFileReconstituter::writeable_address(size_t size) {
  size_t used_size = _buffer_ptr - _buffer;
  if (size + used_size >= _buffer_size) {
    // compute the new buffer size: must be at least twice as big as before
    // plus whatever new is being used; then convert to nice clean block boundary
    size_t new_buffer_size = (size + _buffer_size*2 + 1) / initial_buffer_size
                                                         * initial_buffer_size;

    // VM goes belly-up if the memory isn't available, so cannot do OOM processing
    _buffer = REALLOC_RESOURCE_ARRAY(u1, _buffer, _buffer_size, new_buffer_size);
    _buffer_size = new_buffer_size;
    _buffer_ptr = _buffer + used_size;
  }
  u1* ret_ptr = _buffer_ptr;
  _buffer_ptr += size;
  return ret_ptr;
}
void CodeSection::expand_locs(int new_capacity) {
  if (_locs_start == NULL) {
    initialize_locs(new_capacity);
    return;
  } else {
    int old_count    = locs_count();
    int old_capacity = locs_capacity();
    if (new_capacity < old_capacity * 2)
      new_capacity = old_capacity * 2;
    relocInfo* locs_start;
    if (_locs_own) {
      locs_start = REALLOC_RESOURCE_ARRAY(relocInfo, _locs_start, old_capacity, new_capacity);
    } else {
      locs_start = NEW_RESOURCE_ARRAY(relocInfo, new_capacity);
      Copy::conjoint_jbytes(_locs_start, locs_start, old_capacity * sizeof(relocInfo));
      _locs_own = true;
    }
    _locs_start    = locs_start;
    _locs_end      = locs_start + old_count;
    _locs_limit    = locs_start + new_capacity;
  }
}