comparison src/share/vm/memory/genMarkSweep.cpp @ 10405:f2110083203d

8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla 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>
author sla
date Mon, 10 Jun 2013 11:30:51 +0200
parents 2f50bc369470
children 330dfb0476f4
comparison
equal deleted inserted replaced
10404:d0add7016434 10405:f2110083203d
1 /* 1 /*
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
27 #include "classfile/symbolTable.hpp" 27 #include "classfile/symbolTable.hpp"
28 #include "classfile/systemDictionary.hpp" 28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/vmSymbols.hpp" 29 #include "classfile/vmSymbols.hpp"
30 #include "code/codeCache.hpp" 30 #include "code/codeCache.hpp"
31 #include "code/icBuffer.hpp" 31 #include "code/icBuffer.hpp"
32 #include "gc_implementation/shared/gcHeapSummary.hpp"
33 #include "gc_implementation/shared/gcTimer.hpp"
34 #include "gc_implementation/shared/gcTrace.hpp"
35 #include "gc_implementation/shared/gcTraceTime.hpp"
32 #include "gc_interface/collectedHeap.inline.hpp" 36 #include "gc_interface/collectedHeap.inline.hpp"
33 #include "memory/genCollectedHeap.hpp" 37 #include "memory/genCollectedHeap.hpp"
34 #include "memory/genMarkSweep.hpp" 38 #include "memory/genMarkSweep.hpp"
35 #include "memory/genOopClosures.inline.hpp" 39 #include "memory/genOopClosures.inline.hpp"
36 #include "memory/generation.inline.hpp" 40 #include "memory/generation.inline.hpp"
63 assert(ref_processor() == NULL, "no stomping"); 67 assert(ref_processor() == NULL, "no stomping");
64 assert(rp != NULL, "should be non-NULL"); 68 assert(rp != NULL, "should be non-NULL");
65 _ref_processor = rp; 69 _ref_processor = rp;
66 rp->setup_policy(clear_all_softrefs); 70 rp->setup_policy(clear_all_softrefs);
67 71
68 TraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty); 72 GCTraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL);
73
74 gch->trace_heap_before_gc(_gc_tracer);
69 75
70 // When collecting the permanent generation Method*s may be moving, 76 // When collecting the permanent generation Method*s may be moving,
71 // so we either have to flush all bcp data or convert it into bci. 77 // so we either have to flush all bcp data or convert it into bci.
72 CodeCache::gc_prologue(); 78 CodeCache::gc_prologue();
73 Threads::gc_prologue(); 79 Threads::gc_prologue();
153 // We need to use a monotonically non-deccreasing time in ms 159 // We need to use a monotonically non-deccreasing time in ms
154 // or we will see time-warp warnings and os::javaTimeMillis() 160 // or we will see time-warp warnings and os::javaTimeMillis()
155 // does not guarantee monotonicity. 161 // does not guarantee monotonicity.
156 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; 162 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
157 gch->update_time_of_last_gc(now); 163 gch->update_time_of_last_gc(now);
164
165 gch->trace_heap_after_gc(_gc_tracer);
158 } 166 }
159 167
160 void GenMarkSweep::allocate_stacks() { 168 void GenMarkSweep::allocate_stacks() {
161 GenCollectedHeap* gch = GenCollectedHeap::heap(); 169 GenCollectedHeap* gch = GenCollectedHeap::heap();
162 // Scratch request on behalf of oldest generation; will do no 170 // Scratch request on behalf of oldest generation; will do no
190 } 198 }
191 199
192 void GenMarkSweep::mark_sweep_phase1(int level, 200 void GenMarkSweep::mark_sweep_phase1(int level,
193 bool clear_all_softrefs) { 201 bool clear_all_softrefs) {
194 // Recursively traverse all live objects and mark them 202 // Recursively traverse all live objects and mark them
195 TraceTime tm("phase 1", PrintGC && Verbose, true, gclog_or_tty); 203 GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer);
196 trace(" 1"); 204 trace(" 1");
197 205
198 GenCollectedHeap* gch = GenCollectedHeap::heap(); 206 GenCollectedHeap* gch = GenCollectedHeap::heap();
199 207
200 // Because follow_root_closure is created statically, cannot 208 // Because follow_root_closure is created statically, cannot
217 &follow_klass_closure); 225 &follow_klass_closure);
218 226
219 // Process reference objects found during marking 227 // Process reference objects found during marking
220 { 228 {
221 ref_processor()->setup_policy(clear_all_softrefs); 229 ref_processor()->setup_policy(clear_all_softrefs);
222 ref_processor()->process_discovered_references( 230 const ReferenceProcessorStats& stats =
223 &is_alive, &keep_alive, &follow_stack_closure, NULL); 231 ref_processor()->process_discovered_references(
232 &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
233 gc_tracer()->report_gc_reference_stats(stats);
224 } 234 }
225 235
226 // This is the point where the entire marking should have completed. 236 // This is the point where the entire marking should have completed.
227 assert(_marking_stack.is_empty(), "Marking should have completed"); 237 assert(_marking_stack.is_empty(), "Marking should have completed");
228 238
238 // Delete entries for dead interned strings. 248 // Delete entries for dead interned strings.
239 StringTable::unlink(&is_alive); 249 StringTable::unlink(&is_alive);
240 250
241 // Clean up unreferenced symbols in symbol table. 251 // Clean up unreferenced symbols in symbol table.
242 SymbolTable::unlink(); 252 SymbolTable::unlink();
253
254 gc_tracer()->report_object_count_after_gc(&is_alive);
243 } 255 }
244 256
245 257
246 void GenMarkSweep::mark_sweep_phase2() { 258 void GenMarkSweep::mark_sweep_phase2() {
247 // Now all live objects are marked, compute the new object addresses. 259 // Now all live objects are marked, compute the new object addresses.
257 // phase2, phase3 and phase4, but the ValidateMarkSweep live oops 269 // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
258 // tracking expects us to do so. See comment under phase4. 270 // tracking expects us to do so. See comment under phase4.
259 271
260 GenCollectedHeap* gch = GenCollectedHeap::heap(); 272 GenCollectedHeap* gch = GenCollectedHeap::heap();
261 273
262 TraceTime tm("phase 2", PrintGC && Verbose, true, gclog_or_tty); 274 GCTraceTime tm("phase 2", PrintGC && Verbose, true, _gc_timer);
263 trace("2"); 275 trace("2");
264 276
265 gch->prepare_for_compaction(); 277 gch->prepare_for_compaction();
266 } 278 }
267 279
274 286
275 void GenMarkSweep::mark_sweep_phase3(int level) { 287 void GenMarkSweep::mark_sweep_phase3(int level) {
276 GenCollectedHeap* gch = GenCollectedHeap::heap(); 288 GenCollectedHeap* gch = GenCollectedHeap::heap();
277 289
278 // Adjust the pointers to reflect the new locations 290 // Adjust the pointers to reflect the new locations
279 TraceTime tm("phase 3", PrintGC && Verbose, true, gclog_or_tty); 291 GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer);
280 trace("3"); 292 trace("3");
281 293
282 // Need new claim bits for the pointer adjustment tracing. 294 // Need new claim bits for the pointer adjustment tracing.
283 ClassLoaderDataGraph::clear_claimed_marks(); 295 ClassLoaderDataGraph::clear_claimed_marks();
284 296
329 // in the same order in phase2, phase3 and phase4. We don't quite do that 341 // in the same order in phase2, phase3 and phase4. We don't quite do that
330 // here (perm_gen first rather than last), so we tell the validate code 342 // here (perm_gen first rather than last), so we tell the validate code
331 // to use a higher index (saved from phase2) when verifying perm_gen. 343 // to use a higher index (saved from phase2) when verifying perm_gen.
332 GenCollectedHeap* gch = GenCollectedHeap::heap(); 344 GenCollectedHeap* gch = GenCollectedHeap::heap();
333 345
334 TraceTime tm("phase 4", PrintGC && Verbose, true, gclog_or_tty); 346 GCTraceTime tm("phase 4", PrintGC && Verbose, true, _gc_timer);
335 trace("4"); 347 trace("4");
336 348
337 GenCompactClosure blk; 349 GenCompactClosure blk;
338 gch->generation_iterate(&blk, true); 350 gch->generation_iterate(&blk, true);
339 } 351 }