提交 234fc716 编写于 作者: S stefank

7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots

Summary: Fix the iteration over the system classes and report the correct reference kind.
Reviewed-by: coleenp, rbackman
上级 4275ef20
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
#include "memory/iterator.hpp" #include "memory/iterator.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
void KlassToOopClosure::do_klass(Klass* k) {
k->oops_do(_oop_closure);
}
void ObjectToOopClosure::do_object(oop obj) { void ObjectToOopClosure::do_object(oop obj) {
obj->oop_iterate(_cl); obj->oop_iterate(_cl);
} }
......
...@@ -128,6 +128,13 @@ class KlassClosure : public Closure { ...@@ -128,6 +128,13 @@ class KlassClosure : public Closure {
virtual void do_klass(Klass* k) = 0; virtual void do_klass(Klass* k) = 0;
}; };
class KlassToOopClosure : public KlassClosure {
OopClosure* _oop_closure;
public:
KlassToOopClosure(OopClosure* oop_closure) : _oop_closure(oop_closure) {}
virtual void do_klass(Klass* k);
};
// ObjectClosure is used for iterating through an object space // ObjectClosure is used for iterating through an object space
class ObjectClosure : public Closure { class ObjectClosure : public Closure {
......
...@@ -2552,15 +2552,17 @@ class SimpleRootsClosure : public OopClosure { ...@@ -2552,15 +2552,17 @@ class SimpleRootsClosure : public OopClosure {
return; return;
} }
jvmtiHeapReferenceKind kind = root_kind();
assert(Universe::heap()->is_in_reserved(o), "should be impossible"); assert(Universe::heap()->is_in_reserved(o), "should be impossible");
jvmtiHeapReferenceKind kind = root_kind();
if (kind == JVMTI_HEAP_REFERENCE_SYSTEM_CLASS) {
// SystemDictionary::always_strong_oops_do reports the application // SystemDictionary::always_strong_oops_do reports the application
// class loader as a root. We want this root to be reported as // class loader as a root. We want this root to be reported as
// a root kind of "OTHER" rather than "SYSTEM_CLASS". // a root kind of "OTHER" rather than "SYSTEM_CLASS".
if (o->is_instance() && root_kind() == JVMTI_HEAP_REFERENCE_SYSTEM_CLASS) { if (!o->is_instanceMirror()) {
kind = JVMTI_HEAP_REFERENCE_OTHER; kind = JVMTI_HEAP_REFERENCE_OTHER;
} }
}
// some objects are ignored - in the case of simple // some objects are ignored - in the case of simple
// roots it's mostly Symbol*s that we are skipping // roots it's mostly Symbol*s that we are skipping
...@@ -2991,7 +2993,8 @@ inline bool VM_HeapWalkOperation::collect_simple_roots() { ...@@ -2991,7 +2993,8 @@ inline bool VM_HeapWalkOperation::collect_simple_roots() {
// Preloaded classes and loader from the system dictionary // Preloaded classes and loader from the system dictionary
blk.set_kind(JVMTI_HEAP_REFERENCE_SYSTEM_CLASS); blk.set_kind(JVMTI_HEAP_REFERENCE_SYSTEM_CLASS);
SystemDictionary::always_strong_oops_do(&blk); SystemDictionary::always_strong_oops_do(&blk);
ClassLoaderDataGraph::always_strong_oops_do(&blk, NULL, false); KlassToOopClosure klass_blk(&blk);
ClassLoaderDataGraph::always_strong_oops_do(&blk, &klass_blk, false);
if (blk.stopped()) { if (blk.stopped()) {
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册