annotate src/share/vm/runtime/statSampler.cpp @ 94:0834225a7916

6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction Summary: The option CMSInitiatingPermOccupancyFraction now controls perm triggering threshold. Even though the actual value of the threshold has not yet been changed, so there is no change in policy, we now have the infrastructure in place for dynamically deciding when to collect the perm gen, an issue that will be addressed in the near future. Reviewed-by: jmasa
author ysr
date Sun, 16 Mar 2008 21:57:25 -0700
parents a61af66fc99e
children f3a650d8df24
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_statSampler.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // --------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // StatSamplerTask
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class StatSamplerTask : public PeriodicTask {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 StatSamplerTask(int interval_time) : PeriodicTask(interval_time) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
34 void task() { StatSampler::collect_sample(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
35 };
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //----------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Implementation of StatSampler
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 StatSamplerTask* StatSampler::_task = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 PerfDataList* StatSampler::_sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
45 * the initialize method is called from the engage() method
a61af66fc99e Initial load
duke
parents:
diff changeset
46 * and is responsible for initializing various global variables.
a61af66fc99e Initial load
duke
parents:
diff changeset
47 */
a61af66fc99e Initial load
duke
parents:
diff changeset
48 void StatSampler::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // create performance data that could not be created prior
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // to vm_init_globals() or otherwise have no logical home.
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 create_misc_perfdata();
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // get copy of the sampled list
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _sampled = PerfDataManager::sampled();
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 * The engage() method is called at initialization time via
a61af66fc99e Initial load
duke
parents:
diff changeset
64 * Thread::create_vm() to initialize the StatSampler and
a61af66fc99e Initial load
duke
parents:
diff changeset
65 * register it with the WatcherThread as a periodic task.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 */
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void StatSampler::engage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (!is_active()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // start up the periodic task
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _task = new StatSamplerTask(PerfDataSamplingInterval);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _task->enroll();
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
a61af66fc99e Initial load
duke
parents:
diff changeset
82 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
83 * the disengage() method is responsible for deactivating the periodic
a61af66fc99e Initial load
duke
parents:
diff changeset
84 * task and, if logging was enabled, for logging the final sample. This
a61af66fc99e Initial load
duke
parents:
diff changeset
85 * method is called from before_exit() in java.cpp and is only called
a61af66fc99e Initial load
duke
parents:
diff changeset
86 * after the WatcherThread has been stopped.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 */
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void StatSampler::disengage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (!is_active())
a61af66fc99e Initial load
duke
parents:
diff changeset
93 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // remove StatSamplerTask
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _task->disenroll();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 delete _task;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _task = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // force a final sample
a61af66fc99e Initial load
duke
parents:
diff changeset
101 sample_data(_sampled);
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 * the destroy method is responsible for releasing any resources used by
a61af66fc99e Initial load
duke
parents:
diff changeset
106 * the StatSampler prior to shutdown of the VM. this method is called from
a61af66fc99e Initial load
duke
parents:
diff changeset
107 * before_exit() in java.cpp and is only called after the WatcherThread
a61af66fc99e Initial load
duke
parents:
diff changeset
108 * has stopped.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 */
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void StatSampler::destroy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (_sampled != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 delete(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 _sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
121 * The sample_data() method is responsible for sampling the
a61af66fc99e Initial load
duke
parents:
diff changeset
122 * the data value for each PerfData instance in the given list.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 */
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void StatSampler::sample_data(PerfDataList* list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 assert(list != NULL, "null list unexpected");
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 for (int index = 0; index < list->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 PerfData* item = list->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 item->sample();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
135 * the collect_sample() method is the method invoked by the
a61af66fc99e Initial load
duke
parents:
diff changeset
136 * WatcherThread via the PeriodicTask::task() method. This method
a61af66fc99e Initial load
duke
parents:
diff changeset
137 * is responsible for collecting data samples from sampled
a61af66fc99e Initial load
duke
parents:
diff changeset
138 * PerfData instances every PerfDataSamplingInterval milliseconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
139 * It is also responsible for logging the requested set of
a61af66fc99e Initial load
duke
parents:
diff changeset
140 * PerfData instances every _sample_count milliseconds. While
a61af66fc99e Initial load
duke
parents:
diff changeset
141 * logging data, it will output a column header after every _print_header
a61af66fc99e Initial load
duke
parents:
diff changeset
142 * rows of data have been logged.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 */
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void StatSampler::collect_sample() {
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // future - check for new PerfData objects. PerfData objects might
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // get added to the PerfDataManager lists after we have already
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // built our local copies.
a61af66fc99e Initial load
duke
parents:
diff changeset
149 //
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // if (PerfDataManager::count() > previous) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // // get a new copy of the sampled list
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // if (_sampled != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // delete(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // _sampled = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // _sampled = PerfDataManager::sampled();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 assert(_sampled != NULL, "list not initialized");
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 sample_data(_sampled);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
165 * method to upcall into Java to return the value of the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
166 * property as a utf8 string, or NULL if does not exist. The caller
a61af66fc99e Initial load
duke
parents:
diff changeset
167 * is responsible for setting a ResourceMark for proper cleanup of
a61af66fc99e Initial load
duke
parents:
diff changeset
168 * the utf8 strings.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 */
a61af66fc99e Initial load
duke
parents:
diff changeset
170 const char* StatSampler::get_system_property(const char* name, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // setup the arguments to getProperty
a61af66fc99e Initial load
duke
parents:
diff changeset
173 Handle key_str = java_lang_String::create_from_str(name, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // return value
a61af66fc99e Initial load
duke
parents:
diff changeset
176 JavaValue result(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // public static String getProperty(String key, String def);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 JavaCalls::call_static(&result,
a61af66fc99e Initial load
duke
parents:
diff changeset
180 KlassHandle(THREAD, SystemDictionary::system_klass()),
a61af66fc99e Initial load
duke
parents:
diff changeset
181 vmSymbolHandles::getProperty_name(),
a61af66fc99e Initial load
duke
parents:
diff changeset
182 vmSymbolHandles::string_string_signature(),
a61af66fc99e Initial load
duke
parents:
diff changeset
183 key_str,
a61af66fc99e Initial load
duke
parents:
diff changeset
184 CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 oop value_oop = (oop)result.get_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (value_oop == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // convert Java String to utf8 string
a61af66fc99e Initial load
duke
parents:
diff changeset
192 char* value = java_lang_String::as_utf8_string(value_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
198 * The list of System Properties that have corresponding PerfData
a61af66fc99e Initial load
duke
parents:
diff changeset
199 * string instrumentation created by retrieving the named property's
a61af66fc99e Initial load
duke
parents:
diff changeset
200 * value from System.getProperty() and unconditionally creating a
a61af66fc99e Initial load
duke
parents:
diff changeset
201 * PerfStringConstant object initialized to the retreived value. This
a61af66fc99e Initial load
duke
parents:
diff changeset
202 * is not an exhustive list of Java properties with corresponding string
a61af66fc99e Initial load
duke
parents:
diff changeset
203 * instrumentation as the create_system_property_instrumentation() method
a61af66fc99e Initial load
duke
parents:
diff changeset
204 * creates other property based instrumentation conditionally.
a61af66fc99e Initial load
duke
parents:
diff changeset
205 */
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // stable interface, supported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
208 static const char* property_counters_ss[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 "java.vm.specification.version",
a61af66fc99e Initial load
duke
parents:
diff changeset
210 "java.vm.specification.name",
a61af66fc99e Initial load
duke
parents:
diff changeset
211 "java.vm.specification.vendor",
a61af66fc99e Initial load
duke
parents:
diff changeset
212 "java.vm.version",
a61af66fc99e Initial load
duke
parents:
diff changeset
213 "java.vm.name",
a61af66fc99e Initial load
duke
parents:
diff changeset
214 "java.vm.vendor",
a61af66fc99e Initial load
duke
parents:
diff changeset
215 "java.vm.info",
a61af66fc99e Initial load
duke
parents:
diff changeset
216 "java.library.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
217 "java.class.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
218 "java.endorsed.dirs",
a61af66fc99e Initial load
duke
parents:
diff changeset
219 "java.ext.dirs",
a61af66fc99e Initial load
duke
parents:
diff changeset
220 "java.home",
a61af66fc99e Initial load
duke
parents:
diff changeset
221 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
222 };
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // unstable interface, supported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
225 static const char* property_counters_us[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
227 };
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // unstable interface, unsupported counters
a61af66fc99e Initial load
duke
parents:
diff changeset
230 static const char* property_counters_uu[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 "sun.boot.class.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
232 "sun.boot.library.path",
a61af66fc99e Initial load
duke
parents:
diff changeset
233 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
234 };
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 const char** property_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 CounterNS name_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 } PropertyCounters;
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 static PropertyCounters property_counters[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 { property_counters_ss, JAVA_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
243 { property_counters_us, COM_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
244 { property_counters_uu, SUN_PROPERTY },
a61af66fc99e Initial load
duke
parents:
diff changeset
245 { NULL, SUN_PROPERTY }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 };
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
250 * Method to create PerfData string instruments that contain the values
a61af66fc99e Initial load
duke
parents:
diff changeset
251 * of various system properties. String instruments are created for each
a61af66fc99e Initial load
duke
parents:
diff changeset
252 * property specified in the property lists provided in property_counters[].
a61af66fc99e Initial load
duke
parents:
diff changeset
253 * Property counters have a counter name space prefix prepended to the
a61af66fc99e Initial load
duke
parents:
diff changeset
254 * property name as indicated in property_counters[].
a61af66fc99e Initial load
duke
parents:
diff changeset
255 */
a61af66fc99e Initial load
duke
parents:
diff changeset
256 void StatSampler::create_system_property_instrumentation(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 for (int i = 0; property_counters[i].property_list != NULL; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 for (int j = 0; property_counters[i].property_list[j] != NULL; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 const char* property_name = property_counters[i].property_list[j];
a61af66fc99e Initial load
duke
parents:
diff changeset
265 assert(property_name != NULL, "property name should not be NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 const char* value = get_system_property(property_name, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // the property must exist
a61af66fc99e Initial load
duke
parents:
diff changeset
270 assert(value != NULL, "property name should be valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 if (value != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // create the property counter
a61af66fc99e Initial load
duke
parents:
diff changeset
274 PerfDataManager::create_string_constant(property_counters[i].name_space,
a61af66fc99e Initial load
duke
parents:
diff changeset
275 property_name, value, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
282 * The create_misc_perfdata() method provides a place to create
a61af66fc99e Initial load
duke
parents:
diff changeset
283 * PerfData instances that would otherwise have no better place
a61af66fc99e Initial load
duke
parents:
diff changeset
284 * to exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
285 */
a61af66fc99e Initial load
duke
parents:
diff changeset
286 void StatSampler::create_misc_perfdata() {
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // numeric constants
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // frequency of the native high resolution timer
a61af66fc99e Initial load
duke
parents:
diff changeset
294 PerfDataManager::create_constant(SUN_OS, "hrt.frequency",
a61af66fc99e Initial load
duke
parents:
diff changeset
295 PerfData::U_Hertz, os::elapsed_frequency(),
a61af66fc99e Initial load
duke
parents:
diff changeset
296 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // string constants
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // create string instrumentation for various Java properties.
a61af66fc99e Initial load
duke
parents:
diff changeset
301 create_system_property_instrumentation(CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // hotspot flags (from .hotspotrc) and args (from command line)
a61af66fc99e Initial load
duke
parents:
diff changeset
304 //
a61af66fc99e Initial load
duke
parents:
diff changeset
305 PerfDataManager::create_string_constant(JAVA_RT, "vmFlags",
a61af66fc99e Initial load
duke
parents:
diff changeset
306 Arguments::jvm_flags(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 PerfDataManager::create_string_constant(JAVA_RT, "vmArgs",
a61af66fc99e Initial load
duke
parents:
diff changeset
308 Arguments::jvm_args(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // java class name/jar file and arguments to main class
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // note: name is cooridnated with launcher and Arguments.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
312 PerfDataManager::create_string_constant(SUN_RT, "javaCommand",
a61af66fc99e Initial load
duke
parents:
diff changeset
313 Arguments::java_command(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // the Java VM Internal version string
a61af66fc99e Initial load
duke
parents:
diff changeset
316 PerfDataManager::create_string_constant(SUN_RT, "internalVersion",
a61af66fc99e Initial load
duke
parents:
diff changeset
317 VM_Version::internal_vm_info_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
318 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // create sampled instrumentation objects
a61af66fc99e Initial load
duke
parents:
diff changeset
321 create_sampled_perfdata();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
325 * helper class to provide for sampling of the elapsed_counter value
a61af66fc99e Initial load
duke
parents:
diff changeset
326 * maintained in the OS class.
a61af66fc99e Initial load
duke
parents:
diff changeset
327 */
a61af66fc99e Initial load
duke
parents:
diff changeset
328 class HighResTimeSampler : public PerfSampleHelper {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
330 jlong take_sample() { return os::elapsed_counter(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 };
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
334 * the create_sampled_perdata() method provides a place to instantiate
a61af66fc99e Initial load
duke
parents:
diff changeset
335 * sampled PerfData instances that would otherwise have no better place
a61af66fc99e Initial load
duke
parents:
diff changeset
336 * to exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
337 */
a61af66fc99e Initial load
duke
parents:
diff changeset
338 void StatSampler::create_sampled_perfdata() {
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // setup sampling of the elapsed time counter maintained in the
a61af66fc99e Initial load
duke
parents:
diff changeset
343 // the os class. This counter can be used as either a time stamp
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // for each logged entry or as a liveness indicator for the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
345 PerfSampleHelper* psh = new HighResTimeSampler();
a61af66fc99e Initial load
duke
parents:
diff changeset
346 PerfDataManager::create_counter(SUN_OS, "hrt.ticks",
a61af66fc99e Initial load
duke
parents:
diff changeset
347 PerfData::U_Ticks, psh, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
351 * the statSampler_exit() function is called from os_init.cpp on
a61af66fc99e Initial load
duke
parents:
diff changeset
352 * exit of the vm.
a61af66fc99e Initial load
duke
parents:
diff changeset
353 */
a61af66fc99e Initial load
duke
parents:
diff changeset
354 void statSampler_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 StatSampler::destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
359 }