< prev index next >

src/share/vm/classfile/systemDictionary.cpp

Print this page
rev 8833 : 8064811: Use THEAD instead of CHECK_NULL in return statements
Summary: Backport from JDK9
Reviewed-by: dholmes, coffeys
rev 8856 : 8210094: Better loading of classloader classes
Reviewed-by: acorn, hseigel, ahgross, rhalade
rev 8876 : Merge
rev 8910 : full patch for jfr

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -992,19 +992,20 @@
   // already be present in the SystemDictionary, otherwise we would not
   // throw potential ClassFormatErrors.
   //
   // Note: "name" is updated.
 
-  instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name,
+  ClassFileParser parser(st);
+  instanceKlassHandle k = parser.parseClassFile(class_name,
                                                              loader_data,
                                                              protection_domain,
                                                              host_klass,
                                                              cp_patches,
                                                              parsed_name,
                                                              true,
                                                              THREAD);
-
+  TRACE_KLASS_CREATION(k, parser, THREAD);
 
   if (host_klass.not_null() && k.not_null()) {
     assert(EnableInvokeDynamic, "");
     // If it's anonymous, initialize it now, since nobody else will.
 

@@ -1074,16 +1075,18 @@
   // already be present in the SystemDictionary, otherwise we would not
   // throw potential ClassFormatErrors.
   //
   // Note: "name" is updated.
 
-  instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name,
+  ClassFileParser parser(st);
+  instanceKlassHandle k = parser.parseClassFile(class_name,
                                                              loader_data,
                                                              protection_domain,
                                                              parsed_name,
                                                              verify,
                                                              THREAD);
+  TRACE_KLASS_CREATION(k, parser, THREAD);
 
   const char* pkg = "java/";
   size_t pkglen = strlen(pkg);
   if (!HAS_PENDING_EXCEPTION &&
       !class_loader.is_null() &&

@@ -1374,10 +1377,23 @@
     // Class is not found or has the wrong name, return NULL
     return nh;
   }
 }
 
+static void class_define_event(InstanceKlass* k,
+                               const ClassLoaderData* def_cld) {
+#if INCLUDE_TRACE
+  EventClassDefine event;
+  if (event.should_commit()) {
+    ResourceMark m;
+    event.set_definedClass(k);
+    event.set_definingClassLoader(def_cld);
+    event.commit();
+  }
+#endif // INCLUDE_TRACE
+}
+
 void SystemDictionary::define_instance_class(instanceKlassHandle k, TRAPS) {
 
   ClassLoaderData* loader_data = k->class_loader_data();
   Handle class_loader_h(THREAD, loader_data->class_loader());
 

@@ -1444,10 +1460,11 @@
       assert(THREAD->is_Java_thread(), "thread->is_Java_thread()");
       JvmtiExport::post_class_load((JavaThread *) THREAD, k());
 
   }
 
+  class_define_event(k(), loader_data);
 }
 
 // Support parallel classloading
 // All parallel class loaders, including bootstrap classloader
 // lock a placeholder entry for this class/class_loader pair

@@ -2681,20 +2698,15 @@
 // utility function for class load event
 void SystemDictionary::post_class_load_event(const Ticks& start_time,
                                              instanceKlassHandle k,
                                              Handle initiating_loader) {
 #if INCLUDE_TRACE
-  EventClassLoad event(UNTIMED);
+  EventClassLoad event;
   if (event.should_commit()) {
-    event.set_starttime(start_time);
     event.set_loadedClass(k());
-    oop defining_class_loader = k->class_loader();
-    event.set_definingClassLoader(defining_class_loader !=  NULL ?
-                                    defining_class_loader->klass() : (Klass*)NULL);
-    oop class_loader = initiating_loader.is_null() ? (oop)NULL : initiating_loader();
-    event.set_initiatingClassLoader(class_loader != NULL ?
-                                      class_loader->klass() : (Klass*)NULL);
+    event.set_definingClassLoader(k->class_loader_data());
+    event.set_initiatingClassLoader(ClassLoaderData::class_loader_data_or_null(initiating_loader()));
     event.commit();
   }
 #endif // INCLUDE_TRACE
 }
 
< prev index next >