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

Mon, 28 Jul 2008 15:30:23 -0700

author
jmasa
date
Mon, 28 Jul 2008 15:30:23 -0700
changeset 704
850fdf70db2b
parent 698
12eea04c8b06
child 772
9ee9cf798b59
permissions
-rw-r--r--

Merge

duke@435 1 /*
duke@435 2 * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 class PSMarkSweepDecorator;
duke@435 26
duke@435 27 class PSYoungGen : public CHeapObj {
duke@435 28 friend class VMStructs;
duke@435 29 friend class ParallelScavengeHeap;
duke@435 30 friend class AdjoiningGenerations;
duke@435 31
duke@435 32 protected:
duke@435 33 MemRegion _reserved;
duke@435 34 PSVirtualSpace* _virtual_space;
duke@435 35
duke@435 36 // Spaces
duke@435 37 MutableSpace* _eden_space;
duke@435 38 MutableSpace* _from_space;
duke@435 39 MutableSpace* _to_space;
duke@435 40
duke@435 41
duke@435 42 // MarkSweep Decorators
duke@435 43 PSMarkSweepDecorator* _eden_mark_sweep;
duke@435 44 PSMarkSweepDecorator* _from_mark_sweep;
duke@435 45 PSMarkSweepDecorator* _to_mark_sweep;
duke@435 46
duke@435 47 // Sizing information, in bytes, set in constructor
duke@435 48 const size_t _init_gen_size;
duke@435 49 const size_t _min_gen_size;
duke@435 50 const size_t _max_gen_size;
duke@435 51
duke@435 52 // Performance counters
duke@435 53 PSGenerationCounters* _gen_counters;
duke@435 54 SpaceCounters* _eden_counters;
duke@435 55 SpaceCounters* _from_counters;
duke@435 56 SpaceCounters* _to_counters;
duke@435 57
duke@435 58 // Initialize the space boundaries
duke@435 59 void compute_initial_space_boundaries();
duke@435 60
duke@435 61 // Space boundary helper
duke@435 62 void set_space_boundaries(size_t eden_size, size_t survivor_size);
duke@435 63
duke@435 64 virtual bool resize_generation(size_t eden_size, size_t survivor_size);
duke@435 65 virtual void resize_spaces(size_t eden_size, size_t survivor_size);
duke@435 66
duke@435 67 // Adjust the spaces to be consistent with the virtual space.
duke@435 68 void post_resize();
duke@435 69
duke@435 70 // Return number of bytes that the generation can change.
duke@435 71 // These should not be used by PSYoungGen
duke@435 72 virtual size_t available_for_expansion();
duke@435 73 virtual size_t available_for_contraction();
duke@435 74
duke@435 75 // Given a desired shrinkage in the size of the young generation,
duke@435 76 // return the actual size available for shrinkage.
duke@435 77 virtual size_t limit_gen_shrink(size_t desired_change);
duke@435 78 // returns the number of bytes available from the current size
duke@435 79 // down to the minimum generation size.
duke@435 80 size_t available_to_min_gen();
duke@435 81 // Return the number of bytes available for shrinkage considering
duke@435 82 // the location the live data in the generation.
duke@435 83 virtual size_t available_to_live();
duke@435 84
duke@435 85 public:
duke@435 86 // Initialize the generation.
duke@435 87 PSYoungGen(size_t initial_byte_size,
duke@435 88 size_t minimum_byte_size,
duke@435 89 size_t maximum_byte_size);
duke@435 90 void initialize_work();
duke@435 91 virtual void initialize(ReservedSpace rs, size_t alignment);
duke@435 92 virtual void initialize_virtual_space(ReservedSpace rs, size_t alignment);
duke@435 93
duke@435 94 MemRegion reserved() const { return _reserved; }
duke@435 95
duke@435 96 bool is_in(const void* p) const {
duke@435 97 return _virtual_space->contains((void *)p);
duke@435 98 }
duke@435 99
duke@435 100 bool is_in_reserved(const void* p) const {
duke@435 101 return reserved().contains((void *)p);
duke@435 102 }
duke@435 103
duke@435 104 MutableSpace* eden_space() const { return _eden_space; }
duke@435 105 MutableSpace* from_space() const { return _from_space; }
duke@435 106 MutableSpace* to_space() const { return _to_space; }
duke@435 107 PSVirtualSpace* virtual_space() const { return _virtual_space; }
duke@435 108
duke@435 109 // For Adaptive size policy
duke@435 110 size_t min_gen_size() { return _min_gen_size; }
duke@435 111
duke@435 112 // MarkSweep support
duke@435 113 PSMarkSweepDecorator* eden_mark_sweep() const { return _eden_mark_sweep; }
duke@435 114 PSMarkSweepDecorator* from_mark_sweep() const { return _from_mark_sweep; }
duke@435 115 PSMarkSweepDecorator* to_mark_sweep() const { return _to_mark_sweep; }
duke@435 116
duke@435 117 void precompact();
duke@435 118 void adjust_pointers();
duke@435 119 void compact();
duke@435 120
duke@435 121 // Parallel Old
duke@435 122 void move_and_update(ParCompactionManager* cm);
duke@435 123
duke@435 124 // Called during/after gc
duke@435 125 void swap_spaces();
duke@435 126
duke@435 127 // Resize generation using suggested free space size and survivor size
duke@435 128 // NOTE: "eden_size" and "survivor_size" are suggestions only. Current
duke@435 129 // heap layout (particularly, live objects in from space) might
duke@435 130 // not allow us to use these values.
duke@435 131 void resize(size_t eden_size, size_t survivor_size);
duke@435 132
duke@435 133 // Size info
duke@435 134 size_t capacity_in_bytes() const;
duke@435 135 size_t used_in_bytes() const;
duke@435 136 size_t free_in_bytes() const;
duke@435 137
duke@435 138 size_t capacity_in_words() const;
duke@435 139 size_t used_in_words() const;
duke@435 140 size_t free_in_words() const;
duke@435 141
duke@435 142 // The max this generation can grow to
duke@435 143 size_t max_size() const { return _reserved.byte_size(); }
duke@435 144
duke@435 145 // The max this generation can grow to if the boundary between
duke@435 146 // the generations are allowed to move.
duke@435 147 size_t gen_size_limit() const { return _max_gen_size; }
duke@435 148
duke@435 149 bool is_maximal_no_gc() const {
duke@435 150 return true; // never expands except at a GC
duke@435 151 }
duke@435 152
duke@435 153 // Allocation
duke@435 154 HeapWord* allocate(size_t word_size, bool is_tlab) {
duke@435 155 HeapWord* result = eden_space()->cas_allocate(word_size);
duke@435 156 return result;
duke@435 157 }
duke@435 158
duke@435 159 HeapWord** top_addr() const { return eden_space()->top_addr(); }
duke@435 160 HeapWord** end_addr() const { return eden_space()->end_addr(); }
duke@435 161
duke@435 162 // Iteration.
duke@435 163 void oop_iterate(OopClosure* cl);
duke@435 164 void object_iterate(ObjectClosure* cl);
duke@435 165
duke@435 166 virtual void reset_after_change();
duke@435 167 virtual void reset_survivors_after_shrink();
duke@435 168
duke@435 169 // Performance Counter support
duke@435 170 void update_counters();
duke@435 171
duke@435 172 // Debugging - do not use for time critical operations
duke@435 173 void print() const;
duke@435 174 void print_on(outputStream* st) const;
duke@435 175 void print_used_change(size_t prev_used) const;
duke@435 176 virtual const char* name() const { return "PSYoungGen"; }
duke@435 177
duke@435 178 void verify(bool allow_dirty);
duke@435 179
duke@435 180 // Space boundary invariant checker
duke@435 181 void space_invariants() PRODUCT_RETURN;
jmasa@698 182
jmasa@698 183 // Helper for mangling survivor spaces.
jmasa@698 184 void mangle_survivors(MutableSpace* s1,
jmasa@698 185 MemRegion s1MR,
jmasa@698 186 MutableSpace* s2,
jmasa@698 187 MemRegion s2MR) PRODUCT_RETURN;
jmasa@698 188
jmasa@698 189 void record_spaces_top() PRODUCT_RETURN;
duke@435 190 };

mercurial