22 */
23
24 #include "precompiled.hpp"
25
26 #include "code/codeCache.hpp"
27 #include "gc_implementation/shenandoah/shenandoahGCTraceTime.hpp"
28 #include "gc_implementation/shared/gcTimer.hpp"
29 #include "gc_implementation/shenandoah/preservedMarks.inline.hpp"
30 #include "gc_implementation/shenandoah/shenandoahForwarding.hpp"
31 #include "gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp"
32 #include "gc_implementation/shenandoah/shenandoahConcurrentMark.inline.hpp"
33 #include "gc_implementation/shenandoah/shenandoahCollectionSet.hpp"
34 #include "gc_implementation/shenandoah/shenandoahFreeSet.hpp"
35 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp"
36 #include "gc_implementation/shenandoah/shenandoahMarkCompact.hpp"
37 #include "gc_implementation/shenandoah/shenandoahHeapRegionSet.hpp"
38 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
39 #include "gc_implementation/shenandoah/shenandoahHeuristics.hpp"
40 #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp"
41 #include "gc_implementation/shenandoah/shenandoahRootProcessor.hpp"
42 #include "gc_implementation/shenandoah/shenandoahTaskqueue.inline.hpp"
43 #include "gc_implementation/shenandoah/shenandoahUtils.hpp"
44 #include "gc_implementation/shenandoah/shenandoahVerifier.hpp"
45 #include "gc_implementation/shenandoah/shenandoahVMOperations.hpp"
46 #include "gc_implementation/shenandoah/shenandoahWorkGroup.hpp"
47 #include "gc_implementation/shenandoah/shenandoahWorkerPolicy.hpp"
48 #include "memory/metaspace.hpp"
49 #include "oops/oop.inline.hpp"
50 #include "runtime/biasedLocking.hpp"
51 #include "runtime/thread.hpp"
52 #include "utilities/copy.hpp"
53 #include "utilities/growableArray.hpp"
54 #include "utilities/workgroup.hpp"
55
56 ShenandoahMarkCompact::ShenandoahMarkCompact() :
57 _gc_timer(NULL),
58 _preserved_marks(new PreservedMarksSet(true)) {}
59
60 void ShenandoahMarkCompact::initialize(GCTimer* gc_timer) {
61 _gc_timer = gc_timer;
69 }
70
71 if (VerifyBeforeGC) {
72 Universe::verify();
73 }
74
75 heap->set_full_gc_in_progress(true);
76
77 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at a safepoint");
78 assert(Thread::current()->is_VM_thread(), "Do full GC only while world is stopped");
79
80 {
81 ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_heapdumps);
82 heap->pre_full_gc_dump(_gc_timer);
83 }
84
85 {
86 ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_prepare);
87 // Full GC is supposed to recover from any GC state:
88
89 // 0. Remember if we have forwarded objects
90 bool has_forwarded_objects = heap->has_forwarded_objects();
91
92 // a. Cancel concurrent mark, if in progress
93 if (heap->is_concurrent_mark_in_progress()) {
94 heap->concurrent_mark()->cancel();
95 heap->stop_concurrent_marking();
96 }
97 assert(!heap->is_concurrent_mark_in_progress(), "sanity");
98
99 // b1. Cancel evacuation, if in progress
100 if (heap->is_evacuation_in_progress()) {
101 heap->set_evacuation_in_progress(false);
102 }
103 assert(!heap->is_evacuation_in_progress(), "sanity");
104
105 // b2. Cancel update-refs, if in progress
106 if (heap->is_update_refs_in_progress()) {
107 heap->set_update_refs_in_progress(false);
108 }
109 assert(!heap->is_update_refs_in_progress(), "sanity");
110
111 // c. Reset the bitmaps for new marking
112 heap->reset_mark_bitmap();
113 assert(heap->marking_context()->is_bitmap_clear(), "sanity");
114 assert(!heap->marking_context()->is_complete(), "sanity");
115
116 // d. Abandon reference discovery and clear all discovered references.
117 ReferenceProcessor *rp = heap->ref_processor();
118 rp->disable_discovery();
119 rp->abandon_partial_discovery();
120 rp->verify_no_references_recorded();
121
122 // e. Set back forwarded objects bit back, in case some steps above dropped it.
123 heap->set_has_forwarded_objects(has_forwarded_objects);
124
125 // f. Sync pinned region status from the CP marks
126 heap->sync_pinned_region_status();
127
128 // The rest of prologue:
129 BiasedLocking::preserve_marks();
|
22 */
23
24 #include "precompiled.hpp"
25
26 #include "code/codeCache.hpp"
27 #include "gc_implementation/shenandoah/shenandoahGCTraceTime.hpp"
28 #include "gc_implementation/shared/gcTimer.hpp"
29 #include "gc_implementation/shenandoah/preservedMarks.inline.hpp"
30 #include "gc_implementation/shenandoah/shenandoahForwarding.hpp"
31 #include "gc_implementation/shenandoah/shenandoahCollectorPolicy.hpp"
32 #include "gc_implementation/shenandoah/shenandoahConcurrentMark.inline.hpp"
33 #include "gc_implementation/shenandoah/shenandoahCollectionSet.hpp"
34 #include "gc_implementation/shenandoah/shenandoahFreeSet.hpp"
35 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp"
36 #include "gc_implementation/shenandoah/shenandoahMarkCompact.hpp"
37 #include "gc_implementation/shenandoah/shenandoahHeapRegionSet.hpp"
38 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
39 #include "gc_implementation/shenandoah/shenandoahHeuristics.hpp"
40 #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp"
41 #include "gc_implementation/shenandoah/shenandoahRootProcessor.hpp"
42 #include "gc_implementation/shenandoah/shenandoahTraversalGC.hpp"
43 #include "gc_implementation/shenandoah/shenandoahTaskqueue.inline.hpp"
44 #include "gc_implementation/shenandoah/shenandoahUtils.hpp"
45 #include "gc_implementation/shenandoah/shenandoahVerifier.hpp"
46 #include "gc_implementation/shenandoah/shenandoahVMOperations.hpp"
47 #include "gc_implementation/shenandoah/shenandoahWorkGroup.hpp"
48 #include "gc_implementation/shenandoah/shenandoahWorkerPolicy.hpp"
49 #include "memory/metaspace.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "runtime/biasedLocking.hpp"
52 #include "runtime/thread.hpp"
53 #include "utilities/copy.hpp"
54 #include "utilities/growableArray.hpp"
55 #include "utilities/workgroup.hpp"
56
57 ShenandoahMarkCompact::ShenandoahMarkCompact() :
58 _gc_timer(NULL),
59 _preserved_marks(new PreservedMarksSet(true)) {}
60
61 void ShenandoahMarkCompact::initialize(GCTimer* gc_timer) {
62 _gc_timer = gc_timer;
70 }
71
72 if (VerifyBeforeGC) {
73 Universe::verify();
74 }
75
76 heap->set_full_gc_in_progress(true);
77
78 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at a safepoint");
79 assert(Thread::current()->is_VM_thread(), "Do full GC only while world is stopped");
80
81 {
82 ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_heapdumps);
83 heap->pre_full_gc_dump(_gc_timer);
84 }
85
86 {
87 ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_prepare);
88 // Full GC is supposed to recover from any GC state:
89
90 // a0. Remember if we have forwarded objects
91 bool has_forwarded_objects = heap->has_forwarded_objects();
92
93 // a1. Cancel evacuation, if in progress
94 if (heap->is_evacuation_in_progress()) {
95 heap->set_evacuation_in_progress(false);
96 }
97 assert(!heap->is_evacuation_in_progress(), "sanity");
98
99 // a2. Cancel update-refs, if in progress
100 if (heap->is_update_refs_in_progress()) {
101 heap->set_update_refs_in_progress(false);
102 }
103 assert(!heap->is_update_refs_in_progress(), "sanity");
104
105 // a3. Cancel concurrent traversal GC, if in progress
106 if (heap->is_concurrent_traversal_in_progress()) {
107 heap->traversal_gc()->reset();
108 heap->set_concurrent_traversal_in_progress(false);
109 }
110
111 // b. Cancel concurrent mark, if in progress
112 if (heap->is_concurrent_mark_in_progress()) {
113 heap->concurrent_mark()->cancel();
114 heap->stop_concurrent_marking();
115 }
116 assert(!heap->is_concurrent_mark_in_progress(), "sanity");
117
118 // c. Reset the bitmaps for new marking
119 heap->reset_mark_bitmap();
120 assert(heap->marking_context()->is_bitmap_clear(), "sanity");
121 assert(!heap->marking_context()->is_complete(), "sanity");
122
123 // d. Abandon reference discovery and clear all discovered references.
124 ReferenceProcessor *rp = heap->ref_processor();
125 rp->disable_discovery();
126 rp->abandon_partial_discovery();
127 rp->verify_no_references_recorded();
128
129 // e. Set back forwarded objects bit back, in case some steps above dropped it.
130 heap->set_has_forwarded_objects(has_forwarded_objects);
131
132 // f. Sync pinned region status from the CP marks
133 heap->sync_pinned_region_status();
134
135 // The rest of prologue:
136 BiasedLocking::preserve_marks();
|