annotate src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp @ 2149:7e37af9d69ef

7011379: G1: overly long concurrent marking cycles Summary: This changeset introduces filtering of SATB buffers at the point when they are about to be enqueued. If this filtering clears enough entries on each buffer, the buffer can then be re-used and not enqueued. This cuts down the number of SATB buffers that need to be processed by the concurrent marking threads. Reviewed-by: johnc, ysr
author tonyp
date Wed, 19 Jan 2011 09:35:17 -0500
parents f95d63e2154a
children eda9eb483d29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "gc_implementation/parallelScavenge/psGenerationCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "gc_implementation/shared/mutableSpace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "gc_implementation/shared/spaceCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/safepoint.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class PSMarkSweepDecorator;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class PSOldGen : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 friend class PSPromotionManager; // Uses the cas_allocate methods
a61af66fc99e Initial load
duke
parents:
diff changeset
40 friend class ParallelScavengeHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 friend class AdjoiningGenerations;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 MemRegion _reserved; // Used for simple containment tests
a61af66fc99e Initial load
duke
parents:
diff changeset
45 PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem
a61af66fc99e Initial load
duke
parents:
diff changeset
46 ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block
a61af66fc99e Initial load
duke
parents:
diff changeset
47 MutableSpace* _object_space; // Where all the objects live
a61af66fc99e Initial load
duke
parents:
diff changeset
48 PSMarkSweepDecorator* _object_mark_sweep; // The mark sweep view of _object_space
a61af66fc99e Initial load
duke
parents:
diff changeset
49 const char* const _name; // Name of this generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Performance Counters
a61af66fc99e Initial load
duke
parents:
diff changeset
52 PSGenerationCounters* _gen_counters;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 SpaceCounters* _space_counters;
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Sizing information, in bytes, set in constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
56 const size_t _init_gen_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 const size_t _min_gen_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 const size_t _max_gen_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Used when initializing the _name field.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static inline const char* select_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 HeapWord* allocate_noexpand(size_t word_size, bool is_tlab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // We assume the heap lock is held here.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 assert(!is_tlab, "Does not support TLAB allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 HeapWord* res = object_space()->allocate(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 if (res != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _start_array.allocate_block(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Support for MT garbage collection. CAS allocation is lower overhead than grabbing
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // and releasing the heap lock, which is held during gc's anyway. This method is not
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // safe for use at the same time as allocate_noexpand()!
a61af66fc99e Initial load
duke
parents:
diff changeset
77 HeapWord* cas_allocate_noexpand(size_t word_size) {
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 337
diff changeset
78 assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79 HeapWord* res = object_space()->cas_allocate(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (res != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _start_array.allocate_block(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Support for MT garbage collection. See above comment.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 HeapWord* cas_allocate(size_t word_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 HeapWord* res = cas_allocate_noexpand(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return (res == NULL) ? expand_and_cas_allocate(word_size) : res;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 HeapWord* expand_and_allocate(size_t word_size, bool is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 HeapWord* expand_and_cas_allocate(size_t word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void expand(size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 bool expand_by(size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 bool expand_to_reserved();
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void shrink(size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void post_resize();
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Initialize the generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 PSOldGen(ReservedSpace rs, size_t alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 size_t initial_size, size_t min_size, size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
106 const char* perf_data_name, int level);
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 PSOldGen(size_t initial_size, size_t min_size, size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 const char* perf_data_name, int level);
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 void initialize(ReservedSpace rs, size_t alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 const char* perf_data_name, int level);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void initialize_virtual_space(ReservedSpace rs, size_t alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void initialize_work(const char* perf_data_name, int level);
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 MemRegion reserved() const { return _reserved; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 virtual size_t max_gen_size() { return _max_gen_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 size_t min_gen_size() { return _min_gen_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Returns limit on the maximum size of the generation. This
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // is the same as _max_gen_size for PSOldGen but need not be
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // for a derived class.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 virtual size_t gen_size_limit();
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 bool is_in(const void* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return _virtual_space->contains((void *)p);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 bool is_in_reserved(const void* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return reserved().contains(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 MutableSpace* object_space() const { return _object_space; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ObjectStartArray* start_array() { return &_start_array; }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 PSVirtualSpace* virtual_space() const { return _virtual_space;}
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Has the generation been successfully allocated?
a61af66fc99e Initial load
duke
parents:
diff changeset
139 bool is_allocated();
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // MarkSweep methods
a61af66fc99e Initial load
duke
parents:
diff changeset
142 virtual void precompact();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void compact();
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Parallel old
a61af66fc99e Initial load
duke
parents:
diff changeset
147 virtual void move_and_update(ParCompactionManager* cm);
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Size info
a61af66fc99e Initial load
duke
parents:
diff changeset
150 size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 size_t used_in_bytes() const { return object_space()->used_in_bytes(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 size_t free_in_bytes() const { return object_space()->free_in_bytes(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 size_t capacity_in_words() const { return object_space()->capacity_in_words(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 size_t used_in_words() const { return object_space()->used_in_words(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 size_t free_in_words() const { return object_space()->free_in_words(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Includes uncommitted memory
a61af66fc99e Initial load
duke
parents:
diff changeset
159 size_t contiguous_available() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 bool is_maximal_no_gc() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return virtual_space()->uncommitted_size() == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // Calculating new sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void resize(size_t desired_free_space);
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Allocation. We report all successful allocations to the size policy
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Note that the perm gen does not use this method, and should not!
a61af66fc99e Initial load
duke
parents:
diff changeset
170 HeapWord* allocate(size_t word_size, bool is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Iteration.
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void oop_iterate(OopClosure* cl) { object_space()->oop_iterate(cl); }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Debugging - do not use for time critical operations
a61af66fc99e Initial load
duke
parents:
diff changeset
177 virtual void print() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 virtual void print_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 void print_used_change(size_t prev_used) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 void verify(bool allow_dirty);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void verify_object_start_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // These should not used
a61af66fc99e Initial load
duke
parents:
diff changeset
185 virtual void reset_after_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // These should not used
a61af66fc99e Initial load
duke
parents:
diff changeset
188 virtual size_t available_for_expansion();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 virtual size_t available_for_contraction();
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 void space_invariants() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // Performace Counter support
a61af66fc99e Initial load
duke
parents:
diff changeset
194 void update_counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Printing support
a61af66fc99e Initial load
duke
parents:
diff changeset
197 virtual const char* name() const { return _name; }
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
198
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
199 // Debugging support
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
200 // Save the tops of all spaces for later use during mangling.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
201 void record_spaces_top() PRODUCT_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
202 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
203
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
204 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP