36 #include "gc_implementation/shared/gcHeapSummary.hpp"
37 #include "gc_implementation/shared/gcTimer.hpp"
38 #include "gc_implementation/shared/gcTrace.hpp"
39 #include "gc_implementation/shared/gcTraceTime.hpp"
40 #include "gc_implementation/shared/isGCActiveMark.hpp"
41 #include "gc_implementation/shared/markSweep.hpp"
42 #include "gc_implementation/shared/spaceDecorator.hpp"
43 #include "gc_interface/gcCause.hpp"
44 #include "memory/gcLocker.inline.hpp"
45 #include "memory/referencePolicy.hpp"
46 #include "memory/referenceProcessor.hpp"
47 #include "oops/oop.inline.hpp"
48 #include "runtime/biasedLocking.hpp"
49 #include "runtime/fprofiler.hpp"
50 #include "runtime/safepoint.hpp"
51 #include "runtime/vmThread.hpp"
52 #include "services/management.hpp"
53 #include "services/memoryService.hpp"
54 #include "utilities/events.hpp"
55 #include "utilities/stack.inline.hpp"
56
57 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
58
59 elapsedTimer PSMarkSweep::_accumulated_time;
60 jlong PSMarkSweep::_time_of_last_gc = 0;
61 CollectorCounters* PSMarkSweep::_counters = NULL;
62
63 void PSMarkSweep::initialize() {
64 MemRegion mr = Universe::heap()->reserved_region();
65 _ref_processor = new ReferenceProcessor(mr); // a vanilla ref proc
66 _counters = new CollectorCounters("PSMarkSweep", 1);
67 }
68
69 // This method contains all heap specific policy for invoking mark sweep.
70 // PSMarkSweep::invoke_no_policy() will only attempt to mark-sweep-compact
71 // the heap. It will do nothing further. If we need to bail out for policy
72 // reasons, scavenge before full gc, or any other specialized behavior, it
73 // needs to be added here.
74 //
75 // Note that this method should only be called from the vm_thread while
614
615 // Need to clear claim bits before the tracing starts.
616 ClassLoaderDataGraph::clear_claimed_marks();
617
618 // General strong roots.
619 Universe::oops_do(adjust_pointer_closure());
620 JNIHandles::oops_do(adjust_pointer_closure()); // Global (strong) JNI handles
621 CLDToOopClosure adjust_from_cld(adjust_pointer_closure());
622 Threads::oops_do(adjust_pointer_closure(), &adjust_from_cld, NULL);
623 ObjectSynchronizer::oops_do(adjust_pointer_closure());
624 FlatProfiler::oops_do(adjust_pointer_closure());
625 Management::oops_do(adjust_pointer_closure());
626 JvmtiExport::oops_do(adjust_pointer_closure());
627 SystemDictionary::oops_do(adjust_pointer_closure());
628 ClassLoaderDataGraph::cld_do(adjust_cld_closure());
629
630 // Now adjust pointers in remaining weak roots. (All of which should
631 // have been cleared if they pointed to non-surviving objects.)
632 // Global (weak) JNI handles
633 JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure());
634
635 CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
636 CodeCache::blobs_do(&adjust_from_blobs);
637 StringTable::oops_do(adjust_pointer_closure());
638 ref_processor()->weak_oops_do(adjust_pointer_closure());
639 PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure());
640
641 adjust_marks();
642
643 young_gen->adjust_pointers();
644 old_gen->adjust_pointers();
645 }
646
647 void PSMarkSweep::mark_sweep_phase4() {
648 EventMark m("4 compact heap");
649 GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id());
650 trace("4");
651
652 // All pointers are now adjusted, move objects accordingly
653
|
36 #include "gc_implementation/shared/gcHeapSummary.hpp"
37 #include "gc_implementation/shared/gcTimer.hpp"
38 #include "gc_implementation/shared/gcTrace.hpp"
39 #include "gc_implementation/shared/gcTraceTime.hpp"
40 #include "gc_implementation/shared/isGCActiveMark.hpp"
41 #include "gc_implementation/shared/markSweep.hpp"
42 #include "gc_implementation/shared/spaceDecorator.hpp"
43 #include "gc_interface/gcCause.hpp"
44 #include "memory/gcLocker.inline.hpp"
45 #include "memory/referencePolicy.hpp"
46 #include "memory/referenceProcessor.hpp"
47 #include "oops/oop.inline.hpp"
48 #include "runtime/biasedLocking.hpp"
49 #include "runtime/fprofiler.hpp"
50 #include "runtime/safepoint.hpp"
51 #include "runtime/vmThread.hpp"
52 #include "services/management.hpp"
53 #include "services/memoryService.hpp"
54 #include "utilities/events.hpp"
55 #include "utilities/stack.inline.hpp"
56 #if INCLUDE_JFR
57 #include "jfr/jfr.hpp"
58 #endif // INCLUDE_JFR
59
60 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
61
62 elapsedTimer PSMarkSweep::_accumulated_time;
63 jlong PSMarkSweep::_time_of_last_gc = 0;
64 CollectorCounters* PSMarkSweep::_counters = NULL;
65
66 void PSMarkSweep::initialize() {
67 MemRegion mr = Universe::heap()->reserved_region();
68 _ref_processor = new ReferenceProcessor(mr); // a vanilla ref proc
69 _counters = new CollectorCounters("PSMarkSweep", 1);
70 }
71
72 // This method contains all heap specific policy for invoking mark sweep.
73 // PSMarkSweep::invoke_no_policy() will only attempt to mark-sweep-compact
74 // the heap. It will do nothing further. If we need to bail out for policy
75 // reasons, scavenge before full gc, or any other specialized behavior, it
76 // needs to be added here.
77 //
78 // Note that this method should only be called from the vm_thread while
617
618 // Need to clear claim bits before the tracing starts.
619 ClassLoaderDataGraph::clear_claimed_marks();
620
621 // General strong roots.
622 Universe::oops_do(adjust_pointer_closure());
623 JNIHandles::oops_do(adjust_pointer_closure()); // Global (strong) JNI handles
624 CLDToOopClosure adjust_from_cld(adjust_pointer_closure());
625 Threads::oops_do(adjust_pointer_closure(), &adjust_from_cld, NULL);
626 ObjectSynchronizer::oops_do(adjust_pointer_closure());
627 FlatProfiler::oops_do(adjust_pointer_closure());
628 Management::oops_do(adjust_pointer_closure());
629 JvmtiExport::oops_do(adjust_pointer_closure());
630 SystemDictionary::oops_do(adjust_pointer_closure());
631 ClassLoaderDataGraph::cld_do(adjust_cld_closure());
632
633 // Now adjust pointers in remaining weak roots. (All of which should
634 // have been cleared if they pointed to non-surviving objects.)
635 // Global (weak) JNI handles
636 JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure());
637 JFR_ONLY(Jfr::weak_oops_do(&always_true, adjust_pointer_closure()));
638
639 CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
640 CodeCache::blobs_do(&adjust_from_blobs);
641 StringTable::oops_do(adjust_pointer_closure());
642 ref_processor()->weak_oops_do(adjust_pointer_closure());
643 PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure());
644
645 adjust_marks();
646
647 young_gen->adjust_pointers();
648 old_gen->adjust_pointers();
649 }
650
651 void PSMarkSweep::mark_sweep_phase4() {
652 EventMark m("4 compact heap");
653 GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id());
654 trace("4");
655
656 // All pointers are now adjusted, move objects accordingly
657
|