< prev index next >

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

Print this page
rev 49661 : imported patch 8200426-sangheon-review
rev 49664 : [mq]: 6672778-partial-queue-trimming
rev 49666 : [mq]: 8201365-remove-should_process_references


2822 
2823       if (VerifyRememberedSets) {
2824         log_info(gc, verify)("[Verifying RemSets before GC]");
2825         VerifyRegionRemSetClosure v_cl;
2826         heap_region_iterate(&v_cl);
2827       }
2828 
2829       _verifier->verify_before_gc(verify_type);
2830 
2831       _verifier->check_bitmaps("GC Start");
2832 
2833 #if COMPILER2_OR_JVMCI
2834       DerivedPointerTable::clear();
2835 #endif
2836 
2837       // Please see comment in g1CollectedHeap.hpp and
2838       // G1CollectedHeap::ref_processing_init() to see how
2839       // reference processing currently works in G1.
2840 
2841       // Enable discovery in the STW reference processor
2842       if (g1_policy()->should_process_references()) {
2843         ref_processor_stw()->enable_discovery();
2844       } else {
2845         ref_processor_stw()->disable_discovery();
2846       }
2847 
2848       {
2849         // We want to temporarily turn off discovery by the
2850         // CM ref processor, if necessary, and turn it back on
2851         // on again later if we do. Using a scoped
2852         // NoRefDiscovery object will do this.
2853         NoRefDiscovery no_cm_discovery(ref_processor_cm());
2854 
2855         // Forget the current alloc region (we might even choose it to be part
2856         // of the collection set!).
2857         _allocator->release_mutator_alloc_region();
2858 
2859         // This timing is only used by the ergonomics to handle our pause target.
2860         // It is unclear why this should not include the full pause. We will
2861         // investigate this in CR 7178365.
2862         //
2863         // Preserving the old comment here if that helps the investigation:
2864         //
2865         // The elapsed time induced by the start time below deliberately elides
2866         // the possible verification above.


4173     // for the G1RootProcessor object. We record the current
4174     // elapsed time before closing the scope so that time
4175     // taken for the destructor is NOT included in the
4176     // reported parallel time.
4177   }
4178 
4179   double par_time_ms = (end_par_time_sec - start_par_time_sec) * 1000.0;
4180   phase_times->record_par_time(par_time_ms);
4181 
4182   double code_root_fixup_time_ms =
4183         (os::elapsedTime() - end_par_time_sec) * 1000.0;
4184   phase_times->record_code_root_fixup_time(code_root_fixup_time_ms);
4185 }
4186 
4187 void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
4188   // Process any discovered reference objects - we have
4189   // to do this _before_ we retire the GC alloc regions
4190   // as we may have to copy some 'reachable' referent
4191   // objects (and their reachable sub-graphs) that were
4192   // not copied during the pause.
4193   if (g1_policy()->should_process_references()) {
4194     preserve_cm_referents(per_thread_states);
4195     process_discovered_references(per_thread_states);
4196   } else {
4197     ref_processor_stw()->verify_no_references_recorded();
4198   }
4199 
4200   G1STWIsAliveClosure is_alive(this);
4201   G1KeepAliveClosure keep_alive(this);
4202 
4203   {
4204     double start = os::elapsedTime();
4205 
4206     WeakProcessor::weak_oops_do(&is_alive, &keep_alive);
4207 
4208     double time_ms = (os::elapsedTime() - start) * 1000.0;
4209     g1_policy()->phase_times()->record_ref_proc_time(time_ms);
4210   }
4211 
4212   if (G1StringDedup::is_enabled()) {
4213     double fixup_start = os::elapsedTime();
4214 
4215     G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive, true, g1_policy()->phase_times());
4216 
4217     double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
4218     g1_policy()->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);


4221   g1_rem_set()->cleanup_after_oops_into_collection_set_do();
4222 
4223   if (evacuation_failed()) {
4224     restore_after_evac_failure();
4225 
4226     // Reset the G1EvacuationFailureALot counters and flags
4227     // Note: the values are reset only when an actual
4228     // evacuation failure occurs.
4229     NOT_PRODUCT(reset_evacuation_should_fail();)
4230   }
4231 
4232   _preserved_marks_set.assert_empty();
4233 
4234   // Enqueue any remaining references remaining on the STW
4235   // reference processor's discovered lists. We need to do
4236   // this after the card table is cleaned (and verified) as
4237   // the act of enqueueing entries on to the pending list
4238   // will log these updates (and dirty their associated
4239   // cards). We need these updates logged to update any
4240   // RSets.
4241   if (g1_policy()->should_process_references()) {
4242     enqueue_discovered_references(per_thread_states);
4243   } else {
4244     g1_policy()->phase_times()->record_ref_enq_time(0);
4245   }
4246 
4247   _allocator->release_gc_alloc_regions(evacuation_info);
4248 
4249   merge_per_thread_state_info(per_thread_states);
4250 
4251   // Reset and re-enable the hot card cache.
4252   // Note the counts for the cards in the regions in the
4253   // collection set are reset when the collection set is freed.
4254   _hot_card_cache->reset_hot_cache();
4255   _hot_card_cache->set_use_cache(true);
4256 
4257   purge_code_root_memory();
4258 
4259   redirty_logged_cards();
4260 #if COMPILER2_OR_JVMCI
4261   double start = os::elapsedTime();
4262   DerivedPointerTable::update_pointers();
4263   g1_policy()->phase_times()->record_derived_pointer_table_update_time((os::elapsedTime() - start) * 1000.0);
4264 #endif
4265   g1_policy()->print_age_table();




