< prev index next >

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

Print this page
rev 48019 : 8191821: Finer granularity for GC verification
Reviewed-by:
rev 48020 : [mq]: 8191821-rev-sang-poonam


1066 
1067 class PostCompactionPrinterClosure: public HeapRegionClosure {
1068 private:
1069   G1HRPrinter* _hr_printer;
1070 public:
1071   bool doHeapRegion(HeapRegion* hr) {
1072     assert(!hr->is_young(), "not expecting to find young regions");
1073     _hr_printer->post_compaction(hr);
1074     return false;
1075   }
1076 
1077   PostCompactionPrinterClosure(G1HRPrinter* hr_printer)
1078     : _hr_printer(hr_printer) { }
1079 };
1080 
1081 void G1CollectedHeap::print_hrm_post_compaction() {
1082   if (_hr_printer.is_active()) {
1083     PostCompactionPrinterClosure cl(hr_printer());
1084     heap_region_iterate(&cl);
1085   }

1086 






1087 }
1088 
1089 void G1CollectedHeap::abort_concurrent_cycle() {
1090   // Note: When we have a more flexible GC logging framework that
1091   // allows us to add optional attributes to a GC log record we
1092   // could consider timing and reporting how long we wait in the
1093   // following two methods.
1094   wait_while_free_regions_coming();
1095   // If we start the compaction before the CM threads finish
1096   // scanning the root regions we might trip them over as we'll
1097   // be moving objects / updating references. So let's wait until
1098   // they are done. By telling them to abort, they should complete
1099   // early.
1100   _cm->root_regions()->abort();
1101   _cm->root_regions()->wait_until_scan_finished();
1102   append_secondary_free_list_if_not_empty_with_lock();
1103 
1104   // Disable discovery and empty the discovered lists
1105   // for the CM ref processor.
1106   ref_processor_cm()->disable_discovery();


2967     }
2968 
2969     G1HeapTransition heap_transition(this);
2970     size_t heap_used_bytes_before_gc = used();
2971 
2972     // Don't dynamically change the number of GC threads this early.  A value of
2973     // 0 is used to indicate serial work.  When parallel work is done,
2974     // it will be set.
2975 
2976     { // Call to jvmpi::post_class_unload_events must occur outside of active GC
2977       IsGCActiveMark x;
2978 
2979       gc_prologue(false);
2980 
2981       if (VerifyRememberedSets) {
2982         log_info(gc, verify)("[Verifying RemSets before GC]");
2983         VerifyRegionRemSetClosure v_cl;
2984         heap_region_iterate(&v_cl);
2985       }
2986 
2987       _verifier->verify_before_gc(collector_state()->yc_type() == Mixed ? G1HeapVerifier::G1VerifyMixed : G1HeapVerifier::G1VerifyYoung);
2988 
2989       _verifier->check_bitmaps("GC Start");
2990 
2991 #if COMPILER2_OR_JVMCI
2992       DerivedPointerTable::clear();
2993 #endif
2994 
2995       // Please see comment in g1CollectedHeap.hpp and
2996       // G1CollectedHeap::ref_processing_init() to see how
2997       // reference processing currently works in G1.
2998 
2999       // Enable discovery in the STW reference processor
3000       if (g1_policy()->should_process_references()) {
3001         ref_processor_stw()->enable_discovery();
3002       } else {
3003         ref_processor_stw()->disable_discovery();
3004       }
3005 
3006       {
3007         // We want to temporarily turn off discovery by the


3127         // has just got initialized after the previous CSet was freed.
3128         _cm->verify_no_cset_oops();
3129 
3130         // This timing is only used by the ergonomics to handle our pause target.
3131         // It is unclear why this should not include the full pause. We will
3132         // investigate this in CR 7178365.
3133         double sample_end_time_sec = os::elapsedTime();
3134         double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
3135         size_t total_cards_scanned = g1_policy()->phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards);
3136         g1_policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
3137 
3138         evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
3139         evacuation_info.set_bytes_copied(g1_policy()->bytes_copied_during_gc());
3140 
3141         if (VerifyRememberedSets) {
3142           log_info(gc, verify)("[Verifying RemSets after GC]");
3143           VerifyRegionRemSetClosure v_cl;
3144           heap_region_iterate(&v_cl);
3145         }
3146 
3147         _verifier->verify_after_gc(collector_state()->yc_type() == Mixed ? G1HeapVerifier::G1VerifyMixed : G1HeapVerifier::G1VerifyYoung);
3148         _verifier->check_bitmaps("GC End");
3149 
3150         assert(!ref_processor_stw()->discovery_enabled(), "Postcondition");
3151         ref_processor_stw()->verify_no_references_recorded();
3152 
3153         // CM reference discovery will be re-enabled if necessary.
3154       }
3155 
3156 #ifdef TRACESPINNING
3157       ParallelTaskTerminator::print_termination_counts();
3158 #endif
3159 
3160       gc_epilogue(false);
3161     }
3162 
3163     // Print the remainder of the GC log output.
3164     if (evacuation_failed()) {
3165       log_info(gc)("To-space exhausted");
3166     }
3167 




