diff src/share/vm/trace/traceEvent.hpp @ 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 56fbd5c60c96
children
line wrap: on
line diff
--- 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