8209843: Optimize oop scan closure closures wrt to reference processing in G1
Summary: Set more appropriate reference iteration mode for G1 closures.
Reviewed-by: kbarrett, pliden
--- a/src/hotspot/share/gc/g1/g1OopClosures.hpp Wed Sep 12 09:12:42 2018 +0100
+++ b/src/hotspot/share/gc/g1/g1OopClosures.hpp Wed Sep 12 11:08:42 2018 +0200
@@ -54,8 +54,8 @@
template <class T>
inline void handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj);
public:
- // This closure needs special handling for InstanceRefKlass.
- virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+ virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
+
void set_region(HeapRegion* from) { _from = from; }
inline void trim_queue_partially();
@@ -98,6 +98,9 @@
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ // We need to do reference discovery while processing evacuated objects.
+ virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+
void set_ref_discoverer(ReferenceDiscoverer* rd) {
set_ref_discoverer_internal(rd);
}
@@ -201,8 +204,7 @@
_worker_i(worker_i) {
}
- // This closure needs special handling for InstanceRefKlass.
- virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+ virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
template <class T> void do_oop_work(T* p);
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
@@ -219,8 +221,8 @@
template <class T> void do_oop_work(T* p);
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
- // This closure needs special handling for InstanceRefKlass.
- virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+
+ virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
};
#endif // SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
--- a/src/hotspot/share/oops/instanceRefKlass.inline.hpp Wed Sep 12 09:12:42 2018 +0100
+++ b/src/hotspot/share/oops/instanceRefKlass.inline.hpp Wed Sep 12 11:08:42 2018 +0200
@@ -98,12 +98,14 @@
template <typename T, class OopClosureType, class Contains>
void InstanceRefKlass::oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains) {
+ assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
do_referent<T>(obj, closure, contains);
do_discovered<T>(obj, closure, contains);
}
template <typename T, class OopClosureType, class Contains>
void InstanceRefKlass::oop_oop_iterate_fields_except_referent(oop obj, OopClosureType* closure, Contains& contains) {
+ assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
do_discovered<T>(obj, closure, contains);
}