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