From aaab39db436ab1c565850503ce715a90f03b9406 Mon Sep 17 00:00:00 2001 From: tschatzl Date: Wed, 26 Feb 2014 15:32:40 +0100 Subject: [PATCH] 8027559: Decrease code size and templatizing in G1ParCopyClosure::do_oop_work Summary: Move methods that are not dependent on any of G1ParCopyClosure's template parameters into G1ParCopyHelper. Further remove unused methods and members of the class hierarchy. Reviewed-by: mgerdin, stefank --- make/excludeSrc.make | 2 +- .../gc_implementation/g1/g1CollectedHeap.cpp | 17 +++------- .../vm/gc_implementation/g1/g1OopClosures.cpp | 31 +++++++++++++++++ .../vm/gc_implementation/g1/g1OopClosures.hpp | 33 ++++++++----------- .../g1/g1OopClosures.inline.hpp | 2 +- 5 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 src/share/vm/gc_implementation/g1/g1OopClosures.cpp diff --git a/make/excludeSrc.make b/make/excludeSrc.make index a95dc1b11..24f1fa20e 100644 --- a/make/excludeSrc.make +++ b/make/excludeSrc.make @@ -86,7 +86,7 @@ ifeq ($(INCLUDE_ALL_GCS), false) concurrentMark.cpp concurrentMarkThread.cpp dirtyCardQueue.cpp g1AllocRegion.cpp \ g1BlockOffsetTable.cpp g1CardCounts.cpp g1CollectedHeap.cpp g1CollectorPolicy.cpp \ g1ErgoVerbose.cpp g1GCPhaseTimes.cpp g1HRPrinter.cpp g1HotCardCache.cpp g1Log.cpp \ - g1MMUTracker.cpp g1MarkSweep.cpp g1MemoryPool.cpp g1MonitoringSupport.cpp \ + g1MMUTracker.cpp g1MarkSweep.cpp g1MemoryPool.cpp g1MonitoringSupport.cpp g1OopClosures.cpp \ g1RemSet.cpp g1RemSetSummary.cpp g1SATBCardTableModRefBS.cpp g1_globals.cpp heapRegion.cpp \ g1BiasedArray.cpp heapRegionRemSet.cpp heapRegionSeq.cpp heapRegionSet.cpp heapRegionSets.cpp \ ptrQueue.cpp satbQueue.cpp sparsePRT.cpp survRateGroup.cpp vm_operations_g1.cpp \ diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 64b2995af..15759cb2d 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -4658,14 +4658,10 @@ void G1ParScanThreadState::trim_queue() { G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : - _g1(g1), _g1_rem(_g1->g1_rem_set()), _cm(_g1->concurrent_mark()), - _par_scan_state(par_scan_state), - _worker_id(par_scan_state->queue_num()), - _during_initial_mark(_g1->g1_policy()->during_initial_mark_pause()), - _mark_in_progress(_g1->mark_in_progress()) { } + _g1(g1), _par_scan_state(par_scan_state), + _worker_id(par_scan_state->queue_num()) { } -template -void G1ParCopyClosure::mark_object(oop obj) { +void G1ParCopyHelper::mark_object(oop obj) { #ifdef ASSERT HeapRegion* hr = _g1->heap_region_containing(obj); assert(hr != NULL, "sanity"); @@ -4676,9 +4672,7 @@ void G1ParCopyClosure::mark_object(oop obj) { _cm->grayRoot(obj, (size_t) obj->size(), _worker_id); } -template -void G1ParCopyClosure - ::mark_forwarded_object(oop from_obj, oop to_obj) { +void G1ParCopyHelper::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"); @@ -4799,8 +4793,7 @@ void G1ParCopyHelper::do_klass_barrier(T* p, oop new_obj) { template template -void G1ParCopyClosure -::do_oop_work(T* p) { +void G1ParCopyClosure::do_oop_work(T* p) { oop obj = oopDesc::load_decode_heap_oop(p); assert(_worker_id == _par_scan_state->queue_num(), "sanity"); diff --git a/src/share/vm/gc_implementation/g1/g1OopClosures.cpp b/src/share/vm/gc_implementation/g1/g1OopClosures.cpp new file mode 100644 index 000000000..a30b00416 --- /dev/null +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp" +#include "gc_implementation/g1/g1OopClosures.inline.hpp" + +G1ParCopyHelper::G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : + G1ParClosureSuper(g1, par_scan_state), _scanned_klass(NULL), + _cm(_g1->concurrent_mark()) {} diff --git a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp index bda11dc6b..27264e336 100644 --- a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp @@ -48,12 +48,8 @@ public: class G1ParClosureSuper : public OopsInHeapRegionClosure { protected: G1CollectedHeap* _g1; - G1RemSet* _g1_rem; - ConcurrentMark* _cm; G1ParScanThreadState* _par_scan_state; uint _worker_id; - bool _during_initial_mark; - bool _mark_in_progress; public: G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); bool apply_to_weak_ref_discovered_field() { return true; } @@ -133,12 +129,21 @@ public: // Add back base class for metadata class G1ParCopyHelper : public G1ParClosureSuper { +protected: Klass* _scanned_klass; + ConcurrentMark* _cm; + + // 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 + // during the GC (i.e., non-CSet objects). It is MT-safe. + void mark_object(oop obj); + // Mark the object if it's not already marked. This is used to mark + // objects pointed to by roots that have been forwarded during a + // GC. It is MT-safe. + void mark_forwarded_object(oop from_obj, oop to_obj); public: - G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : - _scanned_klass(NULL), - G1ParClosureSuper(g1, par_scan_state) {} + G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); void set_scanned_klass(Klass* k) { _scanned_klass = k; } template void do_klass_barrier(T* p, oop new_obj); @@ -150,16 +155,6 @@ class G1ParCopyClosure : public G1ParCopyHelper { template void do_oop_work(T* p); 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 - // during the GC (i.e., non-CSet objects). It is MT-safe. - void mark_object(oop obj); - - // Mark the object if it's not already marked. This is used to mark - // objects pointed to by roots that have been forwarded during a - // GC. It is MT-safe. - void mark_forwarded_object(oop from_obj, oop to_obj); - oop copy_to_survivor_space(oop obj); public: @@ -172,9 +167,7 @@ public: G1ParScanClosure* scanner() { return &_scanner; } - template void do_oop_nv(T* p) { - do_oop_work(p); - } + template void do_oop_nv(T* p) { do_oop_work(p); } virtual void do_oop(oop* p) { do_oop_nv(p); } virtual void do_oop(narrowOop* p) { do_oop_nv(p); } }; diff --git a/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp b/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp index e26d2a695..9374d23a2 100644 --- a/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp @@ -82,7 +82,7 @@ inline void G1ParScanClosure::do_oop_nv(T* p) { _par_scan_state->push_on_queue(p); } else { - _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num()); + _par_scan_state->update_rs(_from, p, _worker_id); } } } -- GitLab