22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderDataGraph.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "code/codeCache.hpp"
29 #include "compiler/oopMap.hpp"
30 #include "gc/g1/g1CollectedHeap.hpp"
31 #include "gc/g1/g1FullCollector.inline.hpp"
32 #include "gc/g1/g1FullGCAdjustTask.hpp"
33 #include "gc/g1/g1FullGCCompactTask.hpp"
34 #include "gc/g1/g1FullGCMarker.inline.hpp"
35 #include "gc/g1/g1FullGCMarkTask.hpp"
36 #include "gc/g1/g1FullGCPrepareTask.inline.hpp"
37 #include "gc/g1/g1FullGCResetMetadataTask.hpp"
38 #include "gc/g1/g1FullGCScope.hpp"
39 #include "gc/g1/g1OopClosures.hpp"
40 #include "gc/g1/g1Policy.hpp"
41 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
42 #include "gc/shared/gcTraceTime.inline.hpp"
43 #include "gc/shared/preservedMarks.inline.hpp"
44 #include "gc/shared/referenceProcessor.hpp"
45 #include "gc/shared/verifyOption.hpp"
46 #include "gc/shared/weakProcessor.inline.hpp"
47 #include "gc/shared/workerPolicy.hpp"
48 #include "logging/log.hpp"
49 #include "runtime/handles.inline.hpp"
50 #include "utilities/debug.hpp"
51
52 static void clear_and_activate_derived_pointers() {
53 #if COMPILER2_OR_JVMCI
54 DerivedPointerTable::clear();
55 #endif
56 }
57
58 static void deactivate_derived_pointers() {
59 #if COMPILER2_OR_JVMCI
60 DerivedPointerTable::set_active(false);
61 #endif
193 _heap->prepare_heap_for_full_collection();
194
195 PrepareRegionsClosure cl(this);
196 _heap->heap_region_iterate(&cl);
197
198 reference_processor()->start_discovery(scope()->should_clear_soft_refs());
199
200 // Clear and activate derived pointer collection.
201 clear_and_activate_derived_pointers();
202 }
203
204 void G1FullCollector::collect() {
205 G1CollectedHeap::start_codecache_marking_cycle_if_inactive(false /* concurrent_mark_start */);
206
207 phase1_mark_live_objects();
208 verify_after_marking();
209
210 // Don't add any more derived pointers during later phases
211 deactivate_derived_pointers();
212
213 phase2_prepare_compaction();
214
215 if (has_compaction_targets()) {
216 phase3_adjust_pointers();
217
218 phase4_do_compaction();
219 } else {
220 // All regions have a high live ratio thus will not be compacted.
221 // The live ratio is only considered if do_maximal_compaction is false.
222 log_info(gc, phases) ("No Regions selected for compaction. Skipping Phase 3: Adjust pointers and Phase 4: Compact heap");
223 }
224
225 phase5_reset_metadata();
226
227 G1CollectedHeap::finish_codecache_marking_cycle();
228 }
229
230 void G1FullCollector::complete_collection() {
231 // Restore all marks.
232 restore_marks();
233
234 // When the pointers have been adjusted and moved, we can
235 // update the derived pointer table.
236 update_derived_pointers();
237
238 // Need completely cleared claim bits for the next concurrent marking or full gc.
239 ClassLoaderDataGraph::clear_claimed_marks();
240
241 // Prepare the bitmap for the next (potentially concurrent) marking.
242 _heap->concurrent_mark()->clear_bitmap(_heap->workers());
243
244 _heap->prepare_for_mutator_after_full_collection();
|
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderDataGraph.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "code/codeCache.hpp"
29 #include "compiler/oopMap.hpp"
30 #include "gc/g1/g1CollectedHeap.hpp"
31 #include "gc/g1/g1FullCollector.inline.hpp"
32 #include "gc/g1/g1FullGCAdjustTask.hpp"
33 #include "gc/g1/g1FullGCCompactTask.hpp"
34 #include "gc/g1/g1FullGCMarker.inline.hpp"
35 #include "gc/g1/g1FullGCMarkTask.hpp"
36 #include "gc/g1/g1FullGCPrepareTask.inline.hpp"
37 #include "gc/g1/g1FullGCResetMetadataTask.hpp"
38 #include "gc/g1/g1FullGCScope.hpp"
39 #include "gc/g1/g1OopClosures.hpp"
40 #include "gc/g1/g1Policy.hpp"
41 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
42 #include "gc/shared/gcForwarding.hpp"
43 #include "gc/shared/gcTraceTime.inline.hpp"
44 #include "gc/shared/preservedMarks.inline.hpp"
45 #include "gc/shared/referenceProcessor.hpp"
46 #include "gc/shared/verifyOption.hpp"
47 #include "gc/shared/weakProcessor.inline.hpp"
48 #include "gc/shared/workerPolicy.hpp"
49 #include "logging/log.hpp"
50 #include "runtime/handles.inline.hpp"
51 #include "utilities/debug.hpp"
52
53 static void clear_and_activate_derived_pointers() {
54 #if COMPILER2_OR_JVMCI
55 DerivedPointerTable::clear();
56 #endif
57 }
58
59 static void deactivate_derived_pointers() {
60 #if COMPILER2_OR_JVMCI
61 DerivedPointerTable::set_active(false);
62 #endif
194 _heap->prepare_heap_for_full_collection();
195
196 PrepareRegionsClosure cl(this);
197 _heap->heap_region_iterate(&cl);
198
199 reference_processor()->start_discovery(scope()->should_clear_soft_refs());
200
201 // Clear and activate derived pointer collection.
202 clear_and_activate_derived_pointers();
203 }
204
205 void G1FullCollector::collect() {
206 G1CollectedHeap::start_codecache_marking_cycle_if_inactive(false /* concurrent_mark_start */);
207
208 phase1_mark_live_objects();
209 verify_after_marking();
210
211 // Don't add any more derived pointers during later phases
212 deactivate_derived_pointers();
213
214 GCForwarding::begin();
215 phase2_prepare_compaction();
216
217 if (has_compaction_targets()) {
218 phase3_adjust_pointers();
219
220 phase4_do_compaction();
221 } else {
222 // All regions have a high live ratio thus will not be compacted.
223 // The live ratio is only considered if do_maximal_compaction is false.
224 log_info(gc, phases) ("No Regions selected for compaction. Skipping Phase 3: Adjust pointers and Phase 4: Compact heap");
225 }
226
227 GCForwarding::end();
228
229 phase5_reset_metadata();
230
231 G1CollectedHeap::finish_codecache_marking_cycle();
232 }
233
234 void G1FullCollector::complete_collection() {
235 // Restore all marks.
236 restore_marks();
237
238 // When the pointers have been adjusted and moved, we can
239 // update the derived pointer table.
240 update_derived_pointers();
241
242 // Need completely cleared claim bits for the next concurrent marking or full gc.
243 ClassLoaderDataGraph::clear_claimed_marks();
244
245 // Prepare the bitmap for the next (potentially concurrent) marking.
246 _heap->concurrent_mark()->clear_bitmap(_heap->workers());
247
248 _heap->prepare_for_mutator_after_full_collection();
|