< prev index next >

src/share/vm/gc/shared/blockOffsetTable.cpp

Print this page




  52   if (!_vs.initialize(rs, 0)) {
  53     vm_exit_during_initialization("Could not reserve enough space for heap offset array");
  54   }
  55   _offset_array = (u_char*)_vs.low_boundary();
  56   resize(init_word_size);
  57   log_trace(gc, bot)("BlockOffsetSharedArray::BlockOffsetSharedArray: ");
  58   log_trace(gc, bot)("   rs.base(): " INTPTR_FORMAT " rs.size(): " INTPTR_FORMAT " rs end(): " INTPTR_FORMAT,
  59                      p2i(rs.base()), rs.size(), p2i(rs.base() + rs.size()));
  60   log_trace(gc, bot)("   _vs.low_boundary(): " INTPTR_FORMAT "  _vs.high_boundary(): " INTPTR_FORMAT,
  61                      p2i(_vs.low_boundary()), p2i(_vs.high_boundary()));
  62 }
  63 
  64 void BlockOffsetSharedArray::resize(size_t new_word_size) {
  65   assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved");
  66   size_t new_size = compute_size(new_word_size);
  67   size_t old_size = _vs.committed_size();
  68   size_t delta;
  69   char* high = _vs.high();
  70   _end = _reserved.start() + new_word_size;
  71   if (new_size > old_size) {
  72     delta = ReservedSpace::page_align_size_up(new_size - old_size);
  73     assert(delta > 0, "just checking");
  74     if (!_vs.expand_by(delta)) {
  75       // Do better than this for Merlin
  76       vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
  77     }
  78     assert(_vs.high() == high + delta, "invalid expansion");
  79   } else {
  80     delta = ReservedSpace::page_align_size_down(old_size - new_size);
  81     if (delta == 0) return;
  82     _vs.shrink_by(delta);
  83     assert(_vs.high() == high - delta, "invalid expansion");
  84   }
  85 }
  86 
  87 bool BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
  88   assert(p >= _reserved.start(), "just checking");
  89   size_t delta = pointer_delta(p, _reserved.start());
  90   return (delta & right_n_bits((int)BOTConstants::LogN_words)) == (size_t)NoBits;
  91 }
  92 
  93 
  94 //////////////////////////////////////////////////////////////////////
  95 // BlockOffsetArray
  96 //////////////////////////////////////////////////////////////////////
  97 
  98 BlockOffsetArray::BlockOffsetArray(BlockOffsetSharedArray* array,
  99                                    MemRegion mr, bool init_to_zero_) :
 100   BlockOffsetTable(mr.start(), mr.end()),




  52   if (!_vs.initialize(rs, 0)) {
  53     vm_exit_during_initialization("Could not reserve enough space for heap offset array");
  54   }
  55   _offset_array = (u_char*)_vs.low_boundary();
  56   resize(init_word_size);
  57   log_trace(gc, bot)("BlockOffsetSharedArray::BlockOffsetSharedArray: ");
  58   log_trace(gc, bot)("   rs.base(): " INTPTR_FORMAT " rs.size(): " INTPTR_FORMAT " rs end(): " INTPTR_FORMAT,
  59                      p2i(rs.base()), rs.size(), p2i(rs.base() + rs.size()));
  60   log_trace(gc, bot)("   _vs.low_boundary(): " INTPTR_FORMAT "  _vs.high_boundary(): " INTPTR_FORMAT,
  61                      p2i(_vs.low_boundary()), p2i(_vs.high_boundary()));
  62 }
  63 
  64 void BlockOffsetSharedArray::resize(size_t new_word_size) {
  65   assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved");
  66   size_t new_size = compute_size(new_word_size);
  67   size_t old_size = _vs.committed_size();
  68   size_t delta;
  69   char* high = _vs.high();
  70   _end = _reserved.start() + new_word_size;
  71   if (new_size > old_size) {
  72     delta = ReservedSpace::page_align_up(new_size - old_size);
  73     assert(delta > 0, "just checking");
  74     if (!_vs.expand_by(delta)) {
  75       // Do better than this for Merlin
  76       vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
  77     }
  78     assert(_vs.high() == high + delta, "invalid expansion");
  79   } else {
  80     delta = ReservedSpace::page_align_down(old_size - new_size);
  81     if (delta == 0) return;
  82     _vs.shrink_by(delta);
  83     assert(_vs.high() == high - delta, "invalid expansion");
  84   }
  85 }
  86 
  87 bool BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
  88   assert(p >= _reserved.start(), "just checking");
  89   size_t delta = pointer_delta(p, _reserved.start());
  90   return (delta & right_n_bits((int)BOTConstants::LogN_words)) == (size_t)NoBits;
  91 }
  92 
  93 
  94 //////////////////////////////////////////////////////////////////////
  95 // BlockOffsetArray
  96 //////////////////////////////////////////////////////////////////////
  97 
  98 BlockOffsetArray::BlockOffsetArray(BlockOffsetSharedArray* array,
  99                                    MemRegion mr, bool init_to_zero_) :
 100   BlockOffsetTable(mr.start(), mr.end()),


< prev index next >