--- old/src/share/vm/gc/g1/g1CollectedHeap.cpp 2015-10-13 14:01:34.283767388 +0200 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2015-10-13 14:01:34.187763417 +0200 @@ -4436,10 +4436,7 @@ _root_processor->evacuate_roots(pss->closures(), worker_id); - G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, pss); - size_t cards_scanned = _g1h->g1_rem_set()->oops_into_collection_set_do(&push_heap_rs_cl, - pss->closures()->weak_codeblobs(), - worker_id); + size_t cards_scanned = _g1h->g1_rem_set()->oops_into_collection_set_do(pss->closures(), worker_id); _pss->add_cards_scanned(worker_id, cards_scanned); --- old/src/share/vm/gc/g1/g1RemSet.cpp 2015-10-13 14:01:34.983796337 +0200 +++ new/src/share/vm/gc/g1/g1RemSet.cpp 2015-10-13 14:01:34.887792367 +0200 @@ -32,6 +32,7 @@ #include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1RemSet.inline.hpp" +#include "gc/g1/g1RootClosures.hpp" #include "gc/g1/heapRegionManager.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "memory/iterator.hpp" @@ -226,14 +227,15 @@ size_t cards_looked_up() { return _cards;} }; -size_t G1RemSet::scanRS(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* heap_region_codeblobs, +size_t G1RemSet::scanRS(G1EvacuationRootClosures* closures, uint worker_i) { double rs_time_start = os::elapsedTime(); HeapRegion *startRegion = _g1->start_cset_region_for_worker(worker_i); - ScanRSClosure scanRScl(oc, heap_region_codeblobs, worker_i); + ScanRSClosure scanRScl(closures->inter_region_oops(), + closures->weak_codeblobs(), + worker_i); _g1->collection_set_iterate_from(startRegion, &scanRScl); scanRScl.set_try_claimed(); @@ -293,8 +295,7 @@ HeapRegionRemSet::cleanup(); } -size_t G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* heap_region_codeblobs, +size_t G1RemSet::oops_into_collection_set_do(G1EvacuationRootClosures* closures, uint worker_i) { #if CARD_REPEAT_HISTO ct_freq_update_histo_and_reset(); @@ -303,7 +304,7 @@ // We cache the value of 'oc' closure into the appropriate slot in the // _cset_rs_update_cl for this worker assert(worker_i < n_workers(), "sanity"); - _cset_rs_update_cl[worker_i] = oc; + _cset_rs_update_cl[worker_i] = closures->inter_region_oops(); // A DirtyCardQueue that is used to hold cards containing references // that point into the collection set. This DCQ is associated with a @@ -317,7 +318,7 @@ DirtyCardQueue into_cset_dcq(&_g1->into_cset_dirty_card_queue_set()); updateRS(&into_cset_dcq, worker_i); - size_t cards_scanned = scanRS(oc, heap_region_codeblobs, worker_i); + size_t cards_scanned = scanRS(closures, worker_i); // We now clear the cached values of _cset_rs_update_cl for this worker _cset_rs_update_cl[worker_i] = NULL; --- old/src/share/vm/gc/g1/g1RemSet.hpp 2015-10-13 14:01:35.567820490 +0200 +++ new/src/share/vm/gc/g1/g1RemSet.hpp 2015-10-13 14:01:35.463816189 +0200 @@ -30,8 +30,9 @@ // A G1RemSet provides ways of iterating over pointers into a selected // collection set. -class G1CollectedHeap; class ConcurrentG1Refine; +class G1CollectedHeap; +class G1EvacuationRootClosures; class G1ParPushHeapRSClosure; // A G1RemSet in which each heap region has a rem set that records the @@ -94,8 +95,7 @@ // // Returns the number of cards scanned while looking for pointers // into the collection set. - size_t oops_into_collection_set_do(G1ParPushHeapRSClosure* blk, - CodeBlobClosure* heap_region_codeblobs, + size_t oops_into_collection_set_do(G1EvacuationRootClosures* closures, uint worker_i); // Prepare for and cleanup after an oops_into_collection_set_do @@ -106,8 +106,7 @@ void prepare_for_oops_into_collection_set_do(); void cleanup_after_oops_into_collection_set_do(); - size_t scanRS(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* heap_region_codeblobs, + size_t scanRS(G1EvacuationRootClosures* closures, uint worker_i); void updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i); --- old/src/share/vm/gc/g1/g1RootClosures.cpp 2015-10-13 14:01:36.159844973 +0200 +++ new/src/share/vm/gc/g1/g1RootClosures.cpp 2015-10-13 14:01:36.031839679 +0200 @@ -54,12 +54,14 @@ class G1EvacuationClosures : public G1EvacuationRootClosures { G1SharedClosures _closures; + G1ParPushHeapRSClosure _inter_region_oops; public: G1EvacuationClosures(G1CollectedHeap* g1h, G1ParScanThreadState* pss, bool gcs_are_young) : - _closures(g1h, pss, gcs_are_young, /* must_claim_cld */ false) {} + _closures(g1h, pss, gcs_are_young, /* must_claim_cld */ false), + _inter_region_oops(g1h, pss) {} OopClosure* weak_oops() { return &_closures._buffered_oops; } OopClosure* strong_oops() { return &_closures._buffered_oops; } @@ -78,6 +80,8 @@ OopClosure* raw_strong_oops() { return &_closures._oops; } bool trace_metadata() { return false; } + + G1ParPushHeapRSClosure* inter_region_oops() { return &_inter_region_oops; } }; // Closures used during initial mark. @@ -87,6 +91,7 @@ class G1InitalMarkClosures : public G1EvacuationRootClosures { G1SharedClosures _strong; G1SharedClosures _weak; + G1ParPushHeapRSClosure _inter_region_oops; // Filter method to help with returning the appropriate closures // depending on the class template parameter. @@ -102,7 +107,8 @@ G1InitalMarkClosures(G1CollectedHeap* g1h, G1ParScanThreadState* pss) : _strong(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true), - _weak(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true) {} + _weak(g1h, pss, /* process_only_dirty_klasses */ false, /* must_claim_cld */ true), + _inter_region_oops(g1h, pss) {} OopClosure* weak_oops() { return &_weak._buffered_oops; } OopClosure* strong_oops() { return &_strong._buffered_oops; } @@ -134,6 +140,8 @@ // If we are not marking all weak roots then we are tracing // which metadata is alive. bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; } + + G1ParPushHeapRSClosure* inter_region_oops() { return &_inter_region_oops; } }; G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) { --- old/src/share/vm/gc/g1/g1RootClosures.hpp 2015-10-13 14:01:36.795871276 +0200 +++ new/src/share/vm/gc/g1/g1RootClosures.hpp 2015-10-13 14:01:36.679866479 +0200 @@ -67,6 +67,9 @@ // Is this closure used for tracing metadata? virtual bool trace_metadata() = 0; + // Applied to inter-region pointers, statically typed due to devirtualization. + virtual G1ParPushHeapRSClosure* inter_region_oops() = 0; + static G1EvacuationRootClosures* create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h); };