8139149: Split G1 evacuate_collection_set into multiple steps
Reviewed-by: ehelin, tschatzl
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Mon Oct 26 12:22:24 2015 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Wed Oct 14 14:51:10 2015 +0200
@@ -3934,9 +3934,13 @@
_allocator->init_gc_alloc_regions(evacuation_info);
G1ParScanThreadStateSet per_thread_states(this, workers()->active_workers(), g1_policy()->young_cset_region_length());
+ pre_evacuate_collection_set();
+
// Actually do the work...
evacuate_collection_set(evacuation_info, &per_thread_states);
+ post_evacuate_collection_set(evacuation_info, &per_thread_states);
+
const size_t* surviving_young_words = per_thread_states.surviving_young_words();
free_collection_set(g1_policy()->collection_set(), evacuation_info, surviving_young_words);
@@ -5166,27 +5170,29 @@
g1_policy()->phase_times()->record_ref_enq_time(ref_enq_time * 1000.0);
}
-void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
+void G1CollectedHeap::pre_evacuate_collection_set() {
_expand_heap_after_alloc_failure = true;
_evacuation_failed = false;
- // Should G1EvacuationFailureALot be in effect for this GC?
- NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();)
-
- g1_rem_set()->prepare_for_oops_into_collection_set_do();
-
// Disable the hot card cache.
G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
hot_card_cache->reset_hot_cache_claimed_index();
hot_card_cache->set_use_cache(false);
- const uint n_workers = workers()->active_workers();
+}
+
+void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
+ g1_rem_set()->prepare_for_oops_into_collection_set_do();
+
+ // Should G1EvacuationFailureALot be in effect for this GC?
+ NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();)
assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty");
double start_par_time_sec = os::elapsedTime();
double end_par_time_sec;
{
+ const uint n_workers = workers()->active_workers();
G1RootProcessor root_processor(this, n_workers);
G1ParTask g1_par_task(this, per_thread_states, _task_queues, &root_processor, n_workers);
// InitialMark needs claim bits to keep track of the marked-through CLDs.
@@ -5236,21 +5242,8 @@
phase_times->record_string_dedup_fixup_time(fixup_time_ms);
}
- _allocator->release_gc_alloc_regions(evacuation_info);
g1_rem_set()->cleanup_after_oops_into_collection_set_do();
- per_thread_states->flush();
-
- record_obj_copy_mem_stats();
-
- // Reset and re-enable the hot card cache.
- // Note the counts for the cards in the regions in the
- // collection set are reset when the collection set is freed.
- hot_card_cache->reset_hot_cache();
- hot_card_cache->set_use_cache(true);
-
- purge_code_root_memory();
-
if (evacuation_failed()) {
remove_self_forwarding_pointers();
@@ -5268,6 +5261,23 @@
// cards). We need these updates logged to update any
// RSets.
enqueue_discovered_references(per_thread_states);
+}
+
+void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
+ _allocator->release_gc_alloc_regions(evacuation_info);
+
+ per_thread_states->flush();
+
+ record_obj_copy_mem_stats();
+
+ // Reset and re-enable the hot card cache.
+ // Note the counts for the cards in the regions in the
+ // collection set are reset when the collection set is freed.
+ G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
+ hot_card_cache->reset_hot_cache();
+ hot_card_cache->set_use_cache(true);
+
+ purge_code_root_memory();
redirty_logged_cards();
#if defined(COMPILER2) || INCLUDE_JVMCI
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp Mon Oct 26 12:22:24 2015 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp Wed Oct 14 14:51:10 2015 +0200
@@ -728,7 +728,10 @@
bool do_collection_pause_at_safepoint(double target_pause_time_ms);
// Actually do the work of evacuating the collection set.
- void evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states);
+ virtual void evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states);
+
+ void pre_evacuate_collection_set();
+ void post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
// Print the header for the per-thread termination statistics.
static void print_termination_stats_hdr(outputStream* const st);