2822 
2823       if (VerifyRememberedSets) {
2824         log_info(gc, verify)("[Verifying RemSets before GC]");
2825         VerifyRegionRemSetClosure v_cl;
2826         heap_region_iterate(&v_cl);
2827       }
2828 
2829       _verifier->verify_before_gc(verify_type);
2830 
2831       _verifier->check_bitmaps("GC Start");
2832 
2833 #if COMPILER2_OR_JVMCI
2834       DerivedPointerTable::clear();
2835 #endif
2836 
2837       // Please see comment in g1CollectedHeap.hpp and
2838       // G1CollectedHeap::ref_processing_init() to see how
2839       // reference processing currently works in G1.
2840 
2841       // Enable discovery in the STW reference processor

2842       ref_processor_stw()->enable_discovery();



2843 
2844       {
2845         // We want to temporarily turn off discovery by the
2846         // CM ref processor, if necessary, and turn it back on
2847         // on again later if we do. Using a scoped
2848         // NoRefDiscovery object will do this.
2849         NoRefDiscovery no_cm_discovery(ref_processor_cm());
2850 
2851         // Forget the current alloc region (we might even choose it to be part
2852         // of the collection set!).
2853         _allocator->release_mutator_alloc_region();
2854 
2855         // This timing is only used by the ergonomics to handle our pause target.
2856         // It is unclear why this should not include the full pause. We will
2857         // investigate this in CR 7178365.
2858         //
2859         // Preserving the old comment here if that helps the investigation:
2860         //
2861         // The elapsed time induced by the start time below deliberately elides
2862         // the possible verification above.


4169     // for the G1RootProcessor object. We record the current
4170     // elapsed time before closing the scope so that time
4171     // taken for the destructor is NOT included in the
4172     // reported parallel time.
4173   }
4174 
4175   double par_time_ms = (end_par_time_sec - start_par_time_sec) * 1000.0;
4176   phase_times->record_par_time(par_time_ms);
4177 
4178   double code_root_fixup_time_ms =
4179         (os::elapsedTime() - end_par_time_sec) * 1000.0;
4180   phase_times->record_code_root_fixup_time(code_root_fixup_time_ms);
4181 }
4182 
4183 void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
4184   // Process any discovered reference objects - we have
4185   // to do this _before_ we retire the GC alloc regions
4186   // as we may have to copy some 'reachable' referent
4187   // objects (and their reachable sub-graphs) that were
4188   // not copied during the pause.

4189   preserve_cm_referents(per_thread_states);
4190   process_discovered_references(per_thread_states);



4191 
4192   G1STWIsAliveClosure is_alive(this);
4193   G1KeepAliveClosure keep_alive(this);
4194 
4195   {
4196     double start = os::elapsedTime();
4197 
4198     WeakProcessor::weak_oops_do(&is_alive, &keep_alive);
4199 
4200     double time_ms = (os::elapsedTime() - start) * 1000.0;
4201     g1_policy()->phase_times()->record_ref_proc_time(time_ms);
4202   }
4203 
4204   if (G1StringDedup::is_enabled()) {
4205     double fixup_start = os::elapsedTime();
4206 
4207     G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive, true, g1_policy()->phase_times());
4208 
4209     double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
4210     g1_policy()->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);


4213   g1_rem_set()->cleanup_after_oops_into_collection_set_do();
4214 
4215   if (evacuation_failed()) {
4216     restore_after_evac_failure();
4217 
4218     // Reset the G1EvacuationFailureALot counters and flags
4219     // Note: the values are reset only when an actual
4220     // evacuation failure occurs.
4221     NOT_PRODUCT(reset_evacuation_should_fail();)
4222   }
4223 
4224   _preserved_marks_set.assert_empty();
4225 
4226   // Enqueue any remaining references remaining on the STW
4227   // reference processor's discovered lists. We need to do
4228   // this after the card table is cleaned (and verified) as
4229   // the act of enqueueing entries on to the pending list
4230   // will log these updates (and dirty their associated
4231   // cards). We need these updates logged to update any
4232   // RSets.

4233   enqueue_discovered_references(per_thread_states);



4234 
4235   _allocator->release_gc_alloc_regions(evacuation_info);
4236 
4237   merge_per_thread_state_info(per_thread_states);
4238 
4239   // Reset and re-enable the hot card cache.
4240   // Note the counts for the cards in the regions in the
4241   // collection set are reset when the collection set is freed.
4242   _hot_card_cache->reset_hot_cache();
4243   _hot_card_cache->set_use_cache(true);
4244 
4245   purge_code_root_memory();
4246 
4247   redirty_logged_cards();
4248 #if COMPILER2_OR_JVMCI
4249   double start = os::elapsedTime();
4250   DerivedPointerTable::update_pointers();
4251   g1_policy()->phase_times()->record_derived_pointer_table_update_time((os::elapsedTime() - start) * 1000.0);
4252 #endif
4253   g1_policy()->print_age_table();


< prev index next >