< prev index next >

src/hotspot/share/gc/g1/g1FullCollector.cpp

Print this page

 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/systemDictionary.hpp"
 27 #include "code/codeCache.hpp"
 28 #include "compiler/oopMap.hpp"
 29 #include "gc/g1/g1CollectedHeap.hpp"
 30 #include "gc/g1/g1FullCollector.inline.hpp"
 31 #include "gc/g1/g1FullGCAdjustTask.hpp"
 32 #include "gc/g1/g1FullGCCompactTask.hpp"
 33 #include "gc/g1/g1FullGCMarker.inline.hpp"
 34 #include "gc/g1/g1FullGCMarkTask.hpp"
 35 #include "gc/g1/g1FullGCPrepareTask.hpp"
 36 #include "gc/g1/g1FullGCScope.hpp"
 37 #include "gc/g1/g1OopClosures.hpp"
 38 #include "gc/g1/g1Policy.hpp"
 39 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
 40 #include "gc/shared/gcTraceTime.inline.hpp"
 41 #include "gc/shared/preservedMarks.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/biasedLocking.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 

184   _heap->heap_region_iterate(&cl);
185 
186   reference_processor()->enable_discovery();
187   reference_processor()->setup_policy(scope()->should_clear_soft_refs());
188 
189   // We should save the marks of the currently locked biased monitors.
190   // The marking doesn't preserve the marks of biased objects.
191   BiasedLocking::preserve_marks();
192 
193   // Clear and activate derived pointer collection.
194   clear_and_activate_derived_pointers();
195 }
196 
197 void G1FullCollector::collect() {
198   phase1_mark_live_objects();
199   verify_after_marking();
200 
201   // Don't add any more derived pointers during later phases
202   deactivate_derived_pointers();
203 


204   phase2_prepare_compaction();
205 
206   phase3_adjust_pointers();
207 
208   phase4_do_compaction();


209 }
210 
211 void G1FullCollector::complete_collection() {
212   // Restore all marks.
213   restore_marks();
214 
215   // When the pointers have been adjusted and moved, we can
216   // update the derived pointer table.
217   update_derived_pointers();
218 
219   BiasedLocking::restore_marks();
220 
221   _heap->concurrent_mark()->swap_mark_bitmaps();
222   // Prepare the bitmap for the next (potentially concurrent) marking.
223   _heap->concurrent_mark()->clear_next_bitmap(_heap->workers());
224 
225   _heap->prepare_heap_for_mutators();
226 
227   _heap->policy()->record_full_collection_end();
228   _heap->gc_epilogue(true);

295     GCTraceTime(Debug, gc, phases) debug("Phase 1: Weak Processing", scope()->timer());
296     WeakProcessor::weak_oops_do(_heap->workers(), &_is_alive, &do_nothing_cl, 1);
297   }
298 
299   // Class unloading and cleanup.
300   if (ClassUnloading) {
301     GCTraceTime(Debug, gc, phases) debug("Phase 1: Class Unloading and Cleanup", scope()->timer());
302     // Unload classes and purge the SystemDictionary.
303     bool purged_class = SystemDictionary::do_unloading(scope()->timer());
304     _heap->complete_cleaning(&_is_alive, purged_class);
305   }
306 
307   {
308     GCTraceTime(Debug, gc, phases) debug("Report Object Count", scope()->timer());
309     scope()->tracer()->report_object_count_after_gc(&_is_alive, _heap->workers());
310   }
311 }
312 
313 void G1FullCollector::phase2_prepare_compaction() {
314   GCTraceTime(Info, gc, phases) info("Phase 2: Prepare for compaction", scope()->timer());

315   G1FullGCPrepareTask task(this);
316   run_task(&task);
317 
318   // To avoid OOM when there is memory left.
319   if (!task.has_freed_regions()) {
320     task.prepare_serial_compaction();
321   }
322 }
323 
324 void G1FullCollector::phase3_adjust_pointers() {
325   // Adjust the pointers to reflect the new locations
326   GCTraceTime(Info, gc, phases) info("Phase 3: Adjust pointers", scope()->timer());
327 
328   G1FullGCAdjustTask task(this);
329   run_task(&task);
330 }
331 
332 void G1FullCollector::phase4_do_compaction() {
333   // Compact the heap using the compaction queues created in phase 2.
334   GCTraceTime(Info, gc, phases) info("Phase 4: Compact heap", scope()->timer());

 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/systemDictionary.hpp"
 27 #include "code/codeCache.hpp"
 28 #include "compiler/oopMap.hpp"
 29 #include "gc/g1/g1CollectedHeap.hpp"
 30 #include "gc/g1/g1FullCollector.inline.hpp"
 31 #include "gc/g1/g1FullGCAdjustTask.hpp"
 32 #include "gc/g1/g1FullGCCompactTask.hpp"
 33 #include "gc/g1/g1FullGCMarker.inline.hpp"
 34 #include "gc/g1/g1FullGCMarkTask.hpp"
 35 #include "gc/g1/g1FullGCPrepareTask.hpp"
 36 #include "gc/g1/g1FullGCScope.hpp"
 37 #include "gc/g1/g1OopClosures.hpp"
 38 #include "gc/g1/g1Policy.hpp"
 39 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
 40 #include "gc/shared/gcTraceTime.inline.hpp"
 41 #include "gc/shared/preservedMarks.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/biasedLocking.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
 62 }
 63 

