annotate src/share/vm/runtime/statSampler.cpp @ 1980:828eafbd85cc

6348631: remove the use of the HPI library from Hotspot Summary: move functions from hpi library to hotspot, communicate with licensees and open source community, check jdk for dependency, file CCC request Reviewed-by: coleenp, acorn, dsamersoff
author ikrylov
date Wed, 01 Dec 2010 18:26:32 -0500
parents f95d63e2154a
children 3582bf76420e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
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: 1142
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "classfile/vmSymbols.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/javaCalls.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "runtime/statSampler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 # include "vm_version_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 # include "vm_version_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
41 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
42 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
43 # include "vm_version_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
44 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // --------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // StatSamplerTask
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class StatSamplerTask : public PeriodicTask {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 StatSamplerTask(int interval_time) : PeriodicTask(interval_time) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void task() { StatSampler::collect_sample(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 };
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 //----------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Implementation of StatSampler
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 StatSamplerTask* StatSampler::_task = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 PerfDataList* StatSampler::_sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
63 * the initialize method is called from the engage() method
a61af66fc99e Initial load
duke
parents:
diff changeset
64 * and is responsible for initializing various global variables.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 */
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void StatSampler::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // create performance data that could not be created prior
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // to vm_init_globals() or otherwise have no logical home.
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 create_misc_perfdata();
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // get copy of the sampled list
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _sampled = PerfDataManager::sampled();
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
81 * The engage() method is called at initialization time via
a61af66fc99e Initial load
duke
parents:
diff changeset
82 * Thread::create_vm() to initialize the StatSampler and
a61af66fc99e Initial load
duke
parents:
diff changeset
83 * register it with the WatcherThread as a periodic task.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 */
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void StatSampler::engage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (!is_active()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // start up the periodic task
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _task = new StatSamplerTask(PerfDataSamplingInterval);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _task->enroll();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
101 * the disengage() method is responsible for deactivating the periodic
a61af66fc99e Initial load
duke
parents:
diff changeset
102 * task and, if logging was enabled, for logging the final sample. This
a61af66fc99e Initial load
duke
parents:
diff changeset
103 * method is called from before_exit() in java.cpp and is only called
a61af66fc99e Initial load
duke
parents:
diff changeset
104 * after the WatcherThread has been stopped.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 */
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void StatSampler::disengage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (!is_active())
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // remove StatSamplerTask
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _task->disenroll();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 delete _task;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 _task = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // force a final sample
a61af66fc99e Initial load
duke
parents:
diff changeset
119 sample_data(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
123 * the destroy method is responsible for releasing any resources used by
a61af66fc99e Initial load
duke
parents:
diff changeset
124 * the StatSampler prior to shutdown of the VM. this method is called from
a61af66fc99e Initial load
duke
parents:
diff changeset
125 * before_exit() in java.cpp and is only called after the WatcherThread
a61af66fc99e Initial load
duke
parents:
diff changeset
126 * has stopped.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 */
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void StatSampler::destroy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (_sampled != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 delete(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 _sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
139 * The sample_data() method is responsible for sampling the
a61af66fc99e Initial load
duke
parents:
diff changeset
140 * the data value for each PerfData instance in the given list.
a61af66fc99e Initial load
duke
parents:
diff changeset
141 */
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void StatSampler::sample_data(PerfDataList* list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 assert(list != NULL, "null list unexpected");
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 for (int index = 0; index < list->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 PerfData* item = list->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 item->sample();
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
153 * the collect_sample() method is the method invoked by the
a61af66fc99e Initial load
duke
parents:
diff changeset
154 * WatcherThread via the PeriodicTask::task() method. This method
a61af66fc99e Initial load
duke
parents:
diff changeset
155 * is responsible for collecting data samples from sampled
a61af66fc99e Initial load
duke
parents:
diff changeset
156 * PerfData instances every PerfDataSamplingInterval milliseconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
157 * It is also responsible for logging the requested set of
a61af66fc99e Initial load
duke
parents:
diff changeset
158 * PerfData instances every _sample_count milliseconds. While
a61af66fc99e Initial load
duke
parents:
diff changeset
159 * logging data, it will output a column header after every _print_header
a61af66fc99e Initial load
duke
parents:
diff changeset
160 * rows of data have been logged.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 */
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void StatSampler::collect_sample() {
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // future - check for new PerfData objects. PerfData objects might
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // get added to the PerfDataManager lists after we have already
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // built our local copies.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 //
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // if (PerfDataManager::count() > previous) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // // get a new copy of the sampled list
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // if (_sampled != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // delete(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // _sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // _sampled = PerfDataManager::sampled();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 assert(_sampled != NULL, "list not initialized");
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 sample_data(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
183 * method to upcall into Java to return the value of the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
184 * property as a utf8 string, or NULL if does not exist. The caller
a61af66fc99e Initial load
duke
parents:
diff changeset
185 * is responsible for setting a ResourceMark for proper cleanup of
a61af66fc99e Initial load
duke
parents:
diff changeset
186 * the utf8 strings.
a61af66fc99e Initial load
duke
parents:
diff changeset
187 */
a61af66fc99e Initial load
duke
parents:
diff changeset
188 const char* StatSampler::get_system_property(const char* name, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // setup the arguments to getProperty
a61af66fc99e Initial load
duke
parents:
diff changeset
191 Handle key_str = java_lang_String::create_from_str(name, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // return value
a61af66fc99e Initial load
duke
parents:
diff changeset
194 JavaValue result(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // public static String getProperty(String key, String def);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 JavaCalls::call_static(&result,
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 337
diff changeset
198 KlassHandle(THREAD, SystemDictionary::System_klass()),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
199 vmSymbolHandles::getProperty_name(),
a61af66fc99e Initial load
duke
parents:
diff changeset
200 vmSymbolHandles::string_string_signature(),
a61af66fc99e Initial load
duke
parents:
diff changeset
201 key_str,
a61af66fc99e Initial load
duke
parents:
diff changeset
202 CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 oop value_oop = (oop)result.get_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (value_oop == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // convert Java String to utf8 string
a61af66fc99e Initial load
duke
parents:
diff changeset
210 char* value = java_lang_String::as_utf8_string(value_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
216 * The list of System Properties that have corresponding PerfData
a61af66fc99e Initial load
duke
parents:
diff changeset
217 * string instrumentation created by retrieving the named property's
a61af66fc99e Initial load
duke
parents:
diff changeset
218 * value from System.getProperty() and unconditionally creating a
a61af66fc99e Initial load
duke
parents:
diff changeset
219 * PerfStringConstant object initialized to the retreived value. This
a61af66fc99e Initial load
duke
parents:
diff changeset
220 * is not an exhustive list of Java properties with corresponding string
a61af66fc99e Initial load
duke
parents:
diff changeset
221 * instrumentation as the create_system_property_instrumentation() method
a61af66fc99e Initial load
duke
parents:
diff changeset
222 * creates other property based instrumentation conditionally.
a61af66fc99e Initial load
duke
parents:
diff changeset
223 */
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // stable interface, supported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
226 static const char* property_counters_ss[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 "java.vm.specification.version",
a61af66fc99e Initial load
duke
parents:
diff changeset
228 "java.vm.specification.name",
a61af66fc99e Initial load
duke
parents:
diff changeset
229 "java.vm.specification.vendor",
a61af66fc99e Initial load
duke
parents:
diff changeset
230 "java.vm.version",
a61af66fc99e Initial load
duke
parents:
diff changeset
231 "java.vm.name",
a61af66fc99e Initial load
duke
parents:
diff changeset
232 "java.vm.vendor",
a61af66fc99e Initial load
duke
parents:
diff changeset
233 "java.vm.info",
a61af66fc99e Initial load
duke
parents:
diff changeset
234 "java.library.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
235 "java.class.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
236 "java.endorsed.dirs",
a61af66fc99e Initial load
duke
parents:
diff changeset
237 "java.ext.dirs",
279
f3a650d8df24 6625846: Export system property java.version via jvmstat
thurka
parents: 0
diff changeset
238 "java.version",
0
a61af66fc99e Initial load
duke
parents:
diff changeset
239 "java.home",
a61af66fc99e Initial load
duke
parents:
diff changeset
240 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
241 };
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // unstable interface, supported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
244 static const char* property_counters_us[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
246 };
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // unstable interface, unsupported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
249 static const char* property_counters_uu[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 "sun.boot.class.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
251 "sun.boot.library.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
252 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
253 };
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 const char** property_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 CounterNS name_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 } PropertyCounters;
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 static PropertyCounters property_counters[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 { property_counters_ss, JAVA_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
262 { property_counters_us, COM_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
263 { property_counters_uu, SUN_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
264 { NULL, SUN_PROPERTY }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 };
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
269 * Method to create PerfData string instruments that contain the values
a61af66fc99e Initial load
duke
parents:
diff changeset
270 * of various system properties. String instruments are created for each
a61af66fc99e Initial load
duke
parents:
diff changeset
271 * property specified in the property lists provided in property_counters[].
a61af66fc99e Initial load
duke
parents:
diff changeset
272 * Property counters have a counter name space prefix prepended to the
a61af66fc99e Initial load
duke
parents:
diff changeset
273 * property name as indicated in property_counters[].
a61af66fc99e Initial load
duke
parents:
diff changeset
274 */
a61af66fc99e Initial load
duke
parents:
diff changeset
275 void StatSampler::create_system_property_instrumentation(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 for (int i = 0; property_counters[i].property_list != NULL; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 for (int j = 0; property_counters[i].property_list[j] != NULL; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 const char* property_name = property_counters[i].property_list[j];
a61af66fc99e Initial load
duke
parents:
diff changeset
284 assert(property_name != NULL, "property name should not be NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 const char* value = get_system_property(property_name, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // the property must exist
a61af66fc99e Initial load
duke
parents:
diff changeset
289 assert(value != NULL, "property name should be valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if (value != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // create the property counter
a61af66fc99e Initial load
duke
parents:
diff changeset
293 PerfDataManager::create_string_constant(property_counters[i].name_space,
a61af66fc99e Initial load
duke
parents:
diff changeset
294 property_name, value, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
301 * The create_misc_perfdata() method provides a place to create
a61af66fc99e Initial load
duke
parents:
diff changeset
302 * PerfData instances that would otherwise have no better place
a61af66fc99e Initial load
duke
parents:
diff changeset
303 * to exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
304 */
a61af66fc99e Initial load
duke
parents:
diff changeset
305 void StatSampler::create_misc_perfdata() {
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // numeric constants
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // frequency of the native high resolution timer
a61af66fc99e Initial load
duke
parents:
diff changeset
313 PerfDataManager::create_constant(SUN_OS, "hrt.frequency",
a61af66fc99e Initial load
duke
parents:
diff changeset
314 PerfData::U_Hertz, os::elapsed_frequency(),
a61af66fc99e Initial load
duke
parents:
diff changeset
315 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // string constants
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // create string instrumentation for various Java properties.
a61af66fc99e Initial load
duke
parents:
diff changeset
320 create_system_property_instrumentation(CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // hotspot flags (from .hotspotrc) and args (from command line)
a61af66fc99e Initial load
duke
parents:
diff changeset
323 //
a61af66fc99e Initial load
duke
parents:
diff changeset
324 PerfDataManager::create_string_constant(JAVA_RT, "vmFlags",
a61af66fc99e Initial load
duke
parents:
diff changeset
325 Arguments::jvm_flags(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 PerfDataManager::create_string_constant(JAVA_RT, "vmArgs",
a61af66fc99e Initial load
duke
parents:
diff changeset
327 Arguments::jvm_args(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // java class name/jar file and arguments to main class
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // note: name is cooridnated with launcher and Arguments.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
331 PerfDataManager::create_string_constant(SUN_RT, "javaCommand",
a61af66fc99e Initial load
duke
parents:
diff changeset
332 Arguments::java_command(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // the Java VM Internal version string
a61af66fc99e Initial load
duke
parents:
diff changeset
335 PerfDataManager::create_string_constant(SUN_RT, "internalVersion",
a61af66fc99e Initial load
duke
parents:
diff changeset
336 VM_Version::internal_vm_info_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
337 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // create sampled instrumentation objects
a61af66fc99e Initial load
duke
parents:
diff changeset
340 create_sampled_perfdata();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
344 * helper class to provide for sampling of the elapsed_counter value
a61af66fc99e Initial load
duke
parents:
diff changeset
345 * maintained in the OS class.
a61af66fc99e Initial load
duke
parents:
diff changeset
346 */
a61af66fc99e Initial load
duke
parents:
diff changeset
347 class HighResTimeSampler : public PerfSampleHelper {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
349 jlong take_sample() { return os::elapsed_counter(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
350 };
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
353 * the create_sampled_perdata() method provides a place to instantiate
a61af66fc99e Initial load
duke
parents:
diff changeset
354 * sampled PerfData instances that would otherwise have no better place
a61af66fc99e Initial load
duke
parents:
diff changeset
355 * to exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
356 */
a61af66fc99e Initial load
duke
parents:
diff changeset
357 void StatSampler::create_sampled_perfdata() {
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
360
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // setup sampling of the elapsed time counter maintained in the
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // the os class. This counter can be used as either a time stamp
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // for each logged entry or as a liveness indicator for the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
364 PerfSampleHelper* psh = new HighResTimeSampler();
a61af66fc99e Initial load
duke
parents:
diff changeset
365 PerfDataManager::create_counter(SUN_OS, "hrt.ticks",
a61af66fc99e Initial load
duke
parents:
diff changeset
366 PerfData::U_Ticks, psh, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
370 * the statSampler_exit() function is called from os_init.cpp on
a61af66fc99e Initial load
duke
parents:
diff changeset
371 * exit of the vm.
a61af66fc99e Initial load
duke
parents:
diff changeset
372 */
a61af66fc99e Initial load
duke
parents:
diff changeset
373 void statSampler_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 StatSampler::destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }