Print this page
rev 6909 : 8065361: Fixup headers and definitions for INCLUDE_TRACE
Reviewed-by: sla, stefank
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/hotspot/src/share/vm/trace/traceEvent.hpp
+++ new/hotspot/src/share/vm/trace/traceEvent.hpp
1 1 /*
2 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_TRACE_TRACEEVENT_HPP
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
26 26 #define SHARE_VM_TRACE_TRACEEVENT_HPP
27 27
28 28 #include "utilities/macros.hpp"
29 29
30 30 enum EventStartTime {
31 31 UNTIMED,
32 32 TIMED
33 33 };
34 34
35 35 #if INCLUDE_TRACE
36 -
37 36 #include "trace/traceBackend.hpp"
38 37 #include "trace/tracing.hpp"
39 38 #include "tracefiles/traceEventIds.hpp"
40 39 #include "tracefiles/traceTypes.hpp"
41 40 #include "utilities/ticks.hpp"
42 41
43 42 template<typename T>
44 43 class TraceEvent : public StackObj {
45 44 private:
46 45 bool _started;
47 46 #ifdef ASSERT
48 47 bool _committed;
49 48 bool _cancelled;
50 49 protected:
51 50 bool _ignore_check;
52 51 #endif
53 52
54 53 protected:
55 54 jlong _startTime;
56 55 jlong _endTime;
57 56
58 57 void set_starttime(const TracingTime& time) {
59 58 _startTime = time;
60 59 }
61 60
62 61 void set_endtime(const TracingTime& time) {
63 62 _endTime = time;
64 63 }
65 64
66 65 public:
67 66 TraceEvent(EventStartTime timing=TIMED) :
68 67 _startTime(0),
69 68 _endTime(0),
70 69 _started(false)
71 70 #ifdef ASSERT
72 71 ,
73 72 _committed(false),
74 73 _cancelled(false),
75 74 _ignore_check(false)
76 75 #endif
77 76 {
78 77 if (T::is_enabled()) {
79 78 _started = true;
80 79 if (timing == TIMED && !T::isInstant) {
81 80 static_cast<T *>(this)->set_starttime(Tracing::time());
82 81 }
83 82 }
84 83 }
85 84
86 85 static bool is_enabled() {
87 86 return Tracing::is_event_enabled(T::eventId);
88 87 }
89 88
90 89 bool should_commit() {
91 90 return _started;
92 91 }
93 92
94 93 void ignoreCheck() {
95 94 DEBUG_ONLY(_ignore_check = true);
96 95 }
97 96
98 97 void commit() {
99 98 if (!should_commit()) {
100 99 cancel();
101 100 return;
102 101 }
103 102 if (_endTime == 0) {
104 103 static_cast<T*>(this)->set_endtime(Tracing::time());
105 104 }
106 105 if (static_cast<T*>(this)->should_write()) {
107 106 static_cast<T*>(this)->writeEvent();
108 107 }
109 108 set_commited();
110 109 }
111 110
112 111 void set_starttime(const Ticks& time) {
113 112 _startTime = time.value();
114 113 }
115 114
116 115 void set_endtime(const Ticks& time) {
117 116 _endTime = time.value();
118 117 }
119 118
120 119 TraceEventId id() const {
121 120 return T::eventId;
122 121 }
123 122
124 123 bool is_instant() const {
125 124 return T::isInstant;
126 125 }
127 126
128 127 bool is_requestable() const {
129 128 return T::isRequestable;
130 129 }
131 130
132 131 bool has_thread() const {
133 132 return T::hasThread;
134 133 }
135 134
136 135 bool has_stacktrace() const {
137 136 return T::hasStackTrace;
138 137 }
139 138
140 139 void cancel() {
141 140 assert(!_committed && !_cancelled, "event was already committed/cancelled");
142 141 DEBUG_ONLY(_cancelled = true);
143 142 }
144 143
145 144 void set_commited() {
146 145 assert(!_committed, "event has already been committed");
↓ open down ↓ |
100 lines elided |
↑ open up ↑ |
147 146 DEBUG_ONLY(_committed = true);
148 147 }
149 148
150 149 ~TraceEvent() {
151 150 if (_started) {
152 151 assert(_ignore_check || _committed || _cancelled, "event was not committed/cancelled");
153 152 }
154 153 }
155 154 };
156 155
157 -#endif /* INCLUDE_TRACE */
158 -
159 -#endif /* SHARE_VM_TRACE_TRACEEVENT_HPP */
156 +#endif // INCLUDE_TRACE
157 +#endif // SHARE_VM_TRACE_TRACEEVENT_HPP
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX