8214972: Uses of klass_holder() except GC need to apply GC barriers
Summary: Fix klass_holder() and make all callers use it, remove holder_phantom().
Reviewed-by: eosterlund, dlong
--- a/src/hotspot/share/ci/ciInstanceKlass.cpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/ci/ciInstanceKlass.cpp Fri Dec 07 14:48:35 2018 -0500
@@ -72,7 +72,7 @@
// by the GC but need to be strong roots if reachable from a current compilation.
// InstanceKlass are created for both weak and strong metadata. Ensuring this metadata
// alive covers the cases where there are weak roots without performance cost.
- oop holder = ik->holder_phantom();
+ oop holder = ik->klass_holder();
if (ik->is_unsafe_anonymous()) {
// Though ciInstanceKlass records class loader oop, it's not enough to keep
// VM unsafe anonymous classes alive (loader == NULL). Klass holder should
--- a/src/hotspot/share/classfile/classLoaderData.hpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/classfile/classLoaderData.hpp Fri Dec 07 14:48:35 2018 -0500
@@ -176,12 +176,12 @@
void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
bool has_accumulated_modified_oops() { return _accumulated_modified_oops; }
oop holder_no_keepalive() const;
+ oop holder_phantom() const;
private:
void unload();
bool keep_alive() const { return _keep_alive > 0; }
- oop holder_phantom() const;
void classes_do(void f(Klass* const));
void loaded_classes_do(KlassClosure* klass_closure);
void classes_do(void f(InstanceKlass*));
--- a/src/hotspot/share/gc/g1/g1FullGCMarker.inline.hpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/gc/g1/g1FullGCMarker.inline.hpp Fri Dec 07 14:48:35 2018 -0500
@@ -165,7 +165,7 @@
}
inline void G1FullGCMarker::follow_klass(Klass* k) {
- oop op = k->klass_holder();
+ oop op = k->class_loader_data()->holder_no_keepalive();
mark_and_push(&op);
}
--- a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp Fri Dec 07 14:48:35 2018 -0500
@@ -117,7 +117,7 @@
}
inline void ParCompactionManager::follow_klass(Klass* klass) {
- oop holder = klass->klass_holder();
+ oop holder = klass->class_loader_data()->holder_no_keepalive();
mark_and_push(&holder);
}
--- a/src/hotspot/share/gc/serial/markSweep.inline.hpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/gc/serial/markSweep.inline.hpp Fri Dec 07 14:48:35 2018 -0500
@@ -57,7 +57,7 @@
}
inline void MarkSweep::follow_klass(Klass* klass) {
- oop op = klass->klass_holder();
+ oop op = klass->class_loader_data()->holder_no_keepalive();
MarkSweep::mark_and_push(&op);
}
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Fri Dec 07 14:48:35 2018 -0500
@@ -49,14 +49,14 @@
_thread = thread;
_klass = klass;
if (klass != NULL) {
- _holder = Handle(_thread, klass->holder_phantom());
+ _holder = Handle(_thread, klass->klass_holder());
}
}
JVMCIKlassHandle& JVMCIKlassHandle::operator=(Klass* klass) {
_klass = klass;
if (klass != NULL) {
- _holder = Handle(_thread, klass->holder_phantom());
+ _holder = Handle(_thread, klass->klass_holder());
}
return *this;
}
--- a/src/hotspot/share/oops/instanceKlass.hpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/oops/instanceKlass.hpp Fri Dec 07 14:48:35 2018 -0500
@@ -678,12 +678,6 @@
}
}
- // Oop that keeps the metadata for this class from being unloaded
- // in places where the metadata is stored in other places, like nmethods
- oop klass_holder() const {
- return (is_unsafe_anonymous()) ? java_mirror() : class_loader();
- }
-
bool is_contended() const {
return (_misc_flags & _misc_is_contended) != 0;
}
--- a/src/hotspot/share/oops/klass.cpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/oops/klass.cpp Fri Dec 07 14:48:35 2018 -0500
@@ -467,10 +467,6 @@
}
}
-oop Klass::holder_phantom() const {
- return class_loader_data()->holder_phantom();
-}
-
void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses) {
if (!ClassUnloading || !unloading_occurred) {
return;
--- a/src/hotspot/share/oops/klass.hpp Fri Dec 07 13:59:19 2018 -0500
+++ b/src/hotspot/share/oops/klass.hpp Fri Dec 07 14:48:35 2018 -0500
@@ -500,7 +500,11 @@
oop class_loader() const;
- virtual oop klass_holder() const { return class_loader(); }
+ // This loads the klass's holder as a phantom. This is useful when a weak Klass
+ // pointer has been "peeked" and then must be kept alive before it may
+ // be used safely. All uses of klass_holder need to apply the appropriate barriers,
+ // except during GC.
+ oop klass_holder() const { return class_loader_data()->holder_phantom(); }
protected:
virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
@@ -655,11 +659,6 @@
// unloading, and hence during concurrent class unloading.
bool is_loader_alive() const { return class_loader_data()->is_alive(); }
- // Load the klass's holder as a phantom. This is useful when a weak Klass
- // pointer has been "peeked" and then must be kept alive before it may
- // be used safely.
- oop holder_phantom() const;
-
void clean_subklass();
static void clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses = true);