comparison src/share/vm/gc_implementation/g1/g1MarkSweep.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 71180a6e5080
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.
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/g1/g1Log.hpp" 32 #include "gc_implementation/g1/g1Log.hpp"
33 #include "gc_implementation/g1/g1MarkSweep.hpp" 33 #include "gc_implementation/g1/g1MarkSweep.hpp"
34 #include "gc_implementation/shared/gcHeapSummary.hpp"
35 #include "gc_implementation/shared/gcTimer.hpp"
36 #include "gc_implementation/shared/gcTrace.hpp"
37 #include "gc_implementation/shared/gcTraceTime.hpp"
34 #include "memory/gcLocker.hpp" 38 #include "memory/gcLocker.hpp"
35 #include "memory/genCollectedHeap.hpp" 39 #include "memory/genCollectedHeap.hpp"
36 #include "memory/modRefBarrierSet.hpp" 40 #include "memory/modRefBarrierSet.hpp"
37 #include "memory/referencePolicy.hpp" 41 #include "memory/referencePolicy.hpp"
38 #include "memory/space.hpp" 42 #include "memory/space.hpp"
117 } 121 }
118 122
119 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, 123 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
120 bool clear_all_softrefs) { 124 bool clear_all_softrefs) {
121 // Recursively traverse all live objects and mark them 125 // Recursively traverse all live objects and mark them
122 TraceTime tm("phase 1", G1Log::fine() && Verbose, true, gclog_or_tty); 126 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer());
123 GenMarkSweep::trace(" 1"); 127 GenMarkSweep::trace(" 1");
124 128
125 SharedHeap* sh = SharedHeap::heap(); 129 SharedHeap* sh = SharedHeap::heap();
126 130
127 // Need cleared claim bits for the strong roots processing 131 // Need cleared claim bits for the strong roots processing
137 // Process reference objects found during marking 141 // Process reference objects found during marking
138 ReferenceProcessor* rp = GenMarkSweep::ref_processor(); 142 ReferenceProcessor* rp = GenMarkSweep::ref_processor();
139 assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity"); 143 assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity");
140 144
141 rp->setup_policy(clear_all_softrefs); 145 rp->setup_policy(clear_all_softrefs);
142 rp->process_discovered_references(&GenMarkSweep::is_alive, 146 const ReferenceProcessorStats& stats =
143 &GenMarkSweep::keep_alive, 147 rp->process_discovered_references(&GenMarkSweep::is_alive,
144 &GenMarkSweep::follow_stack_closure, 148 &GenMarkSweep::keep_alive,
145 NULL); 149 &GenMarkSweep::follow_stack_closure,
150 NULL,
151 gc_timer());
152 gc_tracer()->report_gc_reference_stats(stats);
146 153
147 154
148 // This is the point where the entire marking should have completed. 155 // This is the point where the entire marking should have completed.
149 assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed"); 156 assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed");
150 157
183 Universe::heap()->verify(VerifySilently, VerifyOption_G1UseMarkWord); 190 Universe::heap()->verify(VerifySilently, VerifyOption_G1UseMarkWord);
184 if (!VerifySilently) { 191 if (!VerifySilently) {
185 gclog_or_tty->print_cr("]"); 192 gclog_or_tty->print_cr("]");
186 } 193 }
187 } 194 }
195
196 gc_tracer()->report_object_count_after_gc(&GenMarkSweep::is_alive);
188 } 197 }
189 198
190 class G1PrepareCompactClosure: public HeapRegionClosure { 199 class G1PrepareCompactClosure: public HeapRegionClosure {
191 G1CollectedHeap* _g1h; 200 G1CollectedHeap* _g1h;
192 ModRefBarrierSet* _mrbs; 201 ModRefBarrierSet* _mrbs;
255 // phase2, phase3 and phase4, but the ValidateMarkSweep live oops 264 // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
256 // tracking expects us to do so. See comment under phase4. 265 // tracking expects us to do so. See comment under phase4.
257 266
258 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 267 G1CollectedHeap* g1h = G1CollectedHeap::heap();
259 268
260 TraceTime tm("phase 2", G1Log::fine() && Verbose, true, gclog_or_tty); 269 GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer());
261 GenMarkSweep::trace("2"); 270 GenMarkSweep::trace("2");
262 271
263 // find the first region 272 // find the first region
264 HeapRegion* r = g1h->region_at(0); 273 HeapRegion* r = g1h->region_at(0);
265 CompactibleSpace* sp = r; 274 CompactibleSpace* sp = r;
292 301
293 void G1MarkSweep::mark_sweep_phase3() { 302 void G1MarkSweep::mark_sweep_phase3() {
294 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 303 G1CollectedHeap* g1h = G1CollectedHeap::heap();
295 304
296 // Adjust the pointers to reflect the new locations 305 // Adjust the pointers to reflect the new locations
297 TraceTime tm("phase 3", G1Log::fine() && Verbose, true, gclog_or_tty); 306 GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer());
298 GenMarkSweep::trace("3"); 307 GenMarkSweep::trace("3");
299 308
300 SharedHeap* sh = SharedHeap::heap(); 309 SharedHeap* sh = SharedHeap::heap();
301 310
302 // Need cleared claim bits for the strong roots processing 311 // Need cleared claim bits for the strong roots processing
351 // in the same order in phase2, phase3 and phase4. We don't quite do that 360 // in the same order in phase2, phase3 and phase4. We don't quite do that
352 // here (code and comment not fixed for perm removal), so we tell the validate code 361 // here (code and comment not fixed for perm removal), so we tell the validate code
353 // to use a higher index (saved from phase2) when verifying perm_gen. 362 // to use a higher index (saved from phase2) when verifying perm_gen.
354 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 363 G1CollectedHeap* g1h = G1CollectedHeap::heap();
355 364
356 TraceTime tm("phase 4", G1Log::fine() && Verbose, true, gclog_or_tty); 365 GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer());
357 GenMarkSweep::trace("4"); 366 GenMarkSweep::trace("4");
358 367
359 G1SpaceCompactClosure blk; 368 G1SpaceCompactClosure blk;
360 g1h->heap_region_iterate(&blk); 369 g1h->heap_region_iterate(&blk);
361 370