32 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp" |
32 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp" |
33 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp" |
33 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp" |
34 #include "gc_implementation/parallelScavenge/psOldGen.hpp" |
34 #include "gc_implementation/parallelScavenge/psOldGen.hpp" |
35 #include "gc_implementation/parallelScavenge/psScavenge.hpp" |
35 #include "gc_implementation/parallelScavenge/psScavenge.hpp" |
36 #include "gc_implementation/parallelScavenge/psYoungGen.hpp" |
36 #include "gc_implementation/parallelScavenge/psYoungGen.hpp" |
|
37 #include "gc_implementation/shared/gcHeapSummary.hpp" |
|
38 #include "gc_implementation/shared/gcTimer.hpp" |
|
39 #include "gc_implementation/shared/gcTrace.hpp" |
|
40 #include "gc_implementation/shared/gcTraceTime.hpp" |
37 #include "gc_implementation/shared/isGCActiveMark.hpp" |
41 #include "gc_implementation/shared/isGCActiveMark.hpp" |
38 #include "gc_implementation/shared/markSweep.hpp" |
42 #include "gc_implementation/shared/markSweep.hpp" |
39 #include "gc_implementation/shared/spaceDecorator.hpp" |
43 #include "gc_implementation/shared/spaceDecorator.hpp" |
40 #include "gc_interface/gcCause.hpp" |
44 #include "gc_interface/gcCause.hpp" |
41 #include "memory/gcLocker.inline.hpp" |
45 #include "memory/gcLocker.inline.hpp" |
106 if (GC_locker::check_active_before_gc()) { |
110 if (GC_locker::check_active_before_gc()) { |
107 return false; |
111 return false; |
108 } |
112 } |
109 |
113 |
110 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
114 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
|
115 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
111 GCCause::Cause gc_cause = heap->gc_cause(); |
116 GCCause::Cause gc_cause = heap->gc_cause(); |
112 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
117 |
|
118 _gc_timer->register_gc_start(os::elapsed_counter()); |
|
119 _gc_tracer->report_gc_start(gc_cause, _gc_timer->gc_start()); |
|
120 |
113 PSAdaptiveSizePolicy* size_policy = heap->size_policy(); |
121 PSAdaptiveSizePolicy* size_policy = heap->size_policy(); |
114 |
122 |
115 // The scope of casr should end after code that can change |
123 // The scope of casr should end after code that can change |
116 // CollectorPolicy::_should_clear_all_soft_refs. |
124 // CollectorPolicy::_should_clear_all_soft_refs. |
117 ClearedAllSoftRefs casr(clear_all_softrefs, heap->collector_policy()); |
125 ClearedAllSoftRefs casr(clear_all_softrefs, heap->collector_policy()); |
129 _total_invocations++; |
137 _total_invocations++; |
130 |
138 |
131 AdaptiveSizePolicyOutput(size_policy, heap->total_collections()); |
139 AdaptiveSizePolicyOutput(size_policy, heap->total_collections()); |
132 |
140 |
133 heap->print_heap_before_gc(); |
141 heap->print_heap_before_gc(); |
|
142 heap->trace_heap_before_gc(_gc_tracer); |
134 |
143 |
135 // Fill in TLABs |
144 // Fill in TLABs |
136 heap->accumulate_statistics_all_tlabs(); |
145 heap->accumulate_statistics_all_tlabs(); |
137 heap->ensure_parsability(true); // retire TLABs |
146 heap->ensure_parsability(true); // retire TLABs |
138 |
147 |
145 if (VerifyObjectStartArray && |
154 if (VerifyObjectStartArray && |
146 VerifyBeforeGC) { |
155 VerifyBeforeGC) { |
147 old_gen->verify_object_start_array(); |
156 old_gen->verify_object_start_array(); |
148 } |
157 } |
149 |
158 |
150 heap->pre_full_gc_dump(); |
159 heap->pre_full_gc_dump(_gc_timer); |
151 |
160 |
152 // Filled in below to track the state of the young gen after the collection. |
161 // Filled in below to track the state of the young gen after the collection. |
153 bool eden_empty; |
162 bool eden_empty; |
154 bool survivors_empty; |
163 bool survivors_empty; |
155 bool young_gen_empty; |
164 bool young_gen_empty; |
157 { |
166 { |
158 HandleMark hm; |
167 HandleMark hm; |
159 |
168 |
160 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); |
169 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); |
161 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); |
170 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); |
162 TraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty); |
171 GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL); |
163 TraceCollectorStats tcs(counters()); |
172 TraceCollectorStats tcs(counters()); |
164 TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); |
173 TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); |
165 |
174 |
166 if (TraceGen1Time) accumulated_time()->start(); |
175 if (TraceGen1Time) accumulated_time()->start(); |
167 |
176 |
372 } |
381 } |
373 |
382 |
374 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); |
383 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); |
375 |
384 |
376 heap->print_heap_after_gc(); |
385 heap->print_heap_after_gc(); |
377 |
386 heap->trace_heap_after_gc(_gc_tracer); |
378 heap->post_full_gc_dump(); |
387 |
|
388 heap->post_full_gc_dump(_gc_timer); |
379 |
389 |
380 #ifdef TRACESPINNING |
390 #ifdef TRACESPINNING |
381 ParallelTaskTerminator::print_termination_counts(); |
391 ParallelTaskTerminator::print_termination_counts(); |
382 #endif |
392 #endif |
|
393 |
|
394 _gc_timer->register_gc_end(os::elapsed_counter()); |
|
395 |
|
396 _gc_tracer->report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions()); |
383 |
397 |
384 return true; |
398 return true; |
385 } |
399 } |
386 |
400 |
387 bool PSMarkSweep::absorb_live_data_from_eden(PSAdaptiveSizePolicy* size_policy, |
401 bool PSMarkSweep::absorb_live_data_from_eden(PSAdaptiveSizePolicy* size_policy, |
496 _objarray_stack.clear(true); |
510 _objarray_stack.clear(true); |
497 } |
511 } |
498 |
512 |
499 void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { |
513 void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { |
500 // Recursively traverse all live objects and mark them |
514 // Recursively traverse all live objects and mark them |
501 TraceTime tm("phase 1", PrintGCDetails && Verbose, true, gclog_or_tty); |
515 GCTraceTime tm("phase 1", PrintGCDetails && Verbose, true, _gc_timer); |
502 trace(" 1"); |
516 trace(" 1"); |
503 |
517 |
504 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
518 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
505 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
519 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
506 |
520 |
529 follow_stack(); |
543 follow_stack(); |
530 |
544 |
531 // Process reference objects found during marking |
545 // Process reference objects found during marking |
532 { |
546 { |
533 ref_processor()->setup_policy(clear_all_softrefs); |
547 ref_processor()->setup_policy(clear_all_softrefs); |
534 ref_processor()->process_discovered_references( |
548 const ReferenceProcessorStats& stats = |
535 is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL); |
549 ref_processor()->process_discovered_references( |
|
550 is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer); |
|
551 gc_tracer()->report_gc_reference_stats(stats); |
536 } |
552 } |
537 |
553 |
538 // This is the point where the entire marking should have completed. |
554 // This is the point where the entire marking should have completed. |
539 assert(_marking_stack.is_empty(), "Marking should have completed"); |
555 assert(_marking_stack.is_empty(), "Marking should have completed"); |
540 |
556 |
550 // Delete entries for dead interned strings. |
566 // Delete entries for dead interned strings. |
551 StringTable::unlink(is_alive_closure()); |
567 StringTable::unlink(is_alive_closure()); |
552 |
568 |
553 // Clean up unreferenced symbols in symbol table. |
569 // Clean up unreferenced symbols in symbol table. |
554 SymbolTable::unlink(); |
570 SymbolTable::unlink(); |
|
571 _gc_tracer->report_object_count_after_gc(is_alive_closure()); |
555 } |
572 } |
556 |
573 |
557 |
574 |
558 void PSMarkSweep::mark_sweep_phase2() { |
575 void PSMarkSweep::mark_sweep_phase2() { |
559 TraceTime tm("phase 2", PrintGCDetails && Verbose, true, gclog_or_tty); |
576 GCTraceTime tm("phase 2", PrintGCDetails && Verbose, true, _gc_timer); |
560 trace("2"); |
577 trace("2"); |
561 |
578 |
562 // Now all live objects are marked, compute the new object addresses. |
579 // Now all live objects are marked, compute the new object addresses. |
563 |
580 |
564 // It is not required that we traverse spaces in the same order in |
581 // It is not required that we traverse spaces in the same order in |
584 }; |
601 }; |
585 static PSAlwaysTrueClosure always_true; |
602 static PSAlwaysTrueClosure always_true; |
586 |
603 |
587 void PSMarkSweep::mark_sweep_phase3() { |
604 void PSMarkSweep::mark_sweep_phase3() { |
588 // Adjust the pointers to reflect the new locations |
605 // Adjust the pointers to reflect the new locations |
589 TraceTime tm("phase 3", PrintGCDetails && Verbose, true, gclog_or_tty); |
606 GCTraceTime tm("phase 3", PrintGCDetails && Verbose, true, _gc_timer); |
590 trace("3"); |
607 trace("3"); |
591 |
608 |
592 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
609 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
593 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
610 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
594 |
611 |
627 old_gen->adjust_pointers(); |
644 old_gen->adjust_pointers(); |
628 } |
645 } |
629 |
646 |
630 void PSMarkSweep::mark_sweep_phase4() { |
647 void PSMarkSweep::mark_sweep_phase4() { |
631 EventMark m("4 compact heap"); |
648 EventMark m("4 compact heap"); |
632 TraceTime tm("phase 4", PrintGCDetails && Verbose, true, gclog_or_tty); |
649 GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer); |
633 trace("4"); |
650 trace("4"); |
634 |
651 |
635 // All pointers are now adjusted, move objects accordingly |
652 // All pointers are now adjusted, move objects accordingly |
636 |
653 |
637 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
654 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |