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
--- a/hotspot/make/excludeSrc.make Fri Feb 21 10:19:09 2014 +0100
+++ b/hotspot/make/excludeSrc.make Mon Feb 24 09:40:21 2014 +0100
@@ -86,7 +86,7 @@
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 \
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Feb 21 10:19:09 2014 +0100
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Feb 24 09:40:21 2014 +0100
@@ -4653,14 +4653,10 @@
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()) { }
-
-template <G1Barrier barrier, bool do_mark_object>
-void G1ParCopyClosure<barrier, do_mark_object>::mark_object(oop obj) {
+ _g1(g1), _par_scan_state(par_scan_state),
+ _worker_id(par_scan_state->queue_num()) { }
+
+void G1ParCopyHelper::mark_object(oop obj) {
#ifdef ASSERT
HeapRegion* hr = _g1->heap_region_containing(obj);
assert(hr != NULL, "sanity");
@@ -4671,9 +4667,7 @@
_cm->grayRoot(obj, (size_t) obj->size(), _worker_id);
}
-template <G1Barrier barrier, bool do_mark_object>
-void G1ParCopyClosure<barrier, do_mark_object>
- ::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");
@@ -4794,8 +4788,7 @@
template <G1Barrier barrier, bool do_mark_object>
template <class T>
-void G1ParCopyClosure<barrier, do_mark_object>
-::do_oop_work(T* p) {
+void G1ParCopyClosure<barrier, do_mark_object>::do_oop_work(T* p) {
oop obj = oopDesc::load_decode_heap_oop(p);
assert(_worker_id == _par_scan_state->queue_num(), "sanity");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.cpp Mon Feb 24 09:40:21 2014 +0100
@@ -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()) {}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Fri Feb 21 10:19:09 2014 +0100
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Mon Feb 24 09:40:21 2014 +0100
@@ -48,12 +48,8 @@
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 @@
// 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 <class T> void do_klass_barrier(T* p, oop new_obj);
@@ -150,16 +155,6 @@
template <class T> 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 @@
G1ParScanClosure* scanner() { return &_scanner; }
- template <class T> void do_oop_nv(T* p) {
- do_oop_work(p);
- }
+ template <class T> 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); }
};
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp Fri Feb 21 10:19:09 2014 +0100
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp Mon Feb 24 09:40:21 2014 +0100
@@ -82,7 +82,7 @@
_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);
}
}
}