Mercurial > hg > truffle
annotate src/share/vm/services/runtimeService.cpp @ 7090:05ce1defa4f9
Common out some parts of UnsafeLoad/Store in UnsafeAccess
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 29 Nov 2012 13:24:08 +0100 |
parents | fb19af007ffc |
children | db9981fd3124 |
rev | line source |
---|---|
0 | 1 /* |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
4006
diff
changeset
|
2 * Copyright (c) 2003, 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:
1260
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1260
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:
1260
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/classLoader.hpp" | |
27 #include "services/attachListener.hpp" | |
28 #include "services/management.hpp" | |
29 #include "services/runtimeService.hpp" | |
30 #include "utilities/dtrace.hpp" | |
31 #include "utilities/exceptions.hpp" | |
0 | 32 |
4006 | 33 #ifndef USDT2 |
0 | 34 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin); |
35 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end); | |
4006 | 36 #endif /* !USDT2 */ |
0 | 37 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
4006
diff
changeset
|
38 #if INCLUDE_MANAGEMENT |
0 | 39 TimeStamp RuntimeService::_app_timer; |
40 TimeStamp RuntimeService::_safepoint_timer; | |
41 PerfCounter* RuntimeService::_sync_time_ticks = NULL; | |
42 PerfCounter* RuntimeService::_total_safepoints = NULL; | |
43 PerfCounter* RuntimeService::_safepoint_time_ticks = NULL; | |
44 PerfCounter* RuntimeService::_application_time_ticks = NULL; | |
45 PerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL; | |
46 PerfCounter* RuntimeService::_interrupted_before_count = NULL; | |
47 PerfCounter* RuntimeService::_interrupted_during_count = NULL; | |
48 | |
49 void RuntimeService::init() { | |
50 // Make sure the VM version is initialized | |
51 Abstract_VM_Version::initialize(); | |
52 | |
53 if (UsePerfData) { | |
54 EXCEPTION_MARK; | |
55 | |
56 _sync_time_ticks = | |
57 PerfDataManager::create_counter(SUN_RT, "safepointSyncTime", | |
58 PerfData::U_Ticks, CHECK); | |
59 | |
60 _total_safepoints = | |
61 PerfDataManager::create_counter(SUN_RT, "safepoints", | |
62 PerfData::U_Events, CHECK); | |
63 | |
64 _safepoint_time_ticks = | |
65 PerfDataManager::create_counter(SUN_RT, "safepointTime", | |
66 PerfData::U_Ticks, CHECK); | |
67 | |
68 _application_time_ticks = | |
69 PerfDataManager::create_counter(SUN_RT, "applicationTime", | |
70 PerfData::U_Ticks, CHECK); | |
71 | |
72 | |
73 // create performance counters for jvm_version and its capabilities | |
74 PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None, | |
75 (jlong) Abstract_VM_Version::jvm_version(), CHECK); | |
76 | |
77 // I/O interruption related counters | |
78 | |
79 // thread signaling via os::interrupt() | |
80 | |
81 _thread_interrupt_signaled_count = | |
82 PerfDataManager::create_counter(SUN_RT, | |
83 "threadInterruptSignaled", PerfData::U_Events, CHECK); | |
84 | |
85 // OS_INTRPT via "check before" in _INTERRUPTIBLE | |
86 | |
87 _interrupted_before_count = | |
88 PerfDataManager::create_counter(SUN_RT, "interruptedBeforeIO", | |
89 PerfData::U_Events, CHECK); | |
90 | |
91 // OS_INTRPT via "check during" in _INTERRUPTIBLE | |
92 | |
93 _interrupted_during_count = | |
94 PerfDataManager::create_counter(SUN_RT, "interruptedDuringIO", | |
95 PerfData::U_Events, CHECK); | |
96 | |
97 // The capabilities counter is a binary representation of the VM capabilities in string. | |
98 // This string respresentation simplifies the implementation of the client side | |
99 // to parse the value. | |
100 char capabilities[65]; | |
101 size_t len = sizeof(capabilities); | |
102 memset((void*) capabilities, '0', len); | |
103 capabilities[len-1] = '\0'; | |
104 capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0'; | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
4006
diff
changeset
|
105 #if INCLUDE_SERVICES |
0 | 106 capabilities[1] = '1'; |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
4006
diff
changeset
|
107 #endif // INCLUDE_SERVICES |
0 | 108 PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities", |
109 capabilities, CHECK); | |
110 } | |
111 } | |
112 | |
113 void RuntimeService::record_safepoint_begin() { | |
4006 | 114 #ifndef USDT2 |
0 | 115 HS_DTRACE_PROBE(hs_private, safepoint__begin); |
4006 | 116 #else /* USDT2 */ |
117 HS_PRIVATE_SAFEPOINT_BEGIN(); | |
118 #endif /* USDT2 */ | |
1260
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
119 |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
120 // Print the time interval in which the app was executing |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
121 if (PrintGCApplicationConcurrentTime) { |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
122 gclog_or_tty->print_cr("Application time: %3.7f seconds", |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
123 last_application_time_sec()); |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
124 } |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
125 |
0 | 126 // update the time stamp to begin recording safepoint time |
127 _safepoint_timer.update(); | |
128 if (UsePerfData) { | |
129 _total_safepoints->inc(); | |
130 if (_app_timer.is_updated()) { | |
131 _application_time_ticks->inc(_app_timer.ticks_since_update()); | |
132 } | |
133 } | |
134 } | |
135 | |
136 void RuntimeService::record_safepoint_synchronized() { | |
137 if (UsePerfData) { | |
138 _sync_time_ticks->inc(_safepoint_timer.ticks_since_update()); | |
139 } | |
140 } | |
141 | |
142 void RuntimeService::record_safepoint_end() { | |
4006 | 143 #ifndef USDT2 |
0 | 144 HS_DTRACE_PROBE(hs_private, safepoint__end); |
4006 | 145 #else /* USDT2 */ |
146 HS_PRIVATE_SAFEPOINT_END(); | |
147 #endif /* USDT2 */ | |
1260
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
148 |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
149 // Print the time interval for which the app was stopped |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
150 // during the current safepoint operation. |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
151 if (PrintGCApplicationStoppedTime) { |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
152 gclog_or_tty->print_cr("Total time for which application threads " |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
153 "were stopped: %3.7f seconds", |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
154 last_safepoint_time_sec()); |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
155 } |
8859772195c6
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
0
diff
changeset
|
156 |
0 | 157 // update the time stamp to begin recording app time |
158 _app_timer.update(); | |
159 if (UsePerfData) { | |
160 _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update()); | |
161 } | |
162 } | |
163 | |
164 void RuntimeService::record_application_start() { | |
165 // update the time stamp to begin recording app time | |
166 _app_timer.update(); | |
167 } | |
168 | |
169 // Don't need to record application end because we currently | |
170 // exit at a safepoint and record_safepoint_begin() handles updating | |
171 // the application time counter at VM exit. | |
172 | |
173 jlong RuntimeService::safepoint_sync_time_ms() { | |
174 return UsePerfData ? | |
175 Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1; | |
176 } | |
177 | |
178 jlong RuntimeService::safepoint_count() { | |
179 return UsePerfData ? | |
180 _total_safepoints->get_value() : -1; | |
181 } | |
182 jlong RuntimeService::safepoint_time_ms() { | |
183 return UsePerfData ? | |
184 Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1; | |
185 } | |
186 | |
187 jlong RuntimeService::application_time_ms() { | |
188 return UsePerfData ? | |
189 Management::ticks_to_ms(_application_time_ticks->get_value()) : -1; | |
190 } | |
191 | |
192 void RuntimeService::record_interrupted_before_count() { | |
193 if (UsePerfData) { | |
194 _interrupted_before_count->inc(); | |
195 } | |
196 } | |
197 | |
198 void RuntimeService::record_interrupted_during_count() { | |
199 if (UsePerfData) { | |
200 _interrupted_during_count->inc(); | |
201 } | |
202 } | |
203 | |
204 void RuntimeService::record_thread_interrupt_signaled_count() { | |
205 if (UsePerfData) { | |
206 _thread_interrupt_signaled_count->inc(); | |
207 } | |
208 } | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
4006
diff
changeset
|
209 |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
4006
diff
changeset
|
210 #endif // INCLUDE_MANAGEMENT |