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

Thu, 22 Sep 2011 10:57:37 -0700

author
johnc
date
Thu, 22 Sep 2011 10:57:37 -0700
changeset 3175
4dfb2df418f2
parent 2971
c9ca3f51cf41
child 3711
b632e80fc9dc
permissions
-rw-r--r--

6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp

duke@435 1 /*
jcoomes@2783 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSYOUNGGEN_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSYOUNGGEN_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
stefank@2314 29 #include "gc_implementation/parallelScavenge/psGenerationCounters.hpp"
stefank@2314 30 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
stefank@2314 31 #include "gc_implementation/shared/mutableSpace.hpp"
stefank@2314 32 #include "gc_implementation/shared/spaceCounters.hpp"
stefank@2314 33
duke@435 34 class PSMarkSweepDecorator;
duke@435 35
duke@435 36 class PSYoungGen : public CHeapObj {
duke@435 37 friend class VMStructs;
duke@435 38 friend class ParallelScavengeHeap;
duke@435 39 friend class AdjoiningGenerations;
duke@435 40
duke@435 41 protected:
duke@435 42 MemRegion _reserved;
duke@435 43 PSVirtualSpace* _virtual_space;
duke@435 44
duke@435 45 // Spaces
duke@435 46 MutableSpace* _eden_space;
duke@435 47 MutableSpace* _from_space;
duke@435 48 MutableSpace* _to_space;
duke@435 49
duke@435 50
duke@435 51 // MarkSweep Decorators
duke@435 52 PSMarkSweepDecorator* _eden_mark_sweep;
duke@435 53 PSMarkSweepDecorator* _from_mark_sweep;
duke@435 54 PSMarkSweepDecorator* _to_mark_sweep;
duke@435 55
duke@435 56 // Sizing information, in bytes, set in constructor
duke@435 57 const size_t _init_gen_size;
duke@435 58 const size_t _min_gen_size;
duke@435 59 const size_t _max_gen_size;
duke@435 60
duke@435 61 // Performance counters
duke@435 62 PSGenerationCounters* _gen_counters;
duke@435 63 SpaceCounters* _eden_counters;
duke@435 64 SpaceCounters* _from_counters;
duke@435 65 SpaceCounters* _to_counters;
duke@435 66
duke@435 67 // Initialize the space boundaries
duke@435 68 void compute_initial_space_boundaries();
duke@435 69
duke@435 70 // Space boundary helper
duke@435 71 void set_space_boundaries(size_t eden_size, size_t survivor_size);
duke@435 72
duke@435 73 virtual bool resize_generation(size_t eden_size, size_t survivor_size);
duke@435 74 virtual void resize_spaces(size_t eden_size, size_t survivor_size);
duke@435 75
duke@435 76 // Adjust the spaces to be consistent with the virtual space.
duke@435 77 void post_resize();
duke@435 78
duke@435 79 // Return number of bytes that the generation can change.
duke@435 80 // These should not be used by PSYoungGen
duke@435 81 virtual size_t available_for_expansion();
duke@435 82 virtual size_t available_for_contraction();
duke@435 83
duke@435 84 // Given a desired shrinkage in the size of the young generation,
duke@435 85 // return the actual size available for shrinkage.
duke@435 86 virtual size_t limit_gen_shrink(size_t desired_change);
duke@435 87 // returns the number of bytes available from the current size
duke@435 88 // down to the minimum generation size.
duke@435 89 size_t available_to_min_gen();
duke@435 90 // Return the number of bytes available for shrinkage considering
duke@435 91 // the location the live data in the generation.
duke@435 92 virtual size_t available_to_live();
duke@435 93
duke@435 94 public:
duke@435 95 // Initialize the generation.
duke@435 96 PSYoungGen(size_t initial_byte_size,
duke@435 97 size_t minimum_byte_size,
duke@435 98 size_t maximum_byte_size);
duke@435 99 void initialize_work();
duke@435 100 virtual void initialize(ReservedSpace rs, size_t alignment);
duke@435 101 virtual void initialize_virtual_space(ReservedSpace rs, size_t alignment);
duke@435 102
duke@435 103 MemRegion reserved() const { return _reserved; }
duke@435 104
duke@435 105 bool is_in(const void* p) const {
duke@435 106 return _virtual_space->contains((void *)p);
duke@435 107 }
duke@435 108
duke@435 109 bool is_in_reserved(const void* p) const {
duke@435 110 return reserved().contains((void *)p);
duke@435 111 }
duke@435 112
duke@435 113 MutableSpace* eden_space() const { return _eden_space; }
duke@435 114 MutableSpace* from_space() const { return _from_space; }
duke@435 115 MutableSpace* to_space() const { return _to_space; }
duke@435 116 PSVirtualSpace* virtual_space() const { return _virtual_space; }
duke@435 117
duke@435 118 // For Adaptive size policy
duke@435 119 size_t min_gen_size() { return _min_gen_size; }
duke@435 120
duke@435 121 // MarkSweep support
duke@435 122 PSMarkSweepDecorator* eden_mark_sweep() const { return _eden_mark_sweep; }
duke@435 123 PSMarkSweepDecorator* from_mark_sweep() const { return _from_mark_sweep; }
duke@435 124 PSMarkSweepDecorator* to_mark_sweep() const { return _to_mark_sweep; }
duke@435 125
duke@435 126 void precompact();
duke@435 127 void adjust_pointers();
duke@435 128 void compact();
duke@435 129
duke@435 130 // Called during/after gc
duke@435 131 void swap_spaces();
duke@435 132
duke@435 133 // Resize generation using suggested free space size and survivor size
duke@435 134 // NOTE: "eden_size" and "survivor_size" are suggestions only. Current
duke@435 135 // heap layout (particularly, live objects in from space) might
duke@435 136 // not allow us to use these values.
duke@435 137 void resize(size_t eden_size, size_t survivor_size);
duke@435 138
duke@435 139 // Size info
duke@435 140 size_t capacity_in_bytes() const;
duke@435 141 size_t used_in_bytes() const;
duke@435 142 size_t free_in_bytes() const;
duke@435 143
duke@435 144 size_t capacity_in_words() const;
duke@435 145 size_t used_in_words() const;
duke@435 146 size_t free_in_words() const;
duke@435 147
duke@435 148 // The max this generation can grow to
duke@435 149 size_t max_size() const { return _reserved.byte_size(); }
duke@435 150
duke@435 151 // The max this generation can grow to if the boundary between
duke@435 152 // the generations are allowed to move.
duke@435 153 size_t gen_size_limit() const { return _max_gen_size; }
duke@435 154
duke@435 155 bool is_maximal_no_gc() const {
duke@435 156 return true; // never expands except at a GC
duke@435 157 }
duke@435 158
duke@435 159 // Allocation
tonyp@2971 160 HeapWord* allocate(size_t word_size) {
duke@435 161 HeapWord* result = eden_space()->cas_allocate(word_size);
duke@435 162 return result;
duke@435 163 }
duke@435 164
duke@435 165 HeapWord** top_addr() const { return eden_space()->top_addr(); }
duke@435 166 HeapWord** end_addr() const { return eden_space()->end_addr(); }
duke@435 167
duke@435 168 // Iteration.
duke@435 169 void oop_iterate(OopClosure* cl);
duke@435 170 void object_iterate(ObjectClosure* cl);
duke@435 171
duke@435 172 virtual void reset_after_change();
duke@435 173 virtual void reset_survivors_after_shrink();
duke@435 174
duke@435 175 // Performance Counter support
duke@435 176 void update_counters();
duke@435 177
duke@435 178 // Debugging - do not use for time critical operations
duke@435 179 void print() const;
duke@435 180 void print_on(outputStream* st) const;
duke@435 181 void print_used_change(size_t prev_used) const;
duke@435 182 virtual const char* name() const { return "PSYoungGen"; }
duke@435 183
duke@435 184 void verify(bool allow_dirty);
duke@435 185
duke@435 186 // Space boundary invariant checker
duke@435 187 void space_invariants() PRODUCT_RETURN;
jmasa@698 188
jmasa@698 189 // Helper for mangling survivor spaces.
jmasa@698 190 void mangle_survivors(MutableSpace* s1,
jmasa@698 191 MemRegion s1MR,
jmasa@698 192 MutableSpace* s2,
jmasa@698 193 MemRegion s2MR) PRODUCT_RETURN;
jmasa@698 194
jmasa@698 195 void record_spaces_top() PRODUCT_RETURN;
duke@435 196 };
stefank@2314 197
stefank@2314 198 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSYOUNGGEN_HPP

mercurial