Mercurial > hg > graal-jvmci-8
comparison src/share/vm/services/runtimeService.cpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | 8859772195c6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2003-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_runtimeService.cpp.incl" | |
27 | |
28 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin); | |
29 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end); | |
30 | |
31 TimeStamp RuntimeService::_app_timer; | |
32 TimeStamp RuntimeService::_safepoint_timer; | |
33 PerfCounter* RuntimeService::_sync_time_ticks = NULL; | |
34 PerfCounter* RuntimeService::_total_safepoints = NULL; | |
35 PerfCounter* RuntimeService::_safepoint_time_ticks = NULL; | |
36 PerfCounter* RuntimeService::_application_time_ticks = NULL; | |
37 PerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL; | |
38 PerfCounter* RuntimeService::_interrupted_before_count = NULL; | |
39 PerfCounter* RuntimeService::_interrupted_during_count = NULL; | |
40 | |
41 void RuntimeService::init() { | |
42 // Make sure the VM version is initialized | |
43 Abstract_VM_Version::initialize(); | |
44 | |
45 if (UsePerfData) { | |
46 EXCEPTION_MARK; | |
47 | |
48 _sync_time_ticks = | |
49 PerfDataManager::create_counter(SUN_RT, "safepointSyncTime", | |
50 PerfData::U_Ticks, CHECK); | |
51 | |
52 _total_safepoints = | |
53 PerfDataManager::create_counter(SUN_RT, "safepoints", | |
54 PerfData::U_Events, CHECK); | |
55 | |
56 _safepoint_time_ticks = | |
57 PerfDataManager::create_counter(SUN_RT, "safepointTime", | |
58 PerfData::U_Ticks, CHECK); | |
59 | |
60 _application_time_ticks = | |
61 PerfDataManager::create_counter(SUN_RT, "applicationTime", | |
62 PerfData::U_Ticks, CHECK); | |
63 | |
64 | |
65 // create performance counters for jvm_version and its capabilities | |
66 PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None, | |
67 (jlong) Abstract_VM_Version::jvm_version(), CHECK); | |
68 | |
69 // I/O interruption related counters | |
70 | |
71 // thread signaling via os::interrupt() | |
72 | |
73 _thread_interrupt_signaled_count = | |
74 PerfDataManager::create_counter(SUN_RT, | |
75 "threadInterruptSignaled", PerfData::U_Events, CHECK); | |
76 | |
77 // OS_INTRPT via "check before" in _INTERRUPTIBLE | |
78 | |
79 _interrupted_before_count = | |
80 PerfDataManager::create_counter(SUN_RT, "interruptedBeforeIO", | |
81 PerfData::U_Events, CHECK); | |
82 | |
83 // OS_INTRPT via "check during" in _INTERRUPTIBLE | |
84 | |
85 _interrupted_during_count = | |
86 PerfDataManager::create_counter(SUN_RT, "interruptedDuringIO", | |
87 PerfData::U_Events, CHECK); | |
88 | |
89 // The capabilities counter is a binary representation of the VM capabilities in string. | |
90 // This string respresentation simplifies the implementation of the client side | |
91 // to parse the value. | |
92 char capabilities[65]; | |
93 size_t len = sizeof(capabilities); | |
94 memset((void*) capabilities, '0', len); | |
95 capabilities[len-1] = '\0'; | |
96 capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0'; | |
97 #ifdef KERNEL | |
98 capabilities[1] = '1'; | |
99 #endif // KERNEL | |
100 PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities", | |
101 capabilities, CHECK); | |
102 } | |
103 } | |
104 | |
105 void RuntimeService::record_safepoint_begin() { | |
106 HS_DTRACE_PROBE(hs_private, safepoint__begin); | |
107 // update the time stamp to begin recording safepoint time | |
108 _safepoint_timer.update(); | |
109 if (UsePerfData) { | |
110 _total_safepoints->inc(); | |
111 if (_app_timer.is_updated()) { | |
112 _application_time_ticks->inc(_app_timer.ticks_since_update()); | |
113 } | |
114 } | |
115 } | |
116 | |
117 void RuntimeService::record_safepoint_synchronized() { | |
118 if (UsePerfData) { | |
119 _sync_time_ticks->inc(_safepoint_timer.ticks_since_update()); | |
120 } | |
121 } | |
122 | |
123 void RuntimeService::record_safepoint_end() { | |
124 HS_DTRACE_PROBE(hs_private, safepoint__end); | |
125 // update the time stamp to begin recording app time | |
126 _app_timer.update(); | |
127 if (UsePerfData) { | |
128 _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update()); | |
129 } | |
130 } | |
131 | |
132 void RuntimeService::record_application_start() { | |
133 // update the time stamp to begin recording app time | |
134 _app_timer.update(); | |
135 } | |
136 | |
137 // Don't need to record application end because we currently | |
138 // exit at a safepoint and record_safepoint_begin() handles updating | |
139 // the application time counter at VM exit. | |
140 | |
141 jlong RuntimeService::safepoint_sync_time_ms() { | |
142 return UsePerfData ? | |
143 Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1; | |
144 } | |
145 | |
146 jlong RuntimeService::safepoint_count() { | |
147 return UsePerfData ? | |
148 _total_safepoints->get_value() : -1; | |
149 } | |
150 jlong RuntimeService::safepoint_time_ms() { | |
151 return UsePerfData ? | |
152 Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1; | |
153 } | |
154 | |
155 jlong RuntimeService::application_time_ms() { | |
156 return UsePerfData ? | |
157 Management::ticks_to_ms(_application_time_ticks->get_value()) : -1; | |
158 } | |
159 | |
160 void RuntimeService::record_interrupted_before_count() { | |
161 if (UsePerfData) { | |
162 _interrupted_before_count->inc(); | |
163 } | |
164 } | |
165 | |
166 void RuntimeService::record_interrupted_during_count() { | |
167 if (UsePerfData) { | |
168 _interrupted_during_count->inc(); | |
169 } | |
170 } | |
171 | |
172 void RuntimeService::record_thread_interrupt_signaled_count() { | |
173 if (UsePerfData) { | |
174 _thread_interrupt_signaled_count->inc(); | |
175 } | |
176 } |