src/share/vm/memory/space.cpp

changeset 777
37f87013dfd8
parent 548
ba764ed4b6f2
child 779
6aae2f9d0294
     1.1 --- a/src/share/vm/memory/space.cpp	Wed Jun 04 13:51:09 2008 -0700
     1.2 +++ b/src/share/vm/memory/space.cpp	Thu Jun 05 15:57:56 2008 -0700
     1.3 @@ -105,7 +105,7 @@
     1.4           "Only ones we deal with for now.");
     1.5  
     1.6    assert(_precision != CardTableModRefBS::ObjHeadPreciseArray ||
     1.7 -         _last_bottom == NULL ||
     1.8 +         _cl->idempotent() || _last_bottom == NULL ||
     1.9           top <= _last_bottom,
    1.10           "Not decreasing");
    1.11    NOT_PRODUCT(_last_bottom = mr.start());
    1.12 @@ -144,7 +144,14 @@
    1.13      walk_mem_region(mr, bottom_obj, top);
    1.14    }
    1.15  
    1.16 -  _min_done = bottom;
    1.17 +  // An idempotent closure might be applied in any order, so we don't
    1.18 +  // record a _min_done for it.
    1.19 +  if (!_cl->idempotent()) {
    1.20 +    _min_done = bottom;
    1.21 +  } else {
    1.22 +    assert(_min_done == _last_explicit_min_done,
    1.23 +           "Don't update _min_done for idempotent cl");
    1.24 +  }
    1.25  }
    1.26  
    1.27  DirtyCardToOopClosure* Space::new_dcto_cl(OopClosure* cl,
    1.28 @@ -232,13 +239,17 @@
    1.29    return new ContiguousSpaceDCTOC(this, cl, precision, boundary);
    1.30  }
    1.31  
    1.32 -void Space::initialize(MemRegion mr, bool clear_space) {
    1.33 +void Space::set_bounds(MemRegion mr) {
    1.34    HeapWord* bottom = mr.start();
    1.35    HeapWord* end    = mr.end();
    1.36    assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end),
    1.37           "invalid space boundaries");
    1.38    set_bottom(bottom);
    1.39    set_end(end);
    1.40 +}
    1.41 +
    1.42 +void Space::initialize(MemRegion mr, bool clear_space) {
    1.43 +  set_bounds(mr);
    1.44    if (clear_space) clear();
    1.45  }
    1.46  
    1.47 @@ -246,20 +257,35 @@
    1.48    if (ZapUnusedHeapArea) mangle_unused_area();
    1.49  }
    1.50  
    1.51 -void ContiguousSpace::initialize(MemRegion mr, bool clear_space)
    1.52 -{
    1.53 -  CompactibleSpace::initialize(mr, clear_space);
    1.54 -  _concurrent_iteration_safe_limit = top();
    1.55 +void CompactibleSpace::initialize(MemRegion mr, bool clear_space) {
    1.56 +  Space::initialize(mr, false); // We'll do the clearing if there's
    1.57 +                                // clearing to be done.
    1.58 +  _compaction_top = bottom();
    1.59 +  _next_compaction_space = NULL;
    1.60 +  if (clear_space) clear();
    1.61 +}
    1.62 +
    1.63 +void CompactibleSpace::clear() {
    1.64 +  _compaction_top = bottom();
    1.65 +  Space::clear();
    1.66 +}
    1.67 +
    1.68 +void ContiguousSpace::initialize(MemRegion mr, bool clear_space) {
    1.69 +  CompactibleSpace::initialize(mr, false); // We'll do the clearing if there's
    1.70 +                                           // clearing to be done.
    1.71 +  set_top(bottom());
    1.72 +  set_saved_mark();
    1.73 +  if (clear_space) clear();
    1.74  }
    1.75  
    1.76  void ContiguousSpace::clear() {
    1.77    set_top(bottom());
    1.78    set_saved_mark();
    1.79 -  Space::clear();
    1.80 +  CompactibleSpace::clear();
    1.81  }
    1.82  
    1.83  bool Space::is_in(const void* p) const {
    1.84 -  HeapWord* b = block_start(p);
    1.85 +  HeapWord* b = block_start_const(p);
    1.86    return b != NULL && block_is_obj(b);
    1.87  }
    1.88  
    1.89 @@ -271,8 +297,17 @@
    1.90    return p >= _top;
    1.91  }
    1.92  
    1.93 +void OffsetTableContigSpace::initialize(MemRegion mr, bool clear_space) {
    1.94 +  // false ==> we'll do the clearing if there's clearing to be done.
    1.95 +  ContiguousSpace::initialize(mr, false);
    1.96 +  _offsets.zero_bottom_entry();
    1.97 +  _offsets.initialize_threshold();
    1.98 +  if (clear_space) clear();
    1.99 +}
   1.100 +
   1.101  void OffsetTableContigSpace::clear() {
   1.102    ContiguousSpace::clear();
   1.103 +  _offsets.zero_bottom_entry();
   1.104    _offsets.initialize_threshold();
   1.105  }
   1.106  
   1.107 @@ -297,12 +332,6 @@
   1.108    debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord));
   1.109  }
   1.110  
   1.111 -void CompactibleSpace::initialize(MemRegion mr, bool clear_space) {
   1.112 -  Space::initialize(mr, clear_space);
   1.113 -  _compaction_top = bottom();
   1.114 -  _next_compaction_space = NULL;
   1.115 -}
   1.116 -
   1.117  HeapWord* CompactibleSpace::forward(oop q, size_t size,
   1.118                                      CompactPoint* cp, HeapWord* compact_top) {
   1.119    // q is alive
   1.120 @@ -477,8 +506,8 @@
   1.121    }
   1.122    guarantee(p == top(), "end of last object must match end of space");
   1.123    if (top() != end()) {
   1.124 -    guarantee(top() == block_start(end()-1) &&
   1.125 -              top() == block_start(top()),
   1.126 +    guarantee(top() == block_start_const(end()-1) &&
   1.127 +              top() == block_start_const(top()),
   1.128                "top should be start of unallocated block, if it exists");
   1.129    }
   1.130  }
   1.131 @@ -710,7 +739,7 @@
   1.132  #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN
   1.133  
   1.134  // Very general, slow implementation.
   1.135 -HeapWord* ContiguousSpace::block_start(const void* p) const {
   1.136 +HeapWord* ContiguousSpace::block_start_const(const void* p) const {
   1.137    assert(MemRegion(bottom(), end()).contains(p), "p not in space");
   1.138    if (p >= top()) {
   1.139      return top();
   1.140 @@ -913,7 +942,8 @@
   1.141      // For a sampling of objects in the space, find it using the
   1.142      // block offset table.
   1.143      if (blocks == BLOCK_SAMPLE_INTERVAL) {
   1.144 -      guarantee(p == block_start(p + (size/2)), "check offset computation");
   1.145 +      guarantee(p == block_start_const(p + (size/2)),
   1.146 +                "check offset computation");
   1.147        blocks = 0;
   1.148      } else {
   1.149        blocks++;

mercurial