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