# HG changeset patch # User mgronlun # Date 1418826453 -3600 # Node ID 55d4ccd95c6a7c3f0c76b09d7dad8dc4a0cce53f # Parent 47ffd05828f99d4e24e587d4d32027d5f3027f13 8066814: Reduce accessibility in TraceEvent Reviewed-by: diff --git a/src/share/vm/trace/traceEvent.hpp b/src/share/vm/trace/traceEvent.hpp --- a/src/share/vm/trace/traceEvent.hpp +++ b/src/share/vm/trace/traceEvent.hpp @@ -62,7 +62,6 @@ _endTime = time; } - public: TraceEvent(EventStartTime timing=TIMED) : _startTime(0), _endTime(0), @@ -77,37 +76,16 @@ if (T::is_enabled()) { _started = true; if (timing == TIMED && !T::isInstant) { - static_cast(this)->set_starttime(Tracing::time()); + static_cast(this)->set_starttime(Tracing::time()); } } } + public: static bool is_enabled() { return Tracing::is_event_enabled(T::eventId); } - bool should_commit() { - return _started; - } - - void ignoreCheck() { - DEBUG_ONLY(_ignore_check = true); - } - - void commit() { - if (!should_commit()) { - cancel(); - return; - } - if (_endTime == 0) { - static_cast(this)->set_endtime(Tracing::time()); - } - if (static_cast(this)->should_write()) { - static_cast(this)->writeEvent(); - } - set_commited(); - } - void set_starttime(const Ticks& time) { _startTime = time.value(); } @@ -116,24 +94,23 @@ _endTime = time.value(); } - TraceEventId id() const { - return T::eventId; + bool should_commit() { + return _started; } - bool is_instant() const { - return T::isInstant; - } - - bool is_requestable() const { - return T::isRequestable; - } - - bool has_thread() const { - return T::hasThread; - } - - bool has_stacktrace() const { - return T::hasStackTrace; + void commit() { + if (!should_commit()) { + DEBUG_ONLY(cancel()); + return; + } + assert(!_cancelled, "Committing an event that has already been cancelled"); + if (_endTime == 0) { + static_cast(this)->set_endtime(Tracing::time()); + } + if (static_cast(this)->should_write()) { + static_cast(this)->writeEvent(); + } + DEBUG_ONLY(set_commited()); } void cancel() { @@ -141,9 +118,20 @@ DEBUG_ONLY(_cancelled = true); } - void set_commited() { - assert(!_committed, "event has already been committed"); - DEBUG_ONLY(_committed = true); + static bool is_instant() { + return T::isInstant; + } + + static bool is_requestable() { + return T::isRequestable; + } + + static bool has_thread() { + return T::hasThread; + } + + static bool has_stacktrace() { + return T::hasStackTrace; } ~TraceEvent() { @@ -151,6 +139,21 @@ 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 diff --git a/src/share/vm/trace/traceEventClasses.xsl b/src/share/vm/trace/traceEventClasses.xsl --- a/src/share/vm/trace/traceEventClasses.xsl +++ b/src/share/vm/trace/traceEventClasses.xsl @@ -53,11 +53,12 @@ class TraceEvent { public: TraceEvent() {} - void set_starttime(const Ticks& time) {} - void set_endtime(const Ticks& time) {} + void set_starttime(const Ticks& ignore) {} + void set_endtime(const Ticks& ignore) {} bool should_commit() const { return false; } static bool is_enabled() { return false; } - void commit() const {} + void commit() {} + void cancel() {} };