annotate src/share/vm/runtime/statSampler.cpp @ 3917:eca1193ca245

4965777: GC changes to support use of discovered field for pending references Summary: If and when the reference handler thread is able to use the discovered field to link reference objects in its pending list, so will GC. In that case, GC will scan through this field once a reference object has been placed on the pending list, but not scan that field before that stage, as the field is used by the concurrent GC thread to link discovered objects. When ReferenceHandleR thread does not use the discovered field for the purpose of linking the elements in the pending list, as would be the case in older JDKs, the JVM will fall back to the old behaviour of using the next field for that purpose. Reviewed-by: jcoomes, mchung, stefank
author ysr
date Wed, 07 Sep 2011 13:55:42 -0700
parents 1d1603768966
children 63a4eb8bcd23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 2001, 2011, 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
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2177
diff changeset
45 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2177
diff changeset
46 # include "vm_version_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2177
diff changeset
47 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2177
diff changeset
48 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2177
diff changeset
49 # include "vm_version_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2177
diff changeset
50 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // --------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // StatSamplerTask
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 class StatSamplerTask : public PeriodicTask {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 StatSamplerTask(int interval_time) : PeriodicTask(interval_time) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void task() { StatSampler::collect_sample(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 };
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 //----------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Implementation of StatSampler
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 StatSamplerTask* StatSampler::_task = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 PerfDataList* StatSampler::_sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
69 * the initialize method is called from the engage() method
a61af66fc99e Initial load
duke
parents:
diff changeset
70 * and is responsible for initializing various global variables.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 */
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void StatSampler::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // create performance data that could not be created prior
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // to vm_init_globals() or otherwise have no logical home.
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 create_misc_perfdata();
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // get copy of the sampled list
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _sampled = PerfDataManager::sampled();
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
87 * The engage() method is called at initialization time via
a61af66fc99e Initial load
duke
parents:
diff changeset
88 * Thread::create_vm() to initialize the StatSampler and
a61af66fc99e Initial load
duke
parents:
diff changeset
89 * register it with the WatcherThread as a periodic task.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 */
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void StatSampler::engage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (!is_active()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // start up the periodic task
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _task = new StatSamplerTask(PerfDataSamplingInterval);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _task->enroll();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
107 * the disengage() method is responsible for deactivating the periodic
a61af66fc99e Initial load
duke
parents:
diff changeset
108 * task and, if logging was enabled, for logging the final sample. This
a61af66fc99e Initial load
duke
parents:
diff changeset
109 * method is called from before_exit() in java.cpp and is only called
a61af66fc99e Initial load
duke
parents:
diff changeset
110 * after the WatcherThread has been stopped.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 */
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void StatSampler::disengage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (!is_active())
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // remove StatSamplerTask
a61af66fc99e Initial load
duke
parents:
diff changeset
120 _task->disenroll();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 delete _task;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _task = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // force a final sample
a61af66fc99e Initial load
duke
parents:
diff changeset
125 sample_data(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
129 * the destroy method is responsible for releasing any resources used by
a61af66fc99e Initial load
duke
parents:
diff changeset
130 * the StatSampler prior to shutdown of the VM. this method is called from
a61af66fc99e Initial load
duke
parents:
diff changeset
131 * before_exit() in java.cpp and is only called after the WatcherThread
a61af66fc99e Initial load
duke
parents:
diff changeset
132 * has stopped.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 */
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void StatSampler::destroy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (_sampled != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 delete(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 _sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
145 * The sample_data() method is responsible for sampling the
a61af66fc99e Initial load
duke
parents:
diff changeset
146 * the data value for each PerfData instance in the given list.
a61af66fc99e Initial load
duke
parents:
diff changeset
147 */
a61af66fc99e Initial load
duke
parents:
diff changeset
148 void StatSampler::sample_data(PerfDataList* list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 assert(list != NULL, "null list unexpected");
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 for (int index = 0; index < list->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 PerfData* item = list->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 item->sample();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
159 * the collect_sample() method is the method invoked by the
a61af66fc99e Initial load
duke
parents:
diff changeset
160 * WatcherThread via the PeriodicTask::task() method. This method
a61af66fc99e Initial load
duke
parents:
diff changeset
161 * is responsible for collecting data samples from sampled
a61af66fc99e Initial load
duke
parents:
diff changeset
162 * PerfData instances every PerfDataSamplingInterval milliseconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 * It is also responsible for logging the requested set of
a61af66fc99e Initial load
duke
parents:
diff changeset
164 * PerfData instances every _sample_count milliseconds. While
a61af66fc99e Initial load
duke
parents:
diff changeset
165 * logging data, it will output a column header after every _print_header
a61af66fc99e Initial load
duke
parents:
diff changeset
166 * rows of data have been logged.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 */
a61af66fc99e Initial load
duke
parents:
diff changeset
168 void StatSampler::collect_sample() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // future - check for new PerfData objects. PerfData objects might
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // get added to the PerfDataManager lists after we have already
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // built our local copies.
a61af66fc99e Initial load
duke
parents:
diff changeset
173 //
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // if (PerfDataManager::count() > previous) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // // get a new copy of the sampled list
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // if (_sampled != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // delete(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // _sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // _sampled = PerfDataManager::sampled();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 assert(_sampled != NULL, "list not initialized");
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 sample_data(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
189 * method to upcall into Java to return the value of the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
190 * property as a utf8 string, or NULL if does not exist. The caller
a61af66fc99e Initial load
duke
parents:
diff changeset
191 * is responsible for setting a ResourceMark for proper cleanup of
a61af66fc99e Initial load
duke
parents:
diff changeset
192 * the utf8 strings.
a61af66fc99e Initial load
duke
parents:
diff changeset
193 */
a61af66fc99e Initial load
duke
parents:
diff changeset
194 const char* StatSampler::get_system_property(const char* name, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // setup the arguments to getProperty
a61af66fc99e Initial load
duke
parents:
diff changeset
197 Handle key_str = java_lang_String::create_from_str(name, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // return value
a61af66fc99e Initial load
duke
parents:
diff changeset
200 JavaValue result(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // public static String getProperty(String key, String def);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 JavaCalls::call_static(&result,
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 337
diff changeset
204 KlassHandle(THREAD, SystemDictionary::System_klass()),
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
205 vmSymbols::getProperty_name(),
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
206 vmSymbols::string_string_signature(),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
207 key_str,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 oop value_oop = (oop)result.get_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (value_oop == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // convert Java String to utf8 string
a61af66fc99e Initial load
duke
parents:
diff changeset
216 char* value = java_lang_String::as_utf8_string(value_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
222 * The list of System Properties that have corresponding PerfData
a61af66fc99e Initial load
duke
parents:
diff changeset
223 * string instrumentation created by retrieving the named property's
a61af66fc99e Initial load
duke
parents:
diff changeset
224 * value from System.getProperty() and unconditionally creating a
a61af66fc99e Initial load
duke
parents:
diff changeset
225 * PerfStringConstant object initialized to the retreived value. This
a61af66fc99e Initial load
duke
parents:
diff changeset
226 * is not an exhustive list of Java properties with corresponding string
a61af66fc99e Initial load
duke
parents:
diff changeset
227 * instrumentation as the create_system_property_instrumentation() method
a61af66fc99e Initial load
duke
parents:
diff changeset
228 * creates other property based instrumentation conditionally.
a61af66fc99e Initial load
duke
parents:
diff changeset
229 */
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // stable interface, supported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
232 static const char* property_counters_ss[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 "java.vm.specification.version",
a61af66fc99e Initial load
duke
parents:
diff changeset
234 "java.vm.specification.name",
a61af66fc99e Initial load
duke
parents:
diff changeset
235 "java.vm.specification.vendor",
a61af66fc99e Initial load
duke
parents:
diff changeset
236 "java.vm.version",
a61af66fc99e Initial load
duke
parents:
diff changeset
237 "java.vm.name",
a61af66fc99e Initial load
duke
parents:
diff changeset
238 "java.vm.vendor",
a61af66fc99e Initial load
duke
parents:
diff changeset
239 "java.vm.info",
a61af66fc99e Initial load
duke
parents:
diff changeset
240 "java.library.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
241 "java.class.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
242 "java.endorsed.dirs",
a61af66fc99e Initial load
duke
parents:
diff changeset
243 "java.ext.dirs",
279
f3a650d8df24 6625846: Export system property java.version via jvmstat
thurka
parents: 0
diff changeset
244 "java.version",
0
a61af66fc99e Initial load
duke
parents:
diff changeset
245 "java.home",
a61af66fc99e Initial load
duke
parents:
diff changeset
246 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
247 };
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // unstable interface, supported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
250 static const char* property_counters_us[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
252 };
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // unstable interface, unsupported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
255 static const char* property_counters_uu[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 "sun.boot.class.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
257 "sun.boot.library.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
258 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
259 };
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 const char** property_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 CounterNS name_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 } PropertyCounters;
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 static PropertyCounters property_counters[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 { property_counters_ss, JAVA_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
268 { property_counters_us, COM_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
269 { property_counters_uu, SUN_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
270 { NULL, SUN_PROPERTY }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 };
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
275 * Method to create PerfData string instruments that contain the values
a61af66fc99e Initial load
duke
parents:
diff changeset
276 * of various system properties. String instruments are created for each
a61af66fc99e Initial load
duke
parents:
diff changeset
277 * property specified in the property lists provided in property_counters[].
a61af66fc99e Initial load
duke
parents:
diff changeset
278 * Property counters have a counter name space prefix prepended to the
a61af66fc99e Initial load
duke
parents:
diff changeset
279 * property name as indicated in property_counters[].
a61af66fc99e Initial load
duke
parents:
diff changeset
280 */
a61af66fc99e Initial load
duke
parents:
diff changeset
281 void StatSampler::create_system_property_instrumentation(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 for (int i = 0; property_counters[i].property_list != NULL; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 for (int j = 0; property_counters[i].property_list[j] != NULL; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 const char* property_name = property_counters[i].property_list[j];
a61af66fc99e Initial load
duke
parents:
diff changeset
290 assert(property_name != NULL, "property name should not be NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 const char* value = get_system_property(property_name, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // the property must exist
a61af66fc99e Initial load
duke
parents:
diff changeset
295 assert(value != NULL, "property name should be valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (value != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // create the property counter
a61af66fc99e Initial load
duke
parents:
diff changeset
299 PerfDataManager::create_string_constant(property_counters[i].name_space,
a61af66fc99e Initial load
duke
parents:
diff changeset
300 property_name, value, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
307 * The create_misc_perfdata() method provides a place to create
a61af66fc99e Initial load
duke
parents:
diff changeset
308 * PerfData instances that would otherwise have no better place
a61af66fc99e Initial load
duke
parents:
diff changeset
309 * to exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
310 */
a61af66fc99e Initial load
duke
parents:
diff changeset
311 void StatSampler::create_misc_perfdata() {
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // numeric constants
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // frequency of the native high resolution timer
a61af66fc99e Initial load
duke
parents:
diff changeset
319 PerfDataManager::create_constant(SUN_OS, "hrt.frequency",
a61af66fc99e Initial load
duke
parents:
diff changeset
320 PerfData::U_Hertz, os::elapsed_frequency(),
a61af66fc99e Initial load
duke
parents:
diff changeset
321 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // string constants
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // create string instrumentation for various Java properties.
a61af66fc99e Initial load
duke
parents:
diff changeset
326 create_system_property_instrumentation(CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // hotspot flags (from .hotspotrc) and args (from command line)
a61af66fc99e Initial load
duke
parents:
diff changeset
329 //
a61af66fc99e Initial load
duke
parents:
diff changeset
330 PerfDataManager::create_string_constant(JAVA_RT, "vmFlags",
a61af66fc99e Initial load
duke
parents:
diff changeset
331 Arguments::jvm_flags(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
332 PerfDataManager::create_string_constant(JAVA_RT, "vmArgs",
a61af66fc99e Initial load
duke
parents:
diff changeset
333 Arguments::jvm_args(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // java class name/jar file and arguments to main class
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // note: name is cooridnated with launcher and Arguments.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
337 PerfDataManager::create_string_constant(SUN_RT, "javaCommand",
a61af66fc99e Initial load
duke
parents:
diff changeset
338 Arguments::java_command(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // the Java VM Internal version string
a61af66fc99e Initial load
duke
parents:
diff changeset
341 PerfDataManager::create_string_constant(SUN_RT, "internalVersion",
a61af66fc99e Initial load
duke
parents:
diff changeset
342 VM_Version::internal_vm_info_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
343 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // create sampled instrumentation objects
a61af66fc99e Initial load
duke
parents:
diff changeset
346 create_sampled_perfdata();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
350 * helper class to provide for sampling of the elapsed_counter value
a61af66fc99e Initial load
duke
parents:
diff changeset
351 * maintained in the OS class.
a61af66fc99e Initial load
duke
parents:
diff changeset
352 */
a61af66fc99e Initial load
duke
parents:
diff changeset
353 class HighResTimeSampler : public PerfSampleHelper {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
355 jlong take_sample() { return os::elapsed_counter(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 };
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
359 * the create_sampled_perdata() method provides a place to instantiate
a61af66fc99e Initial load
duke
parents:
diff changeset
360 * sampled PerfData instances that would otherwise have no better place
a61af66fc99e Initial load
duke
parents:
diff changeset
361 * to exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
362 */
a61af66fc99e Initial load
duke
parents:
diff changeset
363 void StatSampler::create_sampled_perfdata() {
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // setup sampling of the elapsed time counter maintained in the
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // the os class. This counter can be used as either a time stamp
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // for each logged entry or as a liveness indicator for the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
370 PerfSampleHelper* psh = new HighResTimeSampler();
a61af66fc99e Initial load
duke
parents:
diff changeset
371 PerfDataManager::create_counter(SUN_OS, "hrt.ticks",
a61af66fc99e Initial load
duke
parents:
diff changeset
372 PerfData::U_Ticks, psh, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
376 * the statSampler_exit() function is called from os_init.cpp on
a61af66fc99e Initial load
duke
parents:
diff changeset
377 * exit of the vm.
a61af66fc99e Initial load
duke
parents:
diff changeset
378 */
a61af66fc99e Initial load
duke
parents:
diff changeset
379 void statSampler_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 StatSampler::destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }