diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index fbb264c2352382424aafff5fb1416b7fd650934c..1e1f70f3443381f791a0bbe1942319fa299790f2 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -4355,7 +4355,8 @@ G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, _during_initial_mark(_g1->g1_policy()->during_initial_mark_pause()), _mark_in_progress(_g1->mark_in_progress()) { } -void G1ParCopyHelper::mark_object(oop obj) { +template +void G1ParCopyClosure::mark_object(oop obj) { #ifdef ASSERT HeapRegion* hr = _g1->heap_region_containing(obj); assert(hr != NULL, "sanity"); @@ -4366,7 +4367,9 @@ void G1ParCopyHelper::mark_object(oop obj) { _cm->grayRoot(obj, (size_t) obj->size(), _worker_id); } -void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) { +template +void G1ParCopyClosure + ::mark_forwarded_object(oop from_obj, oop to_obj) { #ifdef ASSERT assert(from_obj->is_forwarded(), "from obj should be forwarded"); assert(from_obj->forwardee() == to_obj, "to obj should be the forwardee"); @@ -4388,7 +4391,9 @@ void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) { _cm->grayRoot(to_obj, (size_t) from_obj->size(), _worker_id); } -oop G1ParCopyHelper::copy_to_survivor_space(oop old) { +template +oop G1ParCopyClosure + ::copy_to_survivor_space(oop old) { size_t word_sz = old->size(); HeapRegion* from_region = _g1->heap_region_containing_raw(old); // +1 to make the -1 indexes valid... @@ -4457,8 +4462,8 @@ oop G1ParCopyHelper::copy_to_survivor_space(oop old) { } else { // No point in using the slower heap_region_containing() method, // given that we know obj is in the heap. - _scanner->set_region(_g1->heap_region_containing_raw(obj)); - obj->oop_iterate_backwards(_scanner); + _scanner.set_region(_g1->heap_region_containing_raw(obj)); + obj->oop_iterate_backwards(&_scanner); } } else { _par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz); diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index c1ccc4fac2bf7e1be7db8b7e661d2b198489d10b..58befab9ab0d699013b875f49ab752fd7586b05d 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -199,7 +199,8 @@ class G1CollectedHeap : public SharedHeap { friend class OldGCAllocRegion; // Closures used in implementation. - friend class G1ParCopyHelper; + template + friend class G1ParCopyClosure; friend class G1IsAliveClosure; friend class G1EvacuateFollowersClosure; friend class G1ParScanThreadState; diff --git a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp index 52a6c50665b8f241206270473a2776f652e5ffbe..c20a1a7713b4263d88ed4ecfd89262bb0c9ea8e7 100644 --- a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp @@ -118,9 +118,11 @@ public: virtual void do_oop(narrowOop* p) { do_oop_nv(p); } }; +template +class G1ParCopyClosure : public G1ParClosureSuper { + G1ParScanClosure _scanner; + template void do_oop_work(T* p); -class G1ParCopyHelper : public G1ParClosureSuper { - G1ParScanClosure *_scanner; protected: // Mark the object if it's not already marked. This is used to mark // objects pointed to by roots that are guaranteed not to move @@ -134,23 +136,11 @@ protected: oop copy_to_survivor_space(oop obj); -public: - G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, - G1ParScanClosure *scanner) : - G1ParClosureSuper(g1, par_scan_state), _scanner(scanner) { } -}; - -template -class G1ParCopyClosure : public G1ParCopyHelper { - G1ParScanClosure _scanner; - - template void do_oop_work(T* p); - public: G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) : _scanner(g1, par_scan_state, rp), - G1ParCopyHelper(g1, par_scan_state, &_scanner) { + G1ParClosureSuper(g1, par_scan_state) { assert(_ref_processor == NULL, "sanity"); }