1066 
1067 class PostCompactionPrinterClosure: public HeapRegionClosure {
1068 private:
1069   G1HRPrinter* _hr_printer;
1070 public:
1071   bool doHeapRegion(HeapRegion* hr) {
1072     assert(!hr->is_young(), "not expecting to find young regions");
1073     _hr_printer->post_compaction(hr);
1074     return false;
1075   }
1076 
1077   PostCompactionPrinterClosure(G1HRPrinter* hr_printer)
1078     : _hr_printer(hr_printer) { }
1079 };
1080 
1081 void G1CollectedHeap::print_hrm_post_compaction() {
1082   if (_hr_printer.is_active()) {
1083     PostCompactionPrinterClosure cl(hr_printer());
1084     heap_region_iterate(&cl);
1085   }
1086 }
1087 
1088 G1HeapVerifier::G1VerifyType G1CollectedHeap::young_verification_type() {
1089   if (collector_state()->yc_type() == Mixed) {
1090     return G1HeapVerifier::G1VerifyMixed;
1091   } else {
1092     return G1HeapVerifier::G1VerifyYoung;
1093   }
1094 }
1095 
1096 void G1CollectedHeap::abort_concurrent_cycle() {
1097   // Note: When we have a more flexible GC logging framework that
1098   // allows us to add optional attributes to a GC log record we
1099   // could consider timing and reporting how long we wait in the
1100   // following two methods.
1101   wait_while_free_regions_coming();
1102   // If we start the compaction before the CM threads finish
1103   // scanning the root regions we might trip them over as we'll
1104   // be moving objects / updating references. So let's wait until
1105   // they are done. By telling them to abort, they should complete
1106   // early.
1107   _cm->root_regions()->abort();
1108   _cm->root_regions()->wait_until_scan_finished();
1109   append_secondary_free_list_if_not_empty_with_lock();
1110 
1111   // Disable discovery and empty the discovered lists
1112   // for the CM ref processor.
1113   ref_processor_cm()->disable_discovery();


2974     }
2975 
2976     G1HeapTransition heap_transition(this);
2977     size_t heap_used_bytes_before_gc = used();
2978 
2979     // Don't dynamically change the number of GC threads this early.  A value of
2980     // 0 is used to indicate serial work.  When parallel work is done,
2981     // it will be set.
2982 
2983     { // Call to jvmpi::post_class_unload_events must occur outside of active GC
2984       IsGCActiveMark x;
2985 
2986       gc_prologue(false);
2987 
2988       if (VerifyRememberedSets) {
2989         log_info(gc, verify)("[Verifying RemSets before GC]");
2990         VerifyRegionRemSetClosure v_cl;
2991         heap_region_iterate(&v_cl);
2992       }
2993 
2994       _verifier->verify_before_gc(young_verification_type());
2995 
2996       _verifier->check_bitmaps("GC Start");
2997 
2998 #if COMPILER2_OR_JVMCI
2999       DerivedPointerTable::clear();
3000 #endif
3001 
3002       // Please see comment in g1CollectedHeap.hpp and
3003       // G1CollectedHeap::ref_processing_init() to see how
3004       // reference processing currently works in G1.
3005 
3006       // Enable discovery in the STW reference processor
3007       if (g1_policy()->should_process_references()) {
3008         ref_processor_stw()->enable_discovery();
3009       } else {
3010         ref_processor_stw()->disable_discovery();
3011       }
3012 
3013       {
3014         // We want to temporarily turn off discovery by the


3134         // has just got initialized after the previous CSet was freed.
3135         _cm->verify_no_cset_oops();
3136 
3137         // This timing is only used by the ergonomics to handle our pause target.
3138         // It is unclear why this should not include the full pause. We will
3139         // investigate this in CR 7178365.
3140         double sample_end_time_sec = os::elapsedTime();
3141         double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
3142         size_t total_cards_scanned = g1_policy()->phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards);
3143         g1_policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
3144 
3145         evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
3146         evacuation_info.set_bytes_copied(g1_policy()->bytes_copied_during_gc());
3147 
3148         if (VerifyRememberedSets) {
3149           log_info(gc, verify)("[Verifying RemSets after GC]");
3150           VerifyRegionRemSetClosure v_cl;
3151           heap_region_iterate(&v_cl);
3152         }
3153 
3154         _verifier->verify_after_gc(young_verification_type());
3155         _verifier->check_bitmaps("GC End");
3156 
3157         assert(!ref_processor_stw()->discovery_enabled(), "Postcondition");
3158         ref_processor_stw()->verify_no_references_recorded();
3159 
3160         // CM reference discovery will be re-enabled if necessary.
3161       }
3162 
3163 #ifdef TRACESPINNING
3164       ParallelTaskTerminator::print_termination_counts();
3165 #endif
3166 
3167       gc_epilogue(false);
3168     }
3169 
3170     // Print the remainder of the GC log output.
3171     if (evacuation_failed()) {
3172       log_info(gc)("To-space exhausted");
3173     }
3174 


< prev index next >