8159666: Better CDS support for Event-based tracing
authoriklam
Mon, 20 Jun 2016 22:02:20 -0700
changeset 39400 daf3af35d6bf
parent 39399 9f8d0683c90f
child 39401 318e93828de1
8159666: Better CDS support for Event-based tracing Reviewed-by: jiangli, mgronlun
hotspot/src/share/vm/oops/instanceKlass.cpp
hotspot/src/share/vm/oops/klass.cpp
hotspot/src/share/vm/trace/traceMacros.hpp
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Jun 20 17:38:14 2016 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Jun 20 22:02:20 2016 -0700
@@ -1961,6 +1961,11 @@
     m->remove_unshareable_info();
   }
 
+  // cached_class_file might be pointing to a malloc'ed buffer allocated by
+  // event-based tracing code at CDS dump time. It's not usable at runtime
+  // so let's clear it.
+  set_cached_class_file(NULL);
+
   // do array classes also.
   array_klasses_do(remove_unshareable_in_class);
 }
--- a/hotspot/src/share/vm/oops/klass.cpp	Mon Jun 20 17:38:14 2016 +0000
+++ b/hotspot/src/share/vm/oops/klass.cpp	Mon Jun 20 22:02:20 2016 -0700
@@ -482,6 +482,7 @@
 
 void Klass::remove_unshareable_info() {
   assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
+  TRACE_REMOVE_KLASS_ID(this);
 
   set_subklass(NULL);
   set_next_sibling(NULL);
@@ -494,7 +495,8 @@
 }
 
 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
-  TRACE_INIT_KLASS_ID(this);
+  TRACE_RESTORE_KLASS_ID(this);
+
   // If an exception happened during CDS restore, some of these fields may already be
   // set.  We leave the class on the CLD list, even if incomplete so that we don't
   // modify the CLD list outside a safepoint.
--- a/hotspot/src/share/vm/trace/traceMacros.hpp	Mon Jun 20 17:38:14 2016 +0000
+++ b/hotspot/src/share/vm/trace/traceMacros.hpp	Mon Jun 20 22:02:20 2016 -0700
@@ -33,6 +33,9 @@
 #define TRACE_KLASS_DEFINITION(k, t)
 
 #define TRACE_INIT_KLASS_ID(k)
+#define TRACE_REMOVE_KLASS_ID(k)
+#define TRACE_RESTORE_KLASS_ID(k)
+
 #define TRACE_INIT_MODULE_ID(m)
 #define TRACE_INIT_PACKAGE_ID(p)
 #define TRACE_INIT_THREAD_ID(td)