src/share/vm/memory/space.cpp

changeset 704
850fdf70db2b
parent 631
d1605aabd0a1
parent 698
12eea04c8b06
child 791
1ee8caae33af
     1.1 --- a/src/share/vm/memory/space.cpp	Fri Jul 25 11:29:03 2008 -0700
     1.2 +++ b/src/share/vm/memory/space.cpp	Mon Jul 28 15:30:23 2008 -0700
     1.3 @@ -232,30 +232,44 @@
     1.4    return new ContiguousSpaceDCTOC(this, cl, precision, boundary);
     1.5  }
     1.6  
     1.7 -void Space::initialize(MemRegion mr, bool clear_space) {
     1.8 +void Space::initialize(MemRegion mr,
     1.9 +                       bool clear_space,
    1.10 +                       bool mangle_space) {
    1.11    HeapWord* bottom = mr.start();
    1.12    HeapWord* end    = mr.end();
    1.13    assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end),
    1.14           "invalid space boundaries");
    1.15    set_bottom(bottom);
    1.16    set_end(end);
    1.17 -  if (clear_space) clear();
    1.18 +  if (clear_space) clear(mangle_space);
    1.19  }
    1.20  
    1.21 -void Space::clear() {
    1.22 -  if (ZapUnusedHeapArea) mangle_unused_area();
    1.23 +void Space::clear(bool mangle_space) {
    1.24 +  if (ZapUnusedHeapArea && mangle_space) {
    1.25 +    mangle_unused_area();
    1.26 +  }
    1.27  }
    1.28  
    1.29 -void ContiguousSpace::initialize(MemRegion mr, bool clear_space)
    1.30 +ContiguousSpace::ContiguousSpace(): CompactibleSpace(), _top(NULL) {
    1.31 +  _mangler = new GenSpaceMangler(this);
    1.32 +}
    1.33 +
    1.34 +ContiguousSpace::~ContiguousSpace() {
    1.35 +  delete _mangler;
    1.36 +}
    1.37 +
    1.38 +void ContiguousSpace::initialize(MemRegion mr,
    1.39 +                                 bool clear_space,
    1.40 +                                 bool mangle_space)
    1.41  {
    1.42 -  CompactibleSpace::initialize(mr, clear_space);
    1.43 +  CompactibleSpace::initialize(mr, clear_space, mangle_space);
    1.44    _concurrent_iteration_safe_limit = top();
    1.45  }
    1.46  
    1.47 -void ContiguousSpace::clear() {
    1.48 +void ContiguousSpace::clear(bool mangle_space) {
    1.49    set_top(bottom());
    1.50    set_saved_mark();
    1.51 -  Space::clear();
    1.52 +  Space::clear(mangle_space);
    1.53  }
    1.54  
    1.55  bool Space::is_in(const void* p) const {
    1.56 @@ -271,8 +285,8 @@
    1.57    return p >= _top;
    1.58  }
    1.59  
    1.60 -void OffsetTableContigSpace::clear() {
    1.61 -  ContiguousSpace::clear();
    1.62 +void OffsetTableContigSpace::clear(bool mangle_space) {
    1.63 +  ContiguousSpace::clear(mangle_space);
    1.64    _offsets.initialize_threshold();
    1.65  }
    1.66  
    1.67 @@ -288,17 +302,46 @@
    1.68    Space::set_end(new_end);
    1.69  }
    1.70  
    1.71 -void ContiguousSpace::mangle_unused_area() {
    1.72 -  // to-space is used for storing marks during mark-sweep
    1.73 -  mangle_region(MemRegion(top(), end()));
    1.74 +#ifndef PRODUCT
    1.75 +
    1.76 +void ContiguousSpace::set_top_for_allocations(HeapWord* v) {
    1.77 +  mangler()->set_top_for_allocations(v);
    1.78 +}
    1.79 +void ContiguousSpace::set_top_for_allocations() {
    1.80 +  mangler()->set_top_for_allocations(top());
    1.81 +}
    1.82 +void ContiguousSpace::check_mangled_unused_area(HeapWord* limit) {
    1.83 +  mangler()->check_mangled_unused_area(limit);
    1.84  }
    1.85  
    1.86 -void ContiguousSpace::mangle_region(MemRegion mr) {
    1.87 -  debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord));
    1.88 +void ContiguousSpace::check_mangled_unused_area_complete() {
    1.89 +  mangler()->check_mangled_unused_area_complete();
    1.90  }
    1.91  
    1.92 -void CompactibleSpace::initialize(MemRegion mr, bool clear_space) {
    1.93 -  Space::initialize(mr, clear_space);
    1.94 +// Mangled only the unused space that has not previously
    1.95 +// been mangled and that has not been allocated since being
    1.96 +// mangled.
    1.97 +void ContiguousSpace::mangle_unused_area() {
    1.98 +  mangler()->mangle_unused_area();
    1.99 +}
   1.100 +void ContiguousSpace::mangle_unused_area_complete() {
   1.101 +  mangler()->mangle_unused_area_complete();
   1.102 +}
   1.103 +void ContiguousSpace::mangle_region(MemRegion mr) {
   1.104 +  // Although this method uses SpaceMangler::mangle_region() which
   1.105 +  // is not specific to a space, the when the ContiguousSpace version
   1.106 +  // is called, it is always with regard to a space and this
   1.107 +  // bounds checking is appropriate.
   1.108 +  MemRegion space_mr(bottom(), end());
   1.109 +  assert(space_mr.contains(mr), "Mangling outside space");
   1.110 +  SpaceMangler::mangle_region(mr);
   1.111 +}
   1.112 +#endif  // NOT_PRODUCT
   1.113 +
   1.114 +void CompactibleSpace::initialize(MemRegion mr,
   1.115 +                                  bool clear_space,
   1.116 +                                  bool mangle_space) {
   1.117 +  Space::initialize(mr, clear_space, mangle_space);
   1.118    _compaction_top = bottom();
   1.119    _next_compaction_space = NULL;
   1.120  }
   1.121 @@ -820,8 +863,8 @@
   1.122    }
   1.123  }
   1.124  
   1.125 -void EdenSpace::clear() {
   1.126 -  ContiguousSpace::clear();
   1.127 +void EdenSpace::clear(bool mangle_space) {
   1.128 +  ContiguousSpace::clear(mangle_space);
   1.129    set_soft_end(end());
   1.130  }
   1.131  
   1.132 @@ -878,7 +921,7 @@
   1.133    _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true)
   1.134  {
   1.135    _offsets.set_contig_space(this);
   1.136 -  initialize(mr, true);
   1.137 +  initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle);
   1.138  }
   1.139  
   1.140  

mercurial