annotate src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp @ 340:9ee9cf798b59

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