Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/timer.cpp @ 16719:b1911c1e44c8
Dump disassembly in crash log
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 07 Aug 2014 11:06:09 -0700 |
parents | 4ca6dc0799b6 |
children | 52b4284cb496 |
rev | line source |
---|---|
0 | 1 /* |
10405 | 2 * Copyright (c) 1997, 2013, 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 |
10405 | 42 double TimeHelper::counter_to_seconds(jlong counter) { |
43 double count = (double) counter; | |
44 double freq = (double) os::elapsed_frequency(); | |
45 return counter/freq; | |
46 } | |
0 | 47 |
13103
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
48 elapsedTimer::elapsedTimer(jlong time, jlong timeUnitsPerSecond) { |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
49 _active = false; |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
50 jlong osTimeUnitsPerSecond = os::elapsed_frequency(); |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
51 assert(osTimeUnitsPerSecond % 1000 == 0, "must be"); |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
52 assert(timeUnitsPerSecond % 1000 == 0, "must be"); |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
53 while (osTimeUnitsPerSecond < timeUnitsPerSecond) { |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
54 timeUnitsPerSecond /= 1000; |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
55 time *= 1000; |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
56 } |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
57 while (osTimeUnitsPerSecond > timeUnitsPerSecond) { |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
58 timeUnitsPerSecond *= 1000; |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
59 time /= 1000; |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
60 } |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
61 _counter = time; |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
62 } |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
10405
diff
changeset
|
63 |
0 | 64 void elapsedTimer::add(elapsedTimer t) { |
65 _counter += t._counter; | |
66 } | |
67 | |
68 void elapsedTimer::start() { | |
69 if (!_active) { | |
70 _active = true; | |
71 _start_counter = os::elapsed_counter(); | |
72 } | |
73 } | |
74 | |
75 void elapsedTimer::stop() { | |
76 if (_active) { | |
77 _counter += os::elapsed_counter() - _start_counter; | |
78 _active = false; | |
79 } | |
80 } | |
81 | |
82 double elapsedTimer::seconds() const { | |
10405 | 83 return TimeHelper::counter_to_seconds(_counter); |
0 | 84 } |
85 | |
86 jlong elapsedTimer::milliseconds() const { | |
87 jlong ticks_per_ms = os::elapsed_frequency() / 1000; | |
88 return _counter / ticks_per_ms; | |
89 } | |
90 | |
91 jlong elapsedTimer::active_ticks() const { | |
92 if (!_active) { | |
93 return ticks(); | |
94 } | |
95 jlong counter = _counter + os::elapsed_counter() - _start_counter; | |
96 return counter; | |
97 } | |
98 | |
99 void TimeStamp::update_to(jlong ticks) { | |
100 _counter = ticks; | |
101 if (_counter == 0) _counter = 1; | |
102 assert(is_updated(), "must not look clear"); | |
103 } | |
104 | |
105 void TimeStamp::update() { | |
106 update_to(os::elapsed_counter()); | |
107 } | |
108 | |
109 double TimeStamp::seconds() const { | |
110 assert(is_updated(), "must not be clear"); | |
111 jlong new_count = os::elapsed_counter(); | |
10405 | 112 return TimeHelper::counter_to_seconds(new_count - _counter); |
0 | 113 } |
114 | |
115 jlong TimeStamp::milliseconds() const { | |
116 assert(is_updated(), "must not be clear"); | |
117 | |
118 jlong new_count = os::elapsed_counter(); | |
119 jlong count = new_count - _counter; | |
120 jlong ticks_per_ms = os::elapsed_frequency() / 1000; | |
121 return count / ticks_per_ms; | |
122 } | |
123 | |
124 jlong TimeStamp::ticks_since_update() const { | |
125 assert(is_updated(), "must not be clear"); | |
126 return os::elapsed_counter() - _counter; | |
127 } | |
128 | |
129 TraceTime::TraceTime(const char* title, | |
10405 | 130 bool doit) { |
0 | 131 _active = doit; |
132 _verbose = true; | |
133 | |
134 if (_active) { | |
135 _accum = NULL; | |
10405 | 136 tty->stamp(PrintGCTimeStamps); |
137 tty->print("[%s", title); | |
138 tty->flush(); | |
0 | 139 _t.start(); |
140 } | |
141 } | |
142 | |
143 TraceTime::TraceTime(const char* title, | |
144 elapsedTimer* accumulator, | |
145 bool doit, | |
10405 | 146 bool verbose) { |
0 | 147 _active = doit; |
148 _verbose = verbose; | |
149 if (_active) { | |
150 if (_verbose) { | |
10405 | 151 tty->stamp(PrintGCTimeStamps); |
152 tty->print("[%s", title); | |
153 tty->flush(); | |
0 | 154 } |
155 _accum = accumulator; | |
156 _t.start(); | |
157 } | |
158 } | |
159 | |
160 TraceTime::~TraceTime() { | |
161 if (_active) { | |
162 _t.stop(); | |
163 if (_accum!=NULL) _accum->add(_t); | |
164 if (_verbose) { | |
10405 | 165 tty->print_cr(", %3.7f secs]", _t.seconds()); |
166 tty->flush(); | |
0 | 167 } |
168 } | |
169 } | |
170 | |
171 TraceCPUTime::TraceCPUTime(bool doit, | |
172 bool print_cr, | |
173 outputStream *logfile) : | |
174 _active(doit), | |
175 _print_cr(print_cr), | |
176 _starting_user_time(0.0), | |
177 _starting_system_time(0.0), | |
178 _starting_real_time(0.0), | |
179 _logfile(logfile), | |
180 _error(false) { | |
181 if (_active) { | |
182 if (logfile != NULL) { | |
183 _logfile = logfile; | |
184 } else { | |
185 _logfile = tty; | |
186 } | |
187 | |
188 _error = !os::getTimesSecs(&_starting_real_time, | |
189 &_starting_user_time, | |
190 &_starting_system_time); | |
191 } | |
192 } | |
193 | |
194 TraceCPUTime::~TraceCPUTime() { | |
195 if (_active) { | |
196 bool valid = false; | |
197 if (!_error) { | |
198 double real_secs; // walk clock time | |
199 double system_secs; // system time | |
200 double user_secs; // user time for all threads | |
201 | |
202 double real_time, user_time, system_time; | |
203 valid = os::getTimesSecs(&real_time, &user_time, &system_time); | |
204 if (valid) { | |
205 | |
206 user_secs = user_time - _starting_user_time; | |
207 system_secs = system_time - _starting_system_time; | |
208 real_secs = real_time - _starting_real_time; | |
209 | |
210 _logfile->print(" [Times: user=%3.2f sys=%3.2f, real=%3.2f secs] ", | |
211 user_secs, system_secs, real_secs); | |
212 | |
213 } else { | |
214 _logfile->print("[Invalid result in TraceCPUTime]"); | |
215 } | |
216 } else { | |
217 _logfile->print("[Error in TraceCPUTime]"); | |
218 } | |
7207
0f80645e9c26
8004170: G1: Verbose GC output is not getting flushed to log file using JDK 8
johnc
parents:
6842
diff
changeset
|
219 if (_print_cr) { |
0 | 220 _logfile->print_cr(""); |
221 } | |
7207
0f80645e9c26
8004170: G1: Verbose GC output is not getting flushed to log file using JDK 8
johnc
parents:
6842
diff
changeset
|
222 _logfile->flush(); |
0 | 223 } |
224 } |