Mercurial > hg > truffle
annotate src/share/vm/runtime/timer.cpp @ 6972:bd7a7ce2e264
6830717: replay of compilations would help with debugging
Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method.
Reviewed-by: kvn, twisti, sspitsyn
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 12 Nov 2012 14:03:53 -0800 |
parents | b9a9ed0f8eeb |
children | 0f80645e9c26 |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6752
diff
changeset
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "oops/oop.inline.hpp" | |
27 #include "runtime/timer.hpp" | |
28 #include "utilities/ostream.hpp" | |
29 #ifdef TARGET_OS_FAMILY_linux | |
30 # include "os_linux.inline.hpp" | |
31 #endif | |
32 #ifdef TARGET_OS_FAMILY_solaris | |
33 # include "os_solaris.inline.hpp" | |
34 #endif | |
35 #ifdef TARGET_OS_FAMILY_windows | |
36 # include "os_windows.inline.hpp" | |
37 #endif | |
3960 | 38 #ifdef TARGET_OS_FAMILY_bsd |
39 # include "os_bsd.inline.hpp" | |
40 #endif | |
0 | 41 |
42 | |
43 void elapsedTimer::add(elapsedTimer t) { | |
44 _counter += t._counter; | |
45 } | |
46 | |
47 void elapsedTimer::start() { | |
48 if (!_active) { | |
49 _active = true; | |
50 _start_counter = os::elapsed_counter(); | |
51 } | |
52 } | |
53 | |
54 void elapsedTimer::stop() { | |
55 if (_active) { | |
56 _counter += os::elapsed_counter() - _start_counter; | |
57 _active = false; | |
58 } | |
59 } | |
60 | |
61 double elapsedTimer::seconds() const { | |
62 double count = (double) _counter; | |
63 double freq = (double) os::elapsed_frequency(); | |
64 return count/freq; | |
65 } | |
66 | |
67 jlong elapsedTimer::milliseconds() const { | |
68 jlong ticks_per_ms = os::elapsed_frequency() / 1000; | |
69 return _counter / ticks_per_ms; | |
70 } | |
71 | |
72 jlong elapsedTimer::active_ticks() const { | |
73 if (!_active) { | |
74 return ticks(); | |
75 } | |
76 jlong counter = _counter + os::elapsed_counter() - _start_counter; | |
77 return counter; | |
78 } | |
79 | |
80 void TimeStamp::update_to(jlong ticks) { | |
81 _counter = ticks; | |
82 if (_counter == 0) _counter = 1; | |
83 assert(is_updated(), "must not look clear"); | |
84 } | |
85 | |
86 void TimeStamp::update() { | |
87 update_to(os::elapsed_counter()); | |
88 } | |
89 | |
90 double TimeStamp::seconds() const { | |
91 assert(is_updated(), "must not be clear"); | |
92 jlong new_count = os::elapsed_counter(); | |
93 double count = (double) new_count - _counter; | |
94 double freq = (double) os::elapsed_frequency(); | |
95 return count/freq; | |
96 } | |
97 | |
98 jlong TimeStamp::milliseconds() const { | |
99 assert(is_updated(), "must not be clear"); | |
100 | |
101 jlong new_count = os::elapsed_counter(); | |
102 jlong count = new_count - _counter; | |
103 jlong ticks_per_ms = os::elapsed_frequency() / 1000; | |
104 return count / ticks_per_ms; | |
105 } | |
106 | |
107 jlong TimeStamp::ticks_since_update() const { | |
108 assert(is_updated(), "must not be clear"); | |
109 return os::elapsed_counter() - _counter; | |
110 } | |
111 | |
112 TraceTime::TraceTime(const char* title, | |
113 bool doit, | |
114 bool print_cr, | |
115 outputStream* logfile) { | |
116 _active = doit; | |
117 _verbose = true; | |
118 _print_cr = print_cr; | |
119 _logfile = (logfile != NULL) ? logfile : tty; | |
120 | |
121 if (_active) { | |
122 _accum = NULL; | |
6752
9646b7ff4d14
7198130: G1: PrintReferenceGC output comes out of order
brutisso
parents:
3960
diff
changeset
|
123 _logfile->stamp(PrintGCTimeStamps); |
0 | 124 _logfile->print("[%s", title); |
125 _logfile->flush(); | |
126 _t.start(); | |
127 } | |
128 } | |
129 | |
130 TraceTime::TraceTime(const char* title, | |
131 elapsedTimer* accumulator, | |
132 bool doit, | |
133 bool verbose, | |
134 outputStream* logfile) { | |
135 _active = doit; | |
136 _verbose = verbose; | |
137 _print_cr = true; | |
138 _logfile = (logfile != NULL) ? logfile : tty; | |
139 if (_active) { | |
140 if (_verbose) { | |
6752
9646b7ff4d14
7198130: G1: PrintReferenceGC output comes out of order
brutisso
parents:
3960
diff
changeset
|
141 _logfile->stamp(PrintGCTimeStamps); |
0 | 142 _logfile->print("[%s", title); |
143 _logfile->flush(); | |
144 } | |
145 _accum = accumulator; | |
146 _t.start(); | |
147 } | |
148 } | |
149 | |
150 TraceTime::~TraceTime() { | |
151 if (_active) { | |
152 _t.stop(); | |
153 if (_accum!=NULL) _accum->add(_t); | |
154 if (_verbose) { | |
155 if (_print_cr) { | |
156 _logfile->print_cr(", %3.7f secs]", _t.seconds()); | |
157 } else { | |
158 _logfile->print(", %3.7f secs]", _t.seconds()); | |
159 } | |
160 _logfile->flush(); | |
161 } | |
162 } | |
163 } | |
164 | |
165 TraceCPUTime::TraceCPUTime(bool doit, | |
166 bool print_cr, | |
167 outputStream *logfile) : | |
168 _active(doit), | |
169 _print_cr(print_cr), | |
170 _starting_user_time(0.0), | |
171 _starting_system_time(0.0), | |
172 _starting_real_time(0.0), | |
173 _logfile(logfile), | |
174 _error(false) { | |
175 if (_active) { | |
176 if (logfile != NULL) { | |
177 _logfile = logfile; | |
178 } else { | |
179 _logfile = tty; | |
180 } | |
181 | |
182 _error = !os::getTimesSecs(&_starting_real_time, | |
183 &_starting_user_time, | |
184 &_starting_system_time); | |
185 } | |
186 } | |
187 | |
188 TraceCPUTime::~TraceCPUTime() { | |
189 if (_active) { | |
190 bool valid = false; | |
191 if (!_error) { | |
192 double real_secs; // walk clock time | |
193 double system_secs; // system time | |
194 double user_secs; // user time for all threads | |
195 | |
196 double real_time, user_time, system_time; | |
197 valid = os::getTimesSecs(&real_time, &user_time, &system_time); | |
198 if (valid) { | |
199 | |
200 user_secs = user_time - _starting_user_time; | |
201 system_secs = system_time - _starting_system_time; | |
202 real_secs = real_time - _starting_real_time; | |
203 | |
204 _logfile->print(" [Times: user=%3.2f sys=%3.2f, real=%3.2f secs] ", | |
205 user_secs, system_secs, real_secs); | |
206 | |
207 } else { | |
208 _logfile->print("[Invalid result in TraceCPUTime]"); | |
209 } | |
210 } else { | |
211 _logfile->print("[Error in TraceCPUTime]"); | |
212 } | |
213 if (_print_cr) { | |
214 _logfile->print_cr(""); | |
215 } | |
216 } | |
217 } |