--- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2014-09-29 13:41:07.542345758 +0200 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2014-09-29 13:41:07.446349085 +0200 @@ -4171,16 +4171,14 @@ void G1CollectedHeap::remove_self_forwarding_pointers() { double remove_self_forwards_start = os::elapsedTime(); - HeapRegionClaimer hrclaimer; - G1ParRemoveSelfForwardPtrsTask rsfp_task(this, &hrclaimer); - if (G1CollectedHeap::use_parallel_gc_threads()) { set_par_threads(); - hrclaimer.initialize(workers()->active_workers()); + G1ParRemoveSelfForwardPtrsTask rsfp_task(this); workers()->run_task(&rsfp_task); set_par_threads(0); } else { - rsfp_task.work(0); + RemoveSelfForwardPtrHRClosure rsfp(this); + _g1h->collection_set_iterate(&rsfp); } // Now restore saved marks, if any. --- old/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp 2014-09-29 13:41:08.114325941 +0200 +++ new/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp 2014-09-29 13:41:08.030328851 +0200 @@ -184,10 +184,11 @@ public: RemoveSelfForwardPtrHRClosure(G1CollectedHeap* g1h, - uint worker_id, - HeapRegionClaimer* hrclaimer) : + uint worker_id = 0, + HeapRegionClaimer* hrclaimer = NULL) : _g1h(g1h), _dcq(&g1h->dirty_card_queue_set()), _update_rset_cl(g1h, &_dcq), _worker_id(worker_id), _cm(_g1h->concurrent_mark()), _hrclaimer(hrclaimer) { + assert(hrclaimer != NULL || worker_id == 0, "Must use a HeapRegionClaimer when used in parallel."); } bool doHeapRegion(HeapRegion *hr) { @@ -197,7 +198,7 @@ assert(!hr->is_humongous(), "sanity"); assert(hr->in_collection_set(), "bad CS"); - if (_hrclaimer->claim_region(hr->hrm_index())) { + if (_hrclaimer == NULL || _hrclaimer->claim_region(hr->hrm_index())) { if (hr->evacuation_failed()) { RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, &_update_rset_cl, during_initial_mark, @@ -235,14 +236,15 @@ class G1ParRemoveSelfForwardPtrsTask: public AbstractGangTask { protected: G1CollectedHeap* _g1h; - HeapRegionClaimer* _hrclaimer; + HeapRegionClaimer _hrclaimer; public: - G1ParRemoveSelfForwardPtrsTask(G1CollectedHeap* g1h, HeapRegionClaimer* hrclaimer) : - AbstractGangTask("G1 Remove Self-forwarding Pointers"), _g1h(g1h), _hrclaimer(hrclaimer) {} + G1ParRemoveSelfForwardPtrsTask(G1CollectedHeap* g1h) : + AbstractGangTask("G1 Remove Self-forwarding Pointers"), _g1h(g1h), + _hrclaimer(g1h->workers()->active_workers()) {} void work(uint worker_id) { - RemoveSelfForwardPtrHRClosure rsfp_cl(_g1h, worker_id, _hrclaimer); + RemoveSelfForwardPtrHRClosure rsfp_cl(_g1h, worker_id, &_hrclaimer); HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id); _g1h->collection_set_iterate_from(hr, &rsfp_cl);