author | pliden |
Fri, 11 Apr 2014 12:29:24 +0200 | |
changeset 24094 | 5dbf1f44de18 |
parent 13728 | 882756847a04 |
child 25715 | d5a8dbdc5150 |
permissions | -rw-r--r-- |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11771
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
4 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
8 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
13 |
* accompanied this code). |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
14 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
18 |
* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
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:
3261
diff
changeset
|
21 |
* questions. |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
22 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
23 |
*/ |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
24 |
|
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "code/codeBlob.hpp" |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "prims/jvm.h" |
|
30 |
#include "runtime/dtraceJSDT.hpp" |
|
31 |
#include "runtime/jniHandles.hpp" |
|
32 |
#include "runtime/os.hpp" |
|
33 |
#include "utilities/exceptions.hpp" |
|
34 |
#include "utilities/globalDefinitions.hpp" |
|
35 |
#include "utilities/utf8.hpp" |
|
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
36 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
37 |
#ifdef HAVE_DTRACE_H |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
38 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
39 |
jlong DTraceJSDT::activate( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
40 |
jint version, jstring module_name, jint providers_count, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
41 |
JVM_DTraceProvider* providers, TRAPS) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
42 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
43 |
size_t count = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
44 |
RegisteredProbes* probes = NULL; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
45 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
46 |
if (!is_supported()) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
47 |
return 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
48 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
49 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
50 |
assert(module_name != NULL, "valid module name"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
51 |
assert(providers != NULL, "valid provider array"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
52 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
53 |
for (int i = 0; i < providers_count; ++i) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
54 |
count += providers[i].probe_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
55 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
56 |
probes = new RegisteredProbes(count); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
57 |
count = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
58 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
59 |
for (int i = 0; i < providers_count; ++i) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
60 |
assert(providers[i].name != NULL, "valid provider name"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
61 |
assert(providers[i].probe_count == 0 || providers[i].probes != NULL, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
62 |
"valid probe count"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
63 |
for (int j = 0; j < providers[i].probe_count; ++j) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
64 |
JVM_DTraceProbe* probe = &(providers[i].probes[j]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
65 |
assert(probe != NULL, "valid probe"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
66 |
assert(probe->method != NULL, "valid method"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
67 |
assert(probe->name != NULL, "valid probe name"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
68 |
assert(probe->function != NULL, "valid probe function spec"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
69 |
methodHandle h_method = |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11771
diff
changeset
|
70 |
methodHandle(THREAD, Method::resolve_jmethod_id(probe->method)); |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
71 |
nmethod* nm = AdapterHandlerLibrary::create_dtrace_nmethod(h_method); |
2732
3ab85419f523
6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents:
670
diff
changeset
|
72 |
if (nm == NULL) { |
3ab85419f523
6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents:
670
diff
changeset
|
73 |
delete probes; |
3ab85419f523
6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents:
670
diff
changeset
|
74 |
THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), |
3ab85419f523
6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents:
670
diff
changeset
|
75 |
"Unable to register DTrace probes (CodeCache: no room for DTrace nmethods)."); |
3ab85419f523
6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents:
670
diff
changeset
|
76 |
} |
6453 | 77 |
h_method()->set_not_compilable(); |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
78 |
h_method()->set_code(h_method, nm); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
79 |
probes->nmethod_at_put(count++, nm); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
80 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
81 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
82 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
83 |
int handle = pd_activate((void*)probes, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
84 |
module_name, providers_count, providers); |
11771 | 85 |
if (handle < 0) { |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
86 |
delete probes; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
87 |
THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
88 |
"Unable to register DTrace probes (internal error)."); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
89 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
90 |
probes->set_helper_handle(handle); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
91 |
return RegisteredProbes::toOpaqueProbes(probes); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
92 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
93 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
94 |
jboolean DTraceJSDT::is_probe_enabled(jmethodID method) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11771
diff
changeset
|
95 |
Method* m = Method::resolve_jmethod_id(method); |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
96 |
return nativeInstruction_at(m->code()->trap_address())->is_dtrace_trap(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
97 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
98 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
99 |
void DTraceJSDT::dispose(OpaqueProbes probes) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
100 |
RegisteredProbes* p = RegisteredProbes::toRegisteredProbes(probes); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
101 |
if (probes != -1 && p != NULL) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
102 |
pd_dispose(p->helper_handle()); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
103 |
delete p; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
104 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
105 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
106 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
107 |
jboolean DTraceJSDT::is_supported() { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
108 |
return pd_is_supported(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
109 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
110 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
111 |
#else // HAVE_DTRACE_H |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
112 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
113 |
jlong DTraceJSDT::activate( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
114 |
jint version, jstring module_name, jint providers_count, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
115 |
JVM_DTraceProvider* providers, TRAPS) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
116 |
return 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
117 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
118 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
119 |
jboolean DTraceJSDT::is_probe_enabled(jmethodID method) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
120 |
return false; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
121 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
122 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
123 |
void DTraceJSDT::dispose(OpaqueProbes probes) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
124 |
return; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
125 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
126 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
127 |
jboolean DTraceJSDT::is_supported() { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
128 |
return false; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
129 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
130 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
131 |
#endif // ndef HAVE_DTRACE_H |