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

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial