author | jlaskey |
Tue, 23 Jul 2013 12:00:29 -0300 | |
changeset 19089 | 51cfdcf21d35 |
parent 18025 | b7bcf7497f93 |
child 22551 | 9bf46d16dcc6 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
15228
e92acc84ade3
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
13975
diff
changeset
|
2 |
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/vmSymbols.hpp" |
|
27 |
#include "oops/oop.inline.hpp" |
|
28 |
#include "runtime/handles.inline.hpp" |
|
29 |
#include "runtime/java.hpp" |
|
30 |
#include "runtime/mutex.hpp" |
|
31 |
#include "runtime/mutexLocker.hpp" |
|
32 |
#include "runtime/os.hpp" |
|
33 |
#include "runtime/perfData.hpp" |
|
34 |
#include "utilities/exceptions.hpp" |
|
35 |
#include "utilities/globalDefinitions.hpp" |
|
1 | 36 |
|
37 |
PerfDataList* PerfDataManager::_all = NULL; |
|
38 |
PerfDataList* PerfDataManager::_sampled = NULL; |
|
39 |
PerfDataList* PerfDataManager::_constants = NULL; |
|
40 |
||
41 |
/* |
|
42 |
* The jvmstat global and subsysem jvmstat counter name spaces. The top |
|
43 |
* level name spaces imply the interface stability level of the counter, |
|
44 |
* which generally follows the Java package, class, and property naming |
|
45 |
* conventions. The CounterNS enumeration values should be used to index |
|
46 |
* into this array. |
|
47 |
*/ |
|
48 |
const char* PerfDataManager::_name_spaces[] = { |
|
49 |
// top level name spaces |
|
50 |
"java", // stable and supported name space |
|
51 |
"com.sun", // unstable but supported name space |
|
52 |
"sun", // unstable and unsupported name space |
|
53 |
// subsystem name spaces |
|
54 |
"java.gc", // Garbage Collection name spaces |
|
55 |
"com.sun.gc", |
|
56 |
"sun.gc", |
|
57 |
"java.ci", // Compiler name spaces |
|
58 |
"com.sun.ci", |
|
59 |
"sun.ci", |
|
60 |
"java.cls", // Class Loader name spaces |
|
61 |
"com.sun.cls", |
|
62 |
"sun.cls", |
|
63 |
"java.rt", // Runtime name spaces |
|
64 |
"com.sun.rt", |
|
65 |
"sun.rt", |
|
66 |
"java.os", // Operating System name spaces |
|
67 |
"com.sun.os", |
|
68 |
"sun.os", |
|
69 |
"java.threads", // Threads System name spaces |
|
70 |
"com.sun.threads", |
|
71 |
"sun.threads", |
|
72 |
"java.property", // Java Property name spaces |
|
73 |
"com.sun.property", |
|
74 |
"sun.property", |
|
75 |
"", |
|
76 |
}; |
|
77 |
||
78 |
PerfData::PerfData(CounterNS ns, const char* name, Units u, Variability v) |
|
79 |
: _name(NULL), _u(u), _v(v), _valuep(NULL), |
|
80 |
_on_c_heap(false) { |
|
81 |
||
82 |
const char* prefix = PerfDataManager::ns_to_string(ns); |
|
83 |
||
13195 | 84 |
_name = NEW_C_HEAP_ARRAY(char, strlen(name) + strlen(prefix) + 2, mtInternal); |
1 | 85 |
assert(_name != NULL && strlen(name) != 0, "invalid name"); |
86 |
||
87 |
if (ns == NULL_NS) { |
|
88 |
// No prefix is added to counters with the NULL_NS namespace. |
|
89 |
strcpy(_name, name); |
|
90 |
// set the F_Supported flag based on the counter name prefix. |
|
91 |
if (PerfDataManager::is_stable_supported(_name) || |
|
92 |
PerfDataManager::is_unstable_supported(_name)) { |
|
93 |
_flags = F_Supported; |
|
94 |
} |
|
95 |
else { |
|
96 |
_flags = F_None; |
|
97 |
} |
|
98 |
} |
|
99 |
else { |
|
100 |
sprintf(_name, "%s.%s", prefix, name); |
|
101 |
// set the F_Supported flag based on the given namespace. |
|
102 |
if (PerfDataManager::is_stable_supported(ns) || |
|
103 |
PerfDataManager::is_unstable_supported(ns)) { |
|
104 |
_flags = F_Supported; |
|
105 |
} |
|
106 |
else { |
|
107 |
_flags = F_None; |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
||
112 |
PerfData::~PerfData() { |
|
113 |
if (_name != NULL) { |
|
13195 | 114 |
FREE_C_HEAP_ARRAY(char, _name, mtInternal); |
1 | 115 |
} |
116 |
if (is_on_c_heap()) { |
|
13195 | 117 |
FREE_C_HEAP_ARRAY(PerfDataEntry, _pdep, mtInternal); |
1 | 118 |
} |
119 |
} |
|
120 |
||
121 |
void PerfData::create_entry(BasicType dtype, size_t dsize, size_t vlen) { |
|
122 |
||
123 |
size_t dlen = vlen==0 ? 1 : vlen; |
|
124 |
||
125 |
size_t namelen = strlen(name()) + 1; // include null terminator |
|
126 |
size_t size = sizeof(PerfDataEntry) + namelen; |
|
127 |
size_t pad_length = ((size % dsize) == 0) ? 0 : dsize - (size % dsize); |
|
128 |
size += pad_length; |
|
129 |
size_t data_start = size; |
|
130 |
size += (dsize * dlen); |
|
131 |
||
132 |
// align size to assure allocation in units of 8 bytes |
|
133 |
int align = sizeof(jlong) - 1; |
|
134 |
size = ((size + align) & ~align); |
|
135 |
char* psmp = PerfMemory::alloc(size); |
|
136 |
||
137 |
if (psmp == NULL) { |
|
138 |
// out of PerfMemory memory resources. allocate on the C heap |
|
139 |
// to avoid vm termination. |
|
13195 | 140 |
psmp = NEW_C_HEAP_ARRAY(char, size, mtInternal); |
1 | 141 |
_on_c_heap = true; |
142 |
} |
|
143 |
||
144 |
// compute the addresses for the name and data |
|
145 |
char* cname = psmp + sizeof(PerfDataEntry); |
|
146 |
||
147 |
// data is in the last dsize*dlen bytes of the entry |
|
148 |
void* valuep = (void*) (psmp + data_start); |
|
149 |
||
150 |
assert(is_on_c_heap() || PerfMemory::contains(cname), "just checking"); |
|
151 |
assert(is_on_c_heap() || PerfMemory::contains((char*)valuep), "just checking"); |
|
152 |
||
153 |
// copy the name, including null terminator, into PerfData memory |
|
154 |
strcpy(cname, name()); |
|
155 |
||
156 |
||
157 |
// set the header values in PerfData memory |
|
158 |
PerfDataEntry* pdep = (PerfDataEntry*)psmp; |
|
159 |
pdep->entry_length = (jint)size; |
|
160 |
pdep->name_offset = (jint) ((uintptr_t) cname - (uintptr_t) psmp); |
|
161 |
pdep->vector_length = (jint)vlen; |
|
162 |
pdep->data_type = (jbyte) type2char(dtype); |
|
163 |
pdep->data_units = units(); |
|
164 |
pdep->data_variability = variability(); |
|
165 |
pdep->flags = (jbyte)flags(); |
|
166 |
pdep->data_offset = (jint) data_start; |
|
167 |
||
168 |
if (PerfTraceDataCreation) { |
|
169 |
tty->print("name = %s, dtype = %d, variability = %d," |
|
170 |
" units = %d, dsize = %d, vlen = %d," |
|
171 |
" pad_length = %d, size = %d, on_c_heap = %s," |
|
172 |
" address = " INTPTR_FORMAT "," |
|
173 |
" data address = " INTPTR_FORMAT "\n", |
|
174 |
cname, dtype, variability(), |
|
175 |
units(), dsize, vlen, |
|
176 |
pad_length, size, is_on_c_heap() ? "TRUE":"FALSE", |
|
177 |
psmp, valuep); |
|
178 |
} |
|
179 |
||
180 |
// record the start of the entry and the location of the data field. |
|
181 |
_pdep = pdep; |
|
182 |
_valuep = valuep; |
|
183 |
||
184 |
// mark the PerfData memory region as having been updated. |
|
185 |
PerfMemory::mark_updated(); |
|
186 |
} |
|
187 |
||
188 |
PerfLong::PerfLong(CounterNS ns, const char* namep, Units u, Variability v) |
|
189 |
: PerfData(ns, namep, u, v) { |
|
190 |
||
191 |
create_entry(T_LONG, sizeof(jlong)); |
|
192 |
} |
|
193 |
||
194 |
int PerfLong::format(char* buffer, int length) { |
|
15228
e92acc84ade3
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
13975
diff
changeset
|
195 |
return jio_snprintf(buffer, length, JLONG_FORMAT, *(jlong*)_valuep); |
1 | 196 |
} |
197 |
||
198 |
PerfLongVariant::PerfLongVariant(CounterNS ns, const char* namep, Units u, |
|
199 |
Variability v, jlong* sampled) |
|
200 |
: PerfLong(ns, namep, u, v), |
|
201 |
_sampled(sampled), _sample_helper(NULL) { |
|
202 |
||
203 |
sample(); |
|
204 |
} |
|
205 |
||
206 |
PerfLongVariant::PerfLongVariant(CounterNS ns, const char* namep, Units u, |
|
207 |
Variability v, PerfLongSampleHelper* helper) |
|
208 |
: PerfLong(ns, namep, u, v), |
|
209 |
_sampled(NULL), _sample_helper(helper) { |
|
210 |
||
211 |
sample(); |
|
212 |
} |
|
213 |
||
214 |
void PerfLongVariant::sample() { |
|
215 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
216 |
// JJJ - This should not happen. Maybe the first sample is taken |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
217 |
// while the _sample_helper is being null'ed out. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
218 |
// assert(_sample_helper != NULL || _sampled != NULL, "unexpected state"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
219 |
if (_sample_helper == NULL) return; |
1 | 220 |
|
221 |
if (_sample_helper != NULL) { |
|
222 |
*(jlong*)_valuep = _sample_helper->take_sample(); |
|
223 |
} |
|
224 |
else if (_sampled != NULL) { |
|
225 |
*(jlong*)_valuep = *_sampled; |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
PerfByteArray::PerfByteArray(CounterNS ns, const char* namep, Units u, |
|
230 |
Variability v, jint length) |
|
231 |
: PerfData(ns, namep, u, v), _length(length) { |
|
232 |
||
233 |
create_entry(T_BYTE, sizeof(jbyte), (size_t)_length); |
|
234 |
} |
|
235 |
||
236 |
void PerfString::set_string(const char* s2) { |
|
237 |
||
238 |
// copy n bytes of the string, assuring the null string is |
|
239 |
// copied if s2 == NULL. |
|
240 |
strncpy((char *)_valuep, s2 == NULL ? "" : s2, _length); |
|
241 |
||
242 |
// assure the string is null terminated when strlen(s2) >= _length |
|
243 |
((char*)_valuep)[_length-1] = '\0'; |
|
244 |
} |
|
245 |
||
246 |
int PerfString::format(char* buffer, int length) { |
|
247 |
return jio_snprintf(buffer, length, "%s", (char*)_valuep); |
|
248 |
} |
|
249 |
||
250 |
PerfStringConstant::PerfStringConstant(CounterNS ns, const char* namep, |
|
251 |
const char* initial_value) |
|
252 |
: PerfString(ns, namep, V_Constant, |
|
253 |
initial_value == NULL ? 1 : |
|
254 |
MIN2((jint)(strlen((char*)initial_value)+1), |
|
255 |
(jint)(PerfMaxStringConstLength+1)), |
|
256 |
initial_value) { |
|
257 |
||
258 |
if (PrintMiscellaneous && Verbose) { |
|
259 |
if (is_valid() && initial_value != NULL && |
|
260 |
((jint)strlen(initial_value) > (jint)PerfMaxStringConstLength)) { |
|
261 |
||
262 |
warning("Truncating PerfStringConstant: name = %s," |
|
263 |
" length = " INT32_FORMAT "," |
|
264 |
" PerfMaxStringConstLength = " INT32_FORMAT "\n", |
|
265 |
namep, |
|
266 |
(jint)strlen(initial_value), |
|
267 |
(jint)PerfMaxStringConstLength); |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
||
272 |
||
273 |
||
274 |
||
275 |
||
276 |
||
277 |
void PerfDataManager::destroy() { |
|
278 |
||
279 |
if (_all == NULL) |
|
280 |
// destroy already called, or initialization never happened |
|
281 |
return; |
|
282 |
||
283 |
for (int index = 0; index < _all->length(); index++) { |
|
284 |
PerfData* p = _all->at(index); |
|
285 |
delete p; |
|
286 |
} |
|
287 |
||
288 |
delete(_all); |
|
289 |
delete(_sampled); |
|
290 |
delete(_constants); |
|
291 |
||
292 |
_all = NULL; |
|
293 |
_sampled = NULL; |
|
294 |
_constants = NULL; |
|
295 |
} |
|
296 |
||
297 |
void PerfDataManager::add_item(PerfData* p, bool sampled) { |
|
298 |
||
299 |
MutexLocker ml(PerfDataManager_lock); |
|
300 |
||
301 |
if (_all == NULL) { |
|
302 |
_all = new PerfDataList(100); |
|
303 |
} |
|
304 |
||
305 |
assert(!_all->contains(p->name()), "duplicate name added"); |
|
306 |
||
307 |
// add to the list of all perf data items |
|
308 |
_all->append(p); |
|
309 |
||
310 |
if (p->variability() == PerfData::V_Constant) { |
|
311 |
if (_constants == NULL) { |
|
312 |
_constants = new PerfDataList(25); |
|
313 |
} |
|
314 |
_constants->append(p); |
|
315 |
return; |
|
316 |
} |
|
317 |
||
318 |
if (sampled) { |
|
319 |
if (_sampled == NULL) { |
|
320 |
_sampled = new PerfDataList(25); |
|
321 |
} |
|
322 |
_sampled->append(p); |
|
323 |
} |
|
324 |
} |
|
325 |
||
18025 | 326 |
PerfData* PerfDataManager::find_by_name(const char* name) { |
327 |
return _all->find_by_name(name); |
|
328 |
} |
|
329 |
||
1 | 330 |
PerfDataList* PerfDataManager::all() { |
331 |
||
332 |
MutexLocker ml(PerfDataManager_lock); |
|
333 |
||
334 |
if (_all == NULL) |
|
335 |
return NULL; |
|
336 |
||
337 |
PerfDataList* clone = _all->clone(); |
|
338 |
return clone; |
|
339 |
} |
|
340 |
||
341 |
PerfDataList* PerfDataManager::sampled() { |
|
342 |
||
343 |
MutexLocker ml(PerfDataManager_lock); |
|
344 |
||
345 |
if (_sampled == NULL) |
|
346 |
return NULL; |
|
347 |
||
348 |
PerfDataList* clone = _sampled->clone(); |
|
349 |
return clone; |
|
350 |
} |
|
351 |
||
352 |
PerfDataList* PerfDataManager::constants() { |
|
353 |
||
354 |
MutexLocker ml(PerfDataManager_lock); |
|
355 |
||
356 |
if (_constants == NULL) |
|
357 |
return NULL; |
|
358 |
||
359 |
PerfDataList* clone = _constants->clone(); |
|
360 |
return clone; |
|
361 |
} |
|
362 |
||
363 |
char* PerfDataManager::counter_name(const char* ns, const char* name) { |
|
364 |
assert(ns != NULL, "ns string required"); |
|
365 |
assert(name != NULL, "name string required"); |
|
366 |
||
367 |
size_t len = strlen(ns) + strlen(name) + 2; |
|
368 |
char* result = NEW_RESOURCE_ARRAY(char, len); |
|
369 |
sprintf(result, "%s.%s", ns, name); |
|
370 |
return result; |
|
371 |
} |
|
372 |
||
373 |
char* PerfDataManager::name_space(const char* ns, const char* sub, |
|
374 |
int instance) { |
|
375 |
char intbuf[40]; |
|
376 |
jio_snprintf(intbuf, 40, UINT32_FORMAT, instance); |
|
377 |
return name_space(ns, name_space(sub, intbuf)); |
|
378 |
} |
|
379 |
||
380 |
char *PerfDataManager::name_space(const char* ns, int instance) { |
|
381 |
char intbuf[40]; |
|
382 |
jio_snprintf(intbuf, 40, UINT32_FORMAT, instance); |
|
383 |
return name_space(ns, intbuf); |
|
384 |
} |
|
385 |
||
386 |
PerfStringConstant* PerfDataManager::create_string_constant(CounterNS ns, |
|
387 |
const char* name, |
|
388 |
const char* s, |
|
389 |
TRAPS) { |
|
390 |
||
391 |
PerfStringConstant* p = new PerfStringConstant(ns, name, s); |
|
392 |
||
393 |
if (!p->is_valid()) { |
|
394 |
// allocation of native resources failed. |
|
395 |
delete p; |
|
396 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
397 |
} |
|
398 |
||
399 |
add_item(p, false); |
|
400 |
||
401 |
return p; |
|
402 |
} |
|
403 |
||
404 |
PerfLongConstant* PerfDataManager::create_long_constant(CounterNS ns, |
|
405 |
const char* name, |
|
406 |
PerfData::Units u, |
|
407 |
jlong val, TRAPS) { |
|
408 |
||
409 |
PerfLongConstant* p = new PerfLongConstant(ns, name, u, val); |
|
410 |
||
411 |
if (!p->is_valid()) { |
|
412 |
// allocation of native resources failed. |
|
413 |
delete p; |
|
414 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
415 |
} |
|
416 |
||
417 |
add_item(p, false); |
|
418 |
||
419 |
return p; |
|
420 |
} |
|
421 |
||
422 |
PerfStringVariable* PerfDataManager::create_string_variable(CounterNS ns, |
|
423 |
const char* name, |
|
424 |
jint max_length, |
|
425 |
const char* s, |
|
426 |
TRAPS) { |
|
427 |
||
428 |
if (max_length == 0 && s != NULL) max_length = (jint)strlen(s); |
|
429 |
||
430 |
assert(max_length != 0, "PerfStringVariable with length 0"); |
|
431 |
||
432 |
PerfStringVariable* p = new PerfStringVariable(ns, name, max_length, s); |
|
433 |
||
434 |
if (!p->is_valid()) { |
|
435 |
// allocation of native resources failed. |
|
436 |
delete p; |
|
437 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
438 |
} |
|
439 |
||
440 |
add_item(p, false); |
|
441 |
||
442 |
return p; |
|
443 |
} |
|
444 |
||
445 |
PerfLongVariable* PerfDataManager::create_long_variable(CounterNS ns, |
|
446 |
const char* name, |
|
447 |
PerfData::Units u, |
|
448 |
jlong ival, TRAPS) { |
|
449 |
||
450 |
PerfLongVariable* p = new PerfLongVariable(ns, name, u, ival); |
|
451 |
||
452 |
if (!p->is_valid()) { |
|
453 |
// allocation of native resources failed. |
|
454 |
delete p; |
|
455 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
456 |
} |
|
457 |
||
458 |
add_item(p, false); |
|
459 |
||
460 |
return p; |
|
461 |
} |
|
462 |
||
463 |
PerfLongVariable* PerfDataManager::create_long_variable(CounterNS ns, |
|
464 |
const char* name, |
|
465 |
PerfData::Units u, |
|
466 |
jlong* sp, TRAPS) { |
|
467 |
||
468 |
// Sampled counters not supported if UsePerfData is false |
|
469 |
if (!UsePerfData) return NULL; |
|
470 |
||
471 |
PerfLongVariable* p = new PerfLongVariable(ns, name, u, sp); |
|
472 |
||
473 |
if (!p->is_valid()) { |
|
474 |
// allocation of native resources failed. |
|
475 |
delete p; |
|
476 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
477 |
} |
|
478 |
||
479 |
add_item(p, true); |
|
480 |
||
481 |
return p; |
|
482 |
} |
|
483 |
||
484 |
PerfLongVariable* PerfDataManager::create_long_variable(CounterNS ns, |
|
485 |
const char* name, |
|
486 |
PerfData::Units u, |
|
487 |
PerfSampleHelper* sh, |
|
488 |
TRAPS) { |
|
489 |
||
490 |
// Sampled counters not supported if UsePerfData is false |
|
491 |
if (!UsePerfData) return NULL; |
|
492 |
||
493 |
PerfLongVariable* p = new PerfLongVariable(ns, name, u, sh); |
|
494 |
||
495 |
if (!p->is_valid()) { |
|
496 |
// allocation of native resources failed. |
|
497 |
delete p; |
|
498 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
499 |
} |
|
500 |
||
501 |
add_item(p, true); |
|
502 |
||
503 |
return p; |
|
504 |
} |
|
505 |
||
506 |
PerfLongCounter* PerfDataManager::create_long_counter(CounterNS ns, |
|
507 |
const char* name, |
|
508 |
PerfData::Units u, |
|
509 |
jlong ival, TRAPS) { |
|
510 |
||
511 |
PerfLongCounter* p = new PerfLongCounter(ns, name, u, ival); |
|
512 |
||
513 |
if (!p->is_valid()) { |
|
514 |
// allocation of native resources failed. |
|
515 |
delete p; |
|
516 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
517 |
} |
|
518 |
||
519 |
add_item(p, false); |
|
520 |
||
521 |
return p; |
|
522 |
} |
|
523 |
||
524 |
PerfLongCounter* PerfDataManager::create_long_counter(CounterNS ns, |
|
525 |
const char* name, |
|
526 |
PerfData::Units u, |
|
527 |
jlong* sp, TRAPS) { |
|
528 |
||
529 |
// Sampled counters not supported if UsePerfData is false |
|
530 |
if (!UsePerfData) return NULL; |
|
531 |
||
532 |
PerfLongCounter* p = new PerfLongCounter(ns, name, u, sp); |
|
533 |
||
534 |
if (!p->is_valid()) { |
|
535 |
// allocation of native resources failed. |
|
536 |
delete p; |
|
537 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
538 |
} |
|
539 |
||
540 |
add_item(p, true); |
|
541 |
||
542 |
return p; |
|
543 |
} |
|
544 |
||
545 |
PerfLongCounter* PerfDataManager::create_long_counter(CounterNS ns, |
|
546 |
const char* name, |
|
547 |
PerfData::Units u, |
|
548 |
PerfSampleHelper* sh, |
|
549 |
TRAPS) { |
|
550 |
||
551 |
// Sampled counters not supported if UsePerfData is false |
|
552 |
if (!UsePerfData) return NULL; |
|
553 |
||
554 |
PerfLongCounter* p = new PerfLongCounter(ns, name, u, sh); |
|
555 |
||
556 |
if (!p->is_valid()) { |
|
557 |
// allocation of native resources failed. |
|
558 |
delete p; |
|
559 |
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); |
|
560 |
} |
|
561 |
||
562 |
add_item(p, true); |
|
563 |
||
564 |
return p; |
|
565 |
} |
|
566 |
||
567 |
PerfDataList::PerfDataList(int length) { |
|
568 |
||
13195 | 569 |
_set = new(ResourceObj::C_HEAP, mtInternal) PerfDataArray(length, true); |
1 | 570 |
} |
571 |
||
572 |
PerfDataList::PerfDataList(PerfDataList* p) { |
|
573 |
||
13195 | 574 |
_set = new(ResourceObj::C_HEAP, mtInternal) PerfDataArray(p->length(), true); |
1 | 575 |
|
576 |
_set->appendAll(p->get_impl()); |
|
577 |
} |
|
578 |
||
579 |
PerfDataList::~PerfDataList() { |
|
580 |
||
581 |
delete _set; |
|
582 |
||
583 |
} |
|
584 |
||
585 |
bool PerfDataList::by_name(void* name, PerfData* pd) { |
|
586 |
||
587 |
if (pd == NULL) |
|
588 |
return false; |
|
589 |
||
590 |
return strcmp((const char*)name, pd->name()) == 0; |
|
591 |
} |
|
592 |
||
593 |
PerfData* PerfDataList::find_by_name(const char* name) { |
|
594 |
||
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
595 |
// if add_item hasn't been called the list won't be initialized |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
596 |
if (this == NULL) |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
597 |
return NULL; |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
598 |
|
1 | 599 |
int i = _set->find((void*)name, PerfDataList::by_name); |
600 |
||
601 |
if (i >= 0 && i <= _set->length()) |
|
602 |
return _set->at(i); |
|
603 |
else |
|
604 |
return NULL; |
|
605 |
} |
|
606 |
||
607 |
PerfDataList* PerfDataList::clone() { |
|
608 |
||
609 |
PerfDataList* copy = new PerfDataList(this); |
|
610 |
||
611 |
assert(copy != NULL, "just checking"); |
|
612 |
||
613 |
return copy; |
|
614 |
} |