src/share/vm/memory/space.cpp

changeset 791
1ee8caae33af
parent 782
60fb9c4db4e6
parent 704
850fdf70db2b
child 873
122d10c82f3f
     1.1 --- a/src/share/vm/memory/space.cpp	Wed Aug 06 11:57:31 2008 -0400
     1.2 +++ b/src/share/vm/memory/space.cpp	Thu Aug 21 23:36:31 2008 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -239,50 +239,45 @@
    1.11    return new ContiguousSpaceDCTOC(this, cl, precision, boundary);
    1.12  }
    1.13  
    1.14 -void Space::set_bounds(MemRegion mr) {
    1.15 +void Space::initialize(MemRegion mr,
    1.16 +                       bool clear_space,
    1.17 +                       bool mangle_space) {
    1.18    HeapWord* bottom = mr.start();
    1.19    HeapWord* end    = mr.end();
    1.20    assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end),
    1.21           "invalid space boundaries");
    1.22    set_bottom(bottom);
    1.23    set_end(end);
    1.24 +  if (clear_space) clear(mangle_space);
    1.25  }
    1.26  
    1.27 -void Space::initialize(MemRegion mr, bool clear_space) {
    1.28 -  set_bounds(mr);
    1.29 -  if (clear_space) clear();
    1.30 +void Space::clear(bool mangle_space) {
    1.31 +  if (ZapUnusedHeapArea && mangle_space) {
    1.32 +    mangle_unused_area();
    1.33 +  }
    1.34  }
    1.35  
    1.36 -void Space::clear() {
    1.37 -  if (ZapUnusedHeapArea) mangle_unused_area();
    1.38 +ContiguousSpace::ContiguousSpace(): CompactibleSpace(), _top(NULL),
    1.39 +    _concurrent_iteration_safe_limit(NULL) {
    1.40 +  _mangler = new GenSpaceMangler(this);
    1.41  }
    1.42  
    1.43 -void CompactibleSpace::initialize(MemRegion mr, bool clear_space) {
    1.44 -  Space::initialize(mr, false); // We'll do the clearing if there's
    1.45 -                                // clearing to be done.
    1.46 -  _compaction_top = bottom();
    1.47 -  _next_compaction_space = NULL;
    1.48 -  if (clear_space) clear();
    1.49 +ContiguousSpace::~ContiguousSpace() {
    1.50 +  delete _mangler;
    1.51  }
    1.52  
    1.53 -void CompactibleSpace::clear() {
    1.54 -  _compaction_top = bottom();
    1.55 -  Space::clear();
    1.56 -}
    1.57 -
    1.58 -void ContiguousSpace::initialize(MemRegion mr, bool clear_space) {
    1.59 -  CompactibleSpace::initialize(mr, false); // We'll do the clearing if there's
    1.60 -                                           // clearing to be done.
    1.61 -  set_top(bottom());
    1.62 -  set_saved_mark();
    1.63 -  if (clear_space) clear();
    1.64 +void ContiguousSpace::initialize(MemRegion mr,
    1.65 +                                 bool clear_space,
    1.66 +                                 bool mangle_space)
    1.67 +{
    1.68 +  CompactibleSpace::initialize(mr, clear_space, mangle_space);
    1.69    set_concurrent_iteration_safe_limit(top());
    1.70  }
    1.71  
    1.72 -void ContiguousSpace::clear() {
    1.73 +void ContiguousSpace::clear(bool mangle_space) {
    1.74    set_top(bottom());
    1.75    set_saved_mark();
    1.76 -  CompactibleSpace::clear();
    1.77 +  CompactibleSpace::clear(mangle_space);
    1.78  }
    1.79  
    1.80  bool Space::is_in(const void* p) const {
    1.81 @@ -298,17 +293,8 @@
    1.82    return p >= _top;
    1.83  }
    1.84  
    1.85 -void OffsetTableContigSpace::initialize(MemRegion mr, bool clear_space) {
    1.86 -  // false ==> we'll do the clearing if there's clearing to be done.
    1.87 -  ContiguousSpace::initialize(mr, false);
    1.88 -  _offsets.zero_bottom_entry();
    1.89 -  _offsets.initialize_threshold();
    1.90 -  if (clear_space) clear();
    1.91 -}
    1.92 -
    1.93 -void OffsetTableContigSpace::clear() {
    1.94 -  ContiguousSpace::clear();
    1.95 -  _offsets.zero_bottom_entry();
    1.96 +void OffsetTableContigSpace::clear(bool mangle_space) {
    1.97 +  ContiguousSpace::clear(mangle_space);
    1.98    _offsets.initialize_threshold();
    1.99  }
   1.100  
   1.101 @@ -324,13 +310,53 @@
   1.102    Space::set_end(new_end);
   1.103  }
   1.104  
   1.105 -void ContiguousSpace::mangle_unused_area() {
   1.106 -  // to-space is used for storing marks during mark-sweep
   1.107 -  mangle_region(MemRegion(top(), end()));
   1.108 +#ifndef PRODUCT
   1.109 +
   1.110 +void ContiguousSpace::set_top_for_allocations(HeapWord* v) {
   1.111 +  mangler()->set_top_for_allocations(v);
   1.112 +}
   1.113 +void ContiguousSpace::set_top_for_allocations() {
   1.114 +  mangler()->set_top_for_allocations(top());
   1.115 +}
   1.116 +void ContiguousSpace::check_mangled_unused_area(HeapWord* limit) {
   1.117 +  mangler()->check_mangled_unused_area(limit);
   1.118  }
   1.119  
   1.120 +void ContiguousSpace::check_mangled_unused_area_complete() {
   1.121 +  mangler()->check_mangled_unused_area_complete();
   1.122 +}
   1.123 +
   1.124 +// Mangled only the unused space that has not previously
   1.125 +// been mangled and that has not been allocated since being
   1.126 +// mangled.
   1.127 +void ContiguousSpace::mangle_unused_area() {
   1.128 +  mangler()->mangle_unused_area();
   1.129 +}
   1.130 +void ContiguousSpace::mangle_unused_area_complete() {
   1.131 +  mangler()->mangle_unused_area_complete();
   1.132 +}
   1.133  void ContiguousSpace::mangle_region(MemRegion mr) {
   1.134 -  debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord));
   1.135 +  // Although this method uses SpaceMangler::mangle_region() which
   1.136 +  // is not specific to a space, the when the ContiguousSpace version
   1.137 +  // is called, it is always with regard to a space and this
   1.138 +  // bounds checking is appropriate.
   1.139 +  MemRegion space_mr(bottom(), end());
   1.140 +  assert(space_mr.contains(mr), "Mangling outside space");
   1.141 +  SpaceMangler::mangle_region(mr);
   1.142 +}
   1.143 +#endif  // NOT_PRODUCT
   1.144 +
   1.145 +void CompactibleSpace::initialize(MemRegion mr,
   1.146 +                                  bool clear_space,
   1.147 +                                  bool mangle_space) {
   1.148 +  Space::initialize(mr, clear_space, mangle_space);
   1.149 +  set_compaction_top(bottom());
   1.150 +  _next_compaction_space = NULL;
   1.151 +}
   1.152 +
   1.153 +void CompactibleSpace::clear(bool mangle_space) {
   1.154 +  Space::clear(mangle_space);
   1.155 +  _compaction_top = bottom();
   1.156  }
   1.157  
   1.158  HeapWord* CompactibleSpace::forward(oop q, size_t size,
   1.159 @@ -850,8 +876,8 @@
   1.160    }
   1.161  }
   1.162  
   1.163 -void EdenSpace::clear() {
   1.164 -  ContiguousSpace::clear();
   1.165 +void EdenSpace::clear(bool mangle_space) {
   1.166 +  ContiguousSpace::clear(mangle_space);
   1.167    set_soft_end(end());
   1.168  }
   1.169  
   1.170 @@ -908,7 +934,7 @@
   1.171    _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true)
   1.172  {
   1.173    _offsets.set_contig_space(this);
   1.174 -  initialize(mr, true);
   1.175 +  initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle);
   1.176  }
   1.177  
   1.178  

mercurial