changeset 13616:ecebbbda267a

8179040: Avoid Ticks::now calls when EventClassLoad is not enabled Reviewed-by: ehelin, mgronlun, dholmes, iklam Contributed-by: claes.redestad@oracle.com, markus.gronlund@oracle.com
author redestad
date Mon, 28 Aug 2017 00:20:35 +0200
parents 18bf814595b9
children d8861a784135
files src/share/vm/classfile/systemDictionary.cpp src/share/vm/runtime/synchronizer.cpp src/share/vm/trace/traceDataTypes.hpp src/share/vm/trace/traceEvent.hpp src/share/vm/trace/traceEventClasses.xsl src/share/vm/trace/traceTypes.xsl
diffstat 6 files changed, 31 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/systemDictionary.cpp	Mon Aug 28 02:55:31 2017 -0700
+++ b/src/share/vm/classfile/systemDictionary.cpp	Mon Aug 28 00:20:35 2017 +0200
@@ -77,9 +77,8 @@
 #include "services/classLoadingService.hpp"
 #include "services/diagnosticCommand.hpp"
 #include "services/threadService.hpp"
-#include "trace/traceMacros.hpp"
+#include "trace/tracing.hpp"
 #include "utilities/macros.hpp"
-#include "utilities/ticks.hpp"
 #if INCLUDE_CDS
 #include "classfile/sharedClassUtil.hpp"
 #include "classfile/systemDictionaryShared.hpp"
@@ -87,9 +86,6 @@
 #if INCLUDE_JVMCI
 #include "jvmci/jvmciRuntime.hpp"
 #endif
-#if INCLUDE_TRACE
-#include "trace/tracing.hpp"
-#endif
 
 PlaceholderTable*      SystemDictionary::_placeholders        = NULL;
 Dictionary*            SystemDictionary::_shared_dictionary   = NULL;
@@ -615,17 +611,17 @@
   return NULL;
 }
 
