annotate src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp @ 795:215f81b4d9b3

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