src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp

changeset 435
a61af66fc99e
child 698
12eea04c8b06
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,182 @@
     1.4 +/*
     1.5 + * Copyright 2001-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +class PSMarkSweepDecorator;
    1.29 +
    1.30 +class PSYoungGen : public CHeapObj {
    1.31 +  friend class VMStructs;
    1.32 +  friend class ParallelScavengeHeap;
    1.33 +  friend class AdjoiningGenerations;
    1.34 +
    1.35 + protected:
    1.36 +  MemRegion       _reserved;
    1.37 +  PSVirtualSpace* _virtual_space;
    1.38 +
    1.39 +  // Spaces
    1.40 +  MutableSpace* _eden_space;
    1.41 +  MutableSpace* _from_space;
    1.42 +  MutableSpace* _to_space;
    1.43 +
    1.44 +
    1.45 +  // MarkSweep Decorators
    1.46 +  PSMarkSweepDecorator* _eden_mark_sweep;
    1.47 +  PSMarkSweepDecorator* _from_mark_sweep;
    1.48 +  PSMarkSweepDecorator* _to_mark_sweep;
    1.49 +
    1.50 +  // Sizing information, in bytes, set in constructor
    1.51 +  const size_t _init_gen_size;
    1.52 +  const size_t _min_gen_size;
    1.53 +  const size_t _max_gen_size;
    1.54 +
    1.55 +  // Performance counters
    1.56 +  PSGenerationCounters*     _gen_counters;
    1.57 +  SpaceCounters*            _eden_counters;
    1.58 +  SpaceCounters*            _from_counters;
    1.59 +  SpaceCounters*            _to_counters;
    1.60 +
    1.61 +  // Initialize the space boundaries
    1.62 +  void compute_initial_space_boundaries();
    1.63 +
    1.64 +  // Space boundary helper
    1.65 +  void set_space_boundaries(size_t eden_size, size_t survivor_size);
    1.66 +
    1.67 +  virtual bool resize_generation(size_t eden_size, size_t survivor_size);
    1.68 +  virtual void resize_spaces(size_t eden_size, size_t survivor_size);
    1.69 +
    1.70 +  // Adjust the spaces to be consistent with the virtual space.
    1.71 +  void post_resize();
    1.72 +
    1.73 +  // Return number of bytes that the generation can change.
    1.74 +  // These should not be used by PSYoungGen
    1.75 +  virtual size_t available_for_expansion();
    1.76 +  virtual size_t available_for_contraction();
    1.77 +
    1.78 +  // Given a desired shrinkage in the size of the young generation,
    1.79 +  // return the actual size available for shrinkage.
    1.80 +  virtual size_t limit_gen_shrink(size_t desired_change);
    1.81 +  // returns the number of bytes available from the current size
    1.82 +  // down to the minimum generation size.
    1.83 +  size_t available_to_min_gen();
    1.84 +  // Return the number of bytes available for shrinkage considering
    1.85 +  // the location the live data in the generation.
    1.86 +  virtual size_t available_to_live();
    1.87 +
    1.88 + public:
    1.89 +  // Initialize the generation.
    1.90 +  PSYoungGen(size_t        initial_byte_size,
    1.91 +             size_t        minimum_byte_size,
    1.92 +             size_t        maximum_byte_size);
    1.93 +  void initialize_work();
    1.94 +  virtual void initialize(ReservedSpace rs, size_t alignment);
    1.95 +  virtual void initialize_virtual_space(ReservedSpace rs, size_t alignment);
    1.96 +
    1.97 +  MemRegion reserved() const            { return _reserved; }
    1.98 +
    1.99 +  bool is_in(const void* p) const   {
   1.100 +      return _virtual_space->contains((void *)p);
   1.101 +  }
   1.102 +
   1.103 +  bool is_in_reserved(const void* p) const   {
   1.104 +      return reserved().contains((void *)p);
   1.105 +  }
   1.106 +
   1.107 +  MutableSpace*   eden_space() const    { return _eden_space; }
   1.108 +  MutableSpace*   from_space() const    { return _from_space; }
   1.109 +  MutableSpace*   to_space() const      { return _to_space; }
   1.110 +  PSVirtualSpace* virtual_space() const { return _virtual_space; }
   1.111 +
   1.112 +  // For Adaptive size policy
   1.113 +  size_t min_gen_size() { return _min_gen_size; }
   1.114 +
   1.115 +  // MarkSweep support
   1.116 +  PSMarkSweepDecorator* eden_mark_sweep() const    { return _eden_mark_sweep; }
   1.117 +  PSMarkSweepDecorator* from_mark_sweep() const    { return _from_mark_sweep; }
   1.118 +  PSMarkSweepDecorator* to_mark_sweep() const      { return _to_mark_sweep;   }
   1.119 +
   1.120 +  void precompact();
   1.121 +  void adjust_pointers();
   1.122 +  void compact();
   1.123 +
   1.124 +  // Parallel Old
   1.125 +  void move_and_update(ParCompactionManager* cm);
   1.126 +
   1.127 +  // Called during/after gc
   1.128 +  void swap_spaces();
   1.129 +
   1.130 +  // Resize generation using suggested free space size and survivor size
   1.131 +  // NOTE:  "eden_size" and "survivor_size" are suggestions only. Current
   1.132 +  //        heap layout (particularly, live objects in from space) might
   1.133 +  //        not allow us to use these values.
   1.134 +  void resize(size_t eden_size, size_t survivor_size);
   1.135 +
   1.136 +  // Size info
   1.137 +  size_t capacity_in_bytes() const;
   1.138 +  size_t used_in_bytes() const;
   1.139 +  size_t free_in_bytes() const;
   1.140 +
   1.141 +  size_t capacity_in_words() const;
   1.142 +  size_t used_in_words() const;
   1.143 +  size_t free_in_words() const;
   1.144 +
   1.145 +  // The max this generation can grow to
   1.146 +  size_t max_size() const            { return _reserved.byte_size(); }
   1.147 +
   1.148 +  // The max this generation can grow to if the boundary between
   1.149 +  // the generations are allowed to move.
   1.150 +  size_t gen_size_limit() const { return _max_gen_size; }
   1.151 +
   1.152 +  bool is_maximal_no_gc() const {
   1.153 +    return true;  // never expands except at a GC
   1.154 +  }
   1.155 +
   1.156 +  // Allocation
   1.157 +  HeapWord* allocate(size_t word_size, bool is_tlab) {
   1.158 +    HeapWord* result = eden_space()->cas_allocate(word_size);
   1.159 +    return result;
   1.160 +  }
   1.161 +
   1.162 +  HeapWord** top_addr() const   { return eden_space()->top_addr(); }
   1.163 +  HeapWord** end_addr() const   { return eden_space()->end_addr(); }
   1.164 +
   1.165 +  // Iteration.
   1.166 +  void oop_iterate(OopClosure* cl);
   1.167 +  void object_iterate(ObjectClosure* cl);
   1.168 +
   1.169 +  virtual void reset_after_change();
   1.170 +  virtual void reset_survivors_after_shrink();
   1.171 +
   1.172 +  // Performance Counter support
   1.173 +  void update_counters();
   1.174 +
   1.175 +  // Debugging - do not use for time critical operations
   1.176 +  void print() const;
   1.177 +  void print_on(outputStream* st) const;
   1.178 +  void print_used_change(size_t prev_used) const;
   1.179 +  virtual const char* name() const { return "PSYoungGen"; }
   1.180 +
   1.181 +  void verify(bool allow_dirty);
   1.182 +
   1.183 +  // Space boundary invariant checker
   1.184 +  void space_invariants() PRODUCT_RETURN;
   1.185 +};

mercurial