annotate src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp @ 6031:6e4b0b4481b9

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