< prev index next >

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

Print this page
rev 12906 : [mq]: gc_interface


  62   // clear and dirty cards.
  63   guarantee(_rs->is_aligned(reserved_mr.start()), "generation must be card aligned");
  64   if (reserved_mr.end() != GenCollectedHeap::heap()->reserved_region().end()) {
  65     // Don't check at the very end of the heap as we'll assert that we're probing off
  66     // the end if we try.
  67     guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
  68   }
  69   _min_heap_delta_bytes = MinHeapDeltaBytes;
  70   _capacity_at_prologue = initial_byte_size;
  71   _used_at_prologue = 0;
  72 }
  73 
  74 bool CardGeneration::grow_by(size_t bytes) {
  75   assert_correct_size_change_locking();
  76   bool result = _virtual_space.expand_by(bytes);
  77   if (result) {
  78     size_t new_word_size =
  79        heap_word_size(_virtual_space.committed_size());
  80     MemRegion mr(space()->bottom(), new_word_size);
  81     // Expand card table
  82     GenCollectedHeap::heap()->barrier_set()->resize_covered_region(mr);
  83     // Expand shared block offset array
  84     _bts->resize(new_word_size);
  85 
  86     // Fix for bug #4668531
  87     if (ZapUnusedHeapArea) {
  88       MemRegion mangle_region(space()->end(),
  89       (HeapWord*)_virtual_space.high());
  90       SpaceMangler::mangle_region(mangle_region);
  91     }
  92 
  93     // Expand space -- also expands space's BOT
  94     // (which uses (part of) shared array above)
  95     space()->set_end((HeapWord*)_virtual_space.high());
  96 
  97     // update the space and generation capacity counters
  98     update_counters();
  99 
 100     size_t new_mem_size = _virtual_space.committed_size();
 101     size_t old_mem_size = new_mem_size - bytes;
 102     log_trace(gc, heap)("Expanding %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K",


 149   return success;
 150 }
 151 
 152 void CardGeneration::shrink(size_t bytes) {
 153   assert_correct_size_change_locking();
 154 
 155   size_t size = ReservedSpace::page_align_size_down(bytes);
 156   if (size == 0) {
 157     return;
 158   }
 159 
 160   // Shrink committed space
 161   _virtual_space.shrink_by(size);
 162   // Shrink space; this also shrinks the space's BOT
 163   space()->set_end((HeapWord*) _virtual_space.high());
 164   size_t new_word_size = heap_word_size(space()->capacity());
 165   // Shrink the shared block offset array
 166   _bts->resize(new_word_size);
 167   MemRegion mr(space()->bottom(), new_word_size);
 168   // Shrink the card table
 169   GenCollectedHeap::heap()->barrier_set()->resize_covered_region(mr);
 170 
 171   size_t new_mem_size = _virtual_space.committed_size();
 172   size_t old_mem_size = new_mem_size + size;
 173   log_trace(gc, heap)("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
 174                       name(), old_mem_size/K, new_mem_size/K);
 175 }
 176 
 177 // No young generation references, clear this generation's cards.
 178 void CardGeneration::clear_remembered_set() {
 179   _rs->clear(reserved());
 180 }
 181 
 182 // Objects in this generation may have moved, invalidate this
 183 // generation's cards.
 184 void CardGeneration::invalidate_remembered_set() {
 185   _rs->invalidate(used_region());
 186 }
 187 
 188 void CardGeneration::compute_new_size() {
 189   assert(_shrink_factor <= 100, "invalid shrink factor");




  62   // clear and dirty cards.
  63   guarantee(_rs->is_aligned(reserved_mr.start()), "generation must be card aligned");
  64   if (reserved_mr.end() != GenCollectedHeap::heap()->reserved_region().end()) {
  65     // Don't check at the very end of the heap as we'll assert that we're probing off
  66     // the end if we try.
  67     guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
  68   }
  69   _min_heap_delta_bytes = MinHeapDeltaBytes;
  70   _capacity_at_prologue = initial_byte_size;
  71   _used_at_prologue = 0;
  72 }
  73 
  74 bool CardGeneration::grow_by(size_t bytes) {
  75   assert_correct_size_change_locking();
  76   bool result = _virtual_space.expand_by(bytes);
  77   if (result) {
  78     size_t new_word_size =
  79        heap_word_size(_virtual_space.committed_size());
  80     MemRegion mr(space()->bottom(), new_word_size);
  81     // Expand card table
  82     GenCollectedHeap::heap()->rem_set()->resize_covered_region(mr);
  83     // Expand shared block offset array
  84     _bts->resize(new_word_size);
  85 
  86     // Fix for bug #4668531
  87     if (ZapUnusedHeapArea) {
  88       MemRegion mangle_region(space()->end(),
  89       (HeapWord*)_virtual_space.high());
  90       SpaceMangler::mangle_region(mangle_region);
  91     }
  92 
  93     // Expand space -- also expands space's BOT
  94     // (which uses (part of) shared array above)
  95     space()->set_end((HeapWord*)_virtual_space.high());
  96 
  97     // update the space and generation capacity counters
  98     update_counters();
  99 
 100     size_t new_mem_size = _virtual_space.committed_size();
 101     size_t old_mem_size = new_mem_size - bytes;
 102     log_trace(gc, heap)("Expanding %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K",


 149   return success;
 150 }
 151 
 152 void CardGeneration::shrink(size_t bytes) {
 153   assert_correct_size_change_locking();
 154 
 155   size_t size = ReservedSpace::page_align_size_down(bytes);
 156   if (size == 0) {
 157     return;
 158   }
 159 
 160   // Shrink committed space
 161   _virtual_space.shrink_by(size);
 162   // Shrink space; this also shrinks the space's BOT
 163   space()->set_end((HeapWord*) _virtual_space.high());
 164   size_t new_word_size = heap_word_size(space()->capacity());
 165   // Shrink the shared block offset array
 166   _bts->resize(new_word_size);
 167   MemRegion mr(space()->bottom(), new_word_size);
 168   // Shrink the card table
 169   GenCollectedHeap::heap()->rem_set()->resize_covered_region(mr);
 170 
 171   size_t new_mem_size = _virtual_space.committed_size();
 172   size_t old_mem_size = new_mem_size + size;
 173   log_trace(gc, heap)("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
 174                       name(), old_mem_size/K, new_mem_size/K);
 175 }
 176 
 177 // No young generation references, clear this generation's cards.
 178 void CardGeneration::clear_remembered_set() {
 179   _rs->clear(reserved());
 180 }
 181 
 182 // Objects in this generation may have moved, invalidate this
 183 // generation's cards.
 184 void CardGeneration::invalidate_remembered_set() {
 185   _rs->invalidate(used_region());
 186 }
 187 
 188 void CardGeneration::compute_new_size() {
 189   assert(_shrink_factor <= 100, "invalid shrink factor");


< prev index next >