185   _heap->heap_region_iterate(&cl);
186 
187   reference_processor()->enable_discovery();
188   reference_processor()->setup_policy(scope()->should_clear_soft_refs());
189 
190   // We should save the marks of the currently locked biased monitors.
191   // The marking doesn't preserve the marks of biased objects.
192   BiasedLocking::preserve_marks();
193 
194   // Clear and activate derived pointer collection.
195   clear_and_activate_derived_pointers();
196 }
197 
198 void G1FullCollector::collect() {
199   phase1_mark_live_objects();
200   verify_after_marking();
201 
202   // Don't add any more derived pointers during later phases
203   deactivate_derived_pointers();
204 
205   SlidingForwarding::begin();
206 
207   phase2_prepare_compaction();
208 
209   phase3_adjust_pointers();
210 
211   phase4_do_compaction();
212 
213   SlidingForwarding::end();
214 }
215 
216 void G1FullCollector::complete_collection() {
217   // Restore all marks.
218   restore_marks();
219 
220   // When the pointers have been adjusted and moved, we can
221   // update the derived pointer table.
222   update_derived_pointers();
223 
224   BiasedLocking::restore_marks();
225 
226   _heap->concurrent_mark()->swap_mark_bitmaps();
227   // Prepare the bitmap for the next (potentially concurrent) marking.
228   _heap->concurrent_mark()->clear_next_bitmap(_heap->workers());
229 
230   _heap->prepare_heap_for_mutators();
231 
232   _heap->policy()->record_full_collection_end();
233   _heap->gc_epilogue(true);

300     GCTraceTime(Debug, gc, phases) debug("Phase 1: Weak Processing", scope()->timer());
301     WeakProcessor::weak_oops_do(_heap->workers(), &_is_alive, &do_nothing_cl, 1);
302   }
303 
304   // Class unloading and cleanup.
305   if (ClassUnloading) {
306     GCTraceTime(Debug, gc, phases) debug("Phase 1: Class Unloading and Cleanup", scope()->timer());
307     // Unload classes and purge the SystemDictionary.
308     bool purged_class = SystemDictionary::do_unloading(scope()->timer());
309     _heap->complete_cleaning(&_is_alive, purged_class);
310   }
311 
312   {
313     GCTraceTime(Debug, gc, phases) debug("Report Object Count", scope()->timer());
314     scope()->tracer()->report_object_count_after_gc(&_is_alive, _heap->workers());
315   }
316 }
317 
318 void G1FullCollector::phase2_prepare_compaction() {
319   GCTraceTime(Info, gc, phases) info("Phase 2: Prepare for compaction", scope()->timer());
320 
321   G1FullGCPrepareTask task(this);
322   run_task(&task);
323 
324   // To avoid OOM when there is memory left.
325   if (!task.has_freed_regions()) {
326     task.prepare_serial_compaction();
327   }
328 }
329 
330 void G1FullCollector::phase3_adjust_pointers() {
331   // Adjust the pointers to reflect the new locations
332   GCTraceTime(Info, gc, phases) info("Phase 3: Adjust pointers", scope()->timer());
333 
334   G1FullGCAdjustTask task(this);
335   run_task(&task);
336 }
337 
338 void G1FullCollector::phase4_do_compaction() {
339   // Compact the heap using the compaction queues created in phase 2.
340   GCTraceTime(Info, gc, phases) info("Phase 4: Compact heap", scope()->timer());
< prev index next >