Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/dtraceJSDT.hpp @ 116:018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
Summary: Initial checkin of JSDT code
Reviewed-by: acorn, sbohne
author | kamg |
---|---|
date | Thu, 17 Apr 2008 22:18:15 -0400 |
parents | |
children | d1605aabd0a1 |
comparison
equal
deleted
inserted
replaced
115:e7a91a357527 | 116:018d5b58dd4f |
---|---|
1 /* | |
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. | |
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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 class RegisteredProbes; | |
26 typedef jlong OpaqueProbes; | |
27 | |
28 class DTraceJSDT : AllStatic { | |
29 private: | |
30 | |
31 static int pd_activate(void* moduleBaseAddress, jstring module, | |
32 jint providers_count, JVM_DTraceProvider* providers); | |
33 static void pd_dispose(int handle); | |
34 static jboolean pd_is_supported(); | |
35 | |
36 public: | |
37 | |
38 static OpaqueProbes activate( | |
39 jint version, jstring module_name, jint providers_count, | |
40 JVM_DTraceProvider* providers, TRAPS); | |
41 static jboolean is_probe_enabled(jmethodID method); | |
42 static void dispose(OpaqueProbes handle); | |
43 static jboolean is_supported(); | |
44 }; | |
45 | |
46 class RegisteredProbes : public CHeapObj { | |
47 private: | |
48 nmethod** _nmethods; // all the probe methods | |
49 size_t _count; // number of probe methods | |
50 int _helper_handle; // DTrace-assigned identifier | |
51 | |
52 public: | |
53 RegisteredProbes(size_t count) { | |
54 _count = count; | |
55 _nmethods = NEW_C_HEAP_ARRAY(nmethod*, count); | |
56 } | |
57 | |
58 ~RegisteredProbes() { | |
59 for (size_t i = 0; i < _count; ++i) { | |
60 // Let the sweeper reclaim it | |
61 _nmethods[i]->make_not_entrant(); | |
62 _nmethods[i]->method()->clear_code(); | |
63 } | |
64 FREE_C_HEAP_ARRAY(nmethod*, _nmethods); | |
65 _nmethods = NULL; | |
66 _count = 0; | |
67 } | |
68 | |
69 static RegisteredProbes* toRegisteredProbes(OpaqueProbes p) { | |
70 return (RegisteredProbes*)(intptr_t)p; | |
71 } | |
72 | |
73 static OpaqueProbes toOpaqueProbes(RegisteredProbes* p) { | |
74 return (OpaqueProbes)(intptr_t)p; | |
75 } | |
76 | |
77 void set_helper_handle(int handle) { _helper_handle = handle; } | |
78 int helper_handle() const { return _helper_handle; } | |
79 | |
80 nmethod* nmethod_at(size_t i) { | |
81 assert(i >= 0 && i < _count, "bad nmethod index"); | |
82 return _nmethods[i]; | |
83 } | |
84 | |
85 void nmethod_at_put(size_t i, nmethod* nm) { | |
86 assert(i >= 0 && i < _count, "bad nmethod index"); | |
87 _nmethods[i] = nm; | |
88 } | |
89 }; |