8214972: Uses of klass_holder() except GC need to apply GC barriers

Fix klass_holder() and make all callers use it, remove holder_phantom().

Reviewed-by: eosterlund, dlong
This commit is contained in:
Coleen Phillimore 2018-12-07 14:48:35 -05:00
parent 0a8c4491c2
commit 3d0faa649c
9 changed files with 12 additions and 23 deletions

View File

@ -72,7 +72,7 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) :
// 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

View File

@ -176,12 +176,12 @@ class ClassLoaderData : public CHeapObj<mtClass> {
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*));

View File

@ -165,7 +165,7 @@ void G1FullGCMarker::drain_stack() {
}
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);
}

View File

@ -117,7 +117,7 @@ inline void ParCompactionManager::mark_and_push(T* p) {
}
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);
}

View File

@ -57,7 +57,7 @@ template <class T> inline void MarkSweep::mark_and_push(T* p) {
}
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);
}

View File

@ -49,14 +49,14 @@ JVMCIKlassHandle::JVMCIKlassHandle(Thread* thread, Klass* klass) {
_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;
}

View File

@ -678,12 +678,6 @@ public:
}
}
// 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;
}

View File

@ -467,10 +467,6 @@ void Klass::clean_subklass() {
}
}
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;

View File

@ -500,7 +500,11 @@ protected:
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 @@ protected:
// 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);