Mercurial > hg > truffle
annotate src/share/vm/prims/jni.cpp @ 21936:49dad3e40b57
Convert addresses in ArrayCopyCallNode to word size
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Fri, 12 Jun 2015 14:52:08 +0200 |
parents | be896a1983c0 |
children |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17898
diff
changeset
|
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
6837
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
3 * Copyright (c) 2012 Red Hat, Inc. |
0 | 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * | |
6 * This code is free software; you can redistribute it and/or modify it | |
7 * under the terms of the GNU General Public License version 2 only, as | |
8 * published by the Free Software Foundation. | |
9 * | |
10 * This code is distributed in the hope that it will be useful, but WITHOUT | |
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 * version 2 for more details (a copy is included in the LICENSE file that | |
14 * accompanied this code). | |
15 * | |
16 * You should have received a copy of the GNU General Public License version | |
17 * 2 along with this work; if not, write to the Free Software Foundation, | |
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
21 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
22 * questions. |
0 | 23 * |
24 */ | |
25 | |
1972 | 26 #include "precompiled.hpp" |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6940
diff
changeset
|
27 #include "ci/ciReplay.hpp" |
6162 | 28 #include "classfile/altHashing.hpp" |
1972 | 29 #include "classfile/classLoader.hpp" |
30 #include "classfile/javaClasses.hpp" | |
31 #include "classfile/symbolTable.hpp" | |
32 #include "classfile/systemDictionary.hpp" | |
33 #include "classfile/vmSymbols.hpp" | |
34 #include "interpreter/linkResolver.hpp" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
35 #include "utilities/macros.hpp" |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
36 #ifdef JVMCI |
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
37 #include "jvmci/jvmciCompiler.hpp" |
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
38 #include "jvmci/jvmciRuntime.hpp" |
4559
723df37192d6
Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4368
diff
changeset
|
39 #endif |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
40 #if INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
41 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
42 #endif // INCLUDE_ALL_GCS |
6197 | 43 #include "memory/allocation.hpp" |
1972 | 44 #include "memory/allocation.inline.hpp" |
45 #include "memory/gcLocker.inline.hpp" | |
46 #include "memory/oopFactory.hpp" | |
47 #include "memory/universe.inline.hpp" | |
48 #include "oops/instanceKlass.hpp" | |
49 #include "oops/instanceOop.hpp" | |
50 #include "oops/markOop.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
51 #include "oops/method.hpp" |
1972 | 52 #include "oops/objArrayKlass.hpp" |
53 #include "oops/objArrayOop.hpp" | |
54 #include "oops/oop.inline.hpp" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
55 #include "oops/symbol.hpp" |
1972 | 56 #include "oops/typeArrayKlass.hpp" |
57 #include "oops/typeArrayOop.hpp" | |
58 #include "prims/jni.h" | |
59 #include "prims/jniCheck.hpp" | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
60 #include "prims/jniExport.hpp" |
1972 | 61 #include "prims/jniFastGetField.hpp" |
62 #include "prims/jvm.h" | |
63 #include "prims/jvm_misc.hpp" | |
64 #include "prims/jvmtiExport.hpp" | |
65 #include "prims/jvmtiThreadState.hpp" | |
66 #include "runtime/compilationPolicy.hpp" | |
67 #include "runtime/fieldDescriptor.hpp" | |
68 #include "runtime/fprofiler.hpp" | |
69 #include "runtime/handles.inline.hpp" | |
70 #include "runtime/interfaceSupport.hpp" | |
71 #include "runtime/java.hpp" | |
72 #include "runtime/javaCalls.hpp" | |
73 #include "runtime/jfieldIDWorkaround.hpp" | |
20197
ce8f6bb717c9
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
17937
diff
changeset
|
74 #include "runtime/orderAccess.inline.hpp" |
1972 | 75 #include "runtime/reflection.hpp" |
76 #include "runtime/sharedRuntime.hpp" | |
77 #include "runtime/signature.hpp" | |
7180
f34d701e952e
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
6985
diff
changeset
|
78 #include "runtime/thread.inline.hpp" |
1972 | 79 #include "runtime/vm_operations.hpp" |
20360 | 80 #include "services/memTracker.hpp" |
1972 | 81 #include "services/runtimeService.hpp" |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
82 #include "trace/tracing.hpp" |
1972 | 83 #include "utilities/defaultStream.hpp" |
84 #include "utilities/dtrace.hpp" | |
85 #include "utilities/events.hpp" | |
86 #include "utilities/histogram.hpp" | |
87 #ifdef TARGET_OS_FAMILY_linux | |
88 # include "os_linux.inline.hpp" | |
89 #endif | |
90 #ifdef TARGET_OS_FAMILY_solaris | |
91 # include "os_solaris.inline.hpp" | |
92 #endif | |
93 #ifdef TARGET_OS_FAMILY_windows | |
94 # include "os_windows.inline.hpp" | |
95 #endif | |
3960 | 96 #ifdef TARGET_OS_FAMILY_bsd |
97 # include "os_bsd.inline.hpp" | |
98 #endif | |
0 | 99 |
8793
499ccc15bbc8
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
bpittore
parents:
8001
diff
changeset
|
100 static jint CurrentVersion = JNI_VERSION_1_8; |
0 | 101 |
102 | |
103 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace | |
104 // '-return' probe regardless of the return path is taken out of the function. | |
105 // Methods that have multiple return paths use this to avoid having to | |
106 // instrument each return path. Methods that use CHECK or THROW must use this | |
107 // since those macros can cause an immedate uninstrumented return. | |
108 // | |
109 // In order to get the return value, a reference to the variable containing | |
110 // the return value must be passed to the contructor of the object, and | |
111 // the return value must be set before return (since the mark object has | |
112 // a reference to it). | |
113 // | |
114 // Example: | |
115 // DT_RETURN_MARK_DECL(SomeFunc, int); | |
116 // JNI_ENTRY(int, SomeFunc, ...) | |
117 // int return_value = 0; | |
118 // DT_RETURN_MARK(SomeFunc, int, (const int&)return_value); | |
119 // foo(CHECK_0) | |
120 // return_value = 5; | |
121 // return return_value; | |
122 // JNI_END | |
4006 | 123 #ifndef USDT2 |
0 | 124 #define DT_RETURN_MARK_DECL(name, type) \ |
125 HS_DTRACE_PROBE_DECL1(hotspot_jni, name##__return, type); \ | |
126 DTRACE_ONLY( \ | |
127 class DTraceReturnProbeMark_##name { \ | |
128 public: \ | |
129 const type& _ret_ref; \ | |
130 DTraceReturnProbeMark_##name(const type& v) : _ret_ref(v) {} \ | |
131 ~DTraceReturnProbeMark_##name() { \ | |
132 HS_DTRACE_PROBE1(hotspot_jni, name##__return, _ret_ref); \ | |
133 } \ | |
134 } \ | |
135 ) | |
136 // Void functions are simpler since there's no return value | |
137 #define DT_VOID_RETURN_MARK_DECL(name) \ | |
138 HS_DTRACE_PROBE_DECL0(hotspot_jni, name##__return); \ | |
139 DTRACE_ONLY( \ | |
140 class DTraceReturnProbeMark_##name { \ | |
141 public: \ | |
142 ~DTraceReturnProbeMark_##name() { \ | |
143 HS_DTRACE_PROBE0(hotspot_jni, name##__return); \ | |
144 } \ | |
145 } \ | |
146 ) | |
147 | |
4006 | 148 #else /* USDT2 */ |
149 | |
150 #define DT_RETURN_MARK_DECL(name, type, probe) \ | |
151 DTRACE_ONLY( \ | |
152 class DTraceReturnProbeMark_##name { \ | |
153 public: \ | |
154 const type& _ret_ref; \ | |
155 DTraceReturnProbeMark_##name(const type& v) : _ret_ref(v) {} \ | |
156 ~DTraceReturnProbeMark_##name() { \ | |
157 probe; \ | |
158 } \ | |
159 } \ | |
160 ) | |
161 // Void functions are simpler since there's no return value | |
162 #define DT_VOID_RETURN_MARK_DECL(name, probe) \ | |
163 DTRACE_ONLY( \ | |
164 class DTraceReturnProbeMark_##name { \ | |
165 public: \ | |
166 ~DTraceReturnProbeMark_##name() { \ | |
167 probe; \ | |
168 } \ | |
169 } \ | |
170 ) | |
171 #endif /* USDT2 */ | |
0 | 172 |
173 // Place these macros in the function to mark the return. Non-void | |
174 // functions need the type and address of the return value. | |
175 #define DT_RETURN_MARK(name, type, ref) \ | |
176 DTRACE_ONLY( DTraceReturnProbeMark_##name dtrace_return_mark(ref) ) | |
177 #define DT_VOID_RETURN_MARK(name) \ | |
178 DTRACE_ONLY( DTraceReturnProbeMark_##name dtrace_return_mark ) | |
179 | |
180 | |
181 // Use these to select distinct code for floating-point vs. non-floating point | |
182 // situations. Used from within common macros where we need slightly | |
183 // different behavior for Float/Double | |
184 #define FP_SELECT_Boolean(intcode, fpcode) intcode | |
185 #define FP_SELECT_Byte(intcode, fpcode) intcode | |
186 #define FP_SELECT_Char(intcode, fpcode) intcode | |
187 #define FP_SELECT_Short(intcode, fpcode) intcode | |
188 #define FP_SELECT_Object(intcode, fpcode) intcode | |
189 #define FP_SELECT_Int(intcode, fpcode) intcode | |
190 #define FP_SELECT_Long(intcode, fpcode) intcode | |
191 #define FP_SELECT_Float(intcode, fpcode) fpcode | |
192 #define FP_SELECT_Double(intcode, fpcode) fpcode | |
193 #define FP_SELECT(TypeName, intcode, fpcode) \ | |
194 FP_SELECT_##TypeName(intcode, fpcode) | |
195 | |
196 #define COMMA , | |
197 | |
198 // Choose DT_RETURN_MARK macros based on the type: float/double -> void | |
199 // (dtrace doesn't do FP yet) | |
4006 | 200 #ifndef USDT2 |
0 | 201 #define DT_RETURN_MARK_DECL_FOR(TypeName, name, type) \ |
202 FP_SELECT(TypeName, \ | |
203 DT_RETURN_MARK_DECL(name, type), DT_VOID_RETURN_MARK_DECL(name) ) | |
4006 | 204 #else /* USDT2 */ |
205 #define DT_RETURN_MARK_DECL_FOR(TypeName, name, type, probe) \ | |
206 FP_SELECT(TypeName, \ | |
207 DT_RETURN_MARK_DECL(name, type, probe), DT_VOID_RETURN_MARK_DECL(name, probe) ) | |
208 #endif /* USDT2 */ | |
0 | 209 #define DT_RETURN_MARK_FOR(TypeName, name, type, ref) \ |
210 FP_SELECT(TypeName, \ | |
211 DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) ) | |
212 | |
213 | |
214 // out-of-line helpers for class jfieldIDWorkaround: | |
215 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
216 bool jfieldIDWorkaround::is_valid_jfieldID(Klass* k, jfieldID id) { |
0 | 217 if (jfieldIDWorkaround::is_instance_jfieldID(k, id)) { |
218 uintptr_t as_uint = (uintptr_t) id; | |
219 intptr_t offset = raw_instance_offset(id); | |
220 if (is_checked_jfieldID(id)) { | |
221 if (!klass_hash_ok(k, id)) { | |
222 return false; | |
223 } | |
224 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
225 return InstanceKlass::cast(k)->contains_field_offset(offset); |
0 | 226 } else { |
227 JNIid* result = (JNIid*) id; | |
228 #ifdef ASSERT | |
229 return result != NULL && result->is_static_field_id(); | |
230 #else | |
231 return result != NULL; | |
232 #endif | |
233 } | |
234 } | |
235 | |
236 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
237 intptr_t jfieldIDWorkaround::encode_klass_hash(Klass* k, intptr_t offset) { |
0 | 238 if (offset <= small_offset_mask) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
239 Klass* field_klass = k; |
6983 | 240 Klass* super_klass = field_klass->super(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
241 // With compressed oops the most super class with nonstatic fields would |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
242 // be the owner of fields embedded in the header. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
243 while (InstanceKlass::cast(super_klass)->has_nonstatic_fields() && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
244 InstanceKlass::cast(super_klass)->contains_field_offset(offset)) { |
0 | 245 field_klass = super_klass; // super contains the field also |
6983 | 246 super_klass = field_klass->super(); |
0 | 247 } |
248 debug_only(No_Safepoint_Verifier nosafepoint;) | |
249 uintptr_t klass_hash = field_klass->identity_hash(); | |
250 return ((klass_hash & klass_mask) << klass_shift) | checked_mask_in_place; | |
251 } else { | |
252 #if 0 | |
253 #ifndef PRODUCT | |
254 { | |
255 ResourceMark rm; | |
6983 | 256 warning("VerifyJNIFields: long offset %d in %s", offset, k->external_name()); |
0 | 257 } |
258 #endif | |
259 #endif | |
260 return 0; | |
261 } | |
262 } | |
263 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
264 bool jfieldIDWorkaround::klass_hash_ok(Klass* k, jfieldID id) { |
0 | 265 uintptr_t as_uint = (uintptr_t) id; |
266 intptr_t klass_hash = (as_uint >> klass_shift) & klass_mask; | |
267 do { | |
268 debug_only(No_Safepoint_Verifier nosafepoint;) | |
269 // Could use a non-blocking query for identity_hash here... | |
270 if ((k->identity_hash() & klass_mask) == klass_hash) | |
271 return true; | |
6983 | 272 k = k->super(); |
0 | 273 } while (k != NULL); |
274 return false; | |
275 } | |
276 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
277 void jfieldIDWorkaround::verify_instance_jfieldID(Klass* k, jfieldID id) { |
0 | 278 guarantee(jfieldIDWorkaround::is_instance_jfieldID(k, id), "must be an instance field" ); |
279 uintptr_t as_uint = (uintptr_t) id; | |
280 intptr_t offset = raw_instance_offset(id); | |
281 if (VerifyJNIFields) { | |
282 if (is_checked_jfieldID(id)) { | |
283 guarantee(klass_hash_ok(k, id), | |
284 "Bug in native code: jfieldID class must match object"); | |
285 } else { | |
286 #if 0 | |
287 #ifndef PRODUCT | |
288 if (Verbose) { | |
289 ResourceMark rm; | |
6983 | 290 warning("VerifyJNIFields: unverified offset %d for %s", offset, k->external_name()); |
0 | 291 } |
292 #endif | |
293 #endif | |
294 } | |
295 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
296 guarantee(InstanceKlass::cast(k)->contains_field_offset(offset), |
0 | 297 "Bug in native code: jfieldID offset must address interior of object"); |
298 } | |
299 | |
300 // Wrapper to trace JNI functions | |
301 | |
302 #ifdef ASSERT | |
303 Histogram* JNIHistogram; | |
304 static volatile jint JNIHistogram_lock = 0; | |
305 | |
306 class JNITraceWrapper : public StackObj { | |
307 public: | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17898
diff
changeset
|
308 JNITraceWrapper(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) { |
0 | 309 if (TraceJNICalls) { |
310 va_list ap; | |
311 va_start(ap, format); | |
312 tty->print("JNI "); | |
313 tty->vprint_cr(format, ap); | |
314 va_end(ap); | |
315 } | |
316 } | |
317 }; | |
318 | |
319 class JNIHistogramElement : public HistogramElement { | |
320 public: | |
321 JNIHistogramElement(const char* name); | |
322 }; | |
323 | |
324 JNIHistogramElement::JNIHistogramElement(const char* elementName) { | |
325 _name = elementName; | |
326 uintx count = 0; | |
327 | |
328 while (Atomic::cmpxchg(1, &JNIHistogram_lock, 0) != 0) { | |
329 while (OrderAccess::load_acquire(&JNIHistogram_lock) != 0) { | |
330 count +=1; | |
331 if ( (WarnOnStalledSpinLock > 0) | |
332 && (count % WarnOnStalledSpinLock == 0)) { | |
333 warning("JNIHistogram_lock seems to be stalled"); | |
334 } | |
335 } | |
336 } | |
337 | |
338 | |
339 if(JNIHistogram == NULL) | |
340 JNIHistogram = new Histogram("JNI Call Counts",100); | |
341 | |
342 JNIHistogram->add_element(this); | |
343 Atomic::dec(&JNIHistogram_lock); | |
344 } | |
345 | |
346 #define JNICountWrapper(arg) \ | |
347 static JNIHistogramElement* e = new JNIHistogramElement(arg); \ | |
348 /* There is a MT-race condition in VC++. So we need to make sure that that e has been initialized */ \ | |
349 if (e != NULL) e->increment_count() | |
350 #define JNIWrapper(arg) JNICountWrapper(arg); JNITraceWrapper(arg) | |
351 #else | |
352 #define JNIWrapper(arg) | |
353 #endif | |
354 | |
355 | |
356 // Implementation of JNI entries | |
357 | |
4006 | 358 #ifndef USDT2 |
0 | 359 DT_RETURN_MARK_DECL(DefineClass, jclass); |
4006 | 360 #else /* USDT2 */ |
361 DT_RETURN_MARK_DECL(DefineClass, jclass | |
362 , HOTSPOT_JNI_DEFINECLASS_RETURN(_ret_ref)); | |
363 #endif /* USDT2 */ | |
0 | 364 |
365 JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderRef, | |
366 const jbyte *buf, jsize bufLen)) | |
367 JNIWrapper("DefineClass"); | |
368 | |
4006 | 369 #ifndef USDT2 |
0 | 370 DTRACE_PROBE5(hotspot_jni, DefineClass__entry, |
371 env, name, loaderRef, buf, bufLen); | |
4006 | 372 #else /* USDT2 */ |
373 HOTSPOT_JNI_DEFINECLASS_ENTRY( | |
374 env, (char*) name, loaderRef, (char*) buf, bufLen); | |
375 #endif /* USDT2 */ | |
0 | 376 jclass cls = NULL; |
377 DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); | |
378 | |
6125
dcfcdd01af4b
7171703: JNI DefineClass crashes client VM when first parameter is NULL
fparain
parents:
4800
diff
changeset
|
379 TempNewSymbol class_name = NULL; |
0 | 380 // Since exceptions can be thrown, class initialization can take place |
381 // if name is NULL no check for class name in .class stream has to be made. | |
382 if (name != NULL) { | |
383 const int str_len = (int)strlen(name); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
384 if (str_len > Symbol::max_length()) { |
0 | 385 // It's impossible to create this class; the name cannot fit |
386 // into the constant pool. | |
387 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | |
388 } | |
6125
dcfcdd01af4b
7171703: JNI DefineClass crashes client VM when first parameter is NULL
fparain
parents:
4800
diff
changeset
|
389 class_name = SymbolTable::new_symbol(name, CHECK_NULL); |
0 | 390 } |
391 ResourceMark rm(THREAD); | |
392 ClassFileStream st((u1*) buf, bufLen, NULL); | |
393 Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); | |
394 | |
395 if (UsePerfData && !class_loader.is_null()) { | |
396 // check whether the current caller thread holds the lock or not. | |
397 // If not, increment the corresponding counter | |
398 if (ObjectSynchronizer:: | |
399 query_lock_ownership((JavaThread*)THREAD, class_loader) != | |
400 ObjectSynchronizer::owner_self) { | |
401 ClassLoader::sync_JNIDefineClassLockFreeCounter()->inc(); | |
402 } | |
403 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
404 Klass* k = SystemDictionary::resolve_from_stream(class_name, class_loader, |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
657
diff
changeset
|
405 Handle(), &st, true, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
657
diff
changeset
|
406 CHECK_NULL); |
0 | 407 |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
408 if (TraceClassResolution && k != NULL) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
409 trace_class_resolution(k); |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
410 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
411 |
0 | 412 cls = (jclass)JNIHandles::make_local( |
6983 | 413 env, k->java_mirror()); |
0 | 414 return cls; |
415 JNI_END | |
416 | |
417 | |
418 | |
419 static bool first_time_FindClass = true; | |
420 | |
4006 | 421 #ifndef USDT2 |
0 | 422 DT_RETURN_MARK_DECL(FindClass, jclass); |
4006 | 423 #else /* USDT2 */ |
424 DT_RETURN_MARK_DECL(FindClass, jclass | |
425 , HOTSPOT_JNI_FINDCLASS_RETURN(_ret_ref)); | |
426 #endif /* USDT2 */ | |
0 | 427 |
428 JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) | |
429 JNIWrapper("FindClass"); | |
4006 | 430 #ifndef USDT2 |
0 | 431 DTRACE_PROBE2(hotspot_jni, FindClass__entry, env, name); |
4006 | 432 #else /* USDT2 */ |
433 HOTSPOT_JNI_FINDCLASS_ENTRY( | |
434 env, (char *)name); | |
435 #endif /* USDT2 */ | |
0 | 436 |
437 jclass result = NULL; | |
438 DT_RETURN_MARK(FindClass, jclass, (const jclass&)result); | |
439 | |
440 // Remember if we are the first invocation of jni_FindClass | |
441 bool first_time = first_time_FindClass; | |
442 first_time_FindClass = false; | |
443 | |
444 // Sanity check the name: it cannot be null or larger than the maximum size | |
445 // name we can fit in the constant pool. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
446 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
0 | 447 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
448 } | |
449 | |
450 //%note jni_3 | |
451 Handle loader; | |
452 Handle protection_domain; | |
453 // Find calling class | |
454 instanceKlassHandle k (THREAD, thread->security_get_caller_class(0)); | |
455 if (k.not_null()) { | |
456 loader = Handle(THREAD, k->class_loader()); | |
457 // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed | |
458 // in the correct class context. | |
459 if (loader.is_null() && | |
460 k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) { | |
461 JavaValue result(T_OBJECT); | |
462 JavaCalls::call_static(&result, k, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
463 vmSymbols::getFromClass_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
464 vmSymbols::void_class_signature(), |
0 | 465 thread); |
466 if (HAS_PENDING_EXCEPTION) { | |
467 Handle ex(thread, thread->pending_exception()); | |
468 CLEAR_PENDING_EXCEPTION; | |
469 THROW_HANDLE_0(ex); | |
470 } | |
471 oop mirror = (oop) result.get_jobject(); | |
472 loader = Handle(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
473 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->class_loader()); |
0 | 474 protection_domain = Handle(THREAD, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
475 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->protection_domain()); |
0 | 476 } |
477 } else { | |
478 // We call ClassLoader.getSystemClassLoader to obtain the system class loader. | |
479 loader = Handle(THREAD, SystemDictionary::java_system_loader()); | |
480 } | |
481 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
482 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
0 | 483 result = find_class_from_class_loader(env, sym, true, loader, |
484 protection_domain, true, thread); | |
485 | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
486 if (TraceClassResolution && result != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
487 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
488 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
489 |
0 | 490 // If we were the first invocation of jni_FindClass, we enable compilation again |
491 // rather than just allowing invocation counter to overflow and decay. | |
492 // Controlled by flag DelayCompilationDuringStartup. | |
493 if (first_time && !CompileTheWorld) | |
494 CompilationPolicy::completed_vm_startup(); | |
495 | |
496 return result; | |
497 JNI_END | |
498 | |
4006 | 499 #ifndef USDT2 |
0 | 500 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID); |
4006 | 501 #else /* USDT2 */ |
502 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID | |
503 , HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN((uintptr_t)_ret_ref)); | |
504 #endif /* USDT2 */ | |
0 | 505 |
506 JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) | |
507 JNIWrapper("FromReflectedMethod"); | |
4006 | 508 #ifndef USDT2 |
0 | 509 DTRACE_PROBE2(hotspot_jni, FromReflectedMethod__entry, env, method); |
4006 | 510 #else /* USDT2 */ |
511 HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY( | |
512 env, method); | |
513 #endif /* USDT2 */ | |
0 | 514 jmethodID ret = NULL; |
515 DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret); | |
516 | |
517 // method is a handle to a java.lang.reflect.Method object | |
518 oop reflected = JNIHandles::resolve_non_null(method); | |
519 oop mirror = NULL; | |
520 int slot = 0; | |
521 | |
1142 | 522 if (reflected->klass() == SystemDictionary::reflect_Constructor_klass()) { |
0 | 523 mirror = java_lang_reflect_Constructor::clazz(reflected); |
524 slot = java_lang_reflect_Constructor::slot(reflected); | |
525 } else { | |
1142 | 526 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); |
0 | 527 mirror = java_lang_reflect_Method::clazz(reflected); |
528 slot = java_lang_reflect_Method::slot(reflected); | |
529 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
530 Klass* k = java_lang_Class::as_Klass(mirror); |
0 | 531 |
532 KlassHandle k1(THREAD, k); | |
533 // Make sure class is initialized before handing id's out to methods | |
6983 | 534 k1()->initialize(CHECK_NULL); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
535 Method* m = InstanceKlass::cast(k1())->method_with_idnum(slot); |
0 | 536 ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted |
537 return ret; | |
538 JNI_END | |
539 | |
4006 | 540 #ifndef USDT2 |
0 | 541 DT_RETURN_MARK_DECL(FromReflectedField, jfieldID); |
4006 | 542 #else /* USDT2 */ |
543 DT_RETURN_MARK_DECL(FromReflectedField, jfieldID | |
544 , HOTSPOT_JNI_FROMREFLECTEDFIELD_RETURN((uintptr_t)_ret_ref)); | |
545 #endif /* USDT2 */ | |
0 | 546 |
547 JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) | |
548 JNIWrapper("FromReflectedField"); | |
4006 | 549 #ifndef USDT2 |
0 | 550 DTRACE_PROBE2(hotspot_jni, FromReflectedField__entry, env, field); |
4006 | 551 #else /* USDT2 */ |
552 HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY( | |
553 env, field); | |
554 #endif /* USDT2 */ | |
0 | 555 jfieldID ret = NULL; |
556 DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); | |
557 | |
558 // field is a handle to a java.lang.reflect.Field object | |
559 oop reflected = JNIHandles::resolve_non_null(field); | |
560 oop mirror = java_lang_reflect_Field::clazz(reflected); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
561 Klass* k = java_lang_Class::as_Klass(mirror); |
0 | 562 int slot = java_lang_reflect_Field::slot(reflected); |
563 int modifiers = java_lang_reflect_Field::modifiers(reflected); | |
564 | |
565 KlassHandle k1(THREAD, k); | |
566 // Make sure class is initialized before handing id's out to fields | |
6983 | 567 k1()->initialize(CHECK_NULL); |
0 | 568 |
569 // First check if this is a static field | |
570 if (modifiers & JVM_ACC_STATIC) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
571 intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
572 JNIid* id = InstanceKlass::cast(k1())->jni_id_for(offset); |
0 | 573 assert(id != NULL, "corrupt Field object"); |
574 debug_only(id->set_is_static_field_id();) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
575 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass* |
0 | 576 ret = jfieldIDWorkaround::to_static_jfieldID(id); |
577 return ret; | |
578 } | |
579 | |
580 // The slot is the index of the field description in the field-array | |
581 // The jfieldID is the offset of the field within the object | |
582 // It may also have hash bits for k, if VerifyJNIFields is turned on. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
583 intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
584 assert(InstanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); |
0 | 585 ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); |
586 return ret; | |
587 JNI_END | |
588 | |
4006 | 589 #ifndef USDT2 |
0 | 590 DT_RETURN_MARK_DECL(ToReflectedMethod, jobject); |
4006 | 591 #else /* USDT2 */ |
592 DT_RETURN_MARK_DECL(ToReflectedMethod, jobject | |
593 , HOTSPOT_JNI_TOREFLECTEDMETHOD_RETURN(_ret_ref)); | |
594 #endif /* USDT2 */ | |
0 | 595 |
596 JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID method_id, jboolean isStatic)) | |
597 JNIWrapper("ToReflectedMethod"); | |
4006 | 598 #ifndef USDT2 |
0 | 599 DTRACE_PROBE4(hotspot_jni, ToReflectedMethod__entry, env, cls, method_id, isStatic); |
4006 | 600 #else /* USDT2 */ |
601 HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY( | |
602 env, cls, (uintptr_t) method_id, isStatic); | |
603 #endif /* USDT2 */ | |
0 | 604 jobject ret = NULL; |
605 DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); | |
606 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
607 methodHandle m (THREAD, Method::resolve_jmethod_id(method_id)); |
0 | 608 assert(m->is_static() == (isStatic != 0), "jni_ToReflectedMethod access flags doesn't match"); |
609 oop reflection_method; | |
610 if (m->is_initializer()) { | |
611 reflection_method = Reflection::new_constructor(m, CHECK_NULL); | |
612 } else { | |
613 reflection_method = Reflection::new_method(m, UseNewReflection, false, CHECK_NULL); | |
614 } | |
615 ret = JNIHandles::make_local(env, reflection_method); | |
616 return ret; | |
617 JNI_END | |
618 | |
4006 | 619 #ifndef USDT2 |
0 | 620 DT_RETURN_MARK_DECL(GetSuperclass, jclass); |
4006 | 621 #else /* USDT2 */ |
622 DT_RETURN_MARK_DECL(GetSuperclass, jclass | |
623 , HOTSPOT_JNI_GETSUPERCLASS_RETURN(_ret_ref)); | |
624 #endif /* USDT2 */ | |
0 | 625 |
626 JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) | |
627 JNIWrapper("GetSuperclass"); | |
4006 | 628 #ifndef USDT2 |
0 | 629 DTRACE_PROBE2(hotspot_jni, GetSuperclass__entry, env, sub); |
4006 | 630 #else /* USDT2 */ |
631 HOTSPOT_JNI_GETSUPERCLASS_ENTRY( | |
632 env, sub); | |
633 #endif /* USDT2 */ | |
0 | 634 jclass obj = NULL; |
635 DT_RETURN_MARK(GetSuperclass, jclass, (const jclass&)obj); | |
636 | |
637 oop mirror = JNIHandles::resolve_non_null(sub); | |
638 // primitive classes return NULL | |
639 if (java_lang_Class::is_primitive(mirror)) return NULL; | |
640 | |
641 // Rules of Class.getSuperClass as implemented by KLass::java_super: | |
642 // arrays return Object | |
643 // interfaces return NULL | |
644 // proper classes return Klass::super() | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
645 Klass* k = java_lang_Class::as_Klass(mirror); |
6983 | 646 if (k->is_interface()) return NULL; |
0 | 647 |
648 // return mirror for superclass | |
6983 | 649 Klass* super = k->java_super(); |
0 | 650 // super2 is the value computed by the compiler's getSuperClass intrinsic: |
6983 | 651 debug_only(Klass* super2 = ( k->oop_is_array() |
1142 | 652 ? SystemDictionary::Object_klass() |
6983 | 653 : k->super() ) ); |
0 | 654 assert(super == super2, |
655 "java_super computation depends on interface, array, other super"); | |
6983 | 656 obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(super->java_mirror()); |
0 | 657 return obj; |
658 JNI_END | |
659 | |
660 JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass super)) | |
661 JNIWrapper("IsSubclassOf"); | |
4006 | 662 #ifndef USDT2 |
0 | 663 DTRACE_PROBE3(hotspot_jni, IsAssignableFrom__entry, env, sub, super); |
4006 | 664 #else /* USDT2 */ |
665 HOTSPOT_JNI_ISASSIGNABLEFROM_ENTRY( | |
666 env, sub, super); | |
667 #endif /* USDT2 */ | |
0 | 668 oop sub_mirror = JNIHandles::resolve_non_null(sub); |
669 oop super_mirror = JNIHandles::resolve_non_null(super); | |
670 if (java_lang_Class::is_primitive(sub_mirror) || | |
671 java_lang_Class::is_primitive(super_mirror)) { | |
672 jboolean ret = (sub_mirror == super_mirror); | |
4006 | 673 #ifndef USDT2 |
0 | 674 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); |
4006 | 675 #else /* USDT2 */ |
676 HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN( | |
677 ret); | |
678 #endif /* USDT2 */ | |
0 | 679 return ret; |
680 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
681 Klass* sub_klass = java_lang_Class::as_Klass(sub_mirror); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
682 Klass* super_klass = java_lang_Class::as_Klass(super_mirror); |
0 | 683 assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); |
6983 | 684 jboolean ret = sub_klass->is_subtype_of(super_klass) ? |
0 | 685 JNI_TRUE : JNI_FALSE; |
4006 | 686 #ifndef USDT2 |
0 | 687 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); |
4006 | 688 #else /* USDT2 */ |
689 HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN( | |
690 ret); | |
691 #endif /* USDT2 */ | |
0 | 692 return ret; |
693 JNI_END | |
694 | |
4006 | 695 #ifndef USDT2 |
0 | 696 DT_RETURN_MARK_DECL(Throw, jint); |
4006 | 697 #else /* USDT2 */ |
698 DT_RETURN_MARK_DECL(Throw, jint | |
699 , HOTSPOT_JNI_THROW_RETURN(_ret_ref)); | |
700 #endif /* USDT2 */ | |
0 | 701 |
702 JNI_ENTRY(jint, jni_Throw(JNIEnv *env, jthrowable obj)) | |
703 JNIWrapper("Throw"); | |
4006 | 704 #ifndef USDT2 |
0 | 705 DTRACE_PROBE2(hotspot_jni, Throw__entry, env, obj); |
4006 | 706 #else /* USDT2 */ |
707 HOTSPOT_JNI_THROW_ENTRY( | |
708 env, obj); | |
709 #endif /* USDT2 */ | |
0 | 710 jint ret = JNI_OK; |
711 DT_RETURN_MARK(Throw, jint, (const jint&)ret); | |
712 | |
713 THROW_OOP_(JNIHandles::resolve(obj), JNI_OK); | |
714 ShouldNotReachHere(); | |
715 JNI_END | |
716 | |
4006 | 717 #ifndef USDT2 |
0 | 718 DT_RETURN_MARK_DECL(ThrowNew, jint); |
4006 | 719 #else /* USDT2 */ |
720 DT_RETURN_MARK_DECL(ThrowNew, jint | |
721 , HOTSPOT_JNI_THROWNEW_RETURN(_ret_ref)); | |
722 #endif /* USDT2 */ | |
0 | 723 |
724 JNI_ENTRY(jint, jni_ThrowNew(JNIEnv *env, jclass clazz, const char *message)) | |
725 JNIWrapper("ThrowNew"); | |
4006 | 726 #ifndef USDT2 |
0 | 727 DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message); |
4006 | 728 #else /* USDT2 */ |
729 HOTSPOT_JNI_THROWNEW_ENTRY( | |
730 env, clazz, (char *) message); | |
731 #endif /* USDT2 */ | |
0 | 732 jint ret = JNI_OK; |
733 DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); | |
734 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
735 InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
736 Symbol* name = k->name(); |
0 | 737 Handle class_loader (THREAD, k->class_loader()); |
738 Handle protection_domain (THREAD, k->protection_domain()); | |
739 THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK); | |
740 ShouldNotReachHere(); | |
741 JNI_END | |
742 | |
743 | |
744 // JNI functions only transform a pending async exception to a synchronous | |
745 // exception in ExceptionOccurred and ExceptionCheck calls, since | |
746 // delivering an async exception in other places won't change the native | |
747 // code's control flow and would be harmful when native code further calls | |
748 // JNI functions with a pending exception. Async exception is also checked | |
749 // during the call, so ExceptionOccurred/ExceptionCheck won't return | |
750 // false but deliver the async exception at the very end during | |
751 // state transition. | |
752 | |
753 static void jni_check_async_exceptions(JavaThread *thread) { | |
754 assert(thread == Thread::current(), "must be itself"); | |
755 thread->check_and_handle_async_exceptions(); | |
756 } | |
757 | |
758 JNI_ENTRY_NO_PRESERVE(jthrowable, jni_ExceptionOccurred(JNIEnv *env)) | |
759 JNIWrapper("ExceptionOccurred"); | |
4006 | 760 #ifndef USDT2 |
0 | 761 DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__entry, env); |
4006 | 762 #else /* USDT2 */ |
763 HOTSPOT_JNI_EXCEPTIONOCCURRED_ENTRY( | |
764 env); | |
765 #endif /* USDT2 */ | |
0 | 766 jni_check_async_exceptions(thread); |
767 oop exception = thread->pending_exception(); | |
768 jthrowable ret = (jthrowable) JNIHandles::make_local(env, exception); | |
4006 | 769 #ifndef USDT2 |
0 | 770 DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__return, ret); |
4006 | 771 #else /* USDT2 */ |
772 HOTSPOT_JNI_EXCEPTIONOCCURRED_RETURN( | |
773 ret); | |
774 #endif /* USDT2 */ | |
0 | 775 return ret; |
776 JNI_END | |
777 | |
778 | |
779 JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) | |
780 JNIWrapper("ExceptionDescribe"); | |
4006 | 781 #ifndef USDT2 |
0 | 782 DTRACE_PROBE1(hotspot_jni, ExceptionDescribe__entry, env); |
4006 | 783 #else /* USDT2 */ |
784 HOTSPOT_JNI_EXCEPTIONDESCRIBE_ENTRY( | |
785 env); | |
786 #endif /* USDT2 */ | |
0 | 787 if (thread->has_pending_exception()) { |
788 Handle ex(thread, thread->pending_exception()); | |
789 thread->clear_pending_exception(); | |
1142 | 790 if (ex->is_a(SystemDictionary::ThreadDeath_klass())) { |
0 | 791 // Don't print anything if we are being killed. |
792 } else { | |
793 jio_fprintf(defaultStream::error_stream(), "Exception "); | |
794 if (thread != NULL && thread->threadObj() != NULL) { | |
795 ResourceMark rm(THREAD); | |
796 jio_fprintf(defaultStream::error_stream(), | |
797 "in thread \"%s\" ", thread->get_thread_name()); | |
798 } | |
1142 | 799 if (ex->is_a(SystemDictionary::Throwable_klass())) { |
0 | 800 JavaValue result(T_VOID); |
801 JavaCalls::call_virtual(&result, | |
802 ex, | |
803 KlassHandle(THREAD, | |
1142 | 804 SystemDictionary::Throwable_klass()), |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
805 vmSymbols::printStackTrace_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
806 vmSymbols::void_method_signature(), |
0 | 807 THREAD); |
808 // If an exception is thrown in the call it gets thrown away. Not much | |
809 // we can do with it. The native code that calls this, does not check | |
810 // for the exception - hence, it might still be in the thread when DestroyVM gets | |
811 // called, potentially causing a few asserts to trigger - since no pending exception | |
812 // is expected. | |
813 CLEAR_PENDING_EXCEPTION; | |
814 } else { | |
815 ResourceMark rm(THREAD); | |
816 jio_fprintf(defaultStream::error_stream(), | |
817 ". Uncaught exception of type %s.", | |
6983 | 818 ex->klass()->external_name()); |
0 | 819 } |
820 } | |
821 } | |
4006 | 822 #ifndef USDT2 |
0 | 823 DTRACE_PROBE(hotspot_jni, ExceptionDescribe__return); |
4006 | 824 #else /* USDT2 */ |
825 HOTSPOT_JNI_EXCEPTIONDESCRIBE_RETURN( | |
826 ); | |
827 #endif /* USDT2 */ | |
0 | 828 JNI_END |
829 | |
830 | |
831 JNI_QUICK_ENTRY(void, jni_ExceptionClear(JNIEnv *env)) | |
832 JNIWrapper("ExceptionClear"); | |
4006 | 833 #ifndef USDT2 |
0 | 834 DTRACE_PROBE1(hotspot_jni, ExceptionClear__entry, env); |
4006 | 835 #else /* USDT2 */ |
836 HOTSPOT_JNI_EXCEPTIONCLEAR_ENTRY( | |
837 env); | |
838 #endif /* USDT2 */ | |
0 | 839 |
840 // The jni code might be using this API to clear java thrown exception. | |
841 // So just mark jvmti thread exception state as exception caught. | |
842 JvmtiThreadState *state = JavaThread::current()->jvmti_thread_state(); | |
843 if (state != NULL && state->is_exception_detected()) { | |
844 state->set_exception_caught(); | |
845 } | |
846 thread->clear_pending_exception(); | |
4006 | 847 #ifndef USDT2 |
0 | 848 DTRACE_PROBE(hotspot_jni, ExceptionClear__return); |
4006 | 849 #else /* USDT2 */ |
850 HOTSPOT_JNI_EXCEPTIONCLEAR_RETURN( | |
851 ); | |
852 #endif /* USDT2 */ | |
0 | 853 JNI_END |
854 | |
855 | |
856 JNI_ENTRY(void, jni_FatalError(JNIEnv *env, const char *msg)) | |
857 JNIWrapper("FatalError"); | |
4006 | 858 #ifndef USDT2 |
0 | 859 DTRACE_PROBE2(hotspot_jni, FatalError__entry, env, msg); |
4006 | 860 #else /* USDT2 */ |
861 HOTSPOT_JNI_FATALERROR_ENTRY( | |
862 env, (char *) msg); | |
863 #endif /* USDT2 */ | |
0 | 864 tty->print_cr("FATAL ERROR in native method: %s", msg); |
865 thread->print_stack(); | |
227
8d852b81e775
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
113
diff
changeset
|
866 os::abort(); // Dump core and abort |
0 | 867 JNI_END |
868 | |
869 | |
870 JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity)) | |
871 JNIWrapper("PushLocalFrame"); | |
4006 | 872 #ifndef USDT2 |
0 | 873 DTRACE_PROBE2(hotspot_jni, PushLocalFrame__entry, env, capacity); |
4006 | 874 #else /* USDT2 */ |
875 HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY( | |
876 env, capacity); | |
877 #endif /* USDT2 */ | |
0 | 878 //%note jni_11 |
20324
8ae0d26ab728
8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY
dsimms
parents:
20318
diff
changeset
|
879 if (capacity < 0 || |
8ae0d26ab728
8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY
dsimms
parents:
20318
diff
changeset
|
880 ((MaxJNILocalCapacity > 0) && (capacity > MaxJNILocalCapacity))) { |
4006 | 881 #ifndef USDT2 |
0 | 882 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR); |
4006 | 883 #else /* USDT2 */ |
884 HOTSPOT_JNI_PUSHLOCALFRAME_RETURN( | |
885 (uint32_t)JNI_ERR); | |
886 #endif /* USDT2 */ | |
0 | 887 return JNI_ERR; |
888 } | |
889 JNIHandleBlock* old_handles = thread->active_handles(); | |
890 JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread); | |
891 assert(new_handles != NULL, "should not be NULL"); | |
892 new_handles->set_pop_frame_link(old_handles); | |
893 thread->set_active_handles(new_handles); | |
894 jint ret = JNI_OK; | |
4006 | 895 #ifndef USDT2 |
0 | 896 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, ret); |
4006 | 897 #else /* USDT2 */ |
898 HOTSPOT_JNI_PUSHLOCALFRAME_RETURN( | |
899 ret); | |
900 #endif /* USDT2 */ | |
0 | 901 return ret; |
902 JNI_END | |
903 | |
904 | |
905 JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result)) | |
906 JNIWrapper("PopLocalFrame"); | |
4006 | 907 #ifndef USDT2 |
0 | 908 DTRACE_PROBE2(hotspot_jni, PopLocalFrame__entry, env, result); |
4006 | 909 #else /* USDT2 */ |
910 HOTSPOT_JNI_POPLOCALFRAME_ENTRY( | |
911 env, result); | |
912 #endif /* USDT2 */ | |
0 | 913 //%note jni_11 |
914 Handle result_handle(thread, JNIHandles::resolve(result)); | |
915 JNIHandleBlock* old_handles = thread->active_handles(); | |
916 JNIHandleBlock* new_handles = old_handles->pop_frame_link(); | |
917 if (new_handles != NULL) { | |
918 // As a sanity check we only release the handle blocks if the pop_frame_link is not NULL. | |
919 // This way code will still work if PopLocalFrame is called without a corresponding | |
920 // PushLocalFrame call. Note that we set the pop_frame_link to NULL explicitly, otherwise | |
921 // the release_block call will release the blocks. | |
922 thread->set_active_handles(new_handles); | |
923 old_handles->set_pop_frame_link(NULL); // clear link we won't release new_handles below | |
924 JNIHandleBlock::release_block(old_handles, thread); // may block | |
925 result = JNIHandles::make_local(thread, result_handle()); | |
926 } | |
4006 | 927 #ifndef USDT2 |
0 | 928 DTRACE_PROBE1(hotspot_jni, PopLocalFrame__return, result); |
4006 | 929 #else /* USDT2 */ |
930 HOTSPOT_JNI_POPLOCALFRAME_RETURN( | |
931 result); | |
932 #endif /* USDT2 */ | |
0 | 933 return result; |
934 JNI_END | |
935 | |
936 | |
937 JNI_ENTRY(jobject, jni_NewGlobalRef(JNIEnv *env, jobject ref)) | |
938 JNIWrapper("NewGlobalRef"); | |
4006 | 939 #ifndef USDT2 |
0 | 940 DTRACE_PROBE2(hotspot_jni, NewGlobalRef__entry, env, ref); |
4006 | 941 #else /* USDT2 */ |
942 HOTSPOT_JNI_NEWGLOBALREF_ENTRY( | |
943 env, ref); | |
944 #endif /* USDT2 */ | |
0 | 945 Handle ref_handle(thread, JNIHandles::resolve(ref)); |
946 jobject ret = JNIHandles::make_global(ref_handle); | |
4006 | 947 #ifndef USDT2 |
0 | 948 DTRACE_PROBE1(hotspot_jni, NewGlobalRef__return, ret); |
4006 | 949 #else /* USDT2 */ |
950 HOTSPOT_JNI_NEWGLOBALREF_RETURN( | |
951 ret); | |
952 #endif /* USDT2 */ | |
0 | 953 return ret; |
954 JNI_END | |
955 | |
956 // Must be JNI_ENTRY (with HandleMark) | |
957 JNI_ENTRY_NO_PRESERVE(void, jni_DeleteGlobalRef(JNIEnv *env, jobject ref)) | |
958 JNIWrapper("DeleteGlobalRef"); | |
4006 | 959 #ifndef USDT2 |
0 | 960 DTRACE_PROBE2(hotspot_jni, DeleteGlobalRef__entry, env, ref); |
4006 | 961 #else /* USDT2 */ |
962 HOTSPOT_JNI_DELETEGLOBALREF_ENTRY( | |
963 env, ref); | |
964 #endif /* USDT2 */ | |
0 | 965 JNIHandles::destroy_global(ref); |
4006 | 966 #ifndef USDT2 |
0 | 967 DTRACE_PROBE(hotspot_jni, DeleteGlobalRef__return); |
4006 | 968 #else /* USDT2 */ |
969 HOTSPOT_JNI_DELETEGLOBALREF_RETURN( | |
970 ); | |
971 #endif /* USDT2 */ | |
0 | 972 JNI_END |
973 | |
974 JNI_QUICK_ENTRY(void, jni_DeleteLocalRef(JNIEnv *env, jobject obj)) | |
975 JNIWrapper("DeleteLocalRef"); | |
4006 | 976 #ifndef USDT2 |
0 | 977 DTRACE_PROBE2(hotspot_jni, DeleteLocalRef__entry, env, obj); |
4006 | 978 #else /* USDT2 */ |
979 HOTSPOT_JNI_DELETELOCALREF_ENTRY( | |
980 env, obj); | |
981 #endif /* USDT2 */ | |
0 | 982 JNIHandles::destroy_local(obj); |
4006 | 983 #ifndef USDT2 |
0 | 984 DTRACE_PROBE(hotspot_jni, DeleteLocalRef__return); |
4006 | 985 #else /* USDT2 */ |
986 HOTSPOT_JNI_DELETELOCALREF_RETURN( | |
987 ); | |
988 #endif /* USDT2 */ | |
0 | 989 JNI_END |
990 | |
991 JNI_QUICK_ENTRY(jboolean, jni_IsSameObject(JNIEnv *env, jobject r1, jobject r2)) | |
992 JNIWrapper("IsSameObject"); | |
4006 | 993 #ifndef USDT2 |
0 | 994 DTRACE_PROBE3(hotspot_jni, IsSameObject__entry, env, r1, r2); |
4006 | 995 #else /* USDT2 */ |
996 HOTSPOT_JNI_ISSAMEOBJECT_ENTRY( | |
997 env, r1, r2); | |
998 #endif /* USDT2 */ | |
0 | 999 oop a = JNIHandles::resolve(r1); |
1000 oop b = JNIHandles::resolve(r2); | |
1001 jboolean ret = (a == b) ? JNI_TRUE : JNI_FALSE; | |
4006 | 1002 #ifndef USDT2 |
0 | 1003 DTRACE_PROBE1(hotspot_jni, IsSameObject__return, ret); |
4006 | 1004 #else /* USDT2 */ |
1005 HOTSPOT_JNI_ISSAMEOBJECT_RETURN( | |
1006 ret); | |
1007 #endif /* USDT2 */ | |
0 | 1008 return ret; |
1009 JNI_END | |
1010 | |
1011 | |
1012 JNI_ENTRY(jobject, jni_NewLocalRef(JNIEnv *env, jobject ref)) | |
1013 JNIWrapper("NewLocalRef"); | |
4006 | 1014 #ifndef USDT2 |
0 | 1015 DTRACE_PROBE2(hotspot_jni, NewLocalRef__entry, env, ref); |
4006 | 1016 #else /* USDT2 */ |
1017 HOTSPOT_JNI_NEWLOCALREF_ENTRY( | |
1018 env, ref); | |
1019 #endif /* USDT2 */ | |
0 | 1020 jobject ret = JNIHandles::make_local(env, JNIHandles::resolve(ref)); |
4006 | 1021 #ifndef USDT2 |
0 | 1022 DTRACE_PROBE1(hotspot_jni, NewLocalRef__return, ret); |
4006 | 1023 #else /* USDT2 */ |
1024 HOTSPOT_JNI_NEWLOCALREF_RETURN( | |
1025 ret); | |
1026 #endif /* USDT2 */ | |
0 | 1027 return ret; |
1028 JNI_END | |
1029 | |
1030 JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity)) | |
1031 JNIWrapper("EnsureLocalCapacity"); | |
4006 | 1032 #ifndef USDT2 |
0 | 1033 DTRACE_PROBE2(hotspot_jni, EnsureLocalCapacity__entry, env, capacity); |
4006 | 1034 #else /* USDT2 */ |
1035 HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY( | |
1036 env, capacity); | |
1037 #endif /* USDT2 */ | |
0 | 1038 jint ret; |
20324
8ae0d26ab728
8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY
dsimms
parents:
20318
diff
changeset
|
1039 if (capacity >= 0 && |
8ae0d26ab728
8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY
dsimms
parents:
20318
diff
changeset
|
1040 ((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) { |
0 | 1041 ret = JNI_OK; |
1042 } else { | |
1043 ret = JNI_ERR; | |
1044 } | |
4006 | 1045 #ifndef USDT2 |
0 | 1046 DTRACE_PROBE1(hotspot_jni, EnsureLocalCapacity__return, ret); |
4006 | 1047 #else /* USDT2 */ |
1048 HOTSPOT_JNI_ENSURELOCALCAPACITY_RETURN( | |
1049 ret); | |
1050 #endif /* USDT2 */ | |
0 | 1051 return ret; |
1052 JNI_END | |
1053 | |
1054 // Return the Handle Type | |
1055 JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj)) | |
1056 JNIWrapper("GetObjectRefType"); | |
4006 | 1057 #ifndef USDT2 |
0 | 1058 DTRACE_PROBE2(hotspot_jni, GetObjectRefType__entry, env, obj); |
4006 | 1059 #else /* USDT2 */ |
1060 HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY( | |
1061 env, obj); | |
1062 #endif /* USDT2 */ | |
0 | 1063 jobjectRefType ret; |
1064 if (JNIHandles::is_local_handle(thread, obj) || | |
1065 JNIHandles::is_frame_handle(thread, obj)) | |
1066 ret = JNILocalRefType; | |
1067 else if (JNIHandles::is_global_handle(obj)) | |
1068 ret = JNIGlobalRefType; | |
1069 else if (JNIHandles::is_weak_global_handle(obj)) | |
1070 ret = JNIWeakGlobalRefType; | |
1071 else | |
1072 ret = JNIInvalidRefType; | |
4006 | 1073 #ifndef USDT2 |
0 | 1074 DTRACE_PROBE1(hotspot_jni, GetObjectRefType__return, ret); |
4006 | 1075 #else /* USDT2 */ |
1076 HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN( | |
1077 (void *) ret); | |
1078 #endif /* USDT2 */ | |
0 | 1079 return ret; |
1080 JNI_END | |
1081 | |
1082 | |
1083 class JNI_ArgumentPusher : public SignatureIterator { | |
1084 protected: | |
1085 JavaCallArguments* _arguments; | |
1086 | |
1087 virtual void get_bool () = 0; | |
1088 virtual void get_char () = 0; | |
1089 virtual void get_short () = 0; | |
1090 virtual void get_byte () = 0; | |
1091 virtual void get_int () = 0; | |
1092 virtual void get_long () = 0; | |
1093 virtual void get_float () = 0; | |
1094 virtual void get_double () = 0; | |
1095 virtual void get_object () = 0; | |
1096 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1097 JNI_ArgumentPusher(Symbol* signature) : SignatureIterator(signature) { |
0 | 1098 this->_return_type = T_ILLEGAL; |
1099 _arguments = NULL; | |
1100 } | |
1101 | |
1102 public: | |
1103 virtual void iterate( uint64_t fingerprint ) = 0; | |
1104 | |
1105 void set_java_argument_object(JavaCallArguments *arguments) { _arguments = arguments; } | |
1106 | |
1107 inline void do_bool() { if (!is_return_type()) get_bool(); } | |
1108 inline void do_char() { if (!is_return_type()) get_char(); } | |
1109 inline void do_short() { if (!is_return_type()) get_short(); } | |
1110 inline void do_byte() { if (!is_return_type()) get_byte(); } | |
1111 inline void do_int() { if (!is_return_type()) get_int(); } | |
1112 inline void do_long() { if (!is_return_type()) get_long(); } | |
1113 inline void do_float() { if (!is_return_type()) get_float(); } | |
1114 inline void do_double() { if (!is_return_type()) get_double(); } | |
1115 inline void do_object(int begin, int end) { if (!is_return_type()) get_object(); } | |
1116 inline void do_array(int begin, int end) { if (!is_return_type()) get_object(); } // do_array uses get_object -- there is no get_array | |
1117 inline void do_void() { } | |
1118 | |
1119 JavaCallArguments* arguments() { return _arguments; } | |
1120 void push_receiver(Handle h) { _arguments->push_oop(h); } | |
1121 }; | |
1122 | |
1123 | |
1124 class JNI_ArgumentPusherVaArg : public JNI_ArgumentPusher { | |
1125 protected: | |
1126 va_list _ap; | |
1127 | |
1128 inline void get_bool() { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg | |
1129 inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg | |
1130 inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg | |
1131 inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg | |
1132 inline void get_int() { _arguments->push_int(va_arg(_ap, jint)); } | |
1133 | |
1134 // each of these paths is exercized by the various jck Call[Static,Nonvirtual,][Void,Int,..]Method[A,V,] tests | |
1135 | |
1136 inline void get_long() { _arguments->push_long(va_arg(_ap, jlong)); } | |
1137 inline void get_float() { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg | |
1138 inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); } | |
1139 inline void get_object() { jobject l = va_arg(_ap, jobject); | |
1140 _arguments->push_oop(Handle((oop *)l, false)); } | |
1141 | |
1142 inline void set_ap(va_list rap) { | |
1143 #ifdef va_copy | |
1144 va_copy(_ap, rap); | |
1145 #elif defined (__va_copy) | |
1146 __va_copy(_ap, rap); | |
1147 #else | |
1148 _ap = rap; | |
1149 #endif | |
1150 } | |
1151 | |
1152 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1153 JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1154 : JNI_ArgumentPusher(signature) { |
0 | 1155 set_ap(rap); |
1156 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1157 JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1158 : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) { |
0 | 1159 set_ap(rap); |
1160 } | |
1161 | |
1162 // Optimized path if we have the bitvector form of signature | |
1163 void iterate( uint64_t fingerprint ) { | |
1164 if ( fingerprint == UCONST64(-1) ) SignatureIterator::iterate();// Must be too many arguments | |
1165 else { | |
1166 _return_type = (BasicType)((fingerprint >> static_feature_size) & | |
1167 result_feature_mask); | |
1168 | |
1169 assert(fingerprint, "Fingerprint should not be 0"); | |
1170 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | |
1171 while ( 1 ) { | |
1172 switch ( fingerprint & parameter_feature_mask ) { | |
1173 case bool_parm: | |
1174 case char_parm: | |
1175 case short_parm: | |
1176 case byte_parm: | |
1177 case int_parm: | |
1178 get_int(); | |
1179 break; | |
1180 case obj_parm: | |
1181 get_object(); | |
1182 break; | |
1183 case long_parm: | |
1184 get_long(); | |
1185 break; | |
1186 case float_parm: | |
1187 get_float(); | |
1188 break; | |
1189 case double_parm: | |
1190 get_double(); | |
1191 break; | |
1192 case done_parm: | |
1193 return; | |
1194 break; | |
1195 default: | |
1196 ShouldNotReachHere(); | |
1197 break; | |
1198 } | |
1199 fingerprint >>= parameter_feature_size; | |
1200 } | |
1201 } | |
1202 } | |
1203 }; | |
1204 | |
1205 | |
1206 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher { | |
1207 protected: | |
1208 const jvalue *_ap; | |
1209 | |
1210 inline void get_bool() { _arguments->push_int((jint)(_ap++)->z); } | |
1211 inline void get_char() { _arguments->push_int((jint)(_ap++)->c); } | |
1212 inline void get_short() { _arguments->push_int((jint)(_ap++)->s); } | |
1213 inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); } | |
1214 inline void get_int() { _arguments->push_int((jint)(_ap++)->i); } | |
1215 | |
1216 inline void get_long() { _arguments->push_long((_ap++)->j); } | |
1217 inline void get_float() { _arguments->push_float((_ap++)->f); } | |
1218 inline void get_double() { _arguments->push_double((_ap++)->d);} | |
1219 inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); } | |
1220 | |
1221 inline void set_ap(const jvalue *rap) { _ap = rap; } | |
1222 | |
1223 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1224 JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1225 : JNI_ArgumentPusher(signature) { |
0 | 1226 set_ap(rap); |
1227 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1228 JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1229 : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) { |
0 | 1230 set_ap(rap); |
1231 } | |
1232 | |
1233 // Optimized path if we have the bitvector form of signature | |
1234 void iterate( uint64_t fingerprint ) { | |
1235 if ( fingerprint == UCONST64(-1) ) SignatureIterator::iterate(); // Must be too many arguments | |
1236 else { | |
1237 _return_type = (BasicType)((fingerprint >> static_feature_size) & | |
1238 result_feature_mask); | |
1239 assert(fingerprint, "Fingerprint should not be 0"); | |
1240 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | |
1241 while ( 1 ) { | |
1242 switch ( fingerprint & parameter_feature_mask ) { | |
1243 case bool_parm: | |
1244 get_bool(); | |
1245 break; | |
1246 case char_parm: | |
1247 get_char(); | |
1248 break; | |
1249 case short_parm: | |
1250 get_short(); | |
1251 break; | |
1252 case byte_parm: | |
1253 get_byte(); | |
1254 break; | |
1255 case int_parm: | |
1256 get_int(); | |
1257 break; | |
1258 case obj_parm: | |
1259 get_object(); | |
1260 break; | |
1261 case long_parm: | |
1262 get_long(); | |
1263 break; | |
1264 case float_parm: | |
1265 get_float(); | |
1266 break; | |
1267 case double_parm: | |
1268 get_double(); | |
1269 break; | |
1270 case done_parm: | |
1271 return; | |
1272 break; | |
1273 default: | |
1274 ShouldNotReachHere(); | |
1275 break; | |
1276 } | |
1277 fingerprint >>= parameter_feature_size; | |
1278 } | |
1279 } | |
1280 } | |
1281 }; | |
1282 | |
1283 | |
1284 enum JNICallType { | |
1285 JNI_STATIC, | |
1286 JNI_VIRTUAL, | |
1287 JNI_NONVIRTUAL | |
1288 }; | |
1289 | |
1290 | |
1291 | |
1292 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1293 methodHandle method(THREAD, Method::resolve_jmethod_id(method_id)); |
0 | 1294 |
1295 // Create object to hold arguments for the JavaCall, and associate it with | |
1296 // the jni parser | |
1297 ResourceMark rm(THREAD); | |
1298 int number_of_parameters = method->size_of_parameters(); | |
1299 JavaCallArguments java_args(number_of_parameters); | |
1300 args->set_java_argument_object(&java_args); | |
1301 | |
1302 assert(method->is_static(), "method should be static"); | |
1303 | |
1304 // Fill out JavaCallArguments object | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1305 args->iterate( Fingerprinter(method).fingerprint() ); |
0 | 1306 // Initialize result type |
1307 result->set_type(args->get_ret_type()); | |
1308 | |
1309 // Invoke the method. Result is returned as oop. | |
1310 JavaCalls::call(result, method, &java_args, CHECK); | |
1311 | |
1312 // Convert result | |
1313 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | |
1314 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | |
1315 } | |
1316 } | |
1317 | |
1318 | |
1319 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | |
1320 oop recv = JNIHandles::resolve(receiver); | |
1321 if (recv == NULL) { | |
1322 THROW(vmSymbols::java_lang_NullPointerException()); | |
1323 } | |
1324 Handle h_recv(THREAD, recv); | |
1325 | |
1326 int number_of_parameters; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1327 Method* selected_method; |
0 | 1328 { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1329 Method* m = Method::resolve_jmethod_id(method_id); |
0 | 1330 number_of_parameters = m->size_of_parameters(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1331 Klass* holder = m->method_holder(); |
6983 | 1332 if (!(holder)->is_interface()) { |
0 | 1333 // non-interface call -- for that little speed boost, don't handlize |
1334 debug_only(No_Safepoint_Verifier nosafepoint;) | |
1335 if (call_type == JNI_VIRTUAL) { | |
1336 // jni_GetMethodID makes sure class is linked and initialized | |
1337 // so m should have a valid vtable index. | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
12111
diff
changeset
|
1338 assert(!m->has_itable_index(), ""); |
0 | 1339 int vtbl_index = m->vtable_index(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1340 if (vtbl_index != Method::nonvirtual_vtable_index) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1341 Klass* k = h_recv->klass(); |
0 | 1342 // k might be an arrayKlassOop but all vtables start at |
1343 // the same place. The cast is to avoid virtual call and assertion. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1344 InstanceKlass *ik = (InstanceKlass*)k; |
0 | 1345 selected_method = ik->method_at_vtable(vtbl_index); |
1346 } else { | |
1347 // final method | |
1348 selected_method = m; | |
1349 } | |
1350 } else { | |
1351 // JNI_NONVIRTUAL call | |
1352 selected_method = m; | |
1353 } | |
1354 } else { | |
1355 // interface call | |
1356 KlassHandle h_holder(THREAD, holder); | |
1357 | |
17685 | 1358 if (call_type == JNI_VIRTUAL) { |
1359 int itbl_index = m->itable_index(); | |
1360 Klass* k = h_recv->klass(); | |
1361 selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); | |
1362 } else { | |
1363 selected_method = m; | |
1364 } | |
0 | 1365 } |
1366 } | |
1367 | |
1368 methodHandle method(THREAD, selected_method); | |
1369 | |
1370 // Create object to hold arguments for the JavaCall, and associate it with | |
1371 // the jni parser | |
1372 ResourceMark rm(THREAD); | |
1373 JavaCallArguments java_args(number_of_parameters); | |
1374 args->set_java_argument_object(&java_args); | |
1375 | |
1376 // handle arguments | |
1377 assert(!method->is_static(), "method should not be static"); | |
1378 args->push_receiver(h_recv); // Push jobject handle | |
1379 | |
1380 // Fill out JavaCallArguments object | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1381 args->iterate( Fingerprinter(method).fingerprint() ); |
0 | 1382 // Initialize result type |
1383 result->set_type(args->get_ret_type()); | |
1384 | |
1385 // Invoke the method. Result is returned as oop. | |
1386 JavaCalls::call(result, method, &java_args, CHECK); | |
1387 | |
1388 // Convert result | |
1389 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | |
1390 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | |
1391 } | |
1392 } | |
1393 | |
1394 | |
1395 static instanceOop alloc_object(jclass clazz, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1396 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
6983 | 1397 k()->check_valid_for_instantiation(false, CHECK_NULL); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1398 InstanceKlass::cast(k())->initialize(CHECK_NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1399 instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD); |
0 | 1400 return ih; |
1401 } | |
1402 | |
4006 | 1403 #ifndef USDT2 |
0 | 1404 DT_RETURN_MARK_DECL(AllocObject, jobject); |
4006 | 1405 #else /* USDT2 */ |
1406 DT_RETURN_MARK_DECL(AllocObject, jobject | |
1407 , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref)); | |
1408 #endif /* USDT2 */ | |
0 | 1409 |
1410 JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) | |
1411 JNIWrapper("AllocObject"); | |
1412 | |
4006 | 1413 #ifndef USDT2 |
0 | 1414 DTRACE_PROBE2(hotspot_jni, AllocObject__entry, env, clazz); |
4006 | 1415 #else /* USDT2 */ |
1416 HOTSPOT_JNI_ALLOCOBJECT_ENTRY( | |
1417 env, clazz); | |
1418 #endif /* USDT2 */ | |
0 | 1419 jobject ret = NULL; |
1420 DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); | |
1421 | |
1422 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1423 ret = JNIHandles::make_local(env, i); | |
1424 return ret; | |
1425 JNI_END | |
1426 | |
4006 | 1427 #ifndef USDT2 |
0 | 1428 DT_RETURN_MARK_DECL(NewObjectA, jobject); |
4006 | 1429 #else /* USDT2 */ |
1430 DT_RETURN_MARK_DECL(NewObjectA, jobject | |
1431 , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref)); | |
1432 #endif /* USDT2 */ | |
0 | 1433 |
1434 JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args)) | |
1435 JNIWrapper("NewObjectA"); | |
4006 | 1436 #ifndef USDT2 |
0 | 1437 DTRACE_PROBE3(hotspot_jni, NewObjectA__entry, env, clazz, methodID); |
4006 | 1438 #else /* USDT2 */ |
1439 HOTSPOT_JNI_NEWOBJECTA_ENTRY( | |
1440 env, clazz, (uintptr_t) methodID); | |
1441 #endif /* USDT2 */ | |
0 | 1442 jobject obj = NULL; |
1443 DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); | |
1444 | |
1445 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1446 obj = JNIHandles::make_local(env, i); | |
1447 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1448 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1449 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1450 return obj; | |
1451 JNI_END | |
1452 | |
4006 | 1453 #ifndef USDT2 |
0 | 1454 DT_RETURN_MARK_DECL(NewObjectV, jobject); |
4006 | 1455 #else /* USDT2 */ |
1456 DT_RETURN_MARK_DECL(NewObjectV, jobject | |
1457 , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref)); | |
1458 #endif /* USDT2 */ | |
0 | 1459 |
1460 JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)) | |
1461 JNIWrapper("NewObjectV"); | |
4006 | 1462 #ifndef USDT2 |
0 | 1463 DTRACE_PROBE3(hotspot_jni, NewObjectV__entry, env, clazz, methodID); |
4006 | 1464 #else /* USDT2 */ |
1465 HOTSPOT_JNI_NEWOBJECTV_ENTRY( | |
1466 env, clazz, (uintptr_t) methodID); | |
1467 #endif /* USDT2 */ | |
0 | 1468 jobject obj = NULL; |
1469 DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); | |
1470 | |
1471 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1472 obj = JNIHandles::make_local(env, i); | |
1473 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1474 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1475 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1476 return obj; | |
1477 JNI_END | |
1478 | |
4006 | 1479 #ifndef USDT2 |
0 | 1480 DT_RETURN_MARK_DECL(NewObject, jobject); |
4006 | 1481 #else /* USDT2 */ |
1482 DT_RETURN_MARK_DECL(NewObject, jobject | |
1483 , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref)); | |
1484 #endif /* USDT2 */ | |
0 | 1485 |
1486 JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)) | |
1487 JNIWrapper("NewObject"); | |
4006 | 1488 #ifndef USDT2 |
0 | 1489 DTRACE_PROBE3(hotspot_jni, NewObject__entry, env, clazz, methodID); |
4006 | 1490 #else /* USDT2 */ |
1491 HOTSPOT_JNI_NEWOBJECT_ENTRY( | |
1492 env, clazz, (uintptr_t) methodID); | |
1493 #endif /* USDT2 */ | |
0 | 1494 jobject obj = NULL; |
1495 DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); | |
1496 | |
1497 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1498 obj = JNIHandles::make_local(env, i); | |
1499 va_list args; | |
1500 va_start(args, methodID); | |
1501 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1502 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1503 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1504 va_end(args); | |
1505 return obj; | |
1506 JNI_END | |
1507 | |
1508 | |
1509 JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj)) | |
1510 JNIWrapper("GetObjectClass"); | |
4006 | 1511 #ifndef USDT2 |
0 | 1512 DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); |
4006 | 1513 #else /* USDT2 */ |
1514 HOTSPOT_JNI_GETOBJECTCLASS_ENTRY( | |
1515 env, obj); | |
1516 #endif /* USDT2 */ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1517 Klass* k = JNIHandles::resolve_non_null(obj)->klass(); |
0 | 1518 jclass ret = |
6983 | 1519 (jclass) JNIHandles::make_local(env, k->java_mirror()); |
4006 | 1520 #ifndef USDT2 |
0 | 1521 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); |
4006 | 1522 #else /* USDT2 */ |
1523 HOTSPOT_JNI_GETOBJECTCLASS_RETURN( | |
1524 ret); | |
1525 #endif /* USDT2 */ | |
0 | 1526 return ret; |
1527 JNI_END | |
1528 | |
1529 JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)) | |
1530 JNIWrapper("IsInstanceOf"); | |
4006 | 1531 #ifndef USDT2 |
0 | 1532 DTRACE_PROBE3(hotspot_jni, IsInstanceOf__entry, env, obj, clazz); |
4006 | 1533 #else /* USDT2 */ |
1534 HOTSPOT_JNI_ISINSTANCEOF_ENTRY( | |
1535 env, obj, clazz); | |
1536 #endif /* USDT2 */ | |
0 | 1537 jboolean ret = JNI_TRUE; |
1538 if (obj != NULL) { | |
1539 ret = JNI_FALSE; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1540 Klass* k = java_lang_Class::as_Klass( |
0 | 1541 JNIHandles::resolve_non_null(clazz)); |
1542 if (k != NULL) { | |
1543 ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; | |
1544 } | |
1545 } | |
4006 | 1546 #ifndef USDT2 |
0 | 1547 DTRACE_PROBE1(hotspot_jni, IsInstanceOf__return, ret); |
4006 | 1548 #else /* USDT2 */ |
1549 HOTSPOT_JNI_ISINSTANCEOF_RETURN( | |
1550 ret); | |
1551 #endif /* USDT2 */ | |
0 | 1552 return ret; |
1553 JNI_END | |
1554 | |
1555 | |
1556 static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, | |
1557 const char *sig, bool is_static, TRAPS) { | |
1558 // %%%% This code should probably just call into a method in the LinkResolver | |
1559 // | |
1560 // The class should have been loaded (we have an instance of the class | |
1561 // passed in) so the method and signature should already be in the symbol | |
1562 // table. If they're not there, the method doesn't exist. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1563 const char *name_to_probe = (name_str == NULL) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1564 ? vmSymbols::object_initializer_name()->as_C_string() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1565 : name_str; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1566 TempNewSymbol name = SymbolTable::probe(name_to_probe, (int)strlen(name_to_probe)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1567 TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1568 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1569 if (name == NULL || signature == NULL) { |
0 | 1570 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
1571 } | |
1572 | |
1573 // Throw a NoSuchMethodError exception if we have an instance of a | |
1574 // primitive java.lang.Class | |
1575 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) { | |
1576 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | |
1577 } | |
1578 | |
1579 KlassHandle klass(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1580 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 1581 |
1582 // Make sure class is linked and initialized before handing id's out to | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1583 // Method*s. |
6983 | 1584 klass()->initialize(CHECK_NULL); |
0 | 1585 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1586 Method* m; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1587 if (name == vmSymbols::object_initializer_name() || |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1588 name == vmSymbols::class_initializer_name()) { |
0 | 1589 // Never search superclasses for constructors |
1590 if (klass->oop_is_instance()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1591 m = InstanceKlass::cast(klass())->find_method(name, signature); |
0 | 1592 } else { |
1593 m = NULL; | |
1594 } | |
1595 } else { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1596 m = klass->lookup_method(name, signature); |
12823
ac9cb1d5a202
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
12819
diff
changeset
|
1597 if (m == NULL && klass->oop_is_instance()) { |
ac9cb1d5a202
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
12819
diff
changeset
|
1598 m = InstanceKlass::cast(klass())->lookup_method_in_ordered_interfaces(name, signature); |
0 | 1599 } |
1600 } | |
1601 if (m == NULL || (m->is_static() != is_static)) { | |
1602 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | |
1603 } | |
1604 return m->jmethod_id(); | |
1605 } | |
1606 | |
1607 | |
1608 JNI_ENTRY(jmethodID, jni_GetMethodID(JNIEnv *env, jclass clazz, | |
1609 const char *name, const char *sig)) | |
1610 JNIWrapper("GetMethodID"); | |
4006 | 1611 #ifndef USDT2 |
0 | 1612 DTRACE_PROBE4(hotspot_jni, GetMethodID__entry, env, clazz, name, sig); |
4006 | 1613 #else /* USDT2 */ |
1614 HOTSPOT_JNI_GETMETHODID_ENTRY( | |
1615 env, clazz, (char *) name, (char *) sig); | |
1616 #endif /* USDT2 */ | |
0 | 1617 jmethodID ret = get_method_id(env, clazz, name, sig, false, thread); |
4006 | 1618 #ifndef USDT2 |
0 | 1619 DTRACE_PROBE1(hotspot_jni, GetMethodID__return, ret); |
4006 | 1620 #else /* USDT2 */ |
1621 HOTSPOT_JNI_GETMETHODID_RETURN( | |
1622 (uintptr_t) ret); | |
1623 #endif /* USDT2 */ | |
0 | 1624 return ret; |
1625 JNI_END | |
1626 | |
1627 | |
1628 JNI_ENTRY(jmethodID, jni_GetStaticMethodID(JNIEnv *env, jclass clazz, | |
1629 const char *name, const char *sig)) | |
1630 JNIWrapper("GetStaticMethodID"); | |
4006 | 1631 #ifndef USDT2 |
0 | 1632 DTRACE_PROBE4(hotspot_jni, GetStaticMethodID__entry, env, clazz, name, sig); |
4006 | 1633 #else /* USDT2 */ |
1634 HOTSPOT_JNI_GETSTATICMETHODID_ENTRY( | |
1635 env, (char *) clazz, (char *) name, (char *)sig); | |
1636 #endif /* USDT2 */ | |
0 | 1637 jmethodID ret = get_method_id(env, clazz, name, sig, true, thread); |
4006 | 1638 #ifndef USDT2 |
0 | 1639 DTRACE_PROBE1(hotspot_jni, GetStaticMethodID__return, ret); |
4006 | 1640 #else /* USDT2 */ |
1641 HOTSPOT_JNI_GETSTATICMETHODID_RETURN( | |
1642 (uintptr_t) ret); | |
1643 #endif /* USDT2 */ | |
0 | 1644 return ret; |
1645 JNI_END | |
1646 | |
1647 | |
1648 | |
1649 // | |
1650 // Calling Methods | |
1651 // | |
1652 | |
4006 | 1653 #ifndef USDT2 |
0 | 1654 #define DEFINE_CALLMETHOD(ResultType, Result, Tag) \ |
1655 \ | |
1656 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType);\ | |
1657 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType);\ | |
1658 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType);\ | |
1659 \ | |
1660 JNI_ENTRY(ResultType, \ | |
1661 jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ | |
1662 JNIWrapper("Call" XSTR(Result) "Method"); \ | |
1663 \ | |
4006 | 1664 DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID); \ |
0 | 1665 ResultType ret = 0;\ |
1666 DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ | |
1667 (const ResultType&)ret);\ | |
1668 \ | |
1669 va_list args; \ | |
1670 va_start(args, methodID); \ | |
1671 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1672 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1673 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1674 va_end(args); \ | |
1675 ret = jvalue.get_##ResultType(); \ | |
1676 return ret;\ | |
1677 JNI_END \ | |
1678 \ | |
1679 \ | |
1680 JNI_ENTRY(ResultType, \ | |
1681 jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ | |
1682 JNIWrapper("Call" XSTR(Result) "MethodV"); \ | |
1683 \ | |
4006 | 1684 DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID); \ |
0 | 1685 ResultType ret = 0;\ |
1686 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ | |
1687 (const ResultType&)ret);\ | |
1688 \ | |
1689 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1690 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1691 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1692 ret = jvalue.get_##ResultType(); \ | |
1693 return ret;\ | |
1694 JNI_END \ | |
1695 \ | |
1696 \ | |
1697 JNI_ENTRY(ResultType, \ | |
1698 jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ | |
1699 JNIWrapper("Call" XSTR(Result) "MethodA"); \ | |
4006 | 1700 DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID); \ |
0 | 1701 ResultType ret = 0;\ |
1702 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ | |
1703 (const ResultType&)ret);\ | |
1704 \ | |
1705 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1706 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 1707 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1708 ret = jvalue.get_##ResultType(); \ | |
1709 return ret;\ | |
1710 JNI_END | |
1711 | |
1712 // the runtime type of subword integral basic types is integer | |
1713 DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN) | |
1714 DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE) | |
1715 DEFINE_CALLMETHOD(jchar, Char, T_CHAR) | |
1716 DEFINE_CALLMETHOD(jshort, Short, T_SHORT) | |
1717 | |
1718 DEFINE_CALLMETHOD(jobject, Object, T_OBJECT) | |
1719 DEFINE_CALLMETHOD(jint, Int, T_INT) | |
1720 DEFINE_CALLMETHOD(jlong, Long, T_LONG) | |
1721 DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT) | |
1722 DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE) | |
1723 | |
1724 DT_VOID_RETURN_MARK_DECL(CallVoidMethod); | |
1725 DT_VOID_RETURN_MARK_DECL(CallVoidMethodV); | |
1726 DT_VOID_RETURN_MARK_DECL(CallVoidMethodA); | |
1727 | |
4006 | 1728 #else /* USDT2 */ |
1729 | |
1730 #define DEFINE_CALLMETHOD(ResultType, Result, Tag \ | |
1731 , EntryProbe, ReturnProbe) \ | |
1732 \ | |
1733 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType \ | |
1734 , ReturnProbe); \ | |
1735 \ | |
1736 JNI_ENTRY(ResultType, \ | |
1737 jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ | |
1738 JNIWrapper("Call" XSTR(Result) "Method"); \ | |
1739 \ | |
1740 EntryProbe; \ | |
1741 ResultType ret = 0;\ | |
1742 DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ | |
1743 (const ResultType&)ret);\ | |
1744 \ | |
1745 va_list args; \ | |
1746 va_start(args, methodID); \ | |
1747 JavaValue jvalue(Tag); \ | |
1748 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
1749 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | |
1750 va_end(args); \ | |
1751 ret = jvalue.get_##ResultType(); \ | |
1752 return ret;\ | |
1753 JNI_END | |
1754 | |
1755 // the runtime type of subword integral basic types is integer | |
1756 DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN | |
1757 , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1758 HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) | |
1759 DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE | |
1760 , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1761 HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) | |
1762 DEFINE_CALLMETHOD(jchar, Char, T_CHAR | |
1763 , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1764 HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) | |
1765 DEFINE_CALLMETHOD(jshort, Short, T_SHORT | |
1766 , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1767 HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) | |
1768 | |
1769 DEFINE_CALLMETHOD(jobject, Object, T_OBJECT | |
1770 , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1771 HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) | |
1772 DEFINE_CALLMETHOD(jint, Int, T_INT, | |
1773 HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1774 HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) | |
1775 DEFINE_CALLMETHOD(jlong, Long, T_LONG | |
1776 , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1777 HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) | |
1778 // Float and double probes don't return value because dtrace doesn't currently support it | |
1779 DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT | |
1780 , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1781 HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) | |
1782 DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE | |
1783 , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1784 HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) | |
1785 | |
1786 #define DEFINE_CALLMETHODV(ResultType, Result, Tag \ | |
1787 , EntryProbe, ReturnProbe) \ | |
1788 \ | |
1789 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType \ | |
1790 , ReturnProbe); \ | |
1791 \ | |
1792 JNI_ENTRY(ResultType, \ | |
1793 jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ | |
1794 JNIWrapper("Call" XSTR(Result) "MethodV"); \ | |
1795 \ | |
1796 EntryProbe;\ | |
1797 ResultType ret = 0;\ | |
1798 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ | |
1799 (const ResultType&)ret);\ | |
1800 \ | |
1801 JavaValue jvalue(Tag); \ | |
1802 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
1803 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | |
1804 ret = jvalue.get_##ResultType(); \ | |
1805 return ret;\ | |
1806 JNI_END | |
1807 | |
1808 // the runtime type of subword integral basic types is integer | |
1809 DEFINE_CALLMETHODV(jboolean, Boolean, T_BOOLEAN | |
1810 , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1811 HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) | |
1812 DEFINE_CALLMETHODV(jbyte, Byte, T_BYTE | |
1813 , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1814 HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) | |
1815 DEFINE_CALLMETHODV(jchar, Char, T_CHAR | |
1816 , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1817 HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) | |
1818 DEFINE_CALLMETHODV(jshort, Short, T_SHORT | |
1819 , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1820 HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) | |
1821 | |
1822 DEFINE_CALLMETHODV(jobject, Object, T_OBJECT | |
1823 , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1824 HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) | |
1825 DEFINE_CALLMETHODV(jint, Int, T_INT, | |
1826 HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1827 HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) | |
1828 DEFINE_CALLMETHODV(jlong, Long, T_LONG | |
1829 , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1830 HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) | |
1831 // Float and double probes don't return value because dtrace doesn't currently support it | |
1832 DEFINE_CALLMETHODV(jfloat, Float, T_FLOAT | |
1833 , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1834 HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) | |
1835 DEFINE_CALLMETHODV(jdouble, Double, T_DOUBLE | |
1836 , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1837 HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) | |
1838 | |
1839 #define DEFINE_CALLMETHODA(ResultType, Result, Tag \ | |
1840 , EntryProbe, ReturnProbe) \ | |
1841 \ | |
1842 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType \ | |
1843 , ReturnProbe); \ | |
1844 \ | |
1845 JNI_ENTRY(ResultType, \ | |
1846 jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ | |
1847 JNIWrapper("Call" XSTR(Result) "MethodA"); \ | |
1848 EntryProbe; \ | |
1849 ResultType ret = 0;\ | |
1850 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ | |
1851 (const ResultType&)ret);\ | |
1852 \ | |
1853 JavaValue jvalue(Tag); \ | |
1854 JNI_ArgumentPusherArray ap(methodID, args); \ | |
1855 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | |
1856 ret = jvalue.get_##ResultType(); \ | |
1857 return ret;\ | |
1858 JNI_END | |
1859 | |
1860 // the runtime type of subword integral basic types is integer | |
1861 DEFINE_CALLMETHODA(jboolean, Boolean, T_BOOLEAN | |
1862 , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1863 HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) | |
1864 DEFINE_CALLMETHODA(jbyte, Byte, T_BYTE | |
1865 , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1866 HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) | |
1867 DEFINE_CALLMETHODA(jchar, Char, T_CHAR | |
1868 , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1869 HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) | |
1870 DEFINE_CALLMETHODA(jshort, Short, T_SHORT | |
1871 , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1872 HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) | |
1873 | |
1874 DEFINE_CALLMETHODA(jobject, Object, T_OBJECT | |
1875 , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1876 HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) | |
1877 DEFINE_CALLMETHODA(jint, Int, T_INT, | |
1878 HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1879 HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) | |
1880 DEFINE_CALLMETHODA(jlong, Long, T_LONG | |
1881 , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1882 HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) | |
1883 // Float and double probes don't return value because dtrace doesn't currently support it | |
1884 DEFINE_CALLMETHODA(jfloat, Float, T_FLOAT | |
1885 , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1886 HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) | |
1887 DEFINE_CALLMETHODA(jdouble, Double, T_DOUBLE | |
1888 , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1889 HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) | |
1890 | |
1891 DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()); | |
1892 DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()); | |
1893 DT_VOID_RETURN_MARK_DECL(CallVoidMethodA, HOTSPOT_JNI_CALLVOIDMETHODA_RETURN()); | |
1894 | |
1895 #endif /* USDT2 */ | |
1896 | |
0 | 1897 JNI_ENTRY(void, jni_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)) |
1898 JNIWrapper("CallVoidMethod"); | |
4006 | 1899 #ifndef USDT2 |
0 | 1900 DTRACE_PROBE3(hotspot_jni, CallVoidMethod__entry, env, obj, methodID); |
4006 | 1901 #else /* USDT2 */ |
1902 HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY( | |
1903 env, obj, (uintptr_t) methodID); | |
1904 #endif /* USDT2 */ | |
0 | 1905 DT_VOID_RETURN_MARK(CallVoidMethod); |
1906 | |
1907 va_list args; | |
1908 va_start(args, methodID); | |
1909 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1910 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1911 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1912 va_end(args); | |
1913 JNI_END | |
1914 | |
1915 | |
1916 JNI_ENTRY(void, jni_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) | |
1917 JNIWrapper("CallVoidMethodV"); | |
4006 | 1918 #ifndef USDT2 |
0 | 1919 DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); |
4006 | 1920 #else /* USDT2 */ |
1921 HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY( | |
1922 env, obj, (uintptr_t) methodID); | |
1923 #endif /* USDT2 */ | |
0 | 1924 DT_VOID_RETURN_MARK(CallVoidMethodV); |
1925 | |
1926 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1927 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1928 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1929 JNI_END | |
1930 | |
1931 | |
1932 JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) | |
1933 JNIWrapper("CallVoidMethodA"); | |
4006 | 1934 #ifndef USDT2 |
0 | 1935 DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); |
4006 | 1936 #else /* USDT2 */ |
1937 HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY( | |
1938 env, obj, (uintptr_t) methodID); | |
1939 #endif /* USDT2 */ | |
0 | 1940 DT_VOID_RETURN_MARK(CallVoidMethodA); |
1941 | |
1942 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1943 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1944 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1945 JNI_END | |
1946 | |
1947 | |
4006 | 1948 #ifndef USDT2 |
0 | 1949 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ |
1950 \ | |
1951 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\ | |
1952 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType);\ | |
1953 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType);\ | |
1954 \ | |
1955 JNI_ENTRY(ResultType, \ | |
1956 jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ | |
1957 JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ | |
1958 \ | |
1959 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##Method__entry, env, obj, cls, methodID);\ | |
1960 ResultType ret;\ | |
1961 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ | |
1962 (const ResultType&)ret);\ | |
1963 \ | |
1964 va_list args; \ | |
1965 va_start(args, methodID); \ | |
1966 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1967 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1968 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1969 va_end(args); \ | |
1970 ret = jvalue.get_##ResultType(); \ | |
1971 return ret;\ | |
1972 JNI_END \ | |
1973 \ | |
1974 JNI_ENTRY(ResultType, \ | |
1975 jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ | |
1976 JNIWrapper("CallNonvitual" XSTR(Result) "#MethodV"); \ | |
1977 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodV__entry, env, obj, cls, methodID);\ | |
1978 ResultType ret;\ | |
1979 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ | |
1980 (const ResultType&)ret);\ | |
1981 \ | |
1982 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1983 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1984 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1985 ret = jvalue.get_##ResultType(); \ | |
1986 return ret;\ | |
1987 JNI_END \ | |
1988 \ | |
1989 JNI_ENTRY(ResultType, \ | |
1990 jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
1991 JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ | |
1992 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodA__entry, env, obj, cls, methodID);\ | |
1993 ResultType ret;\ | |
1994 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ | |
1995 (const ResultType&)ret);\ | |
1996 \ | |
1997 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1998 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 1999 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
2000 ret = jvalue.get_##ResultType(); \ | |
2001 return ret;\ | |
2002 JNI_END | |
2003 | |
2004 // the runtime type of subword integral basic types is integer | |
2005 DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN) | |
2006 DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE) | |
2007 DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR) | |
2008 DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT) | |
2009 | |
2010 DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT) | |
2011 DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT) | |
2012 DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG) | |
2013 DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT) | |
2014 DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE) | |
2015 | |
2016 | |
2017 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod); | |
2018 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV); | |
2019 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA); | |
2020 | |
4006 | 2021 #else /* USDT2 */ |
2022 | |
2023 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag \ | |
2024 , EntryProbe, ReturnProbe) \ | |
2025 \ | |
2026 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType \ | |
2027 , ReturnProbe);\ | |
2028 \ | |
2029 JNI_ENTRY(ResultType, \ | |
2030 jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ | |
2031 JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ | |
2032 \ | |
2033 EntryProbe;\ | |
2034 ResultType ret;\ | |
2035 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ | |
2036 (const ResultType&)ret);\ | |
2037 \ | |
2038 va_list args; \ | |
2039 va_start(args, methodID); \ | |
2040 JavaValue jvalue(Tag); \ | |
2041 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2042 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | |
2043 va_end(args); \ | |
2044 ret = jvalue.get_##ResultType(); \ | |
2045 return ret;\ | |
2046 JNI_END | |
2047 | |
2048 // the runtime type of subword integral basic types is integer | |
2049 DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN | |
2050 , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2051 HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_RETURN(_ret_ref)) | |
2052 DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE | |
2053 , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2054 HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_RETURN(_ret_ref)) | |
2055 DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR | |
2056 , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2057 HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_RETURN(_ret_ref)) | |
2058 DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT | |
2059 , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2060 HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_RETURN(_ret_ref)) | |
2061 | |
2062 DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT | |
2063 , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2064 HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_RETURN(_ret_ref)) | |
2065 DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT | |
2066 , HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2067 HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_RETURN(_ret_ref)) | |
2068 DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG | |
2069 , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2070 // Float and double probes don't return value because dtrace doesn't currently support it | |
2071 HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_RETURN(_ret_ref)) | |
2072 DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT | |
2073 , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2074 HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_RETURN()) | |
2075 DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE | |
2076 , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2077 HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_RETURN()) | |
2078 | |
2079 #define DEFINE_CALLNONVIRTUALMETHODV(ResultType, Result, Tag \ | |
2080 , EntryProbe, ReturnProbe) \ | |
2081 \ | |
2082 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType \ | |
2083 , ReturnProbe);\ | |
2084 \ | |
2085 JNI_ENTRY(ResultType, \ | |
2086 jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ | |
2087 JNIWrapper("CallNonvitual" XSTR(Result) "MethodV"); \ | |
2088 \ | |
2089 EntryProbe;\ | |
2090 ResultType ret;\ | |
2091 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ | |
2092 (const ResultType&)ret);\ | |
2093 \ | |
2094 JavaValue jvalue(Tag); \ | |
2095 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2096 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | |
2097 ret = jvalue.get_##ResultType(); \ | |
2098 return ret;\ | |
2099 JNI_END | |
2100 | |
2101 // the runtime type of subword integral basic types is integer | |
2102 DEFINE_CALLNONVIRTUALMETHODV(jboolean, Boolean, T_BOOLEAN | |
2103 , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2104 HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_RETURN(_ret_ref)) | |
2105 DEFINE_CALLNONVIRTUALMETHODV(jbyte, Byte, T_BYTE | |
2106 , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2107 HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_RETURN(_ret_ref)) | |
2108 DEFINE_CALLNONVIRTUALMETHODV(jchar, Char, T_CHAR | |
2109 , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2110 HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_RETURN(_ret_ref)) | |
2111 DEFINE_CALLNONVIRTUALMETHODV(jshort, Short, T_SHORT | |
2112 , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2113 HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_RETURN(_ret_ref)) | |
2114 | |
2115 DEFINE_CALLNONVIRTUALMETHODV(jobject, Object, T_OBJECT | |
2116 , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2117 HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_RETURN(_ret_ref)) | |
2118 DEFINE_CALLNONVIRTUALMETHODV(jint, Int, T_INT | |
2119 , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2120 HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_RETURN(_ret_ref)) | |
2121 DEFINE_CALLNONVIRTUALMETHODV(jlong, Long, T_LONG | |
2122 , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2123 // Float and double probes don't return value because dtrace doesn't currently support it | |
2124 HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_RETURN(_ret_ref)) | |
2125 DEFINE_CALLNONVIRTUALMETHODV(jfloat, Float, T_FLOAT | |
2126 , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2127 HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_RETURN()) | |
2128 DEFINE_CALLNONVIRTUALMETHODV(jdouble, Double, T_DOUBLE | |
2129 , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2130 HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_RETURN()) | |
2131 | |
2132 #define DEFINE_CALLNONVIRTUALMETHODA(ResultType, Result, Tag \ | |
2133 , EntryProbe, ReturnProbe) \ | |
2134 \ | |
2135 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType \ | |
2136 , ReturnProbe);\ | |
2137 \ | |
2138 JNI_ENTRY(ResultType, \ | |
2139 jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2140 JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ | |
2141 \ | |
2142 EntryProbe;\ | |
2143 ResultType ret;\ | |
2144 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ | |
2145 (const ResultType&)ret);\ | |
2146 \ | |
2147 JavaValue jvalue(Tag); \ | |
2148 JNI_ArgumentPusherArray ap(methodID, args); \ | |
2149 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | |
2150 ret = jvalue.get_##ResultType(); \ | |
2151 return ret;\ | |
2152 JNI_END | |
2153 | |
2154 // the runtime type of subword integral basic types is integer | |
2155 DEFINE_CALLNONVIRTUALMETHODA(jboolean, Boolean, T_BOOLEAN | |
2156 , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2157 HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_RETURN(_ret_ref)) | |
2158 DEFINE_CALLNONVIRTUALMETHODA(jbyte, Byte, T_BYTE | |
2159 , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2160 HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_RETURN(_ret_ref)) | |
2161 DEFINE_CALLNONVIRTUALMETHODA(jchar, Char, T_CHAR | |
2162 , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2163 HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_RETURN(_ret_ref)) | |
2164 DEFINE_CALLNONVIRTUALMETHODA(jshort, Short, T_SHORT | |
2165 , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2166 HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_RETURN(_ret_ref)) | |
2167 | |
2168 DEFINE_CALLNONVIRTUALMETHODA(jobject, Object, T_OBJECT | |
2169 , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2170 HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_RETURN(_ret_ref)) | |
2171 DEFINE_CALLNONVIRTUALMETHODA(jint, Int, T_INT | |
2172 , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2173 HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_RETURN(_ret_ref)) | |
2174 DEFINE_CALLNONVIRTUALMETHODA(jlong, Long, T_LONG | |
2175 , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2176 // Float and double probes don't return value because dtrace doesn't currently support it | |
2177 HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_RETURN(_ret_ref)) | |
2178 DEFINE_CALLNONVIRTUALMETHODA(jfloat, Float, T_FLOAT | |
2179 , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2180 HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_RETURN()) | |
2181 DEFINE_CALLNONVIRTUALMETHODA(jdouble, Double, T_DOUBLE | |
2182 , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2183 HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_RETURN()) | |
2184 | |
2185 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod | |
2186 , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_RETURN()); | |
2187 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV | |
2188 , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN()); | |
2189 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA | |
2190 , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN()); | |
2191 #endif /* USDT2 */ | |
2192 | |
0 | 2193 JNI_ENTRY(void, jni_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) |
2194 JNIWrapper("CallNonvirtualVoidMethod"); | |
2195 | |
4006 | 2196 #ifndef USDT2 |
0 | 2197 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethod__entry, |
2198 env, obj, cls, methodID); | |
4006 | 2199 #else /* USDT2 */ |
2200 HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY( | |
2201 env, obj, cls, (uintptr_t) methodID); | |
2202 #endif /* USDT2 */ | |
0 | 2203 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); |
2204 | |
2205 va_list args; | |
2206 va_start(args, methodID); | |
2207 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2208 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2209 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
2210 va_end(args); | |
2211 JNI_END | |
2212 | |
2213 | |
2214 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) | |
2215 JNIWrapper("CallNonvirtualVoidMethodV"); | |
2216 | |
4006 | 2217 #ifndef USDT2 |
0 | 2218 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, |
2219 env, obj, cls, methodID); | |
4006 | 2220 #else /* USDT2 */ |
2221 HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY( | |
2222 env, obj, cls, (uintptr_t) methodID); | |
2223 #endif /* USDT2 */ | |
0 | 2224 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); |
2225 | |
2226 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2227 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2228 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
2229 JNI_END | |
2230 | |
2231 | |
2232 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) | |
2233 JNIWrapper("CallNonvirtualVoidMethodA"); | |
4006 | 2234 #ifndef USDT2 |
0 | 2235 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, |
2236 env, obj, cls, methodID); | |
4006 | 2237 #else /* USDT2 */ |
2238 HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY( | |
2239 env, obj, cls, (uintptr_t) methodID); | |
2240 #endif /* USDT2 */ | |
0 | 2241 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); |
2242 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2243 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 2244 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
2245 JNI_END | |
2246 | |
2247 | |
4006 | 2248 #ifndef USDT2 |
0 | 2249 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ |
2250 \ | |
2251 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType);\ | |
2252 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType);\ | |
2253 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType);\ | |
2254 \ | |
2255 JNI_ENTRY(ResultType, \ | |
2256 jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ | |
2257 JNIWrapper("CallStatic" XSTR(Result) "Method"); \ | |
2258 \ | |
2259 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##Method__entry, env, cls, methodID);\ | |
2260 ResultType ret = 0;\ | |
2261 DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ | |
2262 (const ResultType&)ret);\ | |
2263 \ | |
2264 va_list args; \ | |
2265 va_start(args, methodID); \ | |
2266 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2267 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 2268 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2269 va_end(args); \ | |
2270 ret = jvalue.get_##ResultType(); \ | |
2271 return ret;\ | |
2272 JNI_END \ | |
2273 \ | |
2274 JNI_ENTRY(ResultType, \ | |
2275 jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ | |
2276 JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ | |
2277 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodV__entry, env, cls, methodID);\ | |
2278 ResultType ret = 0;\ | |
2279 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ | |
2280 (const ResultType&)ret);\ | |
2281 \ | |
2282 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2283 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 2284 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2285 ret = jvalue.get_##ResultType(); \ | |
2286 return ret;\ | |
2287 JNI_END \ | |
2288 \ | |
2289 JNI_ENTRY(ResultType, \ | |
2290 jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2291 JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ | |
2292 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodA__entry, env, cls, methodID);\ | |
2293 ResultType ret = 0;\ | |
2294 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ | |
2295 (const ResultType&)ret);\ | |
2296 \ | |
2297 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2298 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 2299 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2300 ret = jvalue.get_##ResultType(); \ | |
2301 return ret;\ | |
2302 JNI_END | |
2303 | |
2304 // the runtime type of subword integral basic types is integer | |
2305 DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN) | |
2306 DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE) | |
2307 DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR) | |
2308 DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT) | |
2309 | |
2310 DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT) | |
2311 DEFINE_CALLSTATICMETHOD(jint, Int, T_INT) | |
2312 DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG) | |
2313 DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT) | |
2314 DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE) | |
2315 | |
2316 | |
2317 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod); | |
2318 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV); | |
2319 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA); | |
2320 | |
4006 | 2321 #else /* USDT2 */ |
2322 | |
2323 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag \ | |
2324 , EntryProbe, ResultProbe) \ | |
2325 \ | |
2326 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType \ | |
2327 , ResultProbe); \ | |
2328 \ | |
2329 JNI_ENTRY(ResultType, \ | |
2330 jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ | |
2331 JNIWrapper("CallStatic" XSTR(Result) "Method"); \ | |
2332 \ | |
2333 EntryProbe; \ | |
2334 ResultType ret = 0;\ | |
2335 DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ | |
2336 (const ResultType&)ret);\ | |
2337 \ | |
2338 va_list args; \ | |
2339 va_start(args, methodID); \ | |
2340 JavaValue jvalue(Tag); \ | |
2341 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2342 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | |
2343 va_end(args); \ | |
2344 ret = jvalue.get_##ResultType(); \ | |
2345 return ret;\ | |
2346 JNI_END | |
2347 | |
2348 // the runtime type of subword integral basic types is integer | |
2349 DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN | |
2350 , HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2351 HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_RETURN(_ret_ref)); | |
2352 DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE | |
2353 , HOTSPOT_JNI_CALLSTATICBYTEMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2354 HOTSPOT_JNI_CALLSTATICBYTEMETHOD_RETURN(_ret_ref)); | |
2355 DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR | |
2356 , HOTSPOT_JNI_CALLSTATICCHARMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2357 HOTSPOT_JNI_CALLSTATICCHARMETHOD_RETURN(_ret_ref)); | |
2358 DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT | |
2359 , HOTSPOT_JNI_CALLSTATICSHORTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2360 HOTSPOT_JNI_CALLSTATICSHORTMETHOD_RETURN(_ret_ref)); | |
2361 | |
2362 DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT | |
2363 , HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2364 HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_RETURN(_ret_ref)); | |
2365 DEFINE_CALLSTATICMETHOD(jint, Int, T_INT | |
2366 , HOTSPOT_JNI_CALLSTATICINTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2367 HOTSPOT_JNI_CALLSTATICINTMETHOD_RETURN(_ret_ref)); | |
2368 DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG | |
2369 , HOTSPOT_JNI_CALLSTATICLONGMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2370 HOTSPOT_JNI_CALLSTATICLONGMETHOD_RETURN(_ret_ref)); | |
2371 // Float and double probes don't return value because dtrace doesn't currently support it | |
2372 DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT | |
2373 , HOTSPOT_JNI_CALLSTATICFLOATMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2374 HOTSPOT_JNI_CALLSTATICFLOATMETHOD_RETURN()); | |
2375 DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE | |
2376 , HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2377 HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_RETURN()); | |
2378 | |
2379 #define DEFINE_CALLSTATICMETHODV(ResultType, Result, Tag \ | |
2380 , EntryProbe, ResultProbe) \ | |
2381 \ | |
2382 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType \ | |
2383 , ResultProbe); \ | |
2384 \ | |
2385 JNI_ENTRY(ResultType, \ | |
2386 jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ | |
2387 JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ | |
2388 \ | |
2389 EntryProbe; \ | |
2390 ResultType ret = 0;\ | |
2391 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ | |
2392 (const ResultType&)ret);\ | |
2393 \ | |
2394 JavaValue jvalue(Tag); \ | |
2395 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2396 /* Make sure class is initialized before trying to invoke its method */ \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2397 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \ |
6983 | 2398 k()->initialize(CHECK_0); \ |
4006 | 2399 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2400 va_end(args); \ | |
2401 ret = jvalue.get_##ResultType(); \ | |
2402 return ret;\ | |
2403 JNI_END | |
2404 | |
2405 // the runtime type of subword integral basic types is integer | |
2406 DEFINE_CALLSTATICMETHODV(jboolean, Boolean, T_BOOLEAN | |
2407 , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2408 HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_RETURN(_ret_ref)); | |
2409 DEFINE_CALLSTATICMETHODV(jbyte, Byte, T_BYTE | |
2410 , HOTSPOT_JNI_CALLSTATICBYTEMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2411 HOTSPOT_JNI_CALLSTATICBYTEMETHODV_RETURN(_ret_ref)); | |
2412 DEFINE_CALLSTATICMETHODV(jchar, Char, T_CHAR | |
2413 , HOTSPOT_JNI_CALLSTATICCHARMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2414 HOTSPOT_JNI_CALLSTATICCHARMETHODV_RETURN(_ret_ref)); | |
2415 DEFINE_CALLSTATICMETHODV(jshort, Short, T_SHORT | |
2416 , HOTSPOT_JNI_CALLSTATICSHORTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2417 HOTSPOT_JNI_CALLSTATICSHORTMETHODV_RETURN(_ret_ref)); | |
2418 | |
2419 DEFINE_CALLSTATICMETHODV(jobject, Object, T_OBJECT | |
2420 , HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2421 HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_RETURN(_ret_ref)); | |
2422 DEFINE_CALLSTATICMETHODV(jint, Int, T_INT | |
2423 , HOTSPOT_JNI_CALLSTATICINTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2424 HOTSPOT_JNI_CALLSTATICINTMETHODV_RETURN(_ret_ref)); | |
2425 DEFINE_CALLSTATICMETHODV(jlong, Long, T_LONG | |
2426 , HOTSPOT_JNI_CALLSTATICLONGMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2427 HOTSPOT_JNI_CALLSTATICLONGMETHODV_RETURN(_ret_ref)); | |
2428 // Float and double probes don't return value because dtrace doesn't currently support it | |
2429 DEFINE_CALLSTATICMETHODV(jfloat, Float, T_FLOAT | |
2430 , HOTSPOT_JNI_CALLSTATICFLOATMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2431 HOTSPOT_JNI_CALLSTATICFLOATMETHODV_RETURN()); | |
2432 DEFINE_CALLSTATICMETHODV(jdouble, Double, T_DOUBLE | |
2433 , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2434 HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_RETURN()); | |
2435 | |
2436 #define DEFINE_CALLSTATICMETHODA(ResultType, Result, Tag \ | |
2437 , EntryProbe, ResultProbe) \ | |
2438 \ | |
2439 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType \ | |
2440 , ResultProbe); \ | |
2441 \ | |
2442 JNI_ENTRY(ResultType, \ | |
2443 jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2444 JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ | |
2445 \ | |
2446 EntryProbe; \ | |
2447 ResultType ret = 0;\ | |
2448 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ | |
2449 (const ResultType&)ret);\ | |
2450 \ | |
2451 JavaValue jvalue(Tag); \ | |
2452 JNI_ArgumentPusherArray ap(methodID, args); \ | |
2453 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | |
2454 ret = jvalue.get_##ResultType(); \ | |
2455 return ret;\ | |
2456 JNI_END | |
2457 | |
2458 // the runtime type of subword integral basic types is integer | |
2459 DEFINE_CALLSTATICMETHODA(jboolean, Boolean, T_BOOLEAN | |
2460 , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2461 HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_RETURN(_ret_ref)); | |
2462 DEFINE_CALLSTATICMETHODA(jbyte, Byte, T_BYTE | |
2463 , HOTSPOT_JNI_CALLSTATICBYTEMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2464 HOTSPOT_JNI_CALLSTATICBYTEMETHODA_RETURN(_ret_ref)); | |
2465 DEFINE_CALLSTATICMETHODA(jchar, Char, T_CHAR | |
2466 , HOTSPOT_JNI_CALLSTATICCHARMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2467 HOTSPOT_JNI_CALLSTATICCHARMETHODA_RETURN(_ret_ref)); | |
2468 DEFINE_CALLSTATICMETHODA(jshort, Short, T_SHORT | |
2469 , HOTSPOT_JNI_CALLSTATICSHORTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2470 HOTSPOT_JNI_CALLSTATICSHORTMETHODA_RETURN(_ret_ref)); | |
2471 | |
2472 DEFINE_CALLSTATICMETHODA(jobject, Object, T_OBJECT | |
2473 , HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2474 HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_RETURN(_ret_ref)); | |
2475 DEFINE_CALLSTATICMETHODA(jint, Int, T_INT | |
2476 , HOTSPOT_JNI_CALLSTATICINTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2477 HOTSPOT_JNI_CALLSTATICINTMETHODA_RETURN(_ret_ref)); | |
2478 DEFINE_CALLSTATICMETHODA(jlong, Long, T_LONG | |
2479 , HOTSPOT_JNI_CALLSTATICLONGMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2480 HOTSPOT_JNI_CALLSTATICLONGMETHODA_RETURN(_ret_ref)); | |
2481 // Float and double probes don't return value because dtrace doesn't currently support it | |
2482 DEFINE_CALLSTATICMETHODA(jfloat, Float, T_FLOAT | |
2483 , HOTSPOT_JNI_CALLSTATICFLOATMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2484 HOTSPOT_JNI_CALLSTATICFLOATMETHODA_RETURN()); | |
2485 DEFINE_CALLSTATICMETHODA(jdouble, Double, T_DOUBLE | |
2486 , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2487 HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_RETURN()); | |
2488 | |
2489 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod | |
2490 , HOTSPOT_JNI_CALLSTATICVOIDMETHOD_RETURN()); | |
2491 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV | |
2492 , HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN()); | |
2493 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA | |
2494 , HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN()); | |
2495 #endif /* USDT2 */ | |
2496 | |
0 | 2497 JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...)) |
2498 JNIWrapper("CallStaticVoidMethod"); | |
4006 | 2499 #ifndef USDT2 |
0 | 2500 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethod__entry, env, cls, methodID); |
4006 | 2501 #else /* USDT2 */ |
2502 HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY( | |
2503 env, cls, (uintptr_t) methodID); | |
2504 #endif /* USDT2 */ | |
0 | 2505 DT_VOID_RETURN_MARK(CallStaticVoidMethod); |
2506 | |
2507 va_list args; | |
2508 va_start(args, methodID); | |
2509 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2510 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2511 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
2512 va_end(args); | |
2513 JNI_END | |
2514 | |
2515 | |
2516 JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) | |
2517 JNIWrapper("CallStaticVoidMethodV"); | |
4006 | 2518 #ifndef USDT2 |
0 | 2519 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); |
4006 | 2520 #else /* USDT2 */ |
2521 HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY( | |
2522 env, cls, (uintptr_t) methodID); | |
2523 #endif /* USDT2 */ | |
0 | 2524 DT_VOID_RETURN_MARK(CallStaticVoidMethodV); |
2525 | |
2526 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2527 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2528 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
2529 JNI_END | |
2530 | |
2531 | |
2532 JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) | |
2533 JNIWrapper("CallStaticVoidMethodA"); | |
4006 | 2534 #ifndef USDT2 |
0 | 2535 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); |
4006 | 2536 #else /* USDT2 */ |
2537 HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY( | |
2538 env, cls, (uintptr_t) methodID); | |
2539 #endif /* USDT2 */ | |
0 | 2540 DT_VOID_RETURN_MARK(CallStaticVoidMethodA); |
2541 | |
2542 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2543 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 2544 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
2545 JNI_END | |
2546 | |
2547 | |
2548 // | |
2549 // Accessing Fields | |
2550 // | |
2551 | |
2552 | |
4006 | 2553 #ifndef USDT2 |
0 | 2554 DT_RETURN_MARK_DECL(GetFieldID, jfieldID); |
4006 | 2555 #else /* USDT2 */ |
2556 DT_RETURN_MARK_DECL(GetFieldID, jfieldID | |
2557 , HOTSPOT_JNI_GETFIELDID_RETURN((uintptr_t)_ret_ref)); | |
2558 #endif /* USDT2 */ | |
0 | 2559 |
2560 JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, | |
2561 const char *name, const char *sig)) | |
2562 JNIWrapper("GetFieldID"); | |
4006 | 2563 #ifndef USDT2 |
0 | 2564 DTRACE_PROBE4(hotspot_jni, GetFieldID__entry, env, clazz, name, sig); |
4006 | 2565 #else /* USDT2 */ |
2566 HOTSPOT_JNI_GETFIELDID_ENTRY( | |
2567 env, clazz, (char *) name, (char *) sig); | |
2568 #endif /* USDT2 */ | |
0 | 2569 jfieldID ret = 0; |
2570 DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); | |
2571 | |
2572 // The class should have been loaded (we have an instance of the class | |
2573 // passed in) so the field and signature should already be in the symbol | |
2574 // table. If they're not there, the field doesn't exist. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2575 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2576 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2577 if (fieldname == NULL || signame == NULL) { |
0 | 2578 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2579 } | |
2580 KlassHandle k(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2581 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 2582 // Make sure class is initialized before handing id's out to fields |
6983 | 2583 k()->initialize(CHECK_NULL); |
0 | 2584 |
2585 fieldDescriptor fd; | |
6983 | 2586 if (!k()->oop_is_instance() || |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2587 !InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { |
0 | 2588 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2589 } | |
2590 | |
2591 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop | |
2592 // It may also have hash bits for k, if VerifyJNIFields is turned on. | |
2593 ret = jfieldIDWorkaround::to_instance_jfieldID(k(), fd.offset()); | |
2594 return ret; | |
2595 JNI_END | |
2596 | |
2597 | |
2598 JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)) | |
2599 JNIWrapper("GetObjectField"); | |
4006 | 2600 #ifndef USDT2 |
0 | 2601 DTRACE_PROBE3(hotspot_jni, GetObjectField__entry, env, obj, fieldID); |
4006 | 2602 #else /* USDT2 */ |
2603 HOTSPOT_JNI_GETOBJECTFIELD_ENTRY( | |
2604 env, obj, (uintptr_t) fieldID); | |
2605 #endif /* USDT2 */ | |
0 | 2606 oop o = JNIHandles::resolve_non_null(obj); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2607 Klass* k = o->klass(); |
0 | 2608 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2609 // Keep JVMTI addition small and only check enabled flag here. | |
2610 // jni_GetField_probe() assumes that is okay to create handles. | |
2611 if (JvmtiExport::should_post_field_access()) { | |
2612 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); | |
2613 } | |
2614 jobject ret = JNIHandles::make_local(env, o->obj_field(offset)); | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
2615 #if INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2616 // If G1 is enabled and we are accessing the value of the referent |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2617 // field in a reference object then we need to register a non-null |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2618 // referent with the SATB barrier. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2619 if (UseG1GC) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2620 bool needs_barrier = false; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2621 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2622 if (ret != NULL && |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2623 offset == java_lang_ref_Reference::referent_offset && |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2624 InstanceKlass::cast(k)->reference_type() != REF_NONE) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2625 assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2626 needs_barrier = true; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2627 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2628 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2629 if (needs_barrier) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2630 oop referent = JNIHandles::resolve(ret); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2631 G1SATBCardTableModRefBS::enqueue(referent); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2632 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2633 } |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
2634 #endif // INCLUDE_ALL_GCS |
4006 | 2635 #ifndef USDT2 |
0 | 2636 DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); |
4006 | 2637 #else /* USDT2 */ |
2638 HOTSPOT_JNI_GETOBJECTFIELD_RETURN( | |
2639 ret); | |
2640 #endif /* USDT2 */ | |
0 | 2641 return ret; |
2642 JNI_END | |
2643 | |
2644 | |
4006 | 2645 #ifndef USDT2 |
0 | 2646 #define DEFINE_GETFIELD(Return,Fieldname,Result) \ |
2647 \ | |
2648 DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return);\ | |
2649 \ | |
2650 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ | |
2651 JNIWrapper("Get" XSTR(Result) "Field"); \ | |
2652 \ | |
2653 DTRACE_PROBE3(hotspot_jni, Get##Result##Field__entry, env, obj, fieldID);\ | |
2654 Return ret = 0;\ | |
2655 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | |
2656 \ | |
2657 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2658 Klass* k = o->klass(); \ |
0 | 2659 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2660 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2661 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | |
2662 /* and creates a ResetNoHandleMark. */ \ | |
2663 if (JvmtiExport::should_post_field_access()) { \ | |
2664 o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ | |
2665 } \ | |
2666 ret = o->Fieldname##_field(offset); \ | |
2667 return ret; \ | |
2668 JNI_END | |
2669 | |
2670 DEFINE_GETFIELD(jboolean, bool, Boolean) | |
2671 DEFINE_GETFIELD(jbyte, byte, Byte) | |
2672 DEFINE_GETFIELD(jchar, char, Char) | |
2673 DEFINE_GETFIELD(jshort, short, Short) | |
2674 DEFINE_GETFIELD(jint, int, Int) | |
2675 DEFINE_GETFIELD(jlong, long, Long) | |
2676 DEFINE_GETFIELD(jfloat, float, Float) | |
2677 DEFINE_GETFIELD(jdouble, double, Double) | |
2678 | |
4006 | 2679 #else /* USDT2 */ |
2680 | |
2681 #define DEFINE_GETFIELD(Return,Fieldname,Result \ | |
2682 , EntryProbe, ReturnProbe) \ | |
2683 \ | |
2684 DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return \ | |
2685 , ReturnProbe); \ | |
2686 \ | |
2687 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ | |
2688 JNIWrapper("Get" XSTR(Result) "Field"); \ | |
2689 \ | |
2690 EntryProbe; \ | |
2691 Return ret = 0;\ | |
2692 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | |
2693 \ | |
2694 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2695 Klass* k = o->klass(); \ |
4006 | 2696 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2697 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2698 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | |
2699 /* and creates a ResetNoHandleMark. */ \ | |
2700 if (JvmtiExport::should_post_field_access()) { \ | |
2701 o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ | |
2702 } \ | |
2703 ret = o->Fieldname##_field(offset); \ | |
2704 return ret; \ | |
2705 JNI_END | |
2706 | |
2707 DEFINE_GETFIELD(jboolean, bool, Boolean | |
2708 , HOTSPOT_JNI_GETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2709 HOTSPOT_JNI_GETBOOLEANFIELD_RETURN(_ret_ref)) | |
2710 DEFINE_GETFIELD(jbyte, byte, Byte | |
2711 , HOTSPOT_JNI_GETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2712 HOTSPOT_JNI_GETBYTEFIELD_RETURN(_ret_ref)) | |
2713 DEFINE_GETFIELD(jchar, char, Char | |
2714 , HOTSPOT_JNI_GETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2715 HOTSPOT_JNI_GETCHARFIELD_RETURN(_ret_ref)) | |
2716 DEFINE_GETFIELD(jshort, short, Short | |
2717 , HOTSPOT_JNI_GETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2718 HOTSPOT_JNI_GETSHORTFIELD_RETURN(_ret_ref)) | |
2719 DEFINE_GETFIELD(jint, int, Int | |
2720 , HOTSPOT_JNI_GETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2721 HOTSPOT_JNI_GETINTFIELD_RETURN(_ret_ref)) | |
2722 DEFINE_GETFIELD(jlong, long, Long | |
2723 , HOTSPOT_JNI_GETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2724 HOTSPOT_JNI_GETLONGFIELD_RETURN(_ret_ref)) | |
2725 // Float and double probes don't return value because dtrace doesn't currently support it | |
2726 DEFINE_GETFIELD(jfloat, float, Float | |
2727 , HOTSPOT_JNI_GETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2728 HOTSPOT_JNI_GETFLOATFIELD_RETURN()) | |
2729 DEFINE_GETFIELD(jdouble, double, Double | |
2730 , HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2731 HOTSPOT_JNI_GETDOUBLEFIELD_RETURN()) | |
2732 #endif /* USDT2 */ | |
2733 | |
0 | 2734 address jni_GetBooleanField_addr() { |
2735 return (address)jni_GetBooleanField; | |
2736 } | |
2737 address jni_GetByteField_addr() { | |
2738 return (address)jni_GetByteField; | |
2739 } | |
2740 address jni_GetCharField_addr() { | |
2741 return (address)jni_GetCharField; | |
2742 } | |
2743 address jni_GetShortField_addr() { | |
2744 return (address)jni_GetShortField; | |
2745 } | |
2746 address jni_GetIntField_addr() { | |
2747 return (address)jni_GetIntField; | |
2748 } | |
2749 address jni_GetLongField_addr() { | |
2750 return (address)jni_GetLongField; | |
2751 } | |
2752 address jni_GetFloatField_addr() { | |
2753 return (address)jni_GetFloatField; | |
2754 } | |
2755 address jni_GetDoubleField_addr() { | |
2756 return (address)jni_GetDoubleField; | |
2757 } | |
2758 | |
2759 JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject value)) | |
2760 JNIWrapper("SetObjectField"); | |
4006 | 2761 #ifndef USDT2 |
0 | 2762 DTRACE_PROBE4(hotspot_jni, SetObjectField__entry, env, obj, fieldID, value); |
4006 | 2763 #else /* USDT2 */ |
2764 HOTSPOT_JNI_SETOBJECTFIELD_ENTRY( | |
2765 env, obj, (uintptr_t) fieldID, value); | |
2766 #endif /* USDT2 */ | |
0 | 2767 oop o = JNIHandles::resolve_non_null(obj); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2768 Klass* k = o->klass(); |
0 | 2769 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2770 // Keep JVMTI addition small and only check enabled flag here. | |
2771 // jni_SetField_probe_nh() assumes that is not okay to create handles | |
2772 // and creates a ResetNoHandleMark. | |
2773 if (JvmtiExport::should_post_field_modification()) { | |
2774 jvalue field_value; | |
2775 field_value.l = value; | |
2776 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value); | |
2777 } | |
2778 o->obj_field_put(offset, JNIHandles::resolve(value)); | |
4006 | 2779 #ifndef USDT2 |
0 | 2780 DTRACE_PROBE(hotspot_jni, SetObjectField__return); |
4006 | 2781 #else /* USDT2 */ |
2782 HOTSPOT_JNI_SETOBJECTFIELD_RETURN( | |
2783 ); | |
2784 #endif /* USDT2 */ | |
0 | 2785 JNI_END |
2786 | |
4006 | 2787 #ifndef USDT2 |
0 | 2788 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType) \ |
2789 \ | |
2790 JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ | |
2791 JNIWrapper("Set" XSTR(Result) "Field"); \ | |
2792 \ | |
6837
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
2793 FP_SELECT_##Result( \ |
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
2794 DTRACE_PROBE4(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID, value), \ |
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
2795 DTRACE_PROBE3(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID)); \ |
0 | 2796 \ |
2797 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2798 Klass* k = o->klass(); \ |
0 | 2799 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2800 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2801 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | |
2802 /* and creates a ResetNoHandleMark. */ \ | |
2803 if (JvmtiExport::should_post_field_modification()) { \ | |
2804 jvalue field_value; \ | |
2805 field_value.unionType = value; \ | |
2806 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ | |
2807 } \ | |
2808 o->Fieldname##_field_put(offset, value); \ | |
2809 DTRACE_PROBE(hotspot_jni, Set##Result##Field__return);\ | |
2810 JNI_END | |
2811 | |
2812 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z) | |
2813 DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b) | |
2814 DEFINE_SETFIELD(jchar, char, Char, 'C', c) | |
2815 DEFINE_SETFIELD(jshort, short, Short, 'S', s) | |
2816 DEFINE_SETFIELD(jint, int, Int, 'I', i) | |
2817 DEFINE_SETFIELD(jlong, long, Long, 'J', j) | |
2818 DEFINE_SETFIELD(jfloat, float, Float, 'F', f) | |
2819 DEFINE_SETFIELD(jdouble, double, Double, 'D', d) | |
2820 | |
4006 | 2821 #else /* USDT2 */ |
2822 | |
2823 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType \ | |
2824 , EntryProbe, ReturnProbe) \ | |
2825 \ | |
2826 JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ | |
2827 JNIWrapper("Set" XSTR(Result) "Field"); \ | |
2828 \ | |
2829 EntryProbe; \ | |
2830 \ | |
2831 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2832 Klass* k = o->klass(); \ |
4006 | 2833 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2834 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2835 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | |
2836 /* and creates a ResetNoHandleMark. */ \ | |
2837 if (JvmtiExport::should_post_field_modification()) { \ | |
2838 jvalue field_value; \ | |
2839 field_value.unionType = value; \ | |
2840 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ | |
2841 } \ | |
2842 o->Fieldname##_field_put(offset, value); \ | |
2843 ReturnProbe; \ | |
2844 JNI_END | |
2845 | |
2846 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z | |
2847 , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2848 HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) | |
2849 DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b | |
2850 , HOTSPOT_JNI_SETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2851 HOTSPOT_JNI_SETBYTEFIELD_RETURN()) | |
2852 DEFINE_SETFIELD(jchar, char, Char, 'C', c | |
2853 , HOTSPOT_JNI_SETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2854 HOTSPOT_JNI_SETCHARFIELD_RETURN()) | |
2855 DEFINE_SETFIELD(jshort, short, Short, 'S', s | |
2856 , HOTSPOT_JNI_SETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2857 HOTSPOT_JNI_SETSHORTFIELD_RETURN()) | |
2858 DEFINE_SETFIELD(jint, int, Int, 'I', i | |
2859 , HOTSPOT_JNI_SETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2860 HOTSPOT_JNI_SETINTFIELD_RETURN()) | |
2861 DEFINE_SETFIELD(jlong, long, Long, 'J', j | |
2862 , HOTSPOT_JNI_SETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2863 HOTSPOT_JNI_SETLONGFIELD_RETURN()) | |
2864 // Float and double probes don't return value because dtrace doesn't currently support it | |
2865 DEFINE_SETFIELD(jfloat, float, Float, 'F', f | |
2866 , HOTSPOT_JNI_SETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2867 HOTSPOT_JNI_SETFLOATFIELD_RETURN()) | |
2868 DEFINE_SETFIELD(jdouble, double, Double, 'D', d | |
2869 , HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2870 HOTSPOT_JNI_SETDOUBLEFIELD_RETURN()) | |
2871 #endif /* USDT2 */ | |
2872 | |
2873 #ifndef USDT2 | |
0 | 2874 DT_RETURN_MARK_DECL(ToReflectedField, jobject); |
4006 | 2875 #else /* USDT2 */ |
2876 DT_RETURN_MARK_DECL(ToReflectedField, jobject | |
2877 , HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN(_ret_ref)); | |
2878 #endif /* USDT2 */ | |
0 | 2879 |
2880 JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)) | |
2881 JNIWrapper("ToReflectedField"); | |
4006 | 2882 #ifndef USDT2 |
0 | 2883 DTRACE_PROBE4(hotspot_jni, ToReflectedField__entry, |
2884 env, cls, fieldID, isStatic); | |
4006 | 2885 #else /* USDT2 */ |
2886 HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY( | |
2887 env, cls, (uintptr_t) fieldID, isStatic); | |
2888 #endif /* USDT2 */ | |
0 | 2889 jobject ret = NULL; |
2890 DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); | |
2891 | |
2892 fieldDescriptor fd; | |
2893 bool found = false; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2894 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2895 |
2896 assert(jfieldIDWorkaround::is_static_jfieldID(fieldID) == (isStatic != 0), "invalid fieldID"); | |
2897 | |
2898 if (isStatic) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2899 // Static field. The fieldID a JNIid specifying the field holder and the offset within the Klass*. |
0 | 2900 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
2901 assert(id->is_static_field_id(), "invalid static field id"); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
2902 found = id->find_local_field(&fd); |
0 | 2903 } else { |
2904 // Non-static field. The fieldID is really the offset of the field within the instanceOop. | |
2905 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2906 found = InstanceKlass::cast(k)->find_field_from_offset(offset, false, &fd); |
0 | 2907 } |
2908 assert(found, "bad fieldID passed into jni_ToReflectedField"); | |
2909 oop reflected = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); | |
2910 ret = JNIHandles::make_local(env, reflected); | |
2911 return ret; | |
2912 JNI_END | |
2913 | |
2914 | |
2915 // | |
2916 // Accessing Static Fields | |
2917 // | |
4006 | 2918 #ifndef USDT2 |
0 | 2919 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID); |
4006 | 2920 #else /* USDT2 */ |
2921 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID | |
2922 , HOTSPOT_JNI_GETSTATICFIELDID_RETURN((uintptr_t)_ret_ref)); | |
2923 #endif /* USDT2 */ | |
0 | 2924 |
2925 JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, | |
2926 const char *name, const char *sig)) | |
2927 JNIWrapper("GetStaticFieldID"); | |
4006 | 2928 #ifndef USDT2 |
0 | 2929 DTRACE_PROBE4(hotspot_jni, GetStaticFieldID__entry, env, clazz, name, sig); |
4006 | 2930 #else /* USDT2 */ |
2931 HOTSPOT_JNI_GETSTATICFIELDID_ENTRY( | |
2932 env, clazz, (char *) name, (char *) sig); | |
2933 #endif /* USDT2 */ | |
0 | 2934 jfieldID ret = NULL; |
2935 DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); | |
2936 | |
2937 // The class should have been loaded (we have an instance of the class | |
2938 // passed in) so the field and signature should already be in the symbol | |
2939 // table. If they're not there, the field doesn't exist. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2940 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2941 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2942 if (fieldname == NULL || signame == NULL) { |
0 | 2943 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2944 } | |
2945 KlassHandle k(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2946 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 2947 // Make sure class is initialized before handing id's out to static fields |
6983 | 2948 k()->initialize(CHECK_NULL); |
0 | 2949 |
2950 fieldDescriptor fd; | |
6983 | 2951 if (!k()->oop_is_instance() || |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2952 !InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { |
0 | 2953 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2954 } | |
2955 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2956 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass* |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6856
diff
changeset
|
2957 JNIid* id = fd.field_holder()->jni_id_for(fd.offset()); |
0 | 2958 debug_only(id->set_is_static_field_id();) |
2959 | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
2960 debug_only(id->verify(fd.field_holder())); |
0 | 2961 |
2962 ret = jfieldIDWorkaround::to_static_jfieldID(id); | |
2963 return ret; | |
2964 JNI_END | |
2965 | |
2966 | |
2967 JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)) | |
2968 JNIWrapper("GetStaticObjectField"); | |
4006 | 2969 #ifndef USDT2 |
0 | 2970 DTRACE_PROBE3(hotspot_jni, GetStaticObjectField__entry, env, clazz, fieldID); |
4006 | 2971 #else /* USDT2 */ |
2972 HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY( | |
2973 env, clazz, (uintptr_t) fieldID); | |
2974 #endif /* USDT2 */ | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
2975 #if INCLUDE_JNI_CHECK |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2976 DEBUG_ONLY(Klass* param_k = jniCheck::validate_class(thread, clazz);) |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
2977 #endif // INCLUDE_JNI_CHECK |
0 | 2978 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
2979 assert(id->is_static_field_id(), "invalid static field id"); | |
2980 // Keep JVMTI addition small and only check enabled flag here. | |
2981 // jni_GetField_probe() assumes that is okay to create handles. | |
2982 if (JvmtiExport::should_post_field_access()) { | |
2983 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); | |
2984 } | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
2985 jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset())); |
4006 | 2986 #ifndef USDT2 |
0 | 2987 DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret); |
4006 | 2988 #else /* USDT2 */ |
2989 HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN( | |
2990 ret); | |
2991 #endif /* USDT2 */ | |
0 | 2992 return ret; |
2993 JNI_END | |
2994 | |
4006 | 2995 #ifndef USDT2 |
0 | 2996 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result) \ |
2997 \ | |
2998 DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return);\ | |
2999 \ | |
3000 JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ | |
3001 JNIWrapper("GetStatic" XSTR(Result) "Field"); \ | |
3002 DTRACE_PROBE3(hotspot_jni, GetStatic##Result##Field__entry, env, clazz, fieldID);\ | |
3003 Return ret = 0;\ | |
3004 DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ | |
3005 (const Return&)ret);\ | |
3006 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3007 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3008 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3009 /* jni_GetField_probe() assumes that is okay to create handles. */ \ | |
3010 if (JvmtiExport::should_post_field_access()) { \ | |
3011 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ | |
3012 } \ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3013 ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ |
0 | 3014 return ret;\ |
3015 JNI_END | |
3016 | |
3017 DEFINE_GETSTATICFIELD(jboolean, bool, Boolean) | |
3018 DEFINE_GETSTATICFIELD(jbyte, byte, Byte) | |
3019 DEFINE_GETSTATICFIELD(jchar, char, Char) | |
3020 DEFINE_GETSTATICFIELD(jshort, short, Short) | |
3021 DEFINE_GETSTATICFIELD(jint, int, Int) | |
3022 DEFINE_GETSTATICFIELD(jlong, long, Long) | |
3023 DEFINE_GETSTATICFIELD(jfloat, float, Float) | |
3024 DEFINE_GETSTATICFIELD(jdouble, double, Double) | |
3025 | |
4006 | 3026 #else /* USDT2 */ |
3027 | |
3028 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result \ | |
3029 , EntryProbe, ReturnProbe) \ | |
3030 \ | |
3031 DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return \ | |
3032 , ReturnProbe); \ | |
3033 \ | |
3034 JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ | |
3035 JNIWrapper("GetStatic" XSTR(Result) "Field"); \ | |
3036 EntryProbe; \ | |
3037 Return ret = 0;\ | |
3038 DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ | |
3039 (const Return&)ret);\ | |
3040 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3041 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3042 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3043 /* jni_GetField_probe() assumes that is okay to create handles. */ \ | |
3044 if (JvmtiExport::should_post_field_access()) { \ | |
3045 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ | |
3046 } \ | |
3047 ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ | |
3048 return ret;\ | |
3049 JNI_END | |
3050 | |
3051 DEFINE_GETSTATICFIELD(jboolean, bool, Boolean | |
3052 , HOTSPOT_JNI_GETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBOOLEANFIELD_RETURN(_ret_ref)) | |
3053 DEFINE_GETSTATICFIELD(jbyte, byte, Byte | |
3054 , HOTSPOT_JNI_GETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBYTEFIELD_RETURN(_ret_ref) ) | |
3055 DEFINE_GETSTATICFIELD(jchar, char, Char | |
3056 , HOTSPOT_JNI_GETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICCHARFIELD_RETURN(_ret_ref) ) | |
3057 DEFINE_GETSTATICFIELD(jshort, short, Short | |
3058 , HOTSPOT_JNI_GETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICSHORTFIELD_RETURN(_ret_ref) ) | |
3059 DEFINE_GETSTATICFIELD(jint, int, Int | |
3060 , HOTSPOT_JNI_GETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICINTFIELD_RETURN(_ret_ref) ) | |
3061 DEFINE_GETSTATICFIELD(jlong, long, Long | |
3062 , HOTSPOT_JNI_GETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICLONGFIELD_RETURN(_ret_ref) ) | |
3063 // Float and double probes don't return value because dtrace doesn't currently support it | |
3064 DEFINE_GETSTATICFIELD(jfloat, float, Float | |
3065 , HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN() ) | |
3066 DEFINE_GETSTATICFIELD(jdouble, double, Double | |
3067 , HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN() ) | |
3068 #endif /* USDT2 */ | |
0 | 3069 |
3070 JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)) | |
3071 JNIWrapper("SetStaticObjectField"); | |
4006 | 3072 #ifndef USDT2 |
0 | 3073 DTRACE_PROBE4(hotspot_jni, SetStaticObjectField__entry, env, clazz, fieldID, value); |
4006 | 3074 #else /* USDT2 */ |
3075 HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY( | |
3076 env, clazz, (uintptr_t) fieldID, value); | |
3077 #endif /* USDT2 */ | |
0 | 3078 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
3079 assert(id->is_static_field_id(), "invalid static field id"); | |
3080 // Keep JVMTI addition small and only check enabled flag here. | |
3081 // jni_SetField_probe() assumes that is okay to create handles. | |
3082 if (JvmtiExport::should_post_field_modification()) { | |
3083 jvalue field_value; | |
3084 field_value.l = value; | |
3085 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value); | |
3086 } | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3087 id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value)); |
4006 | 3088 #ifndef USDT2 |
0 | 3089 DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return); |
4006 | 3090 #else /* USDT2 */ |
3091 HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN( | |
3092 ); | |
3093 #endif /* USDT2 */ | |
0 | 3094 JNI_END |
3095 | |
3096 | |
4006 | 3097 #ifndef USDT2 |
0 | 3098 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType) \ |
3099 \ | |
3100 JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ | |
3101 JNIWrapper("SetStatic" XSTR(Result) "Field"); \ | |
6837
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
3102 FP_SELECT_##Result( \ |
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
3103 DTRACE_PROBE4(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID, value), \ |
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
3104 DTRACE_PROBE3(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID)); \ |
0 | 3105 \ |
3106 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3107 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3108 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3109 /* jni_SetField_probe() assumes that is okay to create handles. */ \ | |
3110 if (JvmtiExport::should_post_field_modification()) { \ | |
3111 jvalue field_value; \ | |
3112 field_value.unionType = value; \ | |
3113 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ | |
3114 } \ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3115 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ |
0 | 3116 DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\ |
3117 JNI_END | |
3118 | |
3119 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z) | |
3120 DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b) | |
3121 DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c) | |
3122 DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s) | |
3123 DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i) | |
3124 DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j) | |
3125 DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f) | |
3126 DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d) | |
3127 | |
4006 | 3128 #else /* USDT2 */ |
3129 | |
3130 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType \ | |
3131 , EntryProbe, ReturnProbe) \ | |
3132 \ | |
3133 JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ | |
3134 JNIWrapper("SetStatic" XSTR(Result) "Field"); \ | |
3135 EntryProbe; \ | |
3136 \ | |
3137 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3138 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3139 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3140 /* jni_SetField_probe() assumes that is okay to create handles. */ \ | |
3141 if (JvmtiExport::should_post_field_modification()) { \ | |
3142 jvalue field_value; \ | |
3143 field_value.unionType = value; \ | |
3144 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ | |
3145 } \ | |
3146 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ | |
3147 ReturnProbe;\ | |
3148 JNI_END | |
3149 | |
3150 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z | |
3151 , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), | |
3152 HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) | |
3153 DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b | |
3154 , HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3155 HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN()) | |
3156 DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c | |
3157 , HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3158 HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN()) | |
3159 DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s | |
3160 , HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3161 HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN()) | |
3162 DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i | |
3163 , HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3164 HOTSPOT_JNI_SETSTATICINTFIELD_RETURN()) | |
3165 DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j | |
3166 , HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3167 HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN()) | |
3168 // Float and double probes don't return value because dtrace doesn't currently support it | |
3169 DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f | |
3170 , HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), | |
3171 HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN()) | |
3172 DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d | |
3173 , HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), | |
3174 HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN()) | |
3175 #endif /* USDT2 */ | |
0 | 3176 |
3177 // | |
3178 // String Operations | |
3179 // | |
3180 | |
3181 // Unicode Interface | |
3182 | |
4006 | 3183 #ifndef USDT2 |
0 | 3184 DT_RETURN_MARK_DECL(NewString, jstring); |
4006 | 3185 #else /* USDT2 */ |
3186 DT_RETURN_MARK_DECL(NewString, jstring | |
3187 , HOTSPOT_JNI_NEWSTRING_RETURN(_ret_ref)); | |
3188 #endif /* USDT2 */ | |
0 | 3189 |
3190 JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len)) | |
3191 JNIWrapper("NewString"); | |
4006 | 3192 #ifndef USDT2 |
0 | 3193 DTRACE_PROBE3(hotspot_jni, NewString__entry, env, unicodeChars, len); |
4006 | 3194 #else /* USDT2 */ |
3195 HOTSPOT_JNI_NEWSTRING_ENTRY( | |
3196 env, (uint16_t *) unicodeChars, len); | |
3197 #endif /* USDT2 */ | |
0 | 3198 jstring ret = NULL; |
3199 DT_RETURN_MARK(NewString, jstring, (const jstring&)ret); | |
3200 oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL); | |
3201 ret = (jstring) JNIHandles::make_local(env, string); | |
3202 return ret; | |
3203 JNI_END | |
3204 | |
3205 | |
3206 JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string)) | |
3207 JNIWrapper("GetStringLength"); | |
4006 | 3208 #ifndef USDT2 |
0 | 3209 DTRACE_PROBE2(hotspot_jni, GetStringLength__entry, env, string); |
4006 | 3210 #else /* USDT2 */ |
3211 HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY( | |
3212 env, string); | |
3213 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3214 jsize ret = 0; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3215 oop s = JNIHandles::resolve_non_null(string); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3216 if (java_lang_String::value(s) != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3217 ret = java_lang_String::length(s); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3218 } |
4006 | 3219 #ifndef USDT2 |
0 | 3220 DTRACE_PROBE1(hotspot_jni, GetStringLength__return, ret); |
4006 | 3221 #else /* USDT2 */ |
3222 HOTSPOT_JNI_GETSTRINGLENGTH_RETURN( | |
3223 ret); | |
3224 #endif /* USDT2 */ | |
0 | 3225 return ret; |
3226 JNI_END | |
3227 | |
3228 | |
3229 JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars( | |
3230 JNIEnv *env, jstring string, jboolean *isCopy)) | |
3231 JNIWrapper("GetStringChars"); | |
4006 | 3232 #ifndef USDT2 |
0 | 3233 DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); |
4006 | 3234 #else /* USDT2 */ |
3235 HOTSPOT_JNI_GETSTRINGCHARS_ENTRY( | |
3236 env, string, (uintptr_t *) isCopy); | |
3237 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3238 jchar* buf = NULL; |
0 | 3239 oop s = JNIHandles::resolve_non_null(string); |
3240 typeArrayOop s_value = java_lang_String::value(s); | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3241 if (s_value != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3242 int s_len = java_lang_String::length(s); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3243 int s_offset = java_lang_String::offset(s); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3244 buf = NEW_C_HEAP_ARRAY_RETURN_NULL(jchar, s_len + 1, mtInternal); // add one for zero termination |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3245 /* JNI Specification states return NULL on OOM */ |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3246 if (buf != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3247 if (s_len > 0) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3248 memcpy(buf, s_value->char_at_addr(s_offset), sizeof(jchar)*s_len); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3249 } |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3250 buf[s_len] = 0; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3251 //%note jni_5 |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3252 if (isCopy != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3253 *isCopy = JNI_TRUE; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3254 } |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3255 } |
0 | 3256 } |
4006 | 3257 #ifndef USDT2 |
0 | 3258 DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); |
4006 | 3259 #else /* USDT2 */ |
3260 HOTSPOT_JNI_GETSTRINGCHARS_RETURN( | |
3261 buf); | |
3262 #endif /* USDT2 */ | |
0 | 3263 return buf; |
3264 JNI_END | |
3265 | |
3266 | |
3267 JNI_QUICK_ENTRY(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)) | |
3268 JNIWrapper("ReleaseStringChars"); | |
4006 | 3269 #ifndef USDT2 |
0 | 3270 DTRACE_PROBE3(hotspot_jni, ReleaseStringChars__entry, env, str, chars); |
4006 | 3271 #else /* USDT2 */ |
3272 HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY( | |
3273 env, str, (uint16_t *) chars); | |
3274 #endif /* USDT2 */ | |
0 | 3275 //%note jni_6 |
3276 if (chars != NULL) { | |
3277 // Since String objects are supposed to be immutable, don't copy any | |
3278 // new data back. A bad user will have to go after the char array. | |
3279 FreeHeap((void*) chars); | |
3280 } | |
4006 | 3281 #ifndef USDT2 |
0 | 3282 DTRACE_PROBE(hotspot_jni, ReleaseStringChars__return); |
4006 | 3283 #else /* USDT2 */ |
3284 HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN( | |
3285 ); | |
3286 #endif /* USDT2 */ | |
0 | 3287 JNI_END |
3288 | |
3289 | |
3290 // UTF Interface | |
3291 | |
4006 | 3292 #ifndef USDT2 |
0 | 3293 DT_RETURN_MARK_DECL(NewStringUTF, jstring); |
4006 | 3294 #else /* USDT2 */ |
3295 DT_RETURN_MARK_DECL(NewStringUTF, jstring | |
3296 , HOTSPOT_JNI_NEWSTRINGUTF_RETURN(_ret_ref)); | |
3297 #endif /* USDT2 */ | |
0 | 3298 |
3299 JNI_ENTRY(jstring, jni_NewStringUTF(JNIEnv *env, const char *bytes)) | |
3300 JNIWrapper("NewStringUTF"); | |
4006 | 3301 #ifndef USDT2 |
0 | 3302 DTRACE_PROBE2(hotspot_jni, NewStringUTF__entry, env, bytes); |
4006 | 3303 #else /* USDT2 */ |
3304 HOTSPOT_JNI_NEWSTRINGUTF_ENTRY( | |
3305 env, (char *) bytes); | |
3306 #endif /* USDT2 */ | |
0 | 3307 jstring ret; |
3308 DT_RETURN_MARK(NewStringUTF, jstring, (const jstring&)ret); | |
3309 | |
3310 oop result = java_lang_String::create_oop_from_str((char*) bytes, CHECK_NULL); | |
3311 ret = (jstring) JNIHandles::make_local(env, result); | |
3312 return ret; | |
3313 JNI_END | |
3314 | |
3315 | |
3316 JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string)) | |
3317 JNIWrapper("GetStringUTFLength"); | |
4006 | 3318 #ifndef USDT2 |
0 | 3319 DTRACE_PROBE2(hotspot_jni, GetStringUTFLength__entry, env, string); |
4006 | 3320 #else /* USDT2 */ |
3321 HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY( | |
3322 env, string); | |
3323 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3324 jsize ret = 0; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3325 oop java_string = JNIHandles::resolve_non_null(string); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3326 if (java_lang_String::value(java_string) != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3327 ret = java_lang_String::utf8_length(java_string); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3328 } |
4006 | 3329 #ifndef USDT2 |
0 | 3330 DTRACE_PROBE1(hotspot_jni, GetStringUTFLength__return, ret); |
4006 | 3331 #else /* USDT2 */ |
3332 HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN( | |
3333 ret); | |
3334 #endif /* USDT2 */ | |
0 | 3335 return ret; |
3336 JNI_END | |
3337 | |
3338 | |
3339 JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) | |
3340 JNIWrapper("GetStringUTFChars"); | |
4006 | 3341 #ifndef USDT2 |
0 | 3342 DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy); |
4006 | 3343 #else /* USDT2 */ |
3344 HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY( | |
3345 env, string, (uintptr_t *) isCopy); | |
3346 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3347 char* result = NULL; |
1989
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1980
diff
changeset
|
3348 oop java_string = JNIHandles::resolve_non_null(string); |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3349 if (java_lang_String::value(java_string) != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3350 size_t length = java_lang_String::utf8_length(java_string); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3351 /* JNI Specification states return NULL on OOM */ |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3352 result = AllocateHeap(length + 1, mtInternal, 0, AllocFailStrategy::RETURN_NULL); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3353 if (result != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3354 java_lang_String::as_utf8_string(java_string, result, (int) length + 1); |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3355 if (isCopy != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3356 *isCopy = JNI_TRUE; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3357 } |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3358 } |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3359 } |
4006 | 3360 #ifndef USDT2 |
0 | 3361 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); |
4006 | 3362 #else /* USDT2 */ |
3363 HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN( | |
3364 result); | |
3365 #endif /* USDT2 */ | |
0 | 3366 return result; |
3367 JNI_END | |
3368 | |
3369 | |
3370 JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars)) | |
3371 JNIWrapper("ReleaseStringUTFChars"); | |
4006 | 3372 #ifndef USDT2 |
0 | 3373 DTRACE_PROBE3(hotspot_jni, ReleaseStringUTFChars__entry, env, str, chars); |
4006 | 3374 #else /* USDT2 */ |
3375 HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY( | |
3376 env, str, (char *) chars); | |
3377 #endif /* USDT2 */ | |
0 | 3378 if (chars != NULL) { |
3379 FreeHeap((char*) chars); | |
3380 } | |
4006 | 3381 #ifndef USDT2 |
0 | 3382 DTRACE_PROBE(hotspot_jni, ReleaseStringUTFChars__return); |
4006 | 3383 #else /* USDT2 */ |
3384 HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN( | |
3385 ); | |
3386 #endif /* USDT2 */ | |
0 | 3387 JNI_END |
3388 | |
3389 | |
3390 JNI_QUICK_ENTRY(jsize, jni_GetArrayLength(JNIEnv *env, jarray array)) | |
3391 JNIWrapper("GetArrayLength"); | |
4006 | 3392 #ifndef USDT2 |
0 | 3393 DTRACE_PROBE2(hotspot_jni, GetArrayLength__entry, env, array); |
4006 | 3394 #else /* USDT2 */ |
3395 HOTSPOT_JNI_GETARRAYLENGTH_ENTRY( | |
3396 env, array); | |
3397 #endif /* USDT2 */ | |
0 | 3398 arrayOop a = arrayOop(JNIHandles::resolve_non_null(array)); |
3399 assert(a->is_array(), "must be array"); | |
3400 jsize ret = a->length(); | |
4006 | 3401 #ifndef USDT2 |
0 | 3402 DTRACE_PROBE1(hotspot_jni, GetArrayLength__return, ret); |
4006 | 3403 #else /* USDT2 */ |
3404 HOTSPOT_JNI_GETARRAYLENGTH_RETURN( | |
3405 ret); | |
3406 #endif /* USDT2 */ | |
0 | 3407 return ret; |
3408 JNI_END | |
3409 | |
3410 | |
3411 // | |
3412 // Object Array Operations | |
3413 // | |
3414 | |
4006 | 3415 #ifndef USDT2 |
0 | 3416 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray); |
4006 | 3417 #else /* USDT2 */ |
3418 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray | |
3419 , HOTSPOT_JNI_NEWOBJECTARRAY_RETURN(_ret_ref)); | |
3420 #endif /* USDT2 */ | |
0 | 3421 |
3422 JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)) | |
3423 JNIWrapper("NewObjectArray"); | |
4006 | 3424 #ifndef USDT2 |
0 | 3425 DTRACE_PROBE4(hotspot_jni, NewObjectArray__entry, env, length, elementClass, initialElement); |
4006 | 3426 #else /* USDT2 */ |
3427 HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY( | |
3428 env, length, elementClass, initialElement); | |
3429 #endif /* USDT2 */ | |
0 | 3430 jobjectArray ret = NULL; |
3431 DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
3432 KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); |
6983 | 3433 Klass* ako = ek()->array_klass(CHECK_NULL); |
0 | 3434 KlassHandle ak = KlassHandle(THREAD, ako); |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3435 ObjArrayKlass::cast(ak())->initialize(CHECK_NULL); |
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3436 objArrayOop result = ObjArrayKlass::cast(ak())->allocate(length, CHECK_NULL); |
0 | 3437 oop initial_value = JNIHandles::resolve(initialElement); |
3438 if (initial_value != NULL) { // array already initialized with NULL | |
3439 for (int index = 0; index < length; index++) { | |
3440 result->obj_at_put(index, initial_value); | |
3441 } | |
3442 } | |
3443 ret = (jobjectArray) JNIHandles::make_local(env, result); | |
3444 return ret; | |
3445 JNI_END | |
3446 | |
4006 | 3447 #ifndef USDT2 |
0 | 3448 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject); |
4006 | 3449 #else /* USDT2 */ |
3450 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject | |
3451 , HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(_ret_ref)); | |
3452 #endif /* USDT2 */ | |
0 | 3453 |
3454 JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)) | |
3455 JNIWrapper("GetObjectArrayElement"); | |
4006 | 3456 #ifndef USDT2 |
0 | 3457 DTRACE_PROBE3(hotspot_jni, GetObjectArrayElement__entry, env, array, index); |
4006 | 3458 #else /* USDT2 */ |
3459 HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY( | |
3460 env, array, index); | |
3461 #endif /* USDT2 */ | |
0 | 3462 jobject ret = NULL; |
3463 DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); | |
3464 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); | |
3465 if (a->is_within_bounds(index)) { | |
1034
08780c8a9f04
6893483: DTrace probe return values for a couple JNI methods are wrong
kamg
parents:
973
diff
changeset
|
3466 ret = JNIHandles::make_local(env, a->obj_at(index)); |
0 | 3467 return ret; |
3468 } else { | |
3469 char buf[jintAsStringSize]; | |
3470 sprintf(buf, "%d", index); | |
3471 THROW_MSG_0(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), buf); | |
3472 } | |
3473 JNI_END | |
3474 | |
4006 | 3475 #ifndef USDT2 |
0 | 3476 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement); |
4006 | 3477 #else /* USDT2 */ |
3478 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement | |
3479 , HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN()); | |
3480 #endif /* USDT2 */ | |
0 | 3481 |
3482 JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value)) | |
3483 JNIWrapper("SetObjectArrayElement"); | |
4006 | 3484 #ifndef USDT2 |
0 | 3485 DTRACE_PROBE4(hotspot_jni, SetObjectArrayElement__entry, env, array, index, value); |
4006 | 3486 #else /* USDT2 */ |
3487 HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY( | |
3488 env, array, index, value); | |
3489 #endif /* USDT2 */ | |
0 | 3490 DT_VOID_RETURN_MARK(SetObjectArrayElement); |
3491 | |
3492 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); | |
3493 oop v = JNIHandles::resolve(value); | |
3494 if (a->is_within_bounds(index)) { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3495 if (v == NULL || v->is_a(ObjArrayKlass::cast(a->klass())->element_klass())) { |
0 | 3496 a->obj_at_put(index, v); |
3497 } else { | |
3498 THROW(vmSymbols::java_lang_ArrayStoreException()); | |
3499 } | |
3500 } else { | |
3501 char buf[jintAsStringSize]; | |
3502 sprintf(buf, "%d", index); | |
3503 THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), buf); | |
3504 } | |
3505 JNI_END | |
3506 | |
3507 | |
4006 | 3508 #ifndef USDT2 |
0 | 3509 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \ |
3510 \ | |
4006 | 3511 DT_RETURN_MARK_DECL(New##Result##Array, Return); \ |
0 | 3512 \ |
3513 JNI_ENTRY(Return, \ | |
3514 jni_New##Result##Array(JNIEnv *env, jsize len)) \ | |
3515 JNIWrapper("New" XSTR(Result) "Array"); \ | |
3516 DTRACE_PROBE2(hotspot_jni, New##Result##Array__entry, env, len);\ | |
3517 Return ret = NULL;\ | |
1034
08780c8a9f04
6893483: DTrace probe return values for a couple JNI methods are wrong
kamg
parents:
973
diff
changeset
|
3518 DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ |
0 | 3519 \ |
3520 oop obj= oopFactory::Allocator(len, CHECK_0); \ | |
3521 ret = (Return) JNIHandles::make_local(env, obj); \ | |
3522 return ret;\ | |
3523 JNI_END | |
3524 | |
3525 DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean) | |
3526 DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte) | |
3527 DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short) | |
3528 DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char) | |
3529 DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int) | |
3530 DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long) | |
3531 DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float) | |
3532 DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double) | |
3533 | |
4006 | 3534 #else /* USDT2 */ |
3535 | |
3536 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result \ | |
3537 ,EntryProbe,ReturnProbe) \ | |
3538 \ | |
3539 DT_RETURN_MARK_DECL(New##Result##Array, Return \ | |
3540 , ReturnProbe); \ | |
3541 \ | |
3542 JNI_ENTRY(Return, \ | |
3543 jni_New##Result##Array(JNIEnv *env, jsize len)) \ | |
3544 JNIWrapper("New" XSTR(Result) "Array"); \ | |
3545 EntryProbe; \ | |
3546 Return ret = NULL;\ | |
3547 DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ | |
3548 \ | |
3549 oop obj= oopFactory::Allocator(len, CHECK_0); \ | |
3550 ret = (Return) JNIHandles::make_local(env, obj); \ | |
3551 return ret;\ | |
3552 JNI_END | |
3553 | |
3554 DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean, | |
3555 HOTSPOT_JNI_NEWBOOLEANARRAY_ENTRY(env, len), | |
3556 HOTSPOT_JNI_NEWBOOLEANARRAY_RETURN(_ret_ref)) | |
3557 DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte, | |
3558 HOTSPOT_JNI_NEWBYTEARRAY_ENTRY(env, len), | |
3559 HOTSPOT_JNI_NEWBYTEARRAY_RETURN(_ret_ref)) | |
3560 DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short, | |
3561 HOTSPOT_JNI_NEWSHORTARRAY_ENTRY(env, len), | |
3562 HOTSPOT_JNI_NEWSHORTARRAY_RETURN(_ret_ref)) | |
3563 DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char, | |
3564 HOTSPOT_JNI_NEWCHARARRAY_ENTRY(env, len), | |
3565 HOTSPOT_JNI_NEWCHARARRAY_RETURN(_ret_ref)) | |
3566 DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int, | |
3567 HOTSPOT_JNI_NEWINTARRAY_ENTRY(env, len), | |
3568 HOTSPOT_JNI_NEWINTARRAY_RETURN(_ret_ref)) | |
3569 DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long, | |
3570 HOTSPOT_JNI_NEWLONGARRAY_ENTRY(env, len), | |
3571 HOTSPOT_JNI_NEWLONGARRAY_RETURN(_ret_ref)) | |
3572 DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float, | |
3573 HOTSPOT_JNI_NEWFLOATARRAY_ENTRY(env, len), | |
3574 HOTSPOT_JNI_NEWFLOATARRAY_RETURN(_ret_ref)) | |
3575 DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double, | |
3576 HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY(env, len), | |
3577 HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN(_ret_ref)) | |
3578 #endif /* USDT2 */ | |
0 | 3579 |
3580 // Return an address which will fault if the caller writes to it. | |
3581 | |
3582 static char* get_bad_address() { | |
3583 static char* bad_address = NULL; | |
3584 if (bad_address == NULL) { | |
3585 size_t size = os::vm_allocation_granularity(); | |
3586 bad_address = os::reserve_memory(size); | |
3587 if (bad_address != NULL) { | |
477
24fda36852ce
6727377: VM stack guard pages on Windows should PAGE_READWRITE not PAGE_EXECUTE_READWRITE
coleenp
parents:
237
diff
changeset
|
3588 os::protect_memory(bad_address, size, os::MEM_PROT_READ, |
24fda36852ce
6727377: VM stack guard pages on Windows should PAGE_READWRITE not PAGE_EXECUTE_READWRITE
coleenp
parents:
237
diff
changeset
|
3589 /*is_committed*/false); |
20360 | 3590 MemTracker::record_virtual_memory_type((void*)bad_address, mtInternal); |
0 | 3591 } |
3592 } | |
3593 return bad_address; | |
3594 } | |
3595 | |
3596 | |
4006 | 3597 #ifndef USDT2 |
0 | 3598 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag) \ |
3599 \ | |
3600 JNI_QUICK_ENTRY(ElementType*, \ | |
3601 jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ | |
3602 JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ | |
3603 DTRACE_PROBE3(hotspot_jni, Get##Result##ArrayElements__entry, env, array, isCopy);\ | |
3604 /* allocate an chunk of memory in c land */ \ | |
3605 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3606 ElementType* result; \ | |
3607 int len = a->length(); \ | |
3608 if (len == 0) { \ | |
3609 /* Empty array: legal but useless, can't return NULL. \ | |
3610 * Return a pointer to something useless. \ | |
3611 * Avoid asserts in typeArrayOop. */ \ | |
3612 result = (ElementType*)get_bad_address(); \ | |
3613 } else { \ | |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3614 /* JNI Specification states return NULL on OOM */ \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3615 result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3616 if (result != NULL) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3617 /* copy the array to the c chunk */ \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3618 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3619 if (isCopy) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3620 *isCopy = JNI_TRUE; \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3621 } \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3622 } \ |
0 | 3623 } \ |
3624 DTRACE_PROBE1(hotspot_jni, Get##Result##ArrayElements__return, result);\ | |
3625 return result; \ | |
3626 JNI_END | |
3627 | |
3628 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | |
3629 DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) | |
3630 DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) | |
3631 DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) | |
3632 DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int) | |
3633 DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long) | |
3634 DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) | |
3635 DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) | |
3636 | |
4006 | 3637 #else /* USDT2 */ |
3638 | |
3639 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag \ | |
3640 , EntryProbe, ReturnProbe) \ | |
3641 \ | |
3642 JNI_QUICK_ENTRY(ElementType*, \ | |
3643 jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ | |
3644 JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ | |
3645 EntryProbe; \ | |
3646 /* allocate an chunk of memory in c land */ \ | |
3647 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3648 ElementType* result; \ | |
3649 int len = a->length(); \ | |
3650 if (len == 0) { \ | |
3651 /* Empty array: legal but useless, can't return NULL. \ | |
3652 * Return a pointer to something useless. \ | |
3653 * Avoid asserts in typeArrayOop. */ \ | |
3654 result = (ElementType*)get_bad_address(); \ | |
3655 } else { \ | |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3656 /* JNI Specification states return NULL on OOM */ \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3657 result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3658 if (result != NULL) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3659 /* copy the array to the c chunk */ \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3660 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3661 if (isCopy) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3662 *isCopy = JNI_TRUE; \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3663 } \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3664 } \ |
4006 | 3665 } \ |
3666 ReturnProbe; \ | |
3667 return result; \ | |
3668 JNI_END | |
3669 | |
3670 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool | |
3671 , HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3672 HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_RETURN((uintptr_t*)result)) | |
3673 DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte | |
3674 , HOTSPOT_JNI_GETBYTEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3675 HOTSPOT_JNI_GETBYTEARRAYELEMENTS_RETURN((char*)result)) | |
3676 DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short | |
3677 , HOTSPOT_JNI_GETSHORTARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy), | |
3678 HOTSPOT_JNI_GETSHORTARRAYELEMENTS_RETURN((uint16_t*)result)) | |
3679 DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char | |
3680 , HOTSPOT_JNI_GETCHARARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy), | |
3681 HOTSPOT_JNI_GETCHARARRAYELEMENTS_RETURN(result)) | |
3682 DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int | |
3683 , HOTSPOT_JNI_GETINTARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3684 HOTSPOT_JNI_GETINTARRAYELEMENTS_RETURN((uint32_t*)result)) | |
3685 DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long | |
3686 , HOTSPOT_JNI_GETLONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3687 HOTSPOT_JNI_GETLONGARRAYELEMENTS_RETURN(((uintptr_t*)result))) | |
3688 // Float and double probes don't return value because dtrace doesn't currently support it | |
3689 DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float | |
3690 , HOTSPOT_JNI_GETFLOATARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3691 HOTSPOT_JNI_GETFLOATARRAYELEMENTS_RETURN(result)) | |
3692 DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double | |
3693 , HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3694 HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN(result)) | |
3695 #endif /* USDT2 */ | |
3696 | |
3697 #ifndef USDT2 | |
0 | 3698 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag) \ |
3699 \ | |
3700 JNI_QUICK_ENTRY(void, \ | |
3701 jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ | |
3702 ElementType *buf, jint mode)) \ | |
3703 JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ | |
3704 DTRACE_PROBE4(hotspot_jni, Release##Result##ArrayElements__entry, env, array, buf, mode);\ | |
3705 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3706 int len = a->length(); \ | |
3707 if (len != 0) { /* Empty array: nothing to free or copy. */ \ | |
3708 if ((mode == 0) || (mode == JNI_COMMIT)) { \ | |
3709 memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ | |
3710 } \ | |
3711 if ((mode == 0) || (mode == JNI_ABORT)) { \ | |
3712 FreeHeap(buf); \ | |
3713 } \ | |
3714 } \ | |
3715 DTRACE_PROBE(hotspot_jni, Release##Result##ArrayElements__return);\ | |
3716 JNI_END | |
3717 | |
3718 DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | |
3719 DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) | |
3720 DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) | |
3721 DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) | |
3722 DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int) | |
3723 DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long) | |
3724 DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) | |
3725 DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) | |
3726 | |
4006 | 3727 #else /* USDT2 */ |
3728 | |
3729 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag \ | |
3730 , EntryProbe, ReturnProbe);\ | |
3731 \ | |
3732 JNI_QUICK_ENTRY(void, \ | |
3733 jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ | |
3734 ElementType *buf, jint mode)) \ | |
3735 JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ | |
3736 EntryProbe; \ | |
3737 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3738 int len = a->length(); \ | |
3739 if (len != 0) { /* Empty array: nothing to free or copy. */ \ | |
3740 if ((mode == 0) || (mode == JNI_COMMIT)) { \ | |
3741 memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ | |
3742 } \ | |
3743 if ((mode == 0) || (mode == JNI_ABORT)) { \ | |
3744 FreeHeap(buf); \ | |
3745 } \ | |
3746 } \ | |
3747 ReturnProbe; \ | |
3748 JNI_END | |
3749 | |
3750 DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool | |
3751 , HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode), | |
3752 HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_RETURN()) | |
3753 DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte | |
3754 , HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_ENTRY(env, array, (char *) buf, mode), | |
3755 HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_RETURN()) | |
3756 DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short | |
3757 , HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode), | |
3758 HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_RETURN()) | |
3759 DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char | |
3760 , HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode), | |
3761 HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_RETURN()) | |
3762 DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int | |
3763 , HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_ENTRY(env, array, (uint32_t *) buf, mode), | |
3764 HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_RETURN()) | |
3765 DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long | |
3766 , HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode), | |
3767 HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_RETURN()) | |
3768 DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float | |
3769 , HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_ENTRY(env, array, (float *) buf, mode), | |
3770 HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_RETURN()) | |
3771 DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double | |
3772 , HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY(env, array, (double *) buf, mode), | |
3773 HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN()) | |
3774 #endif /* USDT2 */ | |
3775 | |
3776 #ifndef USDT2 | |
0 | 3777 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ |
3778 DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion);\ | |
3779 \ | |
3780 JNI_ENTRY(void, \ | |
3781 jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3782 jsize len, ElementType *buf)) \ | |
3783 JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ | |
3784 DTRACE_PROBE5(hotspot_jni, Get##Result##ArrayRegion__entry, env, array, start, len, buf);\ | |
3785 DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ | |
3786 typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3787 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ | |
3788 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3789 } else { \ | |
3790 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3791 int sc = TypeArrayKlass::cast(src->klass())->log2_element_size(); \ |
0 | 3792 memcpy((u_char*) buf, \ |
3793 (u_char*) src->Tag##_at_addr(start), \ | |
3794 len << sc); \ | |
3795 } \ | |
3796 } \ | |
3797 JNI_END | |
3798 | |
3799 DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool) | |
3800 DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) | |
3801 DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short) | |
3802 DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char) | |
3803 DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int) | |
3804 DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long) | |
3805 DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) | |
3806 DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) | |
3807 | |
4006 | 3808 #else /* USDT2 */ |
3809 | |
3810 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ | |
3811 , EntryProbe, ReturnProbe); \ | |
3812 DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion \ | |
3813 , ReturnProbe); \ | |
3814 \ | |
3815 JNI_ENTRY(void, \ | |
3816 jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3817 jsize len, ElementType *buf)) \ | |
3818 JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ | |
3819 EntryProbe; \ | |
3820 DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ | |
3821 typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3822 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ | |
3823 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3824 } else { \ | |
3825 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3826 int sc = TypeArrayKlass::cast(src->klass())->log2_element_size(); \ |
4006 | 3827 memcpy((u_char*) buf, \ |
3828 (u_char*) src->Tag##_at_addr(start), \ | |
3829 len << sc); \ | |
3830 } \ | |
3831 } \ | |
3832 JNI_END | |
3833 | |
3834 DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool | |
3835 , HOTSPOT_JNI_GETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), | |
3836 HOTSPOT_JNI_GETBOOLEANARRAYREGION_RETURN()); | |
3837 DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte | |
3838 , HOTSPOT_JNI_GETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf), | |
3839 HOTSPOT_JNI_GETBYTEARRAYREGION_RETURN()); | |
3840 DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short | |
3841 , HOTSPOT_JNI_GETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), | |
3842 HOTSPOT_JNI_GETSHORTARRAYREGION_RETURN()); | |
3843 DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char | |
3844 , HOTSPOT_JNI_GETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t*) buf), | |
3845 HOTSPOT_JNI_GETCHARARRAYREGION_RETURN()); | |
3846 DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int | |
3847 , HOTSPOT_JNI_GETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t*) buf), | |
3848 HOTSPOT_JNI_GETINTARRAYREGION_RETURN()); | |
3849 DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long | |
3850 , HOTSPOT_JNI_GETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), | |
3851 HOTSPOT_JNI_GETLONGARRAYREGION_RETURN()); | |
3852 DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float | |
3853 , HOTSPOT_JNI_GETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf), | |
3854 HOTSPOT_JNI_GETFLOATARRAYREGION_RETURN()); | |
3855 DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double | |
3856 , HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), | |
3857 HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN()); | |
3858 #endif /* USDT2 */ | |
3859 | |
3860 #ifndef USDT2 | |
0 | 3861 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ |
3862 DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion);\ | |
3863 \ | |
3864 JNI_ENTRY(void, \ | |
3865 jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3866 jsize len, const ElementType *buf)) \ | |
3867 JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ | |
3868 DTRACE_PROBE5(hotspot_jni, Set##Result##ArrayRegion__entry, env, array, start, len, buf);\ | |
3869 DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ | |
3870 typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3871 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ | |
3872 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3873 } else { \ | |
3874 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3875 int sc = TypeArrayKlass::cast(dst->klass())->log2_element_size(); \ |
0 | 3876 memcpy((u_char*) dst->Tag##_at_addr(start), \ |
3877 (u_char*) buf, \ | |
3878 len << sc); \ | |
3879 } \ | |
3880 } \ | |
3881 JNI_END | |
3882 | |
3883 DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool) | |
3884 DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) | |
3885 DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short) | |
3886 DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char) | |
3887 DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int) | |
3888 DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long) | |
3889 DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) | |
3890 DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) | |
3891 | |
4006 | 3892 #else /* USDT2 */ |
3893 | |
3894 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ | |
3895 , EntryProbe, ReturnProbe); \ | |
3896 DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion \ | |
3897 ,ReturnProbe); \ | |
3898 \ | |
3899 JNI_ENTRY(void, \ | |
3900 jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3901 jsize len, const ElementType *buf)) \ | |
3902 JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ | |
3903 EntryProbe; \ | |
3904 DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ | |
3905 typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3906 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ | |
3907 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3908 } else { \ | |
3909 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3910 int sc = TypeArrayKlass::cast(dst->klass())->log2_element_size(); \ |
4006 | 3911 memcpy((u_char*) dst->Tag##_at_addr(start), \ |
3912 (u_char*) buf, \ | |
3913 len << sc); \ | |
3914 } \ | |
3915 } \ | |
3916 JNI_END | |
3917 | |
3918 DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool | |
3919 , HOTSPOT_JNI_SETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *)buf), | |
3920 HOTSPOT_JNI_SETBOOLEANARRAYREGION_RETURN()) | |
3921 DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte | |
3922 , HOTSPOT_JNI_SETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf), | |
3923 HOTSPOT_JNI_SETBYTEARRAYREGION_RETURN()) | |
3924 DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short | |
3925 , HOTSPOT_JNI_SETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), | |
3926 HOTSPOT_JNI_SETSHORTARRAYREGION_RETURN()) | |
3927 DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char | |
3928 , HOTSPOT_JNI_SETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), | |
3929 HOTSPOT_JNI_SETCHARARRAYREGION_RETURN()) | |
3930 DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int | |
3931 , HOTSPOT_JNI_SETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t *) buf), | |
3932 HOTSPOT_JNI_SETINTARRAYREGION_RETURN()) | |
3933 DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long | |
3934 , HOTSPOT_JNI_SETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), | |
3935 HOTSPOT_JNI_SETLONGARRAYREGION_RETURN()) | |
3936 DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float | |
3937 , HOTSPOT_JNI_SETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf), | |
3938 HOTSPOT_JNI_SETFLOATARRAYREGION_RETURN()) | |
3939 DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double | |
3940 , HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), | |
3941 HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN()) | |
3942 #endif /* USDT2 */ | |
3943 | |
0 | 3944 |
3945 // | |
3946 // Interception of natives | |
3947 // | |
3948 | |
3949 // The RegisterNatives call being attempted tried to register with a method that | |
3950 // is not native. Ask JVM TI what prefixes have been specified. Then check | |
3951 // to see if the native method is now wrapped with the prefixes. See the | |
3952 // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
3953 static Method* find_prefixed_native(KlassHandle k, |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
3954 Symbol* name, Symbol* signature, TRAPS) { |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
3955 #if INCLUDE_JVMTI |
0 | 3956 ResourceMark rm(THREAD); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
3957 Method* method; |
0 | 3958 int name_len = name->utf8_length(); |
3959 char* name_str = name->as_utf8(); | |
3960 int prefix_count; | |
3961 char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count); | |
3962 for (int i = 0; i < prefix_count; i++) { | |
3963 char* prefix = prefixes[i]; | |
3964 int prefix_len = (int)strlen(prefix); | |
3965 | |
3966 // try adding this prefix to the method name and see if it matches another method name | |
3967 int trial_len = name_len + prefix_len; | |
3968 char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1); | |
3969 strcpy(trial_name_str, prefix); | |
3970 strcat(trial_name_str, name_str); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
3971 TempNewSymbol trial_name = SymbolTable::probe(trial_name_str, trial_len); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
3972 if (trial_name == NULL) { |
0 | 3973 continue; // no such symbol, so this prefix wasn't used, try the next prefix |
3974 } | |
6983 | 3975 method = k()->lookup_method(trial_name, signature); |
0 | 3976 if (method == NULL) { |
3977 continue; // signature doesn't match, try the next prefix | |
3978 } | |
3979 if (method->is_native()) { | |
3980 method->set_is_prefixed_native(); | |
3981 return method; // wahoo, we found a prefixed version of the method, return it | |
3982 } | |
3983 // found as non-native, so prefix is good, add it, probably just need more prefixes | |
3984 name_len = trial_len; | |
3985 name_str = trial_name_str; | |
3986 } | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
3987 #endif // INCLUDE_JVMTI |
0 | 3988 return NULL; // not found |
3989 } | |
3990 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
3991 static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { |
6983 | 3992 Method* method = k()->lookup_method(name, signature); |
0 | 3993 if (method == NULL) { |
3994 ResourceMark rm; | |
3995 stringStream st; | |
3996 st.print("Method %s name or signature does not match", | |
6983 | 3997 Method::name_and_sig_as_C_string(k(), name, signature)); |
0 | 3998 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
3999 } | |
4000 if (!method->is_native()) { | |
4001 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) | |
4002 method = find_prefixed_native(k, name, signature, THREAD); | |
4003 if (method == NULL) { | |
4004 ResourceMark rm; | |
4005 stringStream st; | |
4006 st.print("Method %s is not declared as native", | |
6983 | 4007 Method::name_and_sig_as_C_string(k(), name, signature)); |
0 | 4008 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
4009 } | |
4010 } | |
4011 | |
4012 if (entry != NULL) { | |
4013 method->set_native_function(entry, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4014 Method::native_bind_event_is_interesting); |
0 | 4015 } else { |
4016 method->clear_native_function(); | |
4017 } | |
4018 if (PrintJNIResolving) { | |
4019 ResourceMark rm(THREAD); | |
4020 tty->print_cr("[Registering JNI native method %s.%s]", | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6856
diff
changeset
|
4021 method->method_holder()->external_name(), |
0 | 4022 method->name()->as_C_string()); |
4023 } | |
4024 return true; | |
4025 } | |
4026 | |
4006 | 4027 #ifndef USDT2 |
0 | 4028 DT_RETURN_MARK_DECL(RegisterNatives, jint); |
4006 | 4029 #else /* USDT2 */ |
4030 DT_RETURN_MARK_DECL(RegisterNatives, jint | |
4031 , HOTSPOT_JNI_REGISTERNATIVES_RETURN(_ret_ref)); | |
4032 #endif /* USDT2 */ | |
0 | 4033 |
4034 JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, | |
4035 const JNINativeMethod *methods, | |
4036 jint nMethods)) | |
4037 JNIWrapper("RegisterNatives"); | |
4006 | 4038 #ifndef USDT2 |
0 | 4039 DTRACE_PROBE4(hotspot_jni, RegisterNatives__entry, env, clazz, methods, nMethods); |
4006 | 4040 #else /* USDT2 */ |
4041 HOTSPOT_JNI_REGISTERNATIVES_ENTRY( | |
4042 env, clazz, (void *) methods, nMethods); | |
4043 #endif /* USDT2 */ | |
0 | 4044 jint ret = 0; |
4045 DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); | |
4046 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4047 KlassHandle h_k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 4048 |
4049 for (int index = 0; index < nMethods; index++) { | |
4050 const char* meth_name = methods[index].name; | |
4051 const char* meth_sig = methods[index].signature; | |
4052 int meth_name_len = (int)strlen(meth_name); | |
4053 | |
4054 // The class should have been loaded (we have an instance of the class | |
4055 // passed in) so the method and signature should already be in the symbol | |
4056 // table. If they're not there, the method doesn't exist. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4057 TempNewSymbol name = SymbolTable::probe(meth_name, meth_name_len); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4058 TempNewSymbol signature = SymbolTable::probe(meth_sig, (int)strlen(meth_sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4059 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4060 if (name == NULL || signature == NULL) { |
0 | 4061 ResourceMark rm; |
4062 stringStream st; | |
6983 | 4063 st.print("Method %s.%s%s not found", h_k()->external_name(), meth_name, meth_sig); |
0 | 4064 // Must return negative value on failure |
4065 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); | |
4066 } | |
4067 | |
4068 bool res = register_native(h_k, name, signature, | |
4069 (address) methods[index].fnPtr, THREAD); | |
4070 if (!res) { | |
4071 ret = -1; | |
4072 break; | |
4073 } | |
4074 } | |
4075 return ret; | |
4076 JNI_END | |
4077 | |
4078 | |
4079 JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) | |
4080 JNIWrapper("UnregisterNatives"); | |
4006 | 4081 #ifndef USDT2 |
0 | 4082 DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); |
4006 | 4083 #else /* USDT2 */ |
4084 HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY( | |
4085 env, clazz); | |
4086 #endif /* USDT2 */ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4087 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); |
0 | 4088 //%note jni_2 |
6983 | 4089 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4090 for (int index = 0; index < InstanceKlass::cast(k)->methods()->length(); index++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4091 Method* m = InstanceKlass::cast(k)->methods()->at(index); |
0 | 4092 if (m->is_native()) { |
4093 m->clear_native_function(); | |
4094 m->set_signature_handler(NULL); | |
4095 } | |
4096 } | |
4097 } | |
4006 | 4098 #ifndef USDT2 |
0 | 4099 DTRACE_PROBE1(hotspot_jni, UnregisterNatives__return, 0); |
4006 | 4100 #else /* USDT2 */ |
4101 HOTSPOT_JNI_UNREGISTERNATIVES_RETURN( | |
4102 0); | |
4103 #endif /* USDT2 */ | |
0 | 4104 return 0; |
4105 JNI_END | |
4106 | |
4107 // | |
4108 // Monitor functions | |
4109 // | |
4110 | |
4006 | 4111 #ifndef USDT2 |
0 | 4112 DT_RETURN_MARK_DECL(MonitorEnter, jint); |
4006 | 4113 #else /* USDT2 */ |
4114 DT_RETURN_MARK_DECL(MonitorEnter, jint | |
4115 , HOTSPOT_JNI_MONITORENTER_RETURN(_ret_ref)); | |
4116 #endif /* USDT2 */ | |
0 | 4117 |
4118 JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) | |
4006 | 4119 #ifndef USDT2 |
0 | 4120 DTRACE_PROBE2(hotspot_jni, MonitorEnter__entry, env, jobj); |
4006 | 4121 #else /* USDT2 */ |
4122 HOTSPOT_JNI_MONITORENTER_ENTRY( | |
4123 env, jobj); | |
4124 #endif /* USDT2 */ | |
0 | 4125 jint ret = JNI_ERR; |
4126 DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret); | |
4127 | |
4128 // If the object is null, we can't do anything with it | |
4129 if (jobj == NULL) { | |
4130 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); | |
4131 } | |
4132 | |
4133 Handle obj(thread, JNIHandles::resolve_non_null(jobj)); | |
4134 ObjectSynchronizer::jni_enter(obj, CHECK_(JNI_ERR)); | |
4135 ret = JNI_OK; | |
4136 return ret; | |
4137 JNI_END | |
4138 | |
4006 | 4139 #ifndef USDT2 |
0 | 4140 DT_RETURN_MARK_DECL(MonitorExit, jint); |
4006 | 4141 #else /* USDT2 */ |
4142 DT_RETURN_MARK_DECL(MonitorExit, jint | |
4143 , HOTSPOT_JNI_MONITOREXIT_RETURN(_ret_ref)); | |
4144 #endif /* USDT2 */ | |
0 | 4145 |
4146 JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj)) | |
4006 | 4147 #ifndef USDT2 |
0 | 4148 DTRACE_PROBE2(hotspot_jni, MonitorExit__entry, env, jobj); |
4006 | 4149 #else /* USDT2 */ |
4150 HOTSPOT_JNI_MONITOREXIT_ENTRY( | |
4151 env, jobj); | |
4152 #endif /* USDT2 */ | |
0 | 4153 jint ret = JNI_ERR; |
4154 DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret); | |
4155 | |
4156 // Don't do anything with a null object | |
4157 if (jobj == NULL) { | |
4158 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); | |
4159 } | |
4160 | |
4161 Handle obj(THREAD, JNIHandles::resolve_non_null(jobj)); | |
4162 ObjectSynchronizer::jni_exit(obj(), CHECK_(JNI_ERR)); | |
4163 | |
4164 ret = JNI_OK; | |
4165 return ret; | |
4166 JNI_END | |
4167 | |
4168 // | |
4169 // Extensions | |
4170 // | |
4171 | |
4006 | 4172 #ifndef USDT2 |
0 | 4173 DT_VOID_RETURN_MARK_DECL(GetStringRegion); |
4006 | 4174 #else /* USDT2 */ |
4175 DT_VOID_RETURN_MARK_DECL(GetStringRegion | |
4176 , HOTSPOT_JNI_GETSTRINGREGION_RETURN()); | |
4177 #endif /* USDT2 */ | |
0 | 4178 |
4179 JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, jsize len, jchar *buf)) | |
4180 JNIWrapper("GetStringRegion"); | |
4006 | 4181 #ifndef USDT2 |
0 | 4182 DTRACE_PROBE5(hotspot_jni, GetStringRegion__entry, env, string, start, len, buf); |
4006 | 4183 #else /* USDT2 */ |
4184 HOTSPOT_JNI_GETSTRINGREGION_ENTRY( | |
4185 env, string, start, len, buf); | |
4186 #endif /* USDT2 */ | |
0 | 4187 DT_VOID_RETURN_MARK(GetStringRegion); |
4188 oop s = JNIHandles::resolve_non_null(string); | |
4189 int s_len = java_lang_String::length(s); | |
4190 if (start < 0 || len < 0 || start + len > s_len) { | |
4191 THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException()); | |
4192 } else { | |
4193 if (len > 0) { | |
4194 int s_offset = java_lang_String::offset(s); | |
4195 typeArrayOop s_value = java_lang_String::value(s); | |
4196 memcpy(buf, s_value->char_at_addr(s_offset+start), sizeof(jchar)*len); | |
4197 } | |
4198 } | |
4199 JNI_END | |
4200 | |
4006 | 4201 #ifndef USDT2 |
0 | 4202 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion); |
4006 | 4203 #else /* USDT2 */ |
4204 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion | |
4205 , HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN()); | |
4206 #endif /* USDT2 */ | |
0 | 4207 |
4208 JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, jsize len, char *buf)) | |
4209 JNIWrapper("GetStringUTFRegion"); | |
4006 | 4210 #ifndef USDT2 |
0 | 4211 DTRACE_PROBE5(hotspot_jni, GetStringUTFRegion__entry, env, string, start, len, buf); |
4006 | 4212 #else /* USDT2 */ |
4213 HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY( | |
4214 env, string, start, len, buf); | |
4215 #endif /* USDT2 */ | |
0 | 4216 DT_VOID_RETURN_MARK(GetStringUTFRegion); |
4217 oop s = JNIHandles::resolve_non_null(string); | |
4218 int s_len = java_lang_String::length(s); | |
4219 if (start < 0 || len < 0 || start + len > s_len) { | |
4220 THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException()); | |
4221 } else { | |
4222 //%note jni_7 | |
4223 if (len > 0) { | |
4224 ResourceMark rm(THREAD); | |
4225 char *utf_region = java_lang_String::as_utf8_string(s, start, len); | |
4226 int utf_len = (int)strlen(utf_region); | |
4227 memcpy(buf, utf_region, utf_len); | |
4228 buf[utf_len] = 0; | |
4229 } else { | |
4230 // JDK null-terminates the buffer even in len is zero | |
4231 if (buf != NULL) { | |
4232 buf[0] = 0; | |
4233 } | |
4234 } | |
4235 } | |
4236 JNI_END | |
4237 | |
4238 | |
4239 JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)) | |
4240 JNIWrapper("GetPrimitiveArrayCritical"); | |
4006 | 4241 #ifndef USDT2 |
0 | 4242 DTRACE_PROBE3(hotspot_jni, GetPrimitiveArrayCritical__entry, env, array, isCopy); |
4006 | 4243 #else /* USDT2 */ |
4244 HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY( | |
4245 env, array, (uintptr_t *) isCopy); | |
4246 #endif /* USDT2 */ | |
0 | 4247 GC_locker::lock_critical(thread); |
4248 if (isCopy != NULL) { | |
4249 *isCopy = JNI_FALSE; | |
4250 } | |
4251 oop a = JNIHandles::resolve_non_null(array); | |
4252 assert(a->is_array(), "just checking"); | |
4253 BasicType type; | |
4254 if (a->is_objArray()) { | |
4255 type = T_OBJECT; | |
4256 } else { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
4257 type = TypeArrayKlass::cast(a->klass())->element_type(); |
0 | 4258 } |
4259 void* ret = arrayOop(a)->base(type); | |
4006 | 4260 #ifndef USDT2 |
0 | 4261 DTRACE_PROBE1(hotspot_jni, GetPrimitiveArrayCritical__return, ret); |
4006 | 4262 #else /* USDT2 */ |
4263 HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN( | |
4264 ret); | |
4265 #endif /* USDT2 */ | |
0 | 4266 return ret; |
4267 JNI_END | |
4268 | |
4269 | |
4270 JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)) | |
4271 JNIWrapper("ReleasePrimitiveArrayCritical"); | |
4006 | 4272 #ifndef USDT2 |
0 | 4273 DTRACE_PROBE4(hotspot_jni, ReleasePrimitiveArrayCritical__entry, env, array, carray, mode); |
4006 | 4274 #else /* USDT2 */ |
4275 HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY( | |
4276 env, array, carray, mode); | |
4277 #endif /* USDT2 */ | |
0 | 4278 // The array, carray and mode arguments are ignored |
4279 GC_locker::unlock_critical(thread); | |
4006 | 4280 #ifndef USDT2 |
0 | 4281 DTRACE_PROBE(hotspot_jni, ReleasePrimitiveArrayCritical__return); |
4006 | 4282 #else /* USDT2 */ |
4283 HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN( | |
4284 ); | |
4285 #endif /* USDT2 */ | |
0 | 4286 JNI_END |
4287 | |
4288 | |
4289 JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy)) | |
4290 JNIWrapper("GetStringCritical"); | |
4006 | 4291 #ifndef USDT2 |
0 | 4292 DTRACE_PROBE3(hotspot_jni, GetStringCritical__entry, env, string, isCopy); |
4006 | 4293 #else /* USDT2 */ |
4294 HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY( | |
4295 env, string, (uintptr_t *) isCopy); | |
4296 #endif /* USDT2 */ | |
0 | 4297 GC_locker::lock_critical(thread); |
4298 if (isCopy != NULL) { | |
4299 *isCopy = JNI_FALSE; | |
4300 } | |
4301 oop s = JNIHandles::resolve_non_null(string); | |
4302 int s_len = java_lang_String::length(s); | |
4303 typeArrayOop s_value = java_lang_String::value(s); | |
4304 int s_offset = java_lang_String::offset(s); | |
4305 const jchar* ret; | |
4306 if (s_len > 0) { | |
4307 ret = s_value->char_at_addr(s_offset); | |
4308 } else { | |
4309 ret = (jchar*) s_value->base(T_CHAR); | |
4310 } | |
4006 | 4311 #ifndef USDT2 |
0 | 4312 DTRACE_PROBE1(hotspot_jni, GetStringCritical__return, ret); |
4006 | 4313 #else /* USDT2 */ |
4314 HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN( | |
4315 (uint16_t *) ret); | |
4316 #endif /* USDT2 */ | |
0 | 4317 return ret; |
4318 JNI_END | |
4319 | |
4320 | |
4321 JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars)) | |
4322 JNIWrapper("ReleaseStringCritical"); | |
4006 | 4323 #ifndef USDT2 |
0 | 4324 DTRACE_PROBE3(hotspot_jni, ReleaseStringCritical__entry, env, str, chars); |
4006 | 4325 #else /* USDT2 */ |
4326 HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY( | |
4327 env, str, (uint16_t *) chars); | |
4328 #endif /* USDT2 */ | |
0 | 4329 // The str and chars arguments are ignored |
4330 GC_locker::unlock_critical(thread); | |
4006 | 4331 #ifndef USDT2 |
0 | 4332 DTRACE_PROBE(hotspot_jni, ReleaseStringCritical__return); |
4006 | 4333 #else /* USDT2 */ |
4334 HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN( | |
4335 ); | |
4336 #endif /* USDT2 */ | |
0 | 4337 JNI_END |
4338 | |
4339 | |
4340 JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) | |
4341 JNIWrapper("jni_NewWeakGlobalRef"); | |
4006 | 4342 #ifndef USDT2 |
0 | 4343 DTRACE_PROBE2(hotspot_jni, NewWeakGlobalRef__entry, env, ref); |
4006 | 4344 #else /* USDT2 */ |
4345 HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY( | |
4346 env, ref); | |
4347 #endif /* USDT2 */ | |
0 | 4348 Handle ref_handle(thread, JNIHandles::resolve(ref)); |
4349 jweak ret = JNIHandles::make_weak_global(ref_handle); | |
4006 | 4350 #ifndef USDT2 |
0 | 4351 DTRACE_PROBE1(hotspot_jni, NewWeakGlobalRef__return, ret); |
4006 | 4352 #else /* USDT2 */ |
4353 HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN( | |
4354 ret); | |
4355 #endif /* USDT2 */ | |
0 | 4356 return ret; |
4357 JNI_END | |
4358 | |
4359 // Must be JNI_ENTRY (with HandleMark) | |
4360 JNI_ENTRY(void, jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref)) | |
4361 JNIWrapper("jni_DeleteWeakGlobalRef"); | |
4006 | 4362 #ifndef USDT2 |
0 | 4363 DTRACE_PROBE2(hotspot_jni, DeleteWeakGlobalRef__entry, env, ref); |
4006 | 4364 #else /* USDT2 */ |
4365 HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY( | |
4366 env, ref); | |
4367 #endif /* USDT2 */ | |
0 | 4368 JNIHandles::destroy_weak_global(ref); |
4006 | 4369 #ifndef USDT2 |
0 | 4370 DTRACE_PROBE(hotspot_jni, DeleteWeakGlobalRef__return); |
4006 | 4371 #else /* USDT2 */ |
4372 HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN( | |
4373 ); | |
4374 #endif /* USDT2 */ | |
0 | 4375 JNI_END |
4376 | |
4377 | |
4378 JNI_QUICK_ENTRY(jboolean, jni_ExceptionCheck(JNIEnv *env)) | |
4379 JNIWrapper("jni_ExceptionCheck"); | |
4006 | 4380 #ifndef USDT2 |
0 | 4381 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__entry, env); |
4006 | 4382 #else /* USDT2 */ |
4383 HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY( | |
4384 env); | |
4385 #endif /* USDT2 */ | |
0 | 4386 jni_check_async_exceptions(thread); |
4387 jboolean ret = (thread->has_pending_exception()) ? JNI_TRUE : JNI_FALSE; | |
4006 | 4388 #ifndef USDT2 |
0 | 4389 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__return, ret); |
4006 | 4390 #else /* USDT2 */ |
4391 HOTSPOT_JNI_EXCEPTIONCHECK_RETURN( | |
4392 ret); | |
4393 #endif /* USDT2 */ | |
0 | 4394 return ret; |
4395 JNI_END | |
4396 | |
4397 | |
4398 // Initialization state for three routines below relating to | |
4399 // java.nio.DirectBuffers | |
4400 static jint directBufferSupportInitializeStarted = 0; | |
4401 static volatile jint directBufferSupportInitializeEnded = 0; | |
4402 static volatile jint directBufferSupportInitializeFailed = 0; | |
4403 static jclass bufferClass = NULL; | |
4404 static jclass directBufferClass = NULL; | |
4405 static jclass directByteBufferClass = NULL; | |
4406 static jmethodID directByteBufferConstructor = NULL; | |
4407 static jfieldID directBufferAddressField = NULL; | |
4408 static jfieldID bufferCapacityField = NULL; | |
4409 | |
4410 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { | |
4411 Handle loader; // null (bootstrap) loader | |
4412 Handle protection_domain; // null protection domain | |
4413 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4414 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4415 jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4416 |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4417 if (TraceClassResolution && result != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4418 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4419 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4420 return result; |
0 | 4421 } |
4422 | |
4423 // These lookups are done with the NULL (bootstrap) ClassLoader to | |
4424 // circumvent any security checks that would be done by jni_FindClass. | |
4425 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env)) | |
4426 { | |
4427 if ((bufferClass = lookupOne(env, "java/nio/Buffer", thread)) == NULL) { return false; } | |
4428 if ((directBufferClass = lookupOne(env, "sun/nio/ch/DirectBuffer", thread)) == NULL) { return false; } | |
4429 if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; } | |
4430 return true; | |
4431 } | |
4432 JNI_END | |
4433 | |
4434 | |
4435 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { | |
4436 if (directBufferSupportInitializeFailed) { | |
4437 return false; | |
4438 } | |
4439 | |
4440 if (Atomic::cmpxchg(1, &directBufferSupportInitializeStarted, 0) == 0) { | |
4441 if (!lookupDirectBufferClasses(env)) { | |
4442 directBufferSupportInitializeFailed = 1; | |
4443 return false; | |
4444 } | |
4445 | |
4446 // Make global references for these | |
4447 bufferClass = (jclass) env->NewGlobalRef(bufferClass); | |
4448 directBufferClass = (jclass) env->NewGlobalRef(directBufferClass); | |
4449 directByteBufferClass = (jclass) env->NewGlobalRef(directByteBufferClass); | |
4450 | |
4451 // Get needed field and method IDs | |
4452 directByteBufferConstructor = env->GetMethodID(directByteBufferClass, "<init>", "(JI)V"); | |
17704
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4453 if (env->ExceptionCheck()) { |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4454 env->ExceptionClear(); |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4455 directBufferSupportInitializeFailed = 1; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4456 return false; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4457 } |
0 | 4458 directBufferAddressField = env->GetFieldID(bufferClass, "address", "J"); |
17704
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4459 if (env->ExceptionCheck()) { |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4460 env->ExceptionClear(); |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4461 directBufferSupportInitializeFailed = 1; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4462 return false; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4463 } |
0 | 4464 bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I"); |
17704
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4465 if (env->ExceptionCheck()) { |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4466 env->ExceptionClear(); |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4467 directBufferSupportInitializeFailed = 1; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4468 return false; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4469 } |
0 | 4470 |
4471 if ((directByteBufferConstructor == NULL) || | |
4472 (directBufferAddressField == NULL) || | |
4473 (bufferCapacityField == NULL)) { | |
4474 directBufferSupportInitializeFailed = 1; | |
4475 return false; | |
4476 } | |
4477 | |
4478 directBufferSupportInitializeEnded = 1; | |
4479 } else { | |
4480 while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) { | |
521
4db4e58c16bd
6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support
xlu
parents:
477
diff
changeset
|
4481 // Set state as yield_all can call os:sleep. On Solaris, yield_all calls |
4db4e58c16bd
6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support
xlu
parents:
477
diff
changeset
|
4482 // os::sleep which requires the VM state transition. On other platforms, it |
4db4e58c16bd
6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support
xlu
parents:
477
diff
changeset
|
4483 // is not necessary. The following call to change the VM state is purposely |
4db4e58c16bd
6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support
xlu
parents:
477
diff
changeset
|
4484 // put inside the loop to avoid potential deadlock when multiple threads |
4db4e58c16bd
6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support
xlu
parents:
477
diff
changeset
|
4485 // try to call this method. See 6791815 for more details. |
4db4e58c16bd
6791815: Fix for 6471657 can cause deadlock on non-Solaris platforms when initializing direct buffer support
xlu
parents:
477
diff
changeset
|
4486 ThreadInVMfromNative tivn(thread); |
0 | 4487 os::yield_all(); |
4488 } | |
4489 } | |
4490 | |
4491 return !directBufferSupportInitializeFailed; | |
4492 } | |
4493 | |
4494 extern "C" jobject JNICALL jni_NewDirectByteBuffer(JNIEnv *env, void* address, jlong capacity) | |
4495 { | |
4496 // thread_from_jni_environment() will block if VM is gone. | |
4497 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
4498 | |
4499 JNIWrapper("jni_NewDirectByteBuffer"); | |
4006 | 4500 #ifndef USDT2 |
0 | 4501 DTRACE_PROBE3(hotspot_jni, NewDirectByteBuffer__entry, env, address, capacity); |
4006 | 4502 #else /* USDT2 */ |
4503 HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY( | |
4504 env, address, capacity); | |
4505 #endif /* USDT2 */ | |
0 | 4506 |
4507 if (!directBufferSupportInitializeEnded) { | |
4508 if (!initializeDirectBufferSupport(env, thread)) { | |
4006 | 4509 #ifndef USDT2 |
0 | 4510 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, NULL); |
4006 | 4511 #else /* USDT2 */ |
4512 HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN( | |
4513 NULL); | |
4514 #endif /* USDT2 */ | |
0 | 4515 return NULL; |
4516 } | |
4517 } | |
4518 | |
4519 // Being paranoid about accidental sign extension on address | |
4520 jlong addr = (jlong) ((uintptr_t) address); | |
4521 // NOTE that package-private DirectByteBuffer constructor currently | |
4522 // takes int capacity | |
4523 jint cap = (jint) capacity; | |
4524 jobject ret = env->NewObject(directByteBufferClass, directByteBufferConstructor, addr, cap); | |
4006 | 4525 #ifndef USDT2 |
0 | 4526 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, ret); |
4006 | 4527 #else /* USDT2 */ |
4528 HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN( | |
4529 ret); | |
4530 #endif /* USDT2 */ | |
0 | 4531 return ret; |
4532 } | |
4533 | |
4006 | 4534 #ifndef USDT2 |
0 | 4535 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*); |
4006 | 4536 #else /* USDT2 */ |
4537 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void* | |
4538 , HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN((void*) _ret_ref)); | |
4539 #endif /* USDT2 */ | |
0 | 4540 |
4541 extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) | |
4542 { | |
4543 // thread_from_jni_environment() will block if VM is gone. | |
4544 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
4545 | |
4546 JNIWrapper("jni_GetDirectBufferAddress"); | |
4006 | 4547 #ifndef USDT2 |
0 | 4548 DTRACE_PROBE2(hotspot_jni, GetDirectBufferAddress__entry, env, buf); |
4006 | 4549 #else /* USDT2 */ |
4550 HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY( | |
4551 env, buf); | |
4552 #endif /* USDT2 */ | |
0 | 4553 void* ret = NULL; |
4554 DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret); | |
4555 | |
4556 if (!directBufferSupportInitializeEnded) { | |
4557 if (!initializeDirectBufferSupport(env, thread)) { | |
4558 return 0; | |
4559 } | |
4560 } | |
4561 | |
4562 if ((buf != NULL) && (!env->IsInstanceOf(buf, directBufferClass))) { | |
4563 return 0; | |
4564 } | |
4565 | |
4566 ret = (void*)(intptr_t)env->GetLongField(buf, directBufferAddressField); | |
4567 return ret; | |
4568 } | |
4569 | |
4006 | 4570 #ifndef USDT2 |
0 | 4571 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong); |
4006 | 4572 #else /* USDT2 */ |
4573 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong | |
4574 , HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN(_ret_ref)); | |
4575 #endif /* USDT2 */ | |
0 | 4576 |
4577 extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) | |
4578 { | |
4579 // thread_from_jni_environment() will block if VM is gone. | |
4580 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
4581 | |
4582 JNIWrapper("jni_GetDirectBufferCapacity"); | |
4006 | 4583 #ifndef USDT2 |
0 | 4584 DTRACE_PROBE2(hotspot_jni, GetDirectBufferCapacity__entry, env, buf); |
4006 | 4585 #else /* USDT2 */ |
4586 HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY( | |
4587 env, buf); | |
4588 #endif /* USDT2 */ | |
0 | 4589 jlong ret = -1; |
4590 DT_RETURN_MARK(GetDirectBufferCapacity, jlong, (const jlong&)ret); | |
4591 | |
4592 if (!directBufferSupportInitializeEnded) { | |
4593 if (!initializeDirectBufferSupport(env, thread)) { | |
4594 ret = 0; | |
4595 return ret; | |
4596 } | |
4597 } | |
4598 | |
4599 if (buf == NULL) { | |
4600 return -1; | |
4601 } | |
4602 | |
4603 if (!env->IsInstanceOf(buf, directBufferClass)) { | |
4604 return -1; | |
4605 } | |
4606 | |
4607 // NOTE that capacity is currently an int in the implementation | |
4608 ret = env->GetIntField(buf, bufferCapacityField); | |
4609 return ret; | |
4610 } | |
4611 | |
4612 | |
4613 JNI_LEAF(jint, jni_GetVersion(JNIEnv *env)) | |
4614 JNIWrapper("GetVersion"); | |
4006 | 4615 #ifndef USDT2 |
0 | 4616 DTRACE_PROBE1(hotspot_jni, GetVersion__entry, env); |
4006 | 4617 #else /* USDT2 */ |
4618 HOTSPOT_JNI_GETVERSION_ENTRY( | |
4619 env); | |
4620 #endif /* USDT2 */ | |
4621 #ifndef USDT2 | |
0 | 4622 DTRACE_PROBE1(hotspot_jni, GetVersion__return, CurrentVersion); |
4006 | 4623 #else /* USDT2 */ |
4624 HOTSPOT_JNI_GETVERSION_RETURN( | |
4625 CurrentVersion); | |
4626 #endif /* USDT2 */ | |
0 | 4627 return CurrentVersion; |
4628 JNI_END | |
4629 | |
4630 extern struct JavaVM_ main_vm; | |
4631 | |
4632 JNI_LEAF(jint, jni_GetJavaVM(JNIEnv *env, JavaVM **vm)) | |
4633 JNIWrapper("jni_GetJavaVM"); | |
4006 | 4634 #ifndef USDT2 |
0 | 4635 DTRACE_PROBE2(hotspot_jni, GetJavaVM__entry, env, vm); |
4006 | 4636 #else /* USDT2 */ |
4637 HOTSPOT_JNI_GETJAVAVM_ENTRY( | |
4638 env, (void **) vm); | |
4639 #endif /* USDT2 */ | |
0 | 4640 *vm = (JavaVM *)(&main_vm); |
4006 | 4641 #ifndef USDT2 |
0 | 4642 DTRACE_PROBE1(hotspot_jni, GetJavaVM__return, JNI_OK); |
4006 | 4643 #else /* USDT2 */ |
4644 HOTSPOT_JNI_GETJAVAVM_RETURN( | |
4645 JNI_OK); | |
4646 #endif /* USDT2 */ | |
0 | 4647 return JNI_OK; |
4648 JNI_END | |
4649 | |
4650 // Structure containing all jni functions | |
4651 struct JNINativeInterface_ jni_NativeInterface = { | |
4652 NULL, | |
4653 NULL, | |
4654 NULL, | |
4655 | |
4656 NULL, | |
4657 | |
4658 jni_GetVersion, | |
4659 | |
4660 jni_DefineClass, | |
4661 jni_FindClass, | |
4662 | |
4663 jni_FromReflectedMethod, | |
4664 jni_FromReflectedField, | |
4665 | |
4666 jni_ToReflectedMethod, | |
4667 | |
4668 jni_GetSuperclass, | |
4669 jni_IsAssignableFrom, | |
4670 | |
4671 jni_ToReflectedField, | |
4672 | |
4673 jni_Throw, | |
4674 jni_ThrowNew, | |
4675 jni_ExceptionOccurred, | |
4676 jni_ExceptionDescribe, | |
4677 jni_ExceptionClear, | |
4678 jni_FatalError, | |
4679 | |
4680 jni_PushLocalFrame, | |
4681 jni_PopLocalFrame, | |
4682 | |
4683 jni_NewGlobalRef, | |
4684 jni_DeleteGlobalRef, | |
4685 jni_DeleteLocalRef, | |
4686 jni_IsSameObject, | |
4687 | |
4688 jni_NewLocalRef, | |
4689 jni_EnsureLocalCapacity, | |
4690 | |
4691 jni_AllocObject, | |
4692 jni_NewObject, | |
4693 jni_NewObjectV, | |
4694 jni_NewObjectA, | |
4695 | |
4696 jni_GetObjectClass, | |
4697 jni_IsInstanceOf, | |
4698 | |
4699 jni_GetMethodID, | |
4700 | |
4701 jni_CallObjectMethod, | |
4702 jni_CallObjectMethodV, | |
4703 jni_CallObjectMethodA, | |
4704 jni_CallBooleanMethod, | |
4705 jni_CallBooleanMethodV, | |
4706 jni_CallBooleanMethodA, | |
4707 jni_CallByteMethod, | |
4708 jni_CallByteMethodV, | |
4709 jni_CallByteMethodA, | |
4710 jni_CallCharMethod, | |
4711 jni_CallCharMethodV, | |
4712 jni_CallCharMethodA, | |
4713 jni_CallShortMethod, | |
4714 jni_CallShortMethodV, | |
4715 jni_CallShortMethodA, | |
4716 jni_CallIntMethod, | |
4717 jni_CallIntMethodV, | |
4718 jni_CallIntMethodA, | |
4719 jni_CallLongMethod, | |
4720 jni_CallLongMethodV, | |
4721 jni_CallLongMethodA, | |
4722 jni_CallFloatMethod, | |
4723 jni_CallFloatMethodV, | |
4724 jni_CallFloatMethodA, | |
4725 jni_CallDoubleMethod, | |
4726 jni_CallDoubleMethodV, | |
4727 jni_CallDoubleMethodA, | |
4728 jni_CallVoidMethod, | |
4729 jni_CallVoidMethodV, | |
4730 jni_CallVoidMethodA, | |
4731 | |
4732 jni_CallNonvirtualObjectMethod, | |
4733 jni_CallNonvirtualObjectMethodV, | |
4734 jni_CallNonvirtualObjectMethodA, | |
4735 jni_CallNonvirtualBooleanMethod, | |
4736 jni_CallNonvirtualBooleanMethodV, | |
4737 jni_CallNonvirtualBooleanMethodA, | |
4738 jni_CallNonvirtualByteMethod, | |
4739 jni_CallNonvirtualByteMethodV, | |
4740 jni_CallNonvirtualByteMethodA, | |
4741 jni_CallNonvirtualCharMethod, | |
4742 jni_CallNonvirtualCharMethodV, | |
4743 jni_CallNonvirtualCharMethodA, | |
4744 jni_CallNonvirtualShortMethod, | |
4745 jni_CallNonvirtualShortMethodV, | |
4746 jni_CallNonvirtualShortMethodA, | |
4747 jni_CallNonvirtualIntMethod, | |
4748 jni_CallNonvirtualIntMethodV, | |
4749 jni_CallNonvirtualIntMethodA, | |
4750 jni_CallNonvirtualLongMethod, | |
4751 jni_CallNonvirtualLongMethodV, | |
4752 jni_CallNonvirtualLongMethodA, | |
4753 jni_CallNonvirtualFloatMethod, | |
4754 jni_CallNonvirtualFloatMethodV, | |
4755 jni_CallNonvirtualFloatMethodA, | |
4756 jni_CallNonvirtualDoubleMethod, | |
4757 jni_CallNonvirtualDoubleMethodV, | |
4758 jni_CallNonvirtualDoubleMethodA, | |
4759 jni_CallNonvirtualVoidMethod, | |
4760 jni_CallNonvirtualVoidMethodV, | |
4761 jni_CallNonvirtualVoidMethodA, | |
4762 | |
4763 jni_GetFieldID, | |
4764 | |
4765 jni_GetObjectField, | |
4766 jni_GetBooleanField, | |
4767 jni_GetByteField, | |
4768 jni_GetCharField, | |
4769 jni_GetShortField, | |
4770 jni_GetIntField, | |
4771 jni_GetLongField, | |
4772 jni_GetFloatField, | |
4773 jni_GetDoubleField, | |
4774 | |
4775 jni_SetObjectField, | |
4776 jni_SetBooleanField, | |
4777 jni_SetByteField, | |
4778 jni_SetCharField, | |
4779 jni_SetShortField, | |
4780 jni_SetIntField, | |
4781 jni_SetLongField, | |
4782 jni_SetFloatField, | |
4783 jni_SetDoubleField, | |
4784 | |
4785 jni_GetStaticMethodID, | |
4786 | |
4787 jni_CallStaticObjectMethod, | |
4788 jni_CallStaticObjectMethodV, | |
4789 jni_CallStaticObjectMethodA, | |
4790 jni_CallStaticBooleanMethod, | |
4791 jni_CallStaticBooleanMethodV, | |
4792 jni_CallStaticBooleanMethodA, | |
4793 jni_CallStaticByteMethod, | |
4794 jni_CallStaticByteMethodV, | |
4795 jni_CallStaticByteMethodA, | |
4796 jni_CallStaticCharMethod, | |
4797 jni_CallStaticCharMethodV, | |
4798 jni_CallStaticCharMethodA, | |
4799 jni_CallStaticShortMethod, | |
4800 jni_CallStaticShortMethodV, | |
4801 jni_CallStaticShortMethodA, | |
4802 jni_CallStaticIntMethod, | |
4803 jni_CallStaticIntMethodV, | |
4804 jni_CallStaticIntMethodA, | |
4805 jni_CallStaticLongMethod, | |
4806 jni_CallStaticLongMethodV, | |
4807 jni_CallStaticLongMethodA, | |
4808 jni_CallStaticFloatMethod, | |
4809 jni_CallStaticFloatMethodV, | |
4810 jni_CallStaticFloatMethodA, | |
4811 jni_CallStaticDoubleMethod, | |
4812 jni_CallStaticDoubleMethodV, | |
4813 jni_CallStaticDoubleMethodA, | |
4814 jni_CallStaticVoidMethod, | |
4815 jni_CallStaticVoidMethodV, | |
4816 jni_CallStaticVoidMethodA, | |
4817 | |
4818 jni_GetStaticFieldID, | |
4819 | |
4820 jni_GetStaticObjectField, | |
4821 jni_GetStaticBooleanField, | |
4822 jni_GetStaticByteField, | |
4823 jni_GetStaticCharField, | |
4824 jni_GetStaticShortField, | |
4825 jni_GetStaticIntField, | |
4826 jni_GetStaticLongField, | |
4827 jni_GetStaticFloatField, | |
4828 jni_GetStaticDoubleField, | |
4829 | |
4830 jni_SetStaticObjectField, | |
4831 jni_SetStaticBooleanField, | |
4832 jni_SetStaticByteField, | |
4833 jni_SetStaticCharField, | |
4834 jni_SetStaticShortField, | |
4835 jni_SetStaticIntField, | |
4836 jni_SetStaticLongField, | |
4837 jni_SetStaticFloatField, | |
4838 jni_SetStaticDoubleField, | |
4839 | |
4840 jni_NewString, | |
4841 jni_GetStringLength, | |
4842 jni_GetStringChars, | |
4843 jni_ReleaseStringChars, | |
4844 | |
4845 jni_NewStringUTF, | |
4846 jni_GetStringUTFLength, | |
4847 jni_GetStringUTFChars, | |
4848 jni_ReleaseStringUTFChars, | |
4849 | |
4850 jni_GetArrayLength, | |
4851 | |
4852 jni_NewObjectArray, | |
4853 jni_GetObjectArrayElement, | |
4854 jni_SetObjectArrayElement, | |
4855 | |
4856 jni_NewBooleanArray, | |
4857 jni_NewByteArray, | |
4858 jni_NewCharArray, | |
4859 jni_NewShortArray, | |
4860 jni_NewIntArray, | |
4861 jni_NewLongArray, | |
4862 jni_NewFloatArray, | |
4863 jni_NewDoubleArray, | |
4864 | |
4865 jni_GetBooleanArrayElements, | |
4866 jni_GetByteArrayElements, | |
4867 jni_GetCharArrayElements, | |
4868 jni_GetShortArrayElements, | |
4869 jni_GetIntArrayElements, | |
4870 jni_GetLongArrayElements, | |
4871 jni_GetFloatArrayElements, | |
4872 jni_GetDoubleArrayElements, | |
4873 | |
4874 jni_ReleaseBooleanArrayElements, | |
4875 jni_ReleaseByteArrayElements, | |
4876 jni_ReleaseCharArrayElements, | |
4877 jni_ReleaseShortArrayElements, | |
4878 jni_ReleaseIntArrayElements, | |
4879 jni_ReleaseLongArrayElements, | |
4880 jni_ReleaseFloatArrayElements, | |
4881 jni_ReleaseDoubleArrayElements, | |
4882 | |
4883 jni_GetBooleanArrayRegion, | |
4884 jni_GetByteArrayRegion, | |
4885 jni_GetCharArrayRegion, | |
4886 jni_GetShortArrayRegion, | |
4887 jni_GetIntArrayRegion, | |
4888 jni_GetLongArrayRegion, | |
4889 jni_GetFloatArrayRegion, | |
4890 jni_GetDoubleArrayRegion, | |
4891 | |
4892 jni_SetBooleanArrayRegion, | |
4893 jni_SetByteArrayRegion, | |
4894 jni_SetCharArrayRegion, | |
4895 jni_SetShortArrayRegion, | |
4896 jni_SetIntArrayRegion, | |
4897 jni_SetLongArrayRegion, | |
4898 jni_SetFloatArrayRegion, | |
4899 jni_SetDoubleArrayRegion, | |
4900 | |
4901 jni_RegisterNatives, | |
4902 jni_UnregisterNatives, | |
4903 | |
4904 jni_MonitorEnter, | |
4905 jni_MonitorExit, | |
4906 | |
4907 jni_GetJavaVM, | |
4908 | |
4909 jni_GetStringRegion, | |
4910 jni_GetStringUTFRegion, | |
4911 | |
4912 jni_GetPrimitiveArrayCritical, | |
4913 jni_ReleasePrimitiveArrayCritical, | |
4914 | |
4915 jni_GetStringCritical, | |
4916 jni_ReleaseStringCritical, | |
4917 | |
4918 jni_NewWeakGlobalRef, | |
4919 jni_DeleteWeakGlobalRef, | |
4920 | |
4921 jni_ExceptionCheck, | |
4922 | |
4923 jni_NewDirectByteBuffer, | |
4924 jni_GetDirectBufferAddress, | |
4925 jni_GetDirectBufferCapacity, | |
4926 | |
4927 // New 1_6 features | |
4928 | |
4929 jni_GetObjectRefType | |
4930 }; | |
4931 | |
4932 | |
4933 // For jvmti use to modify jni function table. | |
4934 // Java threads in native contiues to run until it is transitioned | |
4935 // to VM at safepoint. Before the transition or before it is blocked | |
4936 // for safepoint it may access jni function table. VM could crash if | |
4937 // any java thread access the jni function table in the middle of memcpy. | |
4938 // To avoid this each function pointers are copied automically. | |
4939 void copy_jni_function_table(const struct JNINativeInterface_ *new_jni_NativeInterface) { | |
4940 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | |
4941 intptr_t *a = (intptr_t *) jni_functions(); | |
4942 intptr_t *b = (intptr_t *) new_jni_NativeInterface; | |
4943 for (uint i=0; i < sizeof(struct JNINativeInterface_)/sizeof(void *); i++) { | |
4944 Atomic::store_ptr(*b++, a++); | |
4945 } | |
4946 } | |
4947 | |
4948 void quicken_jni_functions() { | |
4949 // Replace Get<Primitive>Field with fast versions | |
4950 if (UseFastJNIAccessors && !JvmtiExport::can_post_field_access() | |
4951 && !VerifyJNIFields && !TraceJNICalls && !CountJNICalls && !CheckJNICalls | |
4952 #if defined(_WINDOWS) && defined(IA32) && defined(COMPILER2) | |
4953 // windows x86 currently needs SEH wrapper and the gain of the fast | |
4954 // versions currently isn't certain for server vm on uniprocessor. | |
4955 && os::is_MP() | |
4956 #endif | |
4957 ) { | |
4958 address func; | |
4959 func = JNI_FastGetField::generate_fast_get_boolean_field(); | |
4960 if (func != (address)-1) { | |
4961 jni_NativeInterface.GetBooleanField = (GetBooleanField_t)func; | |
4962 } | |
4963 func = JNI_FastGetField::generate_fast_get_byte_field(); | |
4964 if (func != (address)-1) { | |
4965 jni_NativeInterface.GetByteField = (GetByteField_t)func; | |
4966 } | |
4967 func = JNI_FastGetField::generate_fast_get_char_field(); | |
4968 if (func != (address)-1) { | |
4969 jni_NativeInterface.GetCharField = (GetCharField_t)func; | |
4970 } | |
4971 func = JNI_FastGetField::generate_fast_get_short_field(); | |
4972 if (func != (address)-1) { | |
4973 jni_NativeInterface.GetShortField = (GetShortField_t)func; | |
4974 } | |
4975 func = JNI_FastGetField::generate_fast_get_int_field(); | |
4976 if (func != (address)-1) { | |
4977 jni_NativeInterface.GetIntField = (GetIntField_t)func; | |
4978 } | |
4979 func = JNI_FastGetField::generate_fast_get_long_field(); | |
4980 if (func != (address)-1) { | |
4981 jni_NativeInterface.GetLongField = (GetLongField_t)func; | |
4982 } | |
4983 func = JNI_FastGetField::generate_fast_get_float_field(); | |
4984 if (func != (address)-1) { | |
4985 jni_NativeInterface.GetFloatField = (GetFloatField_t)func; | |
4986 } | |
4987 func = JNI_FastGetField::generate_fast_get_double_field(); | |
4988 if (func != (address)-1) { | |
4989 jni_NativeInterface.GetDoubleField = (GetDoubleField_t)func; | |
4990 } | |
4991 } | |
4992 } | |
4993 | |
4994 // Returns the function structure | |
4995 struct JNINativeInterface_* jni_functions() { | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
4996 #if INCLUDE_JNI_CHECK |
0 | 4997 if (CheckJNICalls) return jni_functions_check(); |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
4998 #endif // INCLUDE_JNI_CHECK |
0 | 4999 return &jni_NativeInterface; |
5000 } | |
5001 | |
5002 // Returns the function structure | |
5003 struct JNINativeInterface_* jni_functions_nocheck() { | |
5004 return &jni_NativeInterface; | |
5005 } | |
5006 | |
5007 | |
5008 // Invocation API | |
5009 | |
5010 | |
5011 // Forward declaration | |
5012 extern const struct JNIInvokeInterface_ jni_InvokeInterface; | |
5013 | |
5014 // Global invocation API vars | |
5015 volatile jint vm_created = 0; | |
5016 // Indicate whether it is safe to recreate VM | |
5017 volatile jint safe_to_recreate_vm = 1; | |
5018 struct JavaVM_ main_vm = {&jni_InvokeInterface}; | |
5019 | |
5020 | |
5021 #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */ | |
5022 enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL }; | |
5023 | |
4006 | 5024 #ifndef USDT2 |
0 | 5025 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*); |
5026 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint); | |
4006 | 5027 #else /* USDT2 */ |
5028 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint | |
5029 , HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN(_ret_ref)); | |
5030 #endif /* USDT2 */ | |
0 | 5031 |
5032 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { | |
4006 | 5033 #ifndef USDT2 |
0 | 5034 HS_DTRACE_PROBE1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, args_); |
4006 | 5035 #else /* USDT2 */ |
5036 HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY( | |
5037 args_); | |
5038 #endif /* USDT2 */ | |
0 | 5039 JDK1_1InitArgs *args = (JDK1_1InitArgs *)args_; |
5040 jint ret = JNI_ERR; | |
5041 DT_RETURN_MARK(GetDefaultJavaVMInitArgs, jint, (const jint&)ret); | |
5042 | |
5043 if (Threads::is_supported_jni_version(args->version)) { | |
5044 ret = JNI_OK; | |
5045 } | |
5046 // 1.1 style no longer supported in hotspot. | |
5047 // According the JNI spec, we should update args->version on return. | |
5048 // We also use the structure to communicate with launcher about default | |
5049 // stack size. | |
5050 if (args->version == JNI_VERSION_1_1) { | |
5051 args->version = JNI_VERSION_1_2; | |
5052 // javaStackSize is int in arguments structure | |
5053 assert(jlong(ThreadStackSize) * K < INT_MAX, "integer overflow"); | |
5054 args->javaStackSize = (jint)(ThreadStackSize * K); | |
5055 } | |
5056 return ret; | |
5057 } | |
5058 | |
3779 | 5059 #ifndef PRODUCT |
5060 | |
10405 | 5061 #include "gc_implementation/shared/gcTimer.hpp" |
4708 | 5062 #include "gc_interface/collectedHeap.hpp" |
10333
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5063 #if INCLUDE_ALL_GCS |
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5064 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5065 #endif |
20318
fa62fb12cdca
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
20262
diff
changeset
|
5066 #include "memory/guardedMemory.hpp" |
3779 | 5067 #include "utilities/quickSort.hpp" |
12215 | 5068 #include "utilities/ostream.hpp" |
7171 | 5069 #if INCLUDE_VM_STRUCTS |
5070 #include "runtime/vmStructs.hpp" | |
5071 #endif | |
3779 | 5072 |
4708 | 5073 #define run_unit_test(unit_test_function_call) \ |
5074 tty->print_cr("Running test: " #unit_test_function_call); \ | |
5075 unit_test_function_call | |
5076 | |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5077 // Forward declaration |
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5078 void TestReservedSpace_test(); |
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5079 void TestReserveMemorySpecial_test(); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12111
diff
changeset
|
5080 void TestVirtualSpace_test(); |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12305
diff
changeset
|
5081 void TestMetaspaceAux_test(); |
12902 | 5082 void TestMetachunk_test(); |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12902
diff
changeset
|
5083 void TestVirtualSpaceNode_test(); |
17898
1d01a7f3a336
8033426: Scale initial NewSize using NewRatio if not set on command line
sjohanss
parents:
17829
diff
changeset
|
5084 void TestNewSize_test(); |
20262
76b588255908
8035746: Add missing Klass::oop_is_instanceClassLoader() function
stefank
parents:
20255
diff
changeset
|
5085 void TestKlass_test(); |
20360 | 5086 void Test_linked_list(); |
20619
b12a2a9b05ca
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
20360
diff
changeset
|
5087 void TestChunkedList_test(); |
17694 | 5088 #if INCLUDE_ALL_GCS |
17648
a034dc5e910b
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
12979
diff
changeset
|
5089 void TestOldFreeSpaceCalculation_test(); |
12305
a19bea467577
7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
12269
diff
changeset
|
5090 void TestG1BiasedArray_test(); |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
20197
diff
changeset
|
5091 void TestBufferingOopClosure_test(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
17704
diff
changeset
|
5092 void TestCodeCacheRemSet_test(); |
20337 | 5093 void FreeRegionList_test(); |
12305
a19bea467577
7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
12269
diff
changeset
|
5094 #endif |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5095 |
3779 | 5096 void execute_internal_vm_tests() { |
5097 if (ExecuteInternalVMTests) { | |
4708 | 5098 tty->print_cr("Running internal VM tests"); |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5099 run_unit_test(TestReservedSpace_test()); |
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5100 run_unit_test(TestReserveMemorySpecial_test()); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12111
diff
changeset
|
5101 run_unit_test(TestVirtualSpace_test()); |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12305
diff
changeset
|
5102 run_unit_test(TestMetaspaceAux_test()); |
12902 | 5103 run_unit_test(TestMetachunk_test()); |
12979
1d1ea10fe09f
8015255: NPG: Don't waste fragment at the end of a VirtualSpaceNode before retiring it.
mgerdin
parents:
12902
diff
changeset
|
5104 run_unit_test(TestVirtualSpaceNode_test()); |
9060
cc32ccaaf47f
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
8793
diff
changeset
|
5105 run_unit_test(GlobalDefinitions::test_globals()); |
10405 | 5106 run_unit_test(GCTimerAllTest::all()); |
4708 | 5107 run_unit_test(arrayOopDesc::test_max_array_length()); |
5108 run_unit_test(CollectedHeap::test_is_in()); | |
5109 run_unit_test(QuickSort::test_quick_sort()); | |
20318
fa62fb12cdca
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
20262
diff
changeset
|
5110 run_unit_test(GuardedMemory::test_guarded_memory()); |
6162 | 5111 run_unit_test(AltHashing::test_alt_hash()); |
12215 | 5112 run_unit_test(test_loggc_filename()); |
17898
1d01a7f3a336
8033426: Scale initial NewSize using NewRatio if not set on command line
sjohanss
parents:
17829
diff
changeset
|
5113 run_unit_test(TestNewSize_test()); |
20262
76b588255908
8035746: Add missing Klass::oop_is_instanceClassLoader() function
stefank
parents:
20255
diff
changeset
|
5114 run_unit_test(TestKlass_test()); |
20360 | 5115 run_unit_test(Test_linked_list()); |
20619
b12a2a9b05ca
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
20360
diff
changeset
|
5116 run_unit_test(TestChunkedList_test()); |
7171 | 5117 #if INCLUDE_VM_STRUCTS |
5118 run_unit_test(VMStructs::test()); | |
5119 #endif | |
10333
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5120 #if INCLUDE_ALL_GCS |
17694 | 5121 run_unit_test(TestOldFreeSpaceCalculation_test()); |
12305
a19bea467577
7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
12269
diff
changeset
|
5122 run_unit_test(TestG1BiasedArray_test()); |
10333
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5123 run_unit_test(HeapRegionRemSet::test_prt()); |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
20197
diff
changeset
|
5124 run_unit_test(TestBufferingOopClosure_test()); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
17704
diff
changeset
|
5125 run_unit_test(TestCodeCacheRemSet_test()); |
20337 | 5126 if (UseG1GC) { |
5127 run_unit_test(FreeRegionList_test()); | |
5128 } | |
10333
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5129 #endif |
4070
6fd81579526f
7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents:
4006
diff
changeset
|
5130 tty->print_cr("All internal VM tests passed"); |
3779 | 5131 } |
5132 } | |
5133 | |
4708 | 5134 #undef run_unit_test |
5135 | |
3779 | 5136 #endif |
5137 | |
4006 | 5138 #ifndef USDT2 |
0 | 5139 HS_DTRACE_PROBE_DECL3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); |
5140 DT_RETURN_MARK_DECL(CreateJavaVM, jint); | |
4006 | 5141 #else /* USDT2 */ |
5142 DT_RETURN_MARK_DECL(CreateJavaVM, jint | |
5143 , HOTSPOT_JNI_CREATEJAVAVM_RETURN(_ret_ref)); | |
5144 #endif /* USDT2 */ | |
0 | 5145 |
5146 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) { | |
4006 | 5147 #ifndef USDT2 |
0 | 5148 HS_DTRACE_PROBE3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); |
4006 | 5149 #else /* USDT2 */ |
5150 HOTSPOT_JNI_CREATEJAVAVM_ENTRY( | |
5151 (void **) vm, penv, args); | |
5152 #endif /* USDT2 */ | |
0 | 5153 |
5154 jint result = JNI_ERR; | |
5155 DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result); | |
5156 | |
1078 | 5157 // We're about to use Atomic::xchg for synchronization. Some Zero |
5158 // platforms use the GCC builtin __sync_lock_test_and_set for this, | |
5159 // but __sync_lock_test_and_set is not guaranteed to do what we want | |
5160 // on all architectures. So we check it works before relying on it. | |
5161 #if defined(ZERO) && defined(ASSERT) | |
5162 { | |
5163 jint a = 0xcafebabe; | |
5164 jint b = Atomic::xchg(0xdeadbeef, &a); | |
5165 void *c = &a; | |
5166 void *d = Atomic::xchg_ptr(&b, &c); | |
1132 | 5167 assert(a == (jint) 0xdeadbeef && b == (jint) 0xcafebabe, "Atomic::xchg() works"); |
1078 | 5168 assert(c == &b && d == &a, "Atomic::xchg_ptr() works"); |
5169 } | |
5170 #endif // ZERO && ASSERT | |
5171 | |
0 | 5172 // At the moment it's only possible to have one Java VM, |
5173 // since some of the runtime state is in global variables. | |
5174 | |
5175 // We cannot use our mutex locks here, since they only work on | |
5176 // Threads. We do an atomic compare and exchange to ensure only | |
5177 // one thread can call this method at a time | |
5178 | |
5179 // We use Atomic::xchg rather than Atomic::add/dec since on some platforms | |
5180 // the add/dec implementations are dependent on whether we are running | |
5181 // on a multiprocessor, and at this stage of initialization the os::is_MP | |
5182 // function used to determine this will always return false. Atomic::xchg | |
5183 // does not have this problem. | |
5184 if (Atomic::xchg(1, &vm_created) == 1) { | |
11089
f323bbb0e6c1
8019833: Wrong JNI error code for preexisting JVM
coleenp
parents:
11059
diff
changeset
|
5185 return JNI_EEXIST; // already created, or create attempt in progress |
0 | 5186 } |
5187 if (Atomic::xchg(0, &safe_to_recreate_vm) == 0) { | |
5188 return JNI_ERR; // someone tried and failed and retry not allowed. | |
5189 } | |
5190 | |
5191 assert(vm_created == 1, "vm_created is true during the creation"); | |
5192 | |
5193 /** | |
5194 * Certain errors during initialization are recoverable and do not | |
5195 * prevent this method from being called again at a later time | |
5196 * (perhaps with different arguments). However, at a certain | |
5197 * point during initialization if an error occurs we cannot allow | |
5198 * this function to be called again (or it will crash). In those | |
5199 * situations, the 'canTryAgain' flag is set to false, which atomically | |
5200 * sets safe_to_recreate_vm to 1, such that any new call to | |
5201 * JNI_CreateJavaVM will immediately fail using the above logic. | |
5202 */ | |
5203 bool can_try_again = true; | |
5204 | |
5205 result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again); | |
5206 if (result == JNI_OK) { | |
5207 JavaThread *thread = JavaThread::current(); | |
5208 /* thread is thread_in_vm here */ | |
5209 *vm = (JavaVM *)(&main_vm); | |
5210 *(JNIEnv**)penv = thread->jni_environment(); | |
5211 | |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5212 #if defined(JVMCI) |
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5213 // We turn off CompileTheWorld so that compilation requests are not ignored during bootstrap or that JVMCI can be compiled by C1/C2. |
18134
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5214 bool doCTW = CompileTheWorld; |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5215 CompileTheWorld = false; |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5216 #endif |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5217 |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5218 #ifdef COMPILERJVMCI |
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5219 // JVMCI is initialized on a CompilerThread |
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5220 if (FLAG_IS_DEFAULT(BootstrapJVMCI) ? !TieredCompilation : BootstrapJVMCI) { |
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5221 JVMCICompiler::instance()->bootstrap(); |
13174
b00553202ec2
add NULL check so that -Xint option works again
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13086
diff
changeset
|
5222 } |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5223 #elif defined(JVMCI) |
18134
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5224 if (doCTW) { |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5225 // required for hosted CTW. |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5226 CompilationPolicy::completed_vm_startup(); |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5227 } |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5228 #endif |
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5229 |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5230 #if defined(JVMCI) |
18134
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5231 if (doCTW) { |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
5232 JVMCICompiler::instance()->compile_the_world(); |
18134
6a2f814224b1
hotspot/graal: simplify CTW logic. now, the following configurations are supported:
Bernhard Urban <bernhard.urban@jku.at>
parents:
18041
diff
changeset
|
5233 } |
4368
d8d6b3de346b
Add another #ifdef GRAAL
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4137
diff
changeset
|
5234 #endif |
3650
0e8a2a629afb
Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3540
diff
changeset
|
5235 |
0 | 5236 // Tracks the time application was running before GC |
5237 RuntimeService::record_application_start(); | |
5238 | |
5239 // Notify JVMTI | |
5240 if (JvmtiExport::should_post_thread_life()) { | |
5241 JvmtiExport::post_thread_start(thread); | |
5242 } | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5243 |
10405 | 5244 EventThreadStart event; |
5245 if (event.should_commit()) { | |
5246 event.set_javalangthread(java_lang_Thread::thread_id(thread->threadObj())); | |
5247 event.commit(); | |
5248 } | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5249 |
11092
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5250 #ifndef PRODUCT |
17829
0118c8c7b80f
8038633: crash in VM_Version::get_processor_features() on startup
kvn
parents:
17753
diff
changeset
|
5251 #ifndef CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED |
11092
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5252 #define CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(f) f() |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5253 #endif |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5254 |
0 | 5255 // Check if we should compile all classes on bootclasspath |
11092
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5256 if (CompileTheWorld) ClassLoader::compile_the_world(); |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5257 if (ReplayCompiles) ciReplay::replay(thread); |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5258 |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5259 // Some platforms (like Win*) need a wrapper around these test |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5260 // functions in order to properly handle error conditions. |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5261 CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(test_error_handler); |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5262 CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(execute_internal_vm_tests); |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5263 #endif |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5264 |
0 | 5265 // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. |
5266 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
5267 } else { | |
5268 if (can_try_again) { | |
5269 // reset safe_to_recreate_vm to 1 so that retrial would be possible | |
5270 safe_to_recreate_vm = 1; | |
5271 } | |
5272 | |
5273 // Creation failed. We must reset vm_created | |
5274 *vm = 0; | |
5275 *(JNIEnv**)penv = 0; | |
5276 // reset vm_created last to avoid race condition. Use OrderAccess to | |
5277 // control both compiler and architectural-based reordering. | |
5278 OrderAccess::release_store(&vm_created, 0); | |
5279 } | |
5280 | |
5281 return result; | |
5282 } | |
5283 | |
4006 | 5284 #ifndef USDT2 |
0 | 5285 HS_DTRACE_PROBE_DECL3(hotspot_jni, GetCreatedJavaVMs__entry, \ |
5286 JavaVM**, jsize, jsize*); | |
5287 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetCreatedJavaVMs__return, jint); | |
4006 | 5288 #endif /* !USDT2 */ |
0 | 5289 |
5290 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) { | |
5291 // See bug 4367188, the wrapper can sometimes cause VM crashes | |
5292 // JNIWrapper("GetCreatedJavaVMs"); | |
4006 | 5293 #ifndef USDT2 |
0 | 5294 HS_DTRACE_PROBE3(hotspot_jni, GetCreatedJavaVMs__entry, \ |
5295 vm_buf, bufLen, numVMs); | |
4006 | 5296 #else /* USDT2 */ |
5297 HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY( | |
5298 (void **) vm_buf, bufLen, (uintptr_t *) numVMs); | |
5299 #endif /* USDT2 */ | |
0 | 5300 if (vm_created) { |
5301 if (numVMs != NULL) *numVMs = 1; | |
5302 if (bufLen > 0) *vm_buf = (JavaVM *)(&main_vm); | |
5303 } else { | |
5304 if (numVMs != NULL) *numVMs = 0; | |
5305 } | |
4006 | 5306 #ifndef USDT2 |
0 | 5307 HS_DTRACE_PROBE1(hotspot_jni, GetCreatedJavaVMs__return, JNI_OK); |
4006 | 5308 #else /* USDT2 */ |
5309 HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN( | |
5310 JNI_OK); | |
5311 #endif /* USDT2 */ | |
0 | 5312 return JNI_OK; |
5313 } | |
5314 | |
5315 extern "C" { | |
5316 | |
4006 | 5317 #ifndef USDT2 |
0 | 5318 DT_RETURN_MARK_DECL(DestroyJavaVM, jint); |
4006 | 5319 #else /* USDT2 */ |
5320 DT_RETURN_MARK_DECL(DestroyJavaVM, jint | |
5321 , HOTSPOT_JNI_DESTROYJAVAVM_RETURN(_ret_ref)); | |
5322 #endif /* USDT2 */ | |
0 | 5323 |
5324 jint JNICALL jni_DestroyJavaVM(JavaVM *vm) { | |
4006 | 5325 #ifndef USDT2 |
0 | 5326 DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm); |
4006 | 5327 #else /* USDT2 */ |
5328 HOTSPOT_JNI_DESTROYJAVAVM_ENTRY( | |
5329 vm); | |
5330 #endif /* USDT2 */ | |
0 | 5331 jint res = JNI_ERR; |
5332 DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res); | |
5333 | |
5334 if (!vm_created) { | |
5335 res = JNI_ERR; | |
5336 return res; | |
5337 } | |
5338 | |
5339 JNIWrapper("DestroyJavaVM"); | |
5340 JNIEnv *env; | |
5341 JavaVMAttachArgs destroyargs; | |
5342 destroyargs.version = CurrentVersion; | |
5343 destroyargs.name = (char *)"DestroyJavaVM"; | |
5344 destroyargs.group = NULL; | |
5345 res = vm->AttachCurrentThread((void **)&env, (void *)&destroyargs); | |
5346 if (res != JNI_OK) { | |
5347 return res; | |
5348 } | |
5349 | |
5350 // Since this is not a JVM_ENTRY we have to set the thread state manually before entering. | |
5351 JavaThread* thread = JavaThread::current(); | |
5352 ThreadStateTransition::transition_from_native(thread, _thread_in_vm); | |
5353 if (Threads::destroy_vm()) { | |
5354 // Should not change thread state, VM is gone | |
5355 vm_created = false; | |
5356 res = JNI_OK; | |
5357 return res; | |
5358 } else { | |
5359 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
5360 res = JNI_ERR; | |
5361 return res; | |
5362 } | |
5363 } | |
5364 | |
5365 | |
5366 static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool daemon) { | |
5367 JavaVMAttachArgs *args = (JavaVMAttachArgs *) _args; | |
5368 | |
5369 // Check below commented out from JDK1.2fcs as well | |
5370 /* | |
5371 if (args && (args->version != JNI_VERSION_1_1 || args->version != JNI_VERSION_1_2)) { | |
5372 return JNI_EVERSION; | |
5373 } | |
5374 */ | |
5375 | |
5376 Thread* t = ThreadLocalStorage::get_thread_slow(); | |
5377 if (t != NULL) { | |
5378 // If the thread has been attached this operation is a no-op | |
5379 *(JNIEnv**)penv = ((JavaThread*) t)->jni_environment(); | |
5380 return JNI_OK; | |
5381 } | |
5382 | |
5383 // Create a thread and mark it as attaching so it will be skipped by the | |
5384 // ThreadsListEnumerator - see CR 6404306 | |
5385 JavaThread* thread = new JavaThread(true); | |
5386 | |
5387 // Set correct safepoint info. The thread is going to call into Java when | |
5388 // initializing the Java level thread object. Hence, the correct state must | |
5389 // be set in order for the Safepoint code to deal with it correctly. | |
5390 thread->set_thread_state(_thread_in_vm); | |
5391 // Must do this before initialize_thread_local_storage | |
5392 thread->record_stack_base_and_size(); | |
1290
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5393 |
0 | 5394 thread->initialize_thread_local_storage(); |
5395 | |
5396 if (!os::create_attached_thread(thread)) { | |
5397 delete thread; | |
5398 return JNI_ERR; | |
5399 } | |
1290
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5400 // Enable stack overflow checks |
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5401 thread->create_stack_guard_pages(); |
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5402 |
0 | 5403 thread->initialize_tlab(); |
5404 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
5405 thread->cache_global_variables(); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
5406 |
0 | 5407 // Crucial that we do not have a safepoint check for this thread, since it has |
5408 // not been added to the Thread list yet. | |
5409 { Threads_lock->lock_without_safepoint_check(); | |
5410 // This must be inside this lock in order to get FullGCALot to work properly, i.e., to | |
5411 // avoid this thread trying to do a GC before it is added to the thread-list | |
5412 thread->set_active_handles(JNIHandleBlock::allocate_block()); | |
5413 Threads::add(thread, daemon); | |
5414 Threads_lock->unlock(); | |
5415 } | |
5416 // Create thread group and name info from attach arguments | |
5417 oop group = NULL; | |
5418 char* thread_name = NULL; | |
5419 if (args != NULL && Threads::is_supported_jni_version(args->version)) { | |
5420 group = JNIHandles::resolve(args->group); | |
5421 thread_name = args->name; // may be NULL | |
5422 } | |
5423 if (group == NULL) group = Universe::main_thread_group(); | |
5424 | |
5425 // Create Java level thread object and attach it to this thread | |
5426 bool attach_failed = false; | |
5427 { | |
5428 EXCEPTION_MARK; | |
5429 HandleMark hm(THREAD); | |
5430 Handle thread_group(THREAD, group); | |
5431 thread->allocate_threadObj(thread_group, thread_name, daemon, THREAD); | |
5432 if (HAS_PENDING_EXCEPTION) { | |
5433 CLEAR_PENDING_EXCEPTION; | |
5434 // cleanup outside the handle mark. | |
5435 attach_failed = true; | |
5436 } | |
5437 } | |
5438 | |
5439 if (attach_failed) { | |
5440 // Added missing cleanup | |
5441 thread->cleanup_failed_attach_current_thread(); | |
5442 return JNI_ERR; | |
5443 } | |
5444 | |
5445 // mark the thread as no longer attaching | |
5446 // this uses a fence to push the change through so we don't have | |
5447 // to regrab the threads_lock | |
4006 | 5448 thread->set_done_attaching_via_jni(); |
0 | 5449 |
5450 // Set java thread status. | |
5451 java_lang_Thread::set_thread_status(thread->threadObj(), | |
5452 java_lang_Thread::RUNNABLE); | |
5453 | |
5454 // Notify the debugger | |
5455 if (JvmtiExport::should_post_thread_life()) { | |
5456 JvmtiExport::post_thread_start(thread); | |
5457 } | |
5458 | |
10405 | 5459 EventThreadStart event; |
5460 if (event.should_commit()) { | |
5461 event.set_javalangthread(java_lang_Thread::thread_id(thread->threadObj())); | |
5462 event.commit(); | |
5463 } | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5464 |
0 | 5465 *(JNIEnv**)penv = thread->jni_environment(); |
5466 | |
5467 // Now leaving the VM, so change thread_state. This is normally automatically taken care | |
5468 // of in the JVM_ENTRY. But in this situation we have to do it manually. Notice, that by | |
5469 // using ThreadStateTransition::transition, we do a callback to the safepoint code if | |
5470 // needed. | |
5471 | |
5472 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
5473 | |
5474 // Perform any platform dependent FPU setup | |
5475 os::setup_fpu(); | |
5476 | |
5477 return JNI_OK; | |
5478 } | |
5479 | |
5480 | |
5481 jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) { | |
4006 | 5482 #ifndef USDT2 |
0 | 5483 DTRACE_PROBE3(hotspot_jni, AttachCurrentThread__entry, vm, penv, _args); |
4006 | 5484 #else /* USDT2 */ |
5485 HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY( | |
5486 vm, penv, _args); | |
5487 #endif /* USDT2 */ | |
0 | 5488 if (!vm_created) { |
4006 | 5489 #ifndef USDT2 |
0 | 5490 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, JNI_ERR); |
4006 | 5491 #else /* USDT2 */ |
5492 HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN( | |
5493 (uint32_t) JNI_ERR); | |
5494 #endif /* USDT2 */ | |
0 | 5495 return JNI_ERR; |
5496 } | |
5497 | |
5498 JNIWrapper("AttachCurrentThread"); | |
5499 jint ret = attach_current_thread(vm, penv, _args, false); | |
4006 | 5500 #ifndef USDT2 |
0 | 5501 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, ret); |
4006 | 5502 #else /* USDT2 */ |
5503 HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN( | |
5504 ret); | |
5505 #endif /* USDT2 */ | |
0 | 5506 return ret; |
5507 } | |
5508 | |
5509 | |
5510 jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { | |
4006 | 5511 #ifndef USDT2 |
0 | 5512 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__entry, vm); |
4006 | 5513 #else /* USDT2 */ |
5514 HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY( | |
5515 vm); | |
5516 #endif /* USDT2 */ | |
0 | 5517 VM_Exit::block_if_vm_exited(); |
5518 | |
5519 JNIWrapper("DetachCurrentThread"); | |
5520 | |
5521 // If the thread has been deattacted the operations is a no-op | |
5522 if (ThreadLocalStorage::thread() == NULL) { | |
4006 | 5523 #ifndef USDT2 |
0 | 5524 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); |
4006 | 5525 #else /* USDT2 */ |
5526 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( | |
5527 JNI_OK); | |
5528 #endif /* USDT2 */ | |
0 | 5529 return JNI_OK; |
5530 } | |
5531 | |
5532 JavaThread* thread = JavaThread::current(); | |
5533 if (thread->has_last_Java_frame()) { | |
4006 | 5534 #ifndef USDT2 |
0 | 5535 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_ERR); |
4006 | 5536 #else /* USDT2 */ |
5537 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( | |
5538 (uint32_t) JNI_ERR); | |
5539 #endif /* USDT2 */ | |
0 | 5540 // Can't detach a thread that's running java, that can't work. |
5541 return JNI_ERR; | |
5542 } | |
5543 | |
5544 // Safepoint support. Have to do call-back to safepoint code, if in the | |
5545 // middel of a safepoint operation | |
5546 ThreadStateTransition::transition_from_native(thread, _thread_in_vm); | |
5547 | |
5548 // XXX: Note that JavaThread::exit() call below removes the guards on the | |
5549 // stack pages set up via enable_stack_{red,yellow}_zone() calls | |
5550 // above in jni_AttachCurrentThread. Unfortunately, while the setting | |
5551 // of the guards is visible in jni_AttachCurrentThread above, | |
5552 // the removal of the guards is buried below in JavaThread::exit() | |
5553 // here. The abstraction should be more symmetrically either exposed | |
5554 // or hidden (e.g. it could probably be hidden in the same | |
5555 // (platform-dependent) methods where we do alternate stack | |
5556 // maintenance work?) | |
5557 thread->exit(false, JavaThread::jni_detach); | |
5558 delete thread; | |
5559 | |
4006 | 5560 #ifndef USDT2 |
0 | 5561 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); |
4006 | 5562 #else /* USDT2 */ |
5563 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( | |
5564 JNI_OK); | |
5565 #endif /* USDT2 */ | |
0 | 5566 return JNI_OK; |
5567 } | |
5568 | |
4006 | 5569 #ifndef USDT2 |
0 | 5570 DT_RETURN_MARK_DECL(GetEnv, jint); |
4006 | 5571 #else /* USDT2 */ |
5572 DT_RETURN_MARK_DECL(GetEnv, jint | |
5573 , HOTSPOT_JNI_GETENV_RETURN(_ret_ref)); | |
5574 #endif /* USDT2 */ | |
0 | 5575 |
5576 jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { | |
4006 | 5577 #ifndef USDT2 |
0 | 5578 DTRACE_PROBE3(hotspot_jni, GetEnv__entry, vm, penv, version); |
4006 | 5579 #else /* USDT2 */ |
5580 HOTSPOT_JNI_GETENV_ENTRY( | |
5581 vm, penv, version); | |
5582 #endif /* USDT2 */ | |
0 | 5583 jint ret = JNI_ERR; |
5584 DT_RETURN_MARK(GetEnv, jint, (const jint&)ret); | |
5585 | |
5586 if (!vm_created) { | |
5587 *penv = NULL; | |
5588 ret = JNI_EDETACHED; | |
5589 return ret; | |
5590 } | |
5591 | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5592 if (JniExportedInterface::GetExportedInterface(vm, penv, version, &ret)) { |
0 | 5593 return ret; |
5594 } | |
5595 | |
5596 #ifndef JVMPI_VERSION_1 | |
5597 // need these in order to be polite about older agents | |
5598 #define JVMPI_VERSION_1 ((jint)0x10000001) | |
5599 #define JVMPI_VERSION_1_1 ((jint)0x10000002) | |
5600 #define JVMPI_VERSION_1_2 ((jint)0x10000003) | |
5601 #endif // !JVMPI_VERSION_1 | |
5602 | |
5603 Thread* thread = ThreadLocalStorage::thread(); | |
5604 if (thread != NULL && thread->is_Java_thread()) { | |
5605 if (Threads::is_supported_jni_version_including_1_1(version)) { | |
5606 *(JNIEnv**)penv = ((JavaThread*) thread)->jni_environment(); | |
5607 ret = JNI_OK; | |
5608 return ret; | |
5609 | |
5610 } else if (version == JVMPI_VERSION_1 || | |
5611 version == JVMPI_VERSION_1_1 || | |
5612 version == JVMPI_VERSION_1_2) { | |
5613 tty->print_cr("ERROR: JVMPI, an experimental interface, is no longer supported."); | |
5614 tty->print_cr("Please use the supported interface: the JVM Tool Interface (JVM TI)."); | |
5615 ret = JNI_EVERSION; | |
5616 return ret; | |
5617 } else if (JvmtiExport::is_jvmdi_version(version)) { | |
5618 tty->print_cr("FATAL ERROR: JVMDI is no longer supported."); | |
5619 tty->print_cr("Please use the supported interface: the JVM Tool Interface (JVM TI)."); | |
5620 ret = JNI_EVERSION; | |
5621 return ret; | |
5622 } else { | |
5623 *penv = NULL; | |
5624 ret = JNI_EVERSION; | |
5625 return ret; | |
5626 } | |
5627 } else { | |
5628 *penv = NULL; | |
5629 ret = JNI_EDETACHED; | |
5630 return ret; | |
5631 } | |
5632 } | |
5633 | |
5634 | |
5635 jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) { | |
4006 | 5636 #ifndef USDT2 |
0 | 5637 DTRACE_PROBE3(hotspot_jni, AttachCurrentThreadAsDaemon__entry, vm, penv, _args); |
4006 | 5638 #else /* USDT2 */ |
5639 HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY( | |
5640 vm, penv, _args); | |
5641 #endif /* USDT2 */ | |
0 | 5642 if (!vm_created) { |
4006 | 5643 #ifndef USDT2 |
0 | 5644 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, JNI_ERR); |
4006 | 5645 #else /* USDT2 */ |
5646 HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN( | |
5647 (uint32_t) JNI_ERR); | |
5648 #endif /* USDT2 */ | |
0 | 5649 return JNI_ERR; |
5650 } | |
5651 | |
5652 JNIWrapper("AttachCurrentThreadAsDaemon"); | |
5653 jint ret = attach_current_thread(vm, penv, _args, true); | |
4006 | 5654 #ifndef USDT2 |
0 | 5655 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, ret); |
4006 | 5656 #else /* USDT2 */ |
5657 HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN( | |
5658 ret); | |
5659 #endif /* USDT2 */ | |
0 | 5660 return ret; |
5661 } | |
5662 | |
5663 | |
5664 } // End extern "C" | |
5665 | |
5666 const struct JNIInvokeInterface_ jni_InvokeInterface = { | |
5667 NULL, | |
5668 NULL, | |
5669 NULL, | |
5670 | |
5671 jni_DestroyJavaVM, | |
5672 jni_AttachCurrentThread, | |
5673 jni_DetachCurrentThread, | |
5674 jni_GetEnv, | |
5675 jni_AttachCurrentThreadAsDaemon | |
5676 }; |