-static void post_class_load_event(const Ticks& start_time,
-                                  InstanceKlass* k,
+static void post_class_load_event(EventClassLoad* event,
+                                  const InstanceKlass* k,
                                   const ClassLoaderData* init_cld) {
 #if INCLUDE_TRACE
-  EventClassLoad event(UNTIMED);
-  if (event.should_commit()) {
-    event.set_starttime(start_time);
-    event.set_loadedClass(k);
-    event.set_definingClassLoader(k->class_loader_data());
-    event.set_initiatingClassLoader(init_cld);
-    event.commit();
+  assert(event != NULL, "invariant");
+  assert(k != NULL, "invariant");
+  if (event->should_commit()) {
+    event->set_loadedClass(k);
+    event->set_definingClassLoader(k->class_loader_data());
+    event->set_initiatingClassLoader(init_cld);
+    event->commit();
   }
 #endif // INCLUDE_TRACE
 }
@@ -653,7 +649,7 @@
   assert(name != NULL && !FieldType::is_array(name) &&
          !FieldType::is_obj(name), "invalid class name");
 
-  Ticks class_load_start_time = Ticks::now();
+  EventClassLoad class_load_start_event;
 
   HandleMark hm(THREAD);
 
@@ -899,7 +895,7 @@
     return NULL;
   }
 
-  post_class_load_event(class_load_start_time, k, loader_data);
+  post_class_load_event(&class_load_start_event, k, loader_data);
 
 #ifdef ASSERT
   {
@@ -1006,7 +1002,7 @@
                                               GrowableArray<Handle>* cp_patches,
                                               TRAPS) {
 
-  Ticks class_load_start_time = Ticks::now();
+  EventClassLoad class_load_start_event;
 
   ClassLoaderData* loader_data;
   if (host_klass != NULL) {
@@ -1064,7 +1060,7 @@
         JvmtiExport::post_class_load((JavaThread *) THREAD, k);
     }
 
-    post_class_load_event(class_load_start_time, k, loader_data);
+    post_class_load_event(&class_load_start_event, k, loader_data);
   }
   assert(host_klass != NULL || NULL == cp_patches,
          "cp_patches only found with host_klass");
--- a/src/share/vm/runtime/synchronizer.cpp	Mon Aug 28 02:55:31 2017 -0700
+++ b/src/share/vm/runtime/synchronizer.cpp	Mon Aug 28 00:20:35 2017 +0200
@@ -1407,7 +1407,6 @@
       assert(inf->header()->is_neutral(), "invariant");
       assert(inf->object() == object, "invariant");
       assert(ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid");
-      event.cancel(); // let's not post an inflation event, unless we did the deed ourselves
       return inf;
     }
 
--- a/src/share/vm/trace/traceDataTypes.hpp	Mon Aug 28 02:55:31 2017 -0700
+++ b/src/share/vm/trace/traceDataTypes.hpp	Mon Aug 28 00:20:35 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -28,6 +28,7 @@
 #include <stddef.h>
 
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/ticks.hpp"
 
 enum {
   CONTENT_TYPE_NONE             = 0,
@@ -54,10 +55,11 @@
   NUM_RESERVED_EVENTS = JVM_CONTENT_TYPES_END
 };
 
-typedef enum ReservedEvent ReservedEvent;
-
 typedef u8 traceid;
 
+class ClassLoaderData;
+class Klass;
+class Method;
 class ModuleEntry;
 class PackageEntry;
 class Symbol;
--- a/src/share/vm/trace/traceEvent.hpp	Mon Aug 28 02:55:31 2017 -0700
+++ b/src/share/vm/trace/traceEvent.hpp	Mon Aug 28 00:20:35 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -25,6 +25,7 @@
 #ifndef SHARE_VM_TRACE_TRACEEVENT_HPP
 #define SHARE_VM_TRACE_TRACEEVENT_HPP
 
+#include "trace/traceTime.hpp"
 #include "utilities/macros.hpp"
 
 enum EventStartTime {
@@ -34,25 +35,18 @@
 
 #if INCLUDE_TRACE
 #include "trace/traceBackend.hpp"
-#include "trace/tracing.hpp"
 #include "tracefiles/traceEventIds.hpp"
-#include "tracefiles/traceTypes.hpp"
 #include "utilities/ticks.hpp"
 
 template<typename T>
-class TraceEvent : public StackObj {
+class TraceEvent {
  private:
   bool _started;
-#ifdef ASSERT
-  bool _committed;
-  bool _cancelled;
- protected:
-  bool _ignore_check;
-#endif
 
  protected:
   jlong _startTime;
   jlong _endTime;
+  DEBUG_ONLY(bool _committed;)
 
   void set_starttime(const TracingTime& time) {
     _startTime = time;
@@ -67,10 +61,7 @@
     _endTime(0),
     _started(false)
 #ifdef ASSERT
-    ,
-    _committed(false),
-    _cancelled(false),
-    _ignore_check(false)
+    , _committed(false)
 #endif
   {
     if (T::is_enabled()) {
@@ -100,10 +91,9 @@
 
   void commit() {
     if (!should_commit()) {
-      DEBUG_ONLY(cancel());
       return;
     }
-    assert(!_cancelled, "Committing an event that has already been cancelled");
+    assert(!_committed, "event already committed");
     if (_startTime == 0) {
       static_cast<T*>(this)->set_starttime(Tracing::time());
     } else if (_endTime == 0) {
@@ -111,8 +101,8 @@
     }
     if (static_cast<T*>(this)->should_write()) {
       static_cast<T*>(this)->writeEvent();
+      DEBUG_ONLY(_committed = true;)
     }
-    DEBUG_ONLY(set_commited());
   }
 
   static TraceEventId id() {
@@ -134,32 +124,6 @@
   static bool has_stacktrace() {
     return T::hasStackTrace;
   }
-
-  void cancel() {
-    assert(!_committed && !_cancelled,
-      "event was already committed/cancelled");
-    DEBUG_ONLY(_cancelled = true);
-  }
-
-  ~TraceEvent() {
-    if (_started) {
-      assert(_ignore_check || _committed || _cancelled,
-        "event was not committed/cancelled");
-    }
-  }
-
-#ifdef ASSERT
- protected:
-  void ignoreCheck() {
-    _ignore_check = true;
-  }
-
- private:
-  void set_commited() {
-    assert(!_committed, "event has already been committed");
-    _committed = true;
-  }
-#endif // ASSERT
 };
 
 #endif // INCLUDE_TRACE
--- a/src/share/vm/trace/traceEventClasses.xsl	Mon Aug 28 02:55:31 2017 -0700
+++ b/src/share/vm/trace/traceEventClasses.xsl	Mon Aug 28 00:20:35 2017 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
- Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2012, 2017, 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
@@ -37,10 +37,10 @@
 // INCLUDE_TRACE
 
 #include "tracefiles/traceTypes.hpp"
+#include "utilities/macros.hpp"
+
+#if INCLUDE_TRACE
 #include "trace/traceEvent.hpp"
-#include "utilities/macros.hpp"
-#include "utilities/ticks.hpp"
-#if INCLUDE_TRACE
 #include "trace/traceStream.hpp"
 #include "utilities/ostream.hpp"
 
@@ -57,7 +57,6 @@
   bool should_commit() const { return false; }
   static bool is_enabled() { return false; }
   void commit() {}
-  void cancel() {}
 };
 
   <xsl:apply-templates select="trace/events/struct" mode="empty"/>
--- a/src/share/vm/trace/traceTypes.xsl	Mon Aug 28 02:55:31 2017 -0700
+++ b/src/share/vm/trace/traceTypes.xsl	Mon Aug 28 00:20:35 2017 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
- Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2012, 2017, 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
@@ -32,10 +32,7 @@
 #ifndef TRACEFILES_TRACETYPES_HPP
 #define TRACEFILES_TRACETYPES_HPP
 
-#include "oops/symbol.hpp"
 #include "trace/traceDataTypes.hpp"
-#include "utilities/globalDefinitions.hpp"
-#include "utilities/ticks.hpp"
 
 enum JVMContentType {
   _not_a_content_type = (JVM_CONTENT_TYPES_START - 1),