8211447: Replace oop_pc_update_pointers with oop_iterate and closure
Reviewed-by: sjohanss, tschatzl
--- a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -156,7 +156,10 @@
}
inline void ParCompactionManager::update_contents(oop obj) {
- obj->pc_update_contents(this);
+ if (!obj->klass()->is_typeArray_klass()) {
+ PCAdjustPointerClosure apc(this);
+ obj->oop_iterate(&apc);
+ }
}
inline void ParCompactionManager::follow_class_loader(ClassLoaderData* cld) {
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp Fri Oct 12 12:14:01 2018 +0200
@@ -2203,7 +2203,7 @@
// Need new claim bits when tracing through and adjusting pointers.
ClassLoaderDataGraph::clear_claimed_marks();
- PSParallelCompact::AdjustPointerClosure oop_closure(cm);
+ PCAdjustPointerClosure oop_closure(cm);
// General strong roots.
Universe::oops_do(&oop_closure);
@@ -3096,76 +3096,6 @@
update_state(words);
}
-void InstanceKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
- PSParallelCompact::AdjustPointerClosure closure(cm);
- if (UseCompressedOops) {
- oop_oop_iterate_oop_maps<narrowOop>(obj, &closure);
- } else {
- oop_oop_iterate_oop_maps<oop>(obj, &closure);
- }
-}
-
-void InstanceMirrorKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
- InstanceKlass::oop_pc_update_pointers(obj, cm);
-
- PSParallelCompact::AdjustPointerClosure closure(cm);
- if (UseCompressedOops) {
- oop_oop_iterate_statics<narrowOop>(obj, &closure);
- } else {
- oop_oop_iterate_statics<oop>(obj, &closure);
- }
-}
-
-void InstanceClassLoaderKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
- InstanceKlass::oop_pc_update_pointers(obj, cm);
-}
-
-#ifdef ASSERT
-template <class T> static void trace_reference_gc(const char *s, oop obj,
- T* referent_addr,
- T* discovered_addr) {
- log_develop_trace(gc, ref)("%s obj " PTR_FORMAT, s, p2i(obj));
- log_develop_trace(gc, ref)(" referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
- p2i(referent_addr), referent_addr ? p2i((oop)RawAccess<>::oop_load(referent_addr)) : NULL);
- log_develop_trace(gc, ref)(" discovered_addr/* " PTR_FORMAT " / " PTR_FORMAT,
- p2i(discovered_addr), discovered_addr ? p2i((oop)RawAccess<>::oop_load(discovered_addr)) : NULL);
-}
-#endif
-
-template <class T>
-static void oop_pc_update_pointers_specialized(oop obj, ParCompactionManager* cm) {
- T* referent_addr = (T*)java_lang_ref_Reference::referent_addr_raw(obj);
- PSParallelCompact::adjust_pointer(referent_addr, cm);
- T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr_raw(obj);
- PSParallelCompact::adjust_pointer(discovered_addr, cm);
- debug_only(trace_reference_gc("InstanceRefKlass::oop_update_ptrs", obj,
- referent_addr, discovered_addr);)
-}
-
-void InstanceRefKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
- InstanceKlass::oop_pc_update_pointers(obj, cm);
-
- if (UseCompressedOops) {
- oop_pc_update_pointers_specialized<narrowOop>(obj, cm);
- } else {
- oop_pc_update_pointers_specialized<oop>(obj, cm);
- }
-}
-
-void ObjArrayKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
- assert(obj->is_objArray(), "obj must be obj array");
- PSParallelCompact::AdjustPointerClosure closure(cm);
- if (UseCompressedOops) {
- oop_oop_iterate_elements<narrowOop>(objArrayOop(obj), &closure);
- } else {
- oop_oop_iterate_elements<oop>(objArrayOop(obj), &closure);
- }
-}
-
-void TypeArrayKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
- assert(obj->is_typeArray(),"must be a type array");
-}
-
ParMarkBitMapClosure::IterationStatus
MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
assert(destination() != NULL, "sanity");
--- a/src/hotspot/share/gc/parallel/psParallelCompact.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -934,23 +934,6 @@
virtual bool do_object_b(oop p);
};
- class AdjustPointerClosure: public BasicOopIterateClosure {
- public:
- AdjustPointerClosure(ParCompactionManager* cm) {
- assert(cm != NULL, "associate ParCompactionManage should not be NULL");
- _cm = cm;
- }
- template <typename T> void do_oop_work(T* p);
- virtual void do_oop(oop* p);
- virtual void do_oop(narrowOop* p);
-
- // This closure provides its own oop verification code.
- debug_only(virtual bool should_verify_oops() { return false; })
- private:
- ParCompactionManager* _cm;
- };
-
- friend class AdjustPointerClosure;
friend class RefProcTaskProxy;
friend class PSParallelCompactTest;
--- a/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -124,12 +124,21 @@
}
}
-template <typename T>
-void PSParallelCompact::AdjustPointerClosure::do_oop_work(T* p) {
- adjust_pointer(p, _cm);
-}
+class PCAdjustPointerClosure: public BasicOopIterateClosure {
+public:
+ PCAdjustPointerClosure(ParCompactionManager* cm) {
+ assert(cm != NULL, "associate ParCompactionManage should not be NULL");
+ _cm = cm;
+ }
+ template <typename T> void do_oop_nv(T* p) { PSParallelCompact::adjust_pointer(p, _cm); }
+ virtual void do_oop(oop* p) { do_oop_nv(p); }
+ virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
-inline void PSParallelCompact::AdjustPointerClosure::do_oop(oop* p) { do_oop_work(p); }
-inline void PSParallelCompact::AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
+ // This closure provides its own oop verification code.
+ debug_only(virtual bool should_verify_oops() { return false; })
+ virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
+private:
+ ParCompactionManager* _cm;
+};
#endif // SHARE_VM_GC_PARALLEL_PSPARALLELCOMPACT_INLINE_HPP
--- a/src/hotspot/share/oops/instanceClassLoaderKlass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/instanceClassLoaderKlass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -33,7 +33,7 @@
// An InstanceClassLoaderKlass is a specialization of the InstanceKlass. It does
// not add any field. It is added to walk the dependencies for the class loader
// key that this class loader points to. This is how the loader_data graph is
-// walked and dependant class loaders are kept alive. I thought we walked
+// walked and dependent class loaders are kept alive. I thought we walked
// the list later?
class InstanceClassLoaderKlass: public InstanceKlass {
@@ -48,18 +48,10 @@
public:
InstanceClassLoaderKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
- // GC specific object visitors
- //
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
// Oop fields (and metadata) iterators
//
// The InstanceClassLoaderKlass iterators also visit the CLD pointer (or mirror of anonymous klasses.)
- public:
// Forward iteration
// Iterate over the oop fields and metadata.
template <typename T, class OopClosureType>
--- a/src/hotspot/share/oops/instanceKlass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/instanceKlass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -1183,13 +1183,6 @@
const char* signature_name() const;
static Symbol* package_from_name(const Symbol* name, TRAPS);
- // GC specific object visitors
- //
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
// Oop fields (and metadata) iterators
//
// The InstanceKlass iterators also visits the Object's klass.
--- a/src/hotspot/share/oops/instanceMirrorKlass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/instanceMirrorKlass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -89,13 +89,6 @@
// allocation
instanceOop allocate_instance(Klass* k, TRAPS);
- // GC specific object visitors
- //
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
static void serialize_offsets(class SerializeClosure* f) NOT_CDS_RETURN;
// Oop fields (and metadata) iterators
--- a/src/hotspot/share/oops/instanceRefKlass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/instanceRefKlass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -58,13 +58,6 @@
public:
InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
- // GC specific object visitors
- //
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
// Oop fields (and metadata) iterators
//
// The InstanceRefKlass iterators also support reference processing.
--- a/src/hotspot/share/oops/klass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/klass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -673,13 +673,6 @@
clean_weak_klass_links(/*unloading_occurred*/ true , /* clean_alive_klasses */ false);
}
- // GC specific object visitors
- //
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- virtual void oop_pc_update_pointers(oop obj, ParCompactionManager* cm) = 0;
-#endif
-
virtual void array_klasses_do(void f(Klass* k)) {}
// Return self, except for abstract classes with exactly 1
--- a/src/hotspot/share/oops/objArrayKlass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/objArrayKlass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -120,13 +120,6 @@
// Initialization (virtual from Klass)
void initialize(TRAPS);
- // GC specific object visitors
- //
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
// Oop fields (and metadata) iterators
//
// The ObjArrayKlass iterators also visits the Object's klass.
--- a/src/hotspot/share/oops/oop.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/oop.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -285,13 +285,6 @@
// mark-sweep support
void follow_body(int begin, int end);
- // Garbage Collection support
-
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- inline void pc_update_contents(ParCompactionManager* cm);
-#endif
-
template <typename OopClosureType>
inline void oop_iterate(OopClosureType* cl);
--- a/src/hotspot/share/oops/oop.inline.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/oop.inline.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -426,18 +426,6 @@
}
}
-#if INCLUDE_PARALLELGC
-
-void oopDesc::pc_update_contents(ParCompactionManager* cm) {
- Klass* k = klass();
- if (!k->is_typeArray_klass()) {
- // It might contain oops beyond the header, so take the virtual call.
- k->oop_pc_update_pointers(this, cm);
- }
- // Else skip it. The TypeArrayKlass in the header never needs scavenging.
-}
-#endif // INCLUDE_PARALLELGC
-
template <typename OopClosureType>
void oopDesc::oop_iterate(OopClosureType* cl) {
OopIteratorClosureDispatch::oop_oop_iterate(cl, this, klass());
--- a/src/hotspot/share/oops/typeArrayKlass.hpp Fri Oct 12 12:13:06 2018 +0200
+++ b/src/hotspot/share/oops/typeArrayKlass.hpp Fri Oct 12 12:14:01 2018 +0200
@@ -74,14 +74,6 @@
// Copying
void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
- // GC specific object visitors
- //
-
-#if INCLUDE_PARALLELGC
- // Parallel Compact
- void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
// Oop iterators. Since there are no oops in TypeArrayKlasses,
// these functions only return the size of the object.