Print this page
rev 4141 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp
+++ new/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp
1 1 /*
2 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARALLELSCAVENGEHEAP_HPP
26 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARALLELSCAVENGEHEAP_HPP
27 27
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
28 28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
29 29 #include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp"
30 30 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
31 31 #include "gc_implementation/parallelScavenge/psPermGen.hpp"
32 32 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
33 33 #include "gc_implementation/shared/gcPolicyCounters.hpp"
34 34 #include "gc_interface/collectedHeap.inline.hpp"
35 35 #include "utilities/ostream.hpp"
36 36
37 37 class AdjoiningGenerations;
38 +class CollectorPolicy;
39 +class GCHeapSummary;
38 40 class GCTaskManager;
39 -class PSAdaptiveSizePolicy;
40 41 class GenerationSizer;
41 42 class CollectorPolicy;
43 +class PSAdaptiveSizePolicy;
44 +class PSHeapSummary;
45 +class VirtualSpaceSummary;
42 46
43 47 class ParallelScavengeHeap : public CollectedHeap {
44 48 friend class VMStructs;
45 49 private:
46 50 static PSYoungGen* _young_gen;
47 51 static PSOldGen* _old_gen;
48 52 static PSPermGen* _perm_gen;
49 53
50 54 // Sizing policy for entire heap
51 55 static PSAdaptiveSizePolicy* _size_policy;
52 56 static PSGCAdaptivePolicyCounters* _gc_policy_counters;
53 57
54 58 static ParallelScavengeHeap* _psh;
55 59
56 60 size_t _perm_gen_alignment;
57 61 size_t _young_gen_alignment;
58 62 size_t _old_gen_alignment;
59 63
60 64 GenerationSizer* _collector_policy;
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
61 65
62 66 inline size_t set_alignment(size_t& var, size_t val);
63 67
64 68 // Collection of generations that are adjacent in the
65 69 // space reserved for the heap.
66 70 AdjoiningGenerations* _gens;
67 71 unsigned int _death_march_count;
68 72
69 73 static GCTaskManager* _gc_task_manager; // The task manager.
70 74
75 + void trace_heap(GCWhen::Type when, GCTracer* tracer);
76 +
71 77 protected:
72 78 static inline size_t total_invocations();
73 79 HeapWord* allocate_new_tlab(size_t size);
74 80
75 81 inline bool should_alloc_in_eden(size_t size) const;
76 82 inline void death_march_check(HeapWord* const result, size_t size);
77 83 HeapWord* mem_allocate_old_gen(size_t size);
78 84
79 85 public:
80 86 ParallelScavengeHeap() : CollectedHeap() {
81 87 _death_march_count = 0;
82 88 set_alignment(_perm_gen_alignment, intra_heap_alignment());
83 89 set_alignment(_young_gen_alignment, intra_heap_alignment());
84 90 set_alignment(_old_gen_alignment, intra_heap_alignment());
85 91 }
86 92
87 93 // For use by VM operations
88 94 enum CollectionType {
89 95 Scavenge,
90 96 MarkSweep
91 97 };
92 98
93 99 ParallelScavengeHeap::Name kind() const {
94 100 return CollectedHeap::ParallelScavengeHeap;
95 101 }
96 102
97 103 CollectorPolicy* collector_policy() const { return (CollectorPolicy*) _collector_policy; }
98 104 // GenerationSizer* collector_policy() const { return _collector_policy; }
99 105
100 106 static PSYoungGen* young_gen() { return _young_gen; }
101 107 static PSOldGen* old_gen() { return _old_gen; }
102 108 static PSPermGen* perm_gen() { return _perm_gen; }
103 109
104 110 virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
105 111
106 112 static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
107 113
108 114 static ParallelScavengeHeap* heap();
109 115
110 116 static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }
111 117
112 118 AdjoiningGenerations* gens() { return _gens; }
113 119
114 120 // Returns JNI_OK on success
115 121 virtual jint initialize();
116 122
117 123 void post_initialize();
118 124 void update_counters();
119 125 // The alignment used for the various generations.
120 126 size_t perm_gen_alignment() const { return _perm_gen_alignment; }
121 127 size_t young_gen_alignment() const { return _young_gen_alignment; }
122 128 size_t old_gen_alignment() const { return _old_gen_alignment; }
123 129
124 130 // The alignment used for eden and survivors within the young gen
125 131 // and for boundary between young gen and old gen.
126 132 size_t intra_heap_alignment() const { return 64 * K; }
127 133
128 134 size_t capacity() const;
129 135 size_t used() const;
130 136
131 137 // Return "true" if all generations (but perm) have reached the
132 138 // maximal committed limit that they can reach, without a garbage
133 139 // collection.
134 140 virtual bool is_maximal_no_gc() const;
135 141
136 142 // Return true if the reference points to an object that
137 143 // can be moved in a partial collection. For currently implemented
138 144 // generational collectors that means during a collection of
139 145 // the young gen.
140 146 virtual bool is_scavengable(const void* addr);
141 147
142 148 // Does this heap support heap inspection? (+PrintClassHistogram)
143 149 bool supports_heap_inspection() const { return true; }
144 150
145 151 size_t permanent_capacity() const;
146 152 size_t permanent_used() const;
147 153
148 154 size_t max_capacity() const;
149 155
150 156 // Whether p is in the allocated part of the heap
151 157 bool is_in(const void* p) const;
152 158
153 159 bool is_in_reserved(const void* p) const;
154 160 bool is_in_permanent(const void *p) const { // reserved part
155 161 return perm_gen()->reserved().contains(p);
156 162 }
157 163
158 164 #ifdef ASSERT
159 165 virtual bool is_in_partial_collection(const void *p);
160 166 #endif
161 167
162 168 bool is_permanent(const void *p) const { // committed part
163 169 return perm_gen()->is_in(p);
164 170 }
165 171
166 172 inline bool is_in_young(oop p); // reserved part
167 173 inline bool is_in_old_or_perm(oop p); // reserved part
168 174
169 175 // Memory allocation. "gc_time_limit_was_exceeded" will
170 176 // be set to true if the adaptive size policy determine that
171 177 // an excessive amount of time is being spent doing collections
172 178 // and caused a NULL to be returned. If a NULL is not returned,
173 179 // "gc_time_limit_was_exceeded" has an undefined meaning.
174 180 HeapWord* mem_allocate(size_t size,
175 181 bool* gc_overhead_limit_was_exceeded);
176 182
177 183 // Allocation attempt(s) during a safepoint. It should never be called
178 184 // to allocate a new TLAB as this allocation might be satisfied out
179 185 // of the old generation.
180 186 HeapWord* failed_mem_allocate(size_t size);
181 187
182 188 HeapWord* permanent_mem_allocate(size_t size);
183 189 HeapWord* failed_permanent_mem_allocate(size_t size);
184 190
185 191 // Support for System.gc()
186 192 void collect(GCCause::Cause cause);
187 193
188 194 // This interface assumes that it's being called by the
189 195 // vm thread. It collects the heap assuming that the
190 196 // heap lock is already held and that we are executing in
191 197 // the context of the vm thread.
192 198 void collect_as_vm_thread(GCCause::Cause cause);
193 199
194 200 // These also should be called by the vm thread at a safepoint (e.g., from a
195 201 // VM operation).
196 202 //
197 203 // The first collects the young generation only, unless the scavenge fails; it
198 204 // will then attempt a full gc. The second collects the entire heap; if
199 205 // maximum_compaction is true, it will compact everything and clear all soft
200 206 // references.
201 207 inline void invoke_scavenge();
202 208 inline void invoke_full_gc(bool maximum_compaction);
203 209
204 210 bool supports_inline_contig_alloc() const { return !UseNUMA; }
205 211
206 212 HeapWord** top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord**)-1; }
207 213 HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; }
208 214
209 215 void ensure_parsability(bool retire_tlabs);
210 216 void accumulate_statistics_all_tlabs();
211 217 void resize_all_tlabs();
212 218
213 219 size_t unsafe_max_alloc();
214 220
215 221 bool supports_tlab_allocation() const { return true; }
216 222
217 223 size_t tlab_capacity(Thread* thr) const;
218 224 size_t unsafe_max_tlab_alloc(Thread* thr) const;
219 225
220 226 // Can a compiler initialize a new object without store barriers?
221 227 // This permission only extends from the creation of a new object
222 228 // via a TLAB up to the first subsequent safepoint.
223 229 virtual bool can_elide_tlab_store_barriers() const {
224 230 return true;
225 231 }
226 232
227 233 virtual bool card_mark_must_follow_store() const {
228 234 return false;
229 235 }
230 236
231 237 // Return true if we don't we need a store barrier for
232 238 // initializing stores to an object at this address.
233 239 virtual bool can_elide_initializing_store_barrier(oop new_obj);
234 240
235 241 // Can a compiler elide a store barrier when it writes
236 242 // a permanent oop into the heap? Applies when the compiler
237 243 // is storing x to the heap, where x->is_perm() is true.
238 244 virtual bool can_elide_permanent_oop_store_barriers() const {
239 245 return true;
240 246 }
241 247
242 248 void oop_iterate(OopClosure* cl);
243 249 void object_iterate(ObjectClosure* cl);
244 250 void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
↓ open down ↓ |
164 lines elided |
↑ open up ↑ |
245 251 void permanent_oop_iterate(OopClosure* cl);
246 252 void permanent_object_iterate(ObjectClosure* cl);
247 253
248 254 HeapWord* block_start(const void* addr) const;
249 255 size_t block_size(const HeapWord* addr) const;
250 256 bool block_is_obj(const HeapWord* addr) const;
251 257
252 258 jlong millis_since_last_gc();
253 259
254 260 void prepare_for_verify();
261 + PSHeapSummary create_ps_heap_summary();
262 + VirtualSpaceSummary create_perm_gen_space_summary();
255 263 virtual void print_on(outputStream* st) const;
256 264 virtual void print_gc_threads_on(outputStream* st) const;
257 265 virtual void gc_threads_do(ThreadClosure* tc) const;
258 266 virtual void print_tracing_info() const;
259 267
260 268 void verify(bool silent, VerifyOption option /* ignored */);
261 269
262 270 void print_heap_change(size_t prev_used);
263 271
264 272 // Resize the young generation. The reserved space for the
265 273 // generation may be expanded in preparation for the resize.
266 274 void resize_young_gen(size_t eden_size, size_t survivor_size);
267 275
268 276 // Resize the old generation. The reserved space for the
269 277 // generation may be expanded in preparation for the resize.
270 278 void resize_old_gen(size_t desired_free_space);
271 279
272 280 // Save the tops of the spaces in all generations
273 281 void record_gen_tops_before_GC() PRODUCT_RETURN;
274 282
275 283 // Mangle the unused parts of all spaces in the heap
276 284 void gen_mangle_unused_area() PRODUCT_RETURN;
277 285
278 286 // Call these in sequential code around the processing of strong roots.
279 287 class ParStrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
280 288 public:
281 289 ParStrongRootsScope();
282 290 ~ParStrongRootsScope();
283 291 };
284 292 };
285 293
286 294 inline size_t ParallelScavengeHeap::set_alignment(size_t& var, size_t val)
287 295 {
288 296 assert(is_power_of_2((intptr_t)val), "must be a power of 2");
289 297 var = round_to(val, intra_heap_alignment());
290 298 return var;
291 299 }
292 300
293 301 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARALLELSCAVENGEHEAP_HPP
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX