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