8038332: The trace event vm/class/load is not always being sent
authormockner
Mon, 25 Jul 2016 09:40:31 -0400
changeset 40002 156b2dbb0b54
parent 40001 f37246e66d2b
child 40004 00f34743c49b
child 40008 1a7a8d6fdfc0
8038332: The trace event vm/class/load is not always being sent Summary: Added trace event vm/class/define Reviewed-by: coleenp, egahlin, acorn
hotspot/src/share/vm/classfile/systemDictionary.cpp
hotspot/src/share/vm/trace/traceevents.xml
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Fri Jul 22 10:15:42 2016 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Jul 25 09:40:31 2016 -0400
@@ -655,6 +655,21 @@
 #endif // INCLUDE_TRACE
 }
 
+// utility function for class define event
+static void class_define_event(instanceKlassHandle k) {
+#if INCLUDE_TRACE
+  EventClassDefine event(UNTIMED);
+  if (event.should_commit()) {
+    event.set_definedClass(k());
+    oop defining_class_loader = k->class_loader();
+    event.set_definingClassLoader(defining_class_loader != NULL ?
+      defining_class_loader->klass() : (Klass*)NULL);
+    event.commit();
+  }
+#endif // INCLUDE_TRACE
+}
+
+
 Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
                                                         Handle class_loader,
                                                         Handle protection_domain,
@@ -1675,9 +1690,8 @@
       JvmtiExport::post_class_load((JavaThread *) THREAD, k());
 
   }
-
   TRACE_KLASS_DEFINITION(k, THREAD);
-
+  class_define_event(k);
 }
 
 // Support parallel classloading
--- a/hotspot/src/share/vm/trace/traceevents.xml	Fri Jul 22 10:15:42 2016 -0700
+++ b/hotspot/src/share/vm/trace/traceevents.xml	Mon Jul 25 09:40:31 2016 -0400
@@ -116,6 +116,12 @@
     <value type="CLASS" field="initiatingClassLoader" label="Initiating Class Loader"/>
   </event>
 
+  <event id="ClassDefine" path="vm/class/define" label="Class Define"
+          has_thread="true" has_stacktrace="true" is_instant="true">
+    <value type="CLASS" field="definedClass" label="Defined Class"/>
+    <value type="CLASS" field="definingClassLoader" label="Defining Class Loader"/>
+  </event>
+
   <event id="ClassUnload" path="vm/class/unload" label="Class Unload"
       has_thread="true" is_instant="true">
     <value type="CLASS" field="unloadedClass" label="Unloaded Class"/>