Mercurial > hg > graal-jvmci-8
annotate src/share/vm/prims/jni.cpp @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | 190f5f33b7d3 |
children |
rev | line source |
---|---|
0 | 1 /* |
23614 | 2 * Copyright (c) 1997, 2016, 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" |
22298 | 36 #if INCLUDE_JVMCI |
21559
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 | |
23633
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1128 inline void get_bool() { |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1129 // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1130 // 0 to JNI_FALSE. Boolean return values from native are normalized the same in |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1131 // TemplateInterpreterGenerator::generate_result_handler_for and |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1132 // SharedRuntime::generate_native_wrapper. |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1133 jboolean b = va_arg(_ap, jint); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1134 _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE)); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1135 } |
0 | 1136 inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg |
1137 inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg | |
1138 inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg | |
1139 inline void get_int() { _arguments->push_int(va_arg(_ap, jint)); } | |
1140 | |
1141 // each of these paths is exercized by the various jck Call[Static,Nonvirtual,][Void,Int,..]Method[A,V,] tests | |
1142 | |
1143 inline void get_long() { _arguments->push_long(va_arg(_ap, jlong)); } | |
1144 inline void get_float() { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg | |
1145 inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); } | |
1146 inline void get_object() { jobject l = va_arg(_ap, jobject); | |
1147 _arguments->push_oop(Handle((oop *)l, false)); } | |
1148 | |
1149 inline void set_ap(va_list rap) { | |
1150 #ifdef va_copy | |
1151 va_copy(_ap, rap); | |
1152 #elif defined (__va_copy) | |
1153 __va_copy(_ap, rap); | |
1154 #else | |
1155 _ap = rap; | |
1156 #endif | |
1157 } | |
1158 | |
1159 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1160 JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1161 : JNI_ArgumentPusher(signature) { |
0 | 1162 set_ap(rap); |
1163 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1164 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
|
1165 : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) { |
0 | 1166 set_ap(rap); |
1167 } | |
1168 | |
1169 // Optimized path if we have the bitvector form of signature | |
1170 void iterate( uint64_t fingerprint ) { | |
1171 if ( fingerprint == UCONST64(-1) ) SignatureIterator::iterate();// Must be too many arguments | |
1172 else { | |
1173 _return_type = (BasicType)((fingerprint >> static_feature_size) & | |
1174 result_feature_mask); | |
1175 | |
1176 assert(fingerprint, "Fingerprint should not be 0"); | |
1177 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | |
1178 while ( 1 ) { | |
1179 switch ( fingerprint & parameter_feature_mask ) { | |
1180 case bool_parm: | |
23633
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1181 get_bool(); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1182 break; |
0 | 1183 case char_parm: |
23633
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1184 get_char(); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1185 break; |
0 | 1186 case short_parm: |
23633
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1187 get_short(); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1188 break; |
0 | 1189 case byte_parm: |
23633
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1190 get_byte(); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1191 break; |
0 | 1192 case int_parm: |
1193 get_int(); | |
1194 break; | |
1195 case obj_parm: | |
1196 get_object(); | |
1197 break; | |
1198 case long_parm: | |
1199 get_long(); | |
1200 break; | |
1201 case float_parm: | |
1202 get_float(); | |
1203 break; | |
1204 case double_parm: | |
1205 get_double(); | |
1206 break; | |
1207 case done_parm: | |
1208 return; | |
1209 break; | |
1210 default: | |
1211 ShouldNotReachHere(); | |
1212 break; | |
1213 } | |
1214 fingerprint >>= parameter_feature_size; | |
1215 } | |
1216 } | |
1217 } | |
1218 }; | |
1219 | |
1220 | |
1221 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher { | |
1222 protected: | |
1223 const jvalue *_ap; | |
1224 | |
23633
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1225 inline void get_bool() { |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1226 // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1227 // 0 to JNI_FALSE. Boolean return values from native are normalized the same in |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1228 // TemplateInterpreterGenerator::generate_result_handler_for and |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1229 // SharedRuntime::generate_native_wrapper. |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1230 jboolean b = (_ap++)->z; |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1231 _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE)); |
e4a935cb6f71
8149170: Better byte behavior for native arguments
kevinw
parents:
23614
diff
changeset
|
1232 } |
0 | 1233 inline void get_char() { _arguments->push_int((jint)(_ap++)->c); } |
1234 inline void get_short() { _arguments->push_int((jint)(_ap++)->s); } | |
1235 inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); } | |
1236 inline void get_int() { _arguments->push_int((jint)(_ap++)->i); } | |
1237 | |
1238 inline void get_long() { _arguments->push_long((_ap++)->j); } | |
1239 inline void get_float() { _arguments->push_float((_ap++)->f); } | |
1240 inline void get_double() { _arguments->push_double((_ap++)->d);} | |
1241 inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); } | |
1242 | |
1243 inline void set_ap(const jvalue *rap) { _ap = rap; } | |
1244 | |
1245 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1246 JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1247 : JNI_ArgumentPusher(signature) { |
0 | 1248 set_ap(rap); |
1249 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1250 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
|
1251 : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) { |
0 | 1252 set_ap(rap); |
1253 } | |
1254 | |
1255 // Optimized path if we have the bitvector form of signature | |
1256 void iterate( uint64_t fingerprint ) { | |
1257 if ( fingerprint == UCONST64(-1) ) SignatureIterator::iterate(); // Must be too many arguments | |
1258 else { | |
1259 _return_type = (BasicType)((fingerprint >> static_feature_size) & | |
1260 result_feature_mask); | |
1261 assert(fingerprint, "Fingerprint should not be 0"); | |
1262 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | |
1263 while ( 1 ) { | |
1264 switch ( fingerprint & parameter_feature_mask ) { | |
1265 case bool_parm: | |
1266 get_bool(); | |
1267 break; | |
1268 case char_parm: | |
1269 get_char(); | |
1270 break; | |
1271 case short_parm: | |
1272 get_short(); | |
1273 break; | |
1274 case byte_parm: | |
1275 get_byte(); | |
1276 break; | |
1277 case int_parm: | |
1278 get_int(); | |
1279 break; | |
1280 case obj_parm: | |
1281 get_object(); | |
1282 break; | |
1283 case long_parm: | |
1284 get_long(); | |
1285 break; | |
1286 case float_parm: | |
1287 get_float(); | |
1288 break; | |
1289 case double_parm: | |
1290 get_double(); | |
1291 break; | |
1292 case done_parm: | |
1293 return; | |
1294 break; | |
1295 default: | |
1296 ShouldNotReachHere(); | |
1297 break; | |
1298 } | |
1299 fingerprint >>= parameter_feature_size; | |
1300 } | |
1301 } | |
1302 } | |
1303 }; | |
1304 | |
1305 | |
1306 enum JNICallType { | |
1307 JNI_STATIC, | |
1308 JNI_VIRTUAL, | |
1309 JNI_NONVIRTUAL | |
1310 }; | |
1311 | |
1312 | |
1313 | |
1314 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
|
1315 methodHandle method(THREAD, Method::resolve_jmethod_id(method_id)); |
0 | 1316 |
1317 // Create object to hold arguments for the JavaCall, and associate it with | |
1318 // the jni parser | |
1319 ResourceMark rm(THREAD); | |
1320 int number_of_parameters = method->size_of_parameters(); | |
1321 JavaCallArguments java_args(number_of_parameters); | |
1322 args->set_java_argument_object(&java_args); | |
1323 | |
1324 assert(method->is_static(), "method should be static"); | |
1325 | |
1326 // Fill out JavaCallArguments object | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1327 args->iterate( Fingerprinter(method).fingerprint() ); |
0 | 1328 // Initialize result type |
1329 result->set_type(args->get_ret_type()); | |
1330 | |
1331 // Invoke the method. Result is returned as oop. | |
1332 JavaCalls::call(result, method, &java_args, CHECK); | |
1333 | |
1334 // Convert result | |
1335 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | |
1336 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | |
1337 } | |
1338 } | |
1339 | |
1340 | |
1341 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | |
1342 oop recv = JNIHandles::resolve(receiver); | |
1343 if (recv == NULL) { | |
1344 THROW(vmSymbols::java_lang_NullPointerException()); | |
1345 } | |
1346 Handle h_recv(THREAD, recv); | |
1347 | |
1348 int number_of_parameters; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1349 Method* selected_method; |
0 | 1350 { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1351 Method* m = Method::resolve_jmethod_id(method_id); |
0 | 1352 number_of_parameters = m->size_of_parameters(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1353 Klass* holder = m->method_holder(); |
23062
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1354 if (call_type != JNI_VIRTUAL) { |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1355 selected_method = m; |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1356 } else if (!m->has_itable_index()) { |
0 | 1357 // non-interface call -- for that little speed boost, don't handlize |
1358 debug_only(No_Safepoint_Verifier nosafepoint;) | |
23062
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1359 // jni_GetMethodID makes sure class is linked and initialized |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1360 // so m should have a valid vtable index. |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1361 assert(m->valid_vtable_index(), "no valid vtable index"); |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1362 int vtbl_index = m->vtable_index(); |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1363 if (vtbl_index != Method::nonvirtual_vtable_index) { |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1364 Klass* k = h_recv->klass(); |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1365 // k might be an arrayKlassOop but all vtables start at |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1366 // the same place. The cast is to avoid virtual call and assertion. |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1367 InstanceKlass *ik = (InstanceKlass*)k; |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1368 selected_method = ik->method_at_vtable(vtbl_index); |
0 | 1369 } else { |
23062
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1370 // final method |
0 | 1371 selected_method = m; |
1372 } | |
1373 } else { | |
1374 // interface call | |
1375 KlassHandle h_holder(THREAD, holder); | |
1376 | |
23062
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1377 int itbl_index = m->itable_index(); |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1378 Klass* k = h_recv->klass(); |
3300e511bc3a
8072588: JVM crashes in JNI if toString is declared as an interface method
aeriksso
parents:
22974
diff
changeset
|
1379 selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); |
0 | 1380 } |
1381 } | |
1382 | |
1383 methodHandle method(THREAD, selected_method); | |
1384 | |
1385 // Create object to hold arguments for the JavaCall, and associate it with | |
1386 // the jni parser | |
1387 ResourceMark rm(THREAD); | |
1388 JavaCallArguments java_args(number_of_parameters); | |
1389 args->set_java_argument_object(&java_args); | |
1390 | |
1391 // handle arguments | |
1392 assert(!method->is_static(), "method should not be static"); | |
1393 args->push_receiver(h_recv); // Push jobject handle | |
1394 | |
1395 // Fill out JavaCallArguments object | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1396 args->iterate( Fingerprinter(method).fingerprint() ); |
0 | 1397 // Initialize result type |
1398 result->set_type(args->get_ret_type()); | |
1399 | |
1400 // Invoke the method. Result is returned as oop. | |
1401 JavaCalls::call(result, method, &java_args, CHECK); | |
1402 | |
1403 // Convert result | |
1404 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | |
1405 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | |
1406 } | |
1407 } | |
1408 | |
1409 | |
1410 static instanceOop alloc_object(jclass clazz, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1411 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
23746
0dceb4846c8c
8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types
gdub
parents:
23660
diff
changeset
|
1412 if (k == NULL) { |
0dceb4846c8c
8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types
gdub
parents:
23660
diff
changeset
|
1413 ResourceMark rm(THREAD); |
0dceb4846c8c
8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types
gdub
parents:
23660
diff
changeset
|
1414 THROW_(vmSymbols::java_lang_InstantiationException(), NULL); |
0dceb4846c8c
8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types
gdub
parents:
23660
diff
changeset
|
1415 } |
6983 | 1416 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
|
1417 InstanceKlass::cast(k())->initialize(CHECK_NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1418 instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD); |
0 | 1419 return ih; |
1420 } | |
1421 | |
4006 | 1422 #ifndef USDT2 |
0 | 1423 DT_RETURN_MARK_DECL(AllocObject, jobject); |
4006 | 1424 #else /* USDT2 */ |
1425 DT_RETURN_MARK_DECL(AllocObject, jobject | |
1426 , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref)); | |
1427 #endif /* USDT2 */ | |
0 | 1428 |
1429 JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) | |
1430 JNIWrapper("AllocObject"); | |
1431 | |
4006 | 1432 #ifndef USDT2 |
0 | 1433 DTRACE_PROBE2(hotspot_jni, AllocObject__entry, env, clazz); |
4006 | 1434 #else /* USDT2 */ |
1435 HOTSPOT_JNI_ALLOCOBJECT_ENTRY( | |
1436 env, clazz); | |
1437 #endif /* USDT2 */ | |
0 | 1438 jobject ret = NULL; |
1439 DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); | |
1440 | |
1441 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1442 ret = JNIHandles::make_local(env, i); | |
1443 return ret; | |
1444 JNI_END | |
1445 | |
4006 | 1446 #ifndef USDT2 |
0 | 1447 DT_RETURN_MARK_DECL(NewObjectA, jobject); |
4006 | 1448 #else /* USDT2 */ |
1449 DT_RETURN_MARK_DECL(NewObjectA, jobject | |
1450 , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref)); | |
1451 #endif /* USDT2 */ | |
0 | 1452 |
1453 JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args)) | |
1454 JNIWrapper("NewObjectA"); | |
4006 | 1455 #ifndef USDT2 |
0 | 1456 DTRACE_PROBE3(hotspot_jni, NewObjectA__entry, env, clazz, methodID); |
4006 | 1457 #else /* USDT2 */ |
1458 HOTSPOT_JNI_NEWOBJECTA_ENTRY( | |
1459 env, clazz, (uintptr_t) methodID); | |
1460 #endif /* USDT2 */ | |
0 | 1461 jobject obj = NULL; |
1462 DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); | |
1463 | |
1464 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1465 obj = JNIHandles::make_local(env, i); | |
1466 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1467 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1468 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1469 return obj; | |
1470 JNI_END | |
1471 | |
4006 | 1472 #ifndef USDT2 |
0 | 1473 DT_RETURN_MARK_DECL(NewObjectV, jobject); |
4006 | 1474 #else /* USDT2 */ |
1475 DT_RETURN_MARK_DECL(NewObjectV, jobject | |
1476 , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref)); | |
1477 #endif /* USDT2 */ | |
0 | 1478 |
1479 JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)) | |
1480 JNIWrapper("NewObjectV"); | |
4006 | 1481 #ifndef USDT2 |
0 | 1482 DTRACE_PROBE3(hotspot_jni, NewObjectV__entry, env, clazz, methodID); |
4006 | 1483 #else /* USDT2 */ |
1484 HOTSPOT_JNI_NEWOBJECTV_ENTRY( | |
1485 env, clazz, (uintptr_t) methodID); | |
1486 #endif /* USDT2 */ | |
0 | 1487 jobject obj = NULL; |
1488 DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); | |
1489 | |
1490 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1491 obj = JNIHandles::make_local(env, i); | |
1492 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1493 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1494 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1495 return obj; | |
1496 JNI_END | |
1497 | |
4006 | 1498 #ifndef USDT2 |
0 | 1499 DT_RETURN_MARK_DECL(NewObject, jobject); |
4006 | 1500 #else /* USDT2 */ |
1501 DT_RETURN_MARK_DECL(NewObject, jobject | |
1502 , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref)); | |
1503 #endif /* USDT2 */ | |
0 | 1504 |
1505 JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)) | |
1506 JNIWrapper("NewObject"); | |
4006 | 1507 #ifndef USDT2 |
0 | 1508 DTRACE_PROBE3(hotspot_jni, NewObject__entry, env, clazz, methodID); |
4006 | 1509 #else /* USDT2 */ |
1510 HOTSPOT_JNI_NEWOBJECT_ENTRY( | |
1511 env, clazz, (uintptr_t) methodID); | |
1512 #endif /* USDT2 */ | |
0 | 1513 jobject obj = NULL; |
1514 DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); | |
1515 | |
1516 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1517 obj = JNIHandles::make_local(env, i); | |
1518 va_list args; | |
1519 va_start(args, methodID); | |
1520 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1521 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1522 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1523 va_end(args); | |
1524 return obj; | |
1525 JNI_END | |
1526 | |
1527 | |
1528 JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj)) | |
1529 JNIWrapper("GetObjectClass"); | |
4006 | 1530 #ifndef USDT2 |
0 | 1531 DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); |
4006 | 1532 #else /* USDT2 */ |
1533 HOTSPOT_JNI_GETOBJECTCLASS_ENTRY( | |
1534 env, obj); | |
1535 #endif /* USDT2 */ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1536 Klass* k = JNIHandles::resolve_non_null(obj)->klass(); |
0 | 1537 jclass ret = |
6983 | 1538 (jclass) JNIHandles::make_local(env, k->java_mirror()); |
4006 | 1539 #ifndef USDT2 |
0 | 1540 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); |
4006 | 1541 #else /* USDT2 */ |
1542 HOTSPOT_JNI_GETOBJECTCLASS_RETURN( | |
1543 ret); | |
1544 #endif /* USDT2 */ | |
0 | 1545 return ret; |
1546 JNI_END | |
1547 | |
1548 JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)) | |
1549 JNIWrapper("IsInstanceOf"); | |
4006 | 1550 #ifndef USDT2 |
0 | 1551 DTRACE_PROBE3(hotspot_jni, IsInstanceOf__entry, env, obj, clazz); |
4006 | 1552 #else /* USDT2 */ |
1553 HOTSPOT_JNI_ISINSTANCEOF_ENTRY( | |
1554 env, obj, clazz); | |
1555 #endif /* USDT2 */ | |
0 | 1556 jboolean ret = JNI_TRUE; |
1557 if (obj != NULL) { | |
1558 ret = JNI_FALSE; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1559 Klass* k = java_lang_Class::as_Klass( |
0 | 1560 JNIHandles::resolve_non_null(clazz)); |
1561 if (k != NULL) { | |
1562 ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; | |
1563 } | |
1564 } | |
4006 | 1565 #ifndef USDT2 |
0 | 1566 DTRACE_PROBE1(hotspot_jni, IsInstanceOf__return, ret); |
4006 | 1567 #else /* USDT2 */ |
1568 HOTSPOT_JNI_ISINSTANCEOF_RETURN( | |
1569 ret); | |
1570 #endif /* USDT2 */ | |
0 | 1571 return ret; |
1572 JNI_END | |
1573 | |
1574 | |
1575 static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, | |
1576 const char *sig, bool is_static, TRAPS) { | |
1577 // %%%% This code should probably just call into a method in the LinkResolver | |
1578 // | |
1579 // The class should have been loaded (we have an instance of the class | |
1580 // passed in) so the method and signature should already be in the symbol | |
1581 // 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
|
1582 const char *name_to_probe = (name_str == NULL) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1583 ? vmSymbols::object_initializer_name()->as_C_string() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1584 : name_str; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1585 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
|
1586 TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1587 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1588 if (name == NULL || signature == NULL) { |
0 | 1589 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
1590 } | |
1591 | |
1592 // Throw a NoSuchMethodError exception if we have an instance of a | |
1593 // primitive java.lang.Class | |
1594 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) { | |
1595 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | |
1596 } | |
1597 | |
1598 KlassHandle klass(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1599 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 1600 |
1601 // 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
|
1602 // Method*s. |
6983 | 1603 klass()->initialize(CHECK_NULL); |
0 | 1604 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1605 Method* m; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1606 if (name == vmSymbols::object_initializer_name() || |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1607 name == vmSymbols::class_initializer_name()) { |
0 | 1608 // Never search superclasses for constructors |
1609 if (klass->oop_is_instance()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
1610 m = InstanceKlass::cast(klass())->find_method(name, signature); |
0 | 1611 } else { |
1612 m = NULL; | |
1613 } | |
1614 } else { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1615 m = klass->lookup_method(name, signature); |
12823
ac9cb1d5a202
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
12819
diff
changeset
|
1616 if (m == NULL && klass->oop_is_instance()) { |
ac9cb1d5a202
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
12819
diff
changeset
|
1617 m = InstanceKlass::cast(klass())->lookup_method_in_ordered_interfaces(name, signature); |
0 | 1618 } |
1619 } | |
1620 if (m == NULL || (m->is_static() != is_static)) { | |
1621 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | |
1622 } | |
1623 return m->jmethod_id(); | |
1624 } | |
1625 | |
1626 | |
1627 JNI_ENTRY(jmethodID, jni_GetMethodID(JNIEnv *env, jclass clazz, | |
1628 const char *name, const char *sig)) | |
1629 JNIWrapper("GetMethodID"); | |
4006 | 1630 #ifndef USDT2 |
0 | 1631 DTRACE_PROBE4(hotspot_jni, GetMethodID__entry, env, clazz, name, sig); |
4006 | 1632 #else /* USDT2 */ |
1633 HOTSPOT_JNI_GETMETHODID_ENTRY( | |
1634 env, clazz, (char *) name, (char *) sig); | |
1635 #endif /* USDT2 */ | |
0 | 1636 jmethodID ret = get_method_id(env, clazz, name, sig, false, thread); |
4006 | 1637 #ifndef USDT2 |
0 | 1638 DTRACE_PROBE1(hotspot_jni, GetMethodID__return, ret); |
4006 | 1639 #else /* USDT2 */ |
1640 HOTSPOT_JNI_GETMETHODID_RETURN( | |
1641 (uintptr_t) ret); | |
1642 #endif /* USDT2 */ | |
0 | 1643 return ret; |
1644 JNI_END | |
1645 | |
1646 | |
1647 JNI_ENTRY(jmethodID, jni_GetStaticMethodID(JNIEnv *env, jclass clazz, | |
1648 const char *name, const char *sig)) | |
1649 JNIWrapper("GetStaticMethodID"); | |
4006 | 1650 #ifndef USDT2 |
0 | 1651 DTRACE_PROBE4(hotspot_jni, GetStaticMethodID__entry, env, clazz, name, sig); |
4006 | 1652 #else /* USDT2 */ |
1653 HOTSPOT_JNI_GETSTATICMETHODID_ENTRY( | |
1654 env, (char *) clazz, (char *) name, (char *)sig); | |
1655 #endif /* USDT2 */ | |
0 | 1656 jmethodID ret = get_method_id(env, clazz, name, sig, true, thread); |
4006 | 1657 #ifndef USDT2 |
0 | 1658 DTRACE_PROBE1(hotspot_jni, GetStaticMethodID__return, ret); |
4006 | 1659 #else /* USDT2 */ |
1660 HOTSPOT_JNI_GETSTATICMETHODID_RETURN( | |
1661 (uintptr_t) ret); | |
1662 #endif /* USDT2 */ | |
0 | 1663 return ret; |
1664 JNI_END | |
1665 | |
1666 | |
1667 | |
1668 // | |
1669 // Calling Methods | |
1670 // | |
1671 | |
4006 | 1672 #ifndef USDT2 |
0 | 1673 #define DEFINE_CALLMETHOD(ResultType, Result, Tag) \ |
1674 \ | |
1675 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType);\ | |
1676 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType);\ | |
1677 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType);\ | |
1678 \ | |
1679 JNI_ENTRY(ResultType, \ | |
1680 jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ | |
1681 JNIWrapper("Call" XSTR(Result) "Method"); \ | |
1682 \ | |
4006 | 1683 DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID); \ |
0 | 1684 ResultType ret = 0;\ |
1685 DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ | |
1686 (const ResultType&)ret);\ | |
1687 \ | |
1688 va_list args; \ | |
1689 va_start(args, methodID); \ | |
1690 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1691 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1692 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1693 va_end(args); \ | |
1694 ret = jvalue.get_##ResultType(); \ | |
1695 return ret;\ | |
1696 JNI_END \ | |
1697 \ | |
1698 \ | |
1699 JNI_ENTRY(ResultType, \ | |
1700 jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ | |
1701 JNIWrapper("Call" XSTR(Result) "MethodV"); \ | |
1702 \ | |
4006 | 1703 DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID); \ |
0 | 1704 ResultType ret = 0;\ |
1705 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ | |
1706 (const ResultType&)ret);\ | |
1707 \ | |
1708 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1709 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1710 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1711 ret = jvalue.get_##ResultType(); \ | |
1712 return ret;\ | |
1713 JNI_END \ | |
1714 \ | |
1715 \ | |
1716 JNI_ENTRY(ResultType, \ | |
1717 jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ | |
1718 JNIWrapper("Call" XSTR(Result) "MethodA"); \ | |
4006 | 1719 DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID); \ |
0 | 1720 ResultType ret = 0;\ |
1721 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ | |
1722 (const ResultType&)ret);\ | |
1723 \ | |
1724 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1725 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 1726 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1727 ret = jvalue.get_##ResultType(); \ | |
1728 return ret;\ | |
1729 JNI_END | |
1730 | |
1731 // the runtime type of subword integral basic types is integer | |
1732 DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN) | |
1733 DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE) | |
1734 DEFINE_CALLMETHOD(jchar, Char, T_CHAR) | |
1735 DEFINE_CALLMETHOD(jshort, Short, T_SHORT) | |
1736 | |
1737 DEFINE_CALLMETHOD(jobject, Object, T_OBJECT) | |
1738 DEFINE_CALLMETHOD(jint, Int, T_INT) | |
1739 DEFINE_CALLMETHOD(jlong, Long, T_LONG) | |
1740 DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT) | |
1741 DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE) | |
1742 | |
1743 DT_VOID_RETURN_MARK_DECL(CallVoidMethod); | |
1744 DT_VOID_RETURN_MARK_DECL(CallVoidMethodV); | |
1745 DT_VOID_RETURN_MARK_DECL(CallVoidMethodA); | |
1746 | |
4006 | 1747 #else /* USDT2 */ |
1748 | |
1749 #define DEFINE_CALLMETHOD(ResultType, Result, Tag \ | |
1750 , EntryProbe, ReturnProbe) \ | |
1751 \ | |
1752 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType \ | |
1753 , ReturnProbe); \ | |
1754 \ | |
1755 JNI_ENTRY(ResultType, \ | |
1756 jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ | |
1757 JNIWrapper("Call" XSTR(Result) "Method"); \ | |
1758 \ | |
1759 EntryProbe; \ | |
1760 ResultType ret = 0;\ | |
1761 DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ | |
1762 (const ResultType&)ret);\ | |
1763 \ | |
1764 va_list args; \ | |
1765 va_start(args, methodID); \ | |
1766 JavaValue jvalue(Tag); \ | |
1767 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
1768 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | |
1769 va_end(args); \ | |
1770 ret = jvalue.get_##ResultType(); \ | |
1771 return ret;\ | |
1772 JNI_END | |
1773 | |
1774 // the runtime type of subword integral basic types is integer | |
1775 DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN | |
1776 , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1777 HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) | |
1778 DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE | |
1779 , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1780 HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) | |
1781 DEFINE_CALLMETHOD(jchar, Char, T_CHAR | |
1782 , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1783 HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) | |
1784 DEFINE_CALLMETHOD(jshort, Short, T_SHORT | |
1785 , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1786 HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) | |
1787 | |
1788 DEFINE_CALLMETHOD(jobject, Object, T_OBJECT | |
1789 , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1790 HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) | |
1791 DEFINE_CALLMETHOD(jint, Int, T_INT, | |
1792 HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1793 HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) | |
1794 DEFINE_CALLMETHOD(jlong, Long, T_LONG | |
1795 , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1796 HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) | |
1797 // Float and double probes don't return value because dtrace doesn't currently support it | |
1798 DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT | |
1799 , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1800 HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) | |
1801 DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE | |
1802 , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), | |
1803 HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) | |
1804 | |
1805 #define DEFINE_CALLMETHODV(ResultType, Result, Tag \ | |
1806 , EntryProbe, ReturnProbe) \ | |
1807 \ | |
1808 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType \ | |
1809 , ReturnProbe); \ | |
1810 \ | |
1811 JNI_ENTRY(ResultType, \ | |
1812 jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ | |
1813 JNIWrapper("Call" XSTR(Result) "MethodV"); \ | |
1814 \ | |
1815 EntryProbe;\ | |
1816 ResultType ret = 0;\ | |
1817 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ | |
1818 (const ResultType&)ret);\ | |
1819 \ | |
1820 JavaValue jvalue(Tag); \ | |
1821 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
1822 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | |
1823 ret = jvalue.get_##ResultType(); \ | |
1824 return ret;\ | |
1825 JNI_END | |
1826 | |
1827 // the runtime type of subword integral basic types is integer | |
1828 DEFINE_CALLMETHODV(jboolean, Boolean, T_BOOLEAN | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1829 , HOTSPOT_JNI_CALLBOOLEANMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1830 HOTSPOT_JNI_CALLBOOLEANMETHODV_RETURN(_ret_ref)) |
4006 | 1831 DEFINE_CALLMETHODV(jbyte, Byte, T_BYTE |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1832 , HOTSPOT_JNI_CALLBYTEMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1833 HOTSPOT_JNI_CALLBYTEMETHODV_RETURN(_ret_ref)) |
4006 | 1834 DEFINE_CALLMETHODV(jchar, Char, T_CHAR |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1835 , HOTSPOT_JNI_CALLCHARMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1836 HOTSPOT_JNI_CALLCHARMETHODV_RETURN(_ret_ref)) |
4006 | 1837 DEFINE_CALLMETHODV(jshort, Short, T_SHORT |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1838 , HOTSPOT_JNI_CALLSHORTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1839 HOTSPOT_JNI_CALLSHORTMETHODV_RETURN(_ret_ref)) |
4006 | 1840 |
1841 DEFINE_CALLMETHODV(jobject, Object, T_OBJECT | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1842 , HOTSPOT_JNI_CALLOBJECTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1843 HOTSPOT_JNI_CALLOBJECTMETHODV_RETURN(_ret_ref)) |
4006 | 1844 DEFINE_CALLMETHODV(jint, Int, T_INT, |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1845 HOTSPOT_JNI_CALLINTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1846 HOTSPOT_JNI_CALLINTMETHODV_RETURN(_ret_ref)) |
4006 | 1847 DEFINE_CALLMETHODV(jlong, Long, T_LONG |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1848 , HOTSPOT_JNI_CALLLONGMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1849 HOTSPOT_JNI_CALLLONGMETHODV_RETURN(_ret_ref)) |
4006 | 1850 // Float and double probes don't return value because dtrace doesn't currently support it |
1851 DEFINE_CALLMETHODV(jfloat, Float, T_FLOAT | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1852 , HOTSPOT_JNI_CALLFLOATMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1853 HOTSPOT_JNI_CALLFLOATMETHODV_RETURN()) |
4006 | 1854 DEFINE_CALLMETHODV(jdouble, Double, T_DOUBLE |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1855 , HOTSPOT_JNI_CALLDOUBLEMETHODV_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1856 HOTSPOT_JNI_CALLDOUBLEMETHODV_RETURN()) |
4006 | 1857 |
1858 #define DEFINE_CALLMETHODA(ResultType, Result, Tag \ | |
1859 , EntryProbe, ReturnProbe) \ | |
1860 \ | |
1861 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType \ | |
1862 , ReturnProbe); \ | |
1863 \ | |
1864 JNI_ENTRY(ResultType, \ | |
1865 jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ | |
1866 JNIWrapper("Call" XSTR(Result) "MethodA"); \ | |
1867 EntryProbe; \ | |
1868 ResultType ret = 0;\ | |
1869 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ | |
1870 (const ResultType&)ret);\ | |
1871 \ | |
1872 JavaValue jvalue(Tag); \ | |
1873 JNI_ArgumentPusherArray ap(methodID, args); \ | |
1874 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | |
1875 ret = jvalue.get_##ResultType(); \ | |
1876 return ret;\ | |
1877 JNI_END | |
1878 | |
1879 // the runtime type of subword integral basic types is integer | |
1880 DEFINE_CALLMETHODA(jboolean, Boolean, T_BOOLEAN | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1881 , HOTSPOT_JNI_CALLBOOLEANMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1882 HOTSPOT_JNI_CALLBOOLEANMETHODA_RETURN(_ret_ref)) |
4006 | 1883 DEFINE_CALLMETHODA(jbyte, Byte, T_BYTE |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1884 , HOTSPOT_JNI_CALLBYTEMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1885 HOTSPOT_JNI_CALLBYTEMETHODA_RETURN(_ret_ref)) |
4006 | 1886 DEFINE_CALLMETHODA(jchar, Char, T_CHAR |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1887 , HOTSPOT_JNI_CALLCHARMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1888 HOTSPOT_JNI_CALLCHARMETHODA_RETURN(_ret_ref)) |
4006 | 1889 DEFINE_CALLMETHODA(jshort, Short, T_SHORT |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1890 , HOTSPOT_JNI_CALLSHORTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1891 HOTSPOT_JNI_CALLSHORTMETHODA_RETURN(_ret_ref)) |
4006 | 1892 |
1893 DEFINE_CALLMETHODA(jobject, Object, T_OBJECT | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1894 , HOTSPOT_JNI_CALLOBJECTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1895 HOTSPOT_JNI_CALLOBJECTMETHODA_RETURN(_ret_ref)) |
4006 | 1896 DEFINE_CALLMETHODA(jint, Int, T_INT, |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1897 HOTSPOT_JNI_CALLINTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1898 HOTSPOT_JNI_CALLINTMETHODA_RETURN(_ret_ref)) |
4006 | 1899 DEFINE_CALLMETHODA(jlong, Long, T_LONG |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1900 , HOTSPOT_JNI_CALLLONGMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1901 HOTSPOT_JNI_CALLLONGMETHODA_RETURN(_ret_ref)) |
4006 | 1902 // Float and double probes don't return value because dtrace doesn't currently support it |
1903 DEFINE_CALLMETHODA(jfloat, Float, T_FLOAT | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1904 , HOTSPOT_JNI_CALLFLOATMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1905 HOTSPOT_JNI_CALLFLOATMETHODA_RETURN()) |
4006 | 1906 DEFINE_CALLMETHODA(jdouble, Double, T_DOUBLE |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1907 , HOTSPOT_JNI_CALLDOUBLEMETHODA_ENTRY(env, obj, (uintptr_t)methodID), |
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
1908 HOTSPOT_JNI_CALLDOUBLEMETHODA_RETURN()) |
4006 | 1909 |
1910 DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()); | |
1911 DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()); | |
1912 DT_VOID_RETURN_MARK_DECL(CallVoidMethodA, HOTSPOT_JNI_CALLVOIDMETHODA_RETURN()); | |
1913 | |
1914 #endif /* USDT2 */ | |
1915 | |
0 | 1916 JNI_ENTRY(void, jni_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)) |
1917 JNIWrapper("CallVoidMethod"); | |
4006 | 1918 #ifndef USDT2 |
0 | 1919 DTRACE_PROBE3(hotspot_jni, CallVoidMethod__entry, env, obj, methodID); |
4006 | 1920 #else /* USDT2 */ |
1921 HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY( | |
1922 env, obj, (uintptr_t) methodID); | |
1923 #endif /* USDT2 */ | |
0 | 1924 DT_VOID_RETURN_MARK(CallVoidMethod); |
1925 | |
1926 va_list args; | |
1927 va_start(args, methodID); | |
1928 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1929 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1930 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1931 va_end(args); | |
1932 JNI_END | |
1933 | |
1934 | |
1935 JNI_ENTRY(void, jni_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) | |
1936 JNIWrapper("CallVoidMethodV"); | |
4006 | 1937 #ifndef USDT2 |
0 | 1938 DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); |
4006 | 1939 #else /* USDT2 */ |
1940 HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY( | |
1941 env, obj, (uintptr_t) methodID); | |
1942 #endif /* USDT2 */ | |
0 | 1943 DT_VOID_RETURN_MARK(CallVoidMethodV); |
1944 | |
1945 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1946 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1947 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1948 JNI_END | |
1949 | |
1950 | |
1951 JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) | |
1952 JNIWrapper("CallVoidMethodA"); | |
4006 | 1953 #ifndef USDT2 |
0 | 1954 DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); |
4006 | 1955 #else /* USDT2 */ |
1956 HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY( | |
1957 env, obj, (uintptr_t) methodID); | |
1958 #endif /* USDT2 */ | |
0 | 1959 DT_VOID_RETURN_MARK(CallVoidMethodA); |
1960 | |
1961 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1962 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1963 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1964 JNI_END | |
1965 | |
1966 | |
4006 | 1967 #ifndef USDT2 |
0 | 1968 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ |
1969 \ | |
1970 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\ | |
1971 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType);\ | |
1972 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType);\ | |
1973 \ | |
1974 JNI_ENTRY(ResultType, \ | |
1975 jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ | |
1976 JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ | |
1977 \ | |
1978 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##Method__entry, env, obj, cls, methodID);\ | |
1979 ResultType ret;\ | |
1980 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ | |
1981 (const ResultType&)ret);\ | |
1982 \ | |
1983 va_list args; \ | |
1984 va_start(args, methodID); \ | |
1985 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1986 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1987 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1988 va_end(args); \ | |
1989 ret = jvalue.get_##ResultType(); \ | |
1990 return ret;\ | |
1991 JNI_END \ | |
1992 \ | |
1993 JNI_ENTRY(ResultType, \ | |
1994 jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ | |
1995 JNIWrapper("CallNonvitual" XSTR(Result) "#MethodV"); \ | |
1996 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodV__entry, env, obj, cls, methodID);\ | |
1997 ResultType ret;\ | |
1998 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ | |
1999 (const ResultType&)ret);\ | |
2000 \ | |
2001 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2002 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 2003 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
2004 ret = jvalue.get_##ResultType(); \ | |
2005 return ret;\ | |
2006 JNI_END \ | |
2007 \ | |
2008 JNI_ENTRY(ResultType, \ | |
2009 jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2010 JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ | |
2011 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodA__entry, env, obj, cls, methodID);\ | |
2012 ResultType ret;\ | |
2013 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ | |
2014 (const ResultType&)ret);\ | |
2015 \ | |
2016 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2017 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 2018 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
2019 ret = jvalue.get_##ResultType(); \ | |
2020 return ret;\ | |
2021 JNI_END | |
2022 | |
2023 // the runtime type of subword integral basic types is integer | |
2024 DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN) | |
2025 DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE) | |
2026 DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR) | |
2027 DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT) | |
2028 | |
2029 DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT) | |
2030 DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT) | |
2031 DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG) | |
2032 DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT) | |
2033 DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE) | |
2034 | |
2035 | |
2036 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod); | |
2037 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV); | |
2038 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA); | |
2039 | |
4006 | 2040 #else /* USDT2 */ |
2041 | |
2042 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag \ | |
2043 , EntryProbe, ReturnProbe) \ | |
2044 \ | |
2045 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType \ | |
2046 , ReturnProbe);\ | |
2047 \ | |
2048 JNI_ENTRY(ResultType, \ | |
2049 jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ | |
2050 JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ | |
2051 \ | |
2052 EntryProbe;\ | |
2053 ResultType ret;\ | |
2054 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ | |
2055 (const ResultType&)ret);\ | |
2056 \ | |
2057 va_list args; \ | |
2058 va_start(args, methodID); \ | |
2059 JavaValue jvalue(Tag); \ | |
2060 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2061 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | |
2062 va_end(args); \ | |
2063 ret = jvalue.get_##ResultType(); \ | |
2064 return ret;\ | |
2065 JNI_END | |
2066 | |
2067 // the runtime type of subword integral basic types is integer | |
2068 DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN | |
2069 , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2070 HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_RETURN(_ret_ref)) | |
2071 DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE | |
2072 , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2073 HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_RETURN(_ret_ref)) | |
2074 DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR | |
2075 , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2076 HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_RETURN(_ret_ref)) | |
2077 DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT | |
2078 , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2079 HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_RETURN(_ret_ref)) | |
2080 | |
2081 DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT | |
2082 , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2083 HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_RETURN(_ret_ref)) | |
2084 DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT | |
2085 , HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2086 HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_RETURN(_ret_ref)) | |
2087 DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG | |
2088 , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2089 // Float and double probes don't return value because dtrace doesn't currently support it | |
2090 HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_RETURN(_ret_ref)) | |
2091 DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT | |
2092 , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2093 HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_RETURN()) | |
2094 DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE | |
2095 , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2096 HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_RETURN()) | |
2097 | |
2098 #define DEFINE_CALLNONVIRTUALMETHODV(ResultType, Result, Tag \ | |
2099 , EntryProbe, ReturnProbe) \ | |
2100 \ | |
2101 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType \ | |
2102 , ReturnProbe);\ | |
2103 \ | |
2104 JNI_ENTRY(ResultType, \ | |
2105 jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ | |
2106 JNIWrapper("CallNonvitual" XSTR(Result) "MethodV"); \ | |
2107 \ | |
2108 EntryProbe;\ | |
2109 ResultType ret;\ | |
2110 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ | |
2111 (const ResultType&)ret);\ | |
2112 \ | |
2113 JavaValue jvalue(Tag); \ | |
2114 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2115 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | |
2116 ret = jvalue.get_##ResultType(); \ | |
2117 return ret;\ | |
2118 JNI_END | |
2119 | |
2120 // the runtime type of subword integral basic types is integer | |
2121 DEFINE_CALLNONVIRTUALMETHODV(jboolean, Boolean, T_BOOLEAN | |
2122 , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2123 HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_RETURN(_ret_ref)) | |
2124 DEFINE_CALLNONVIRTUALMETHODV(jbyte, Byte, T_BYTE | |
2125 , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2126 HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_RETURN(_ret_ref)) | |
2127 DEFINE_CALLNONVIRTUALMETHODV(jchar, Char, T_CHAR | |
2128 , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2129 HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_RETURN(_ret_ref)) | |
2130 DEFINE_CALLNONVIRTUALMETHODV(jshort, Short, T_SHORT | |
2131 , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2132 HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_RETURN(_ret_ref)) | |
2133 | |
2134 DEFINE_CALLNONVIRTUALMETHODV(jobject, Object, T_OBJECT | |
2135 , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2136 HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_RETURN(_ret_ref)) | |
2137 DEFINE_CALLNONVIRTUALMETHODV(jint, Int, T_INT | |
2138 , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2139 HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_RETURN(_ret_ref)) | |
2140 DEFINE_CALLNONVIRTUALMETHODV(jlong, Long, T_LONG | |
2141 , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2142 // Float and double probes don't return value because dtrace doesn't currently support it | |
2143 HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_RETURN(_ret_ref)) | |
2144 DEFINE_CALLNONVIRTUALMETHODV(jfloat, Float, T_FLOAT | |
2145 , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2146 HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_RETURN()) | |
2147 DEFINE_CALLNONVIRTUALMETHODV(jdouble, Double, T_DOUBLE | |
2148 , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2149 HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_RETURN()) | |
2150 | |
2151 #define DEFINE_CALLNONVIRTUALMETHODA(ResultType, Result, Tag \ | |
2152 , EntryProbe, ReturnProbe) \ | |
2153 \ | |
2154 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType \ | |
2155 , ReturnProbe);\ | |
2156 \ | |
2157 JNI_ENTRY(ResultType, \ | |
2158 jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2159 JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ | |
2160 \ | |
2161 EntryProbe;\ | |
2162 ResultType ret;\ | |
2163 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ | |
2164 (const ResultType&)ret);\ | |
2165 \ | |
2166 JavaValue jvalue(Tag); \ | |
2167 JNI_ArgumentPusherArray ap(methodID, args); \ | |
2168 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | |
2169 ret = jvalue.get_##ResultType(); \ | |
2170 return ret;\ | |
2171 JNI_END | |
2172 | |
2173 // the runtime type of subword integral basic types is integer | |
2174 DEFINE_CALLNONVIRTUALMETHODA(jboolean, Boolean, T_BOOLEAN | |
2175 , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2176 HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_RETURN(_ret_ref)) | |
2177 DEFINE_CALLNONVIRTUALMETHODA(jbyte, Byte, T_BYTE | |
2178 , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2179 HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_RETURN(_ret_ref)) | |
2180 DEFINE_CALLNONVIRTUALMETHODA(jchar, Char, T_CHAR | |
2181 , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2182 HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_RETURN(_ret_ref)) | |
2183 DEFINE_CALLNONVIRTUALMETHODA(jshort, Short, T_SHORT | |
2184 , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2185 HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_RETURN(_ret_ref)) | |
2186 | |
2187 DEFINE_CALLNONVIRTUALMETHODA(jobject, Object, T_OBJECT | |
2188 , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2189 HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_RETURN(_ret_ref)) | |
2190 DEFINE_CALLNONVIRTUALMETHODA(jint, Int, T_INT | |
2191 , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2192 HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_RETURN(_ret_ref)) | |
2193 DEFINE_CALLNONVIRTUALMETHODA(jlong, Long, T_LONG | |
2194 , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2195 // Float and double probes don't return value because dtrace doesn't currently support it | |
2196 HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_RETURN(_ret_ref)) | |
2197 DEFINE_CALLNONVIRTUALMETHODA(jfloat, Float, T_FLOAT | |
2198 , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2199 HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_RETURN()) | |
2200 DEFINE_CALLNONVIRTUALMETHODA(jdouble, Double, T_DOUBLE | |
2201 , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), | |
2202 HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_RETURN()) | |
2203 | |
2204 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod | |
2205 , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_RETURN()); | |
2206 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV | |
2207 , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN()); | |
2208 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA | |
2209 , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN()); | |
2210 #endif /* USDT2 */ | |
2211 | |
0 | 2212 JNI_ENTRY(void, jni_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) |
2213 JNIWrapper("CallNonvirtualVoidMethod"); | |
2214 | |
4006 | 2215 #ifndef USDT2 |
0 | 2216 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethod__entry, |
2217 env, obj, cls, methodID); | |
4006 | 2218 #else /* USDT2 */ |
2219 HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY( | |
2220 env, obj, cls, (uintptr_t) methodID); | |
2221 #endif /* USDT2 */ | |
0 | 2222 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); |
2223 | |
2224 va_list args; | |
2225 va_start(args, methodID); | |
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 va_end(args); | |
2230 JNI_END | |
2231 | |
2232 | |
2233 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) | |
2234 JNIWrapper("CallNonvirtualVoidMethodV"); | |
2235 | |
4006 | 2236 #ifndef USDT2 |
0 | 2237 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, |
2238 env, obj, cls, methodID); | |
4006 | 2239 #else /* USDT2 */ |
2240 HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY( | |
2241 env, obj, cls, (uintptr_t) methodID); | |
2242 #endif /* USDT2 */ | |
0 | 2243 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); |
2244 | |
2245 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2246 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2247 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
2248 JNI_END | |
2249 | |
2250 | |
2251 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) | |
2252 JNIWrapper("CallNonvirtualVoidMethodA"); | |
4006 | 2253 #ifndef USDT2 |
0 | 2254 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, |
2255 env, obj, cls, methodID); | |
4006 | 2256 #else /* USDT2 */ |
2257 HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY( | |
2258 env, obj, cls, (uintptr_t) methodID); | |
2259 #endif /* USDT2 */ | |
0 | 2260 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); |
2261 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2262 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 2263 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
2264 JNI_END | |
2265 | |
2266 | |
4006 | 2267 #ifndef USDT2 |
0 | 2268 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ |
2269 \ | |
2270 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType);\ | |
2271 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType);\ | |
2272 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType);\ | |
2273 \ | |
2274 JNI_ENTRY(ResultType, \ | |
2275 jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ | |
2276 JNIWrapper("CallStatic" XSTR(Result) "Method"); \ | |
2277 \ | |
2278 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##Method__entry, env, cls, methodID);\ | |
2279 ResultType ret = 0;\ | |
2280 DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ | |
2281 (const ResultType&)ret);\ | |
2282 \ | |
2283 va_list args; \ | |
2284 va_start(args, methodID); \ | |
2285 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2286 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 2287 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2288 va_end(args); \ | |
2289 ret = jvalue.get_##ResultType(); \ | |
2290 return ret;\ | |
2291 JNI_END \ | |
2292 \ | |
2293 JNI_ENTRY(ResultType, \ | |
2294 jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ | |
2295 JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ | |
2296 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodV__entry, env, cls, methodID);\ | |
2297 ResultType ret = 0;\ | |
2298 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ | |
2299 (const ResultType&)ret);\ | |
2300 \ | |
2301 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2302 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 2303 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2304 ret = jvalue.get_##ResultType(); \ | |
2305 return ret;\ | |
2306 JNI_END \ | |
2307 \ | |
2308 JNI_ENTRY(ResultType, \ | |
2309 jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2310 JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ | |
2311 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodA__entry, env, cls, methodID);\ | |
2312 ResultType ret = 0;\ | |
2313 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ | |
2314 (const ResultType&)ret);\ | |
2315 \ | |
2316 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2317 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 2318 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2319 ret = jvalue.get_##ResultType(); \ | |
2320 return ret;\ | |
2321 JNI_END | |
2322 | |
2323 // the runtime type of subword integral basic types is integer | |
2324 DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN) | |
2325 DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE) | |
2326 DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR) | |
2327 DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT) | |
2328 | |
2329 DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT) | |
2330 DEFINE_CALLSTATICMETHOD(jint, Int, T_INT) | |
2331 DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG) | |
2332 DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT) | |
2333 DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE) | |
2334 | |
2335 | |
2336 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod); | |
2337 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV); | |
2338 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA); | |
2339 | |
4006 | 2340 #else /* USDT2 */ |
2341 | |
2342 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag \ | |
2343 , EntryProbe, ResultProbe) \ | |
2344 \ | |
2345 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType \ | |
2346 , ResultProbe); \ | |
2347 \ | |
2348 JNI_ENTRY(ResultType, \ | |
2349 jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ | |
2350 JNIWrapper("CallStatic" XSTR(Result) "Method"); \ | |
2351 \ | |
2352 EntryProbe; \ | |
2353 ResultType ret = 0;\ | |
2354 DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ | |
2355 (const ResultType&)ret);\ | |
2356 \ | |
2357 va_list args; \ | |
2358 va_start(args, methodID); \ | |
2359 JavaValue jvalue(Tag); \ | |
2360 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2361 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | |
2362 va_end(args); \ | |
2363 ret = jvalue.get_##ResultType(); \ | |
2364 return ret;\ | |
2365 JNI_END | |
2366 | |
2367 // the runtime type of subword integral basic types is integer | |
2368 DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN | |
2369 , HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2370 HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_RETURN(_ret_ref)); | |
2371 DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE | |
2372 , HOTSPOT_JNI_CALLSTATICBYTEMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2373 HOTSPOT_JNI_CALLSTATICBYTEMETHOD_RETURN(_ret_ref)); | |
2374 DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR | |
2375 , HOTSPOT_JNI_CALLSTATICCHARMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2376 HOTSPOT_JNI_CALLSTATICCHARMETHOD_RETURN(_ret_ref)); | |
2377 DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT | |
2378 , HOTSPOT_JNI_CALLSTATICSHORTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2379 HOTSPOT_JNI_CALLSTATICSHORTMETHOD_RETURN(_ret_ref)); | |
2380 | |
2381 DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT | |
2382 , HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2383 HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_RETURN(_ret_ref)); | |
2384 DEFINE_CALLSTATICMETHOD(jint, Int, T_INT | |
2385 , HOTSPOT_JNI_CALLSTATICINTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2386 HOTSPOT_JNI_CALLSTATICINTMETHOD_RETURN(_ret_ref)); | |
2387 DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG | |
2388 , HOTSPOT_JNI_CALLSTATICLONGMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2389 HOTSPOT_JNI_CALLSTATICLONGMETHOD_RETURN(_ret_ref)); | |
2390 // Float and double probes don't return value because dtrace doesn't currently support it | |
2391 DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT | |
2392 , HOTSPOT_JNI_CALLSTATICFLOATMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2393 HOTSPOT_JNI_CALLSTATICFLOATMETHOD_RETURN()); | |
2394 DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE | |
2395 , HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_ENTRY(env, cls, (uintptr_t)methodID), | |
2396 HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_RETURN()); | |
2397 | |
2398 #define DEFINE_CALLSTATICMETHODV(ResultType, Result, Tag \ | |
2399 , EntryProbe, ResultProbe) \ | |
2400 \ | |
2401 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType \ | |
2402 , ResultProbe); \ | |
2403 \ | |
2404 JNI_ENTRY(ResultType, \ | |
2405 jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ | |
2406 JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ | |
2407 \ | |
2408 EntryProbe; \ | |
2409 ResultType ret = 0;\ | |
2410 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ | |
2411 (const ResultType&)ret);\ | |
2412 \ | |
2413 JavaValue jvalue(Tag); \ | |
2414 JNI_ArgumentPusherVaArg ap(methodID, args); \ | |
2415 /* 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
|
2416 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \ |
6983 | 2417 k()->initialize(CHECK_0); \ |
4006 | 2418 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2419 va_end(args); \ | |
2420 ret = jvalue.get_##ResultType(); \ | |
2421 return ret;\ | |
2422 JNI_END | |
2423 | |
2424 // the runtime type of subword integral basic types is integer | |
2425 DEFINE_CALLSTATICMETHODV(jboolean, Boolean, T_BOOLEAN | |
2426 , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2427 HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_RETURN(_ret_ref)); | |
2428 DEFINE_CALLSTATICMETHODV(jbyte, Byte, T_BYTE | |
2429 , HOTSPOT_JNI_CALLSTATICBYTEMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2430 HOTSPOT_JNI_CALLSTATICBYTEMETHODV_RETURN(_ret_ref)); | |
2431 DEFINE_CALLSTATICMETHODV(jchar, Char, T_CHAR | |
2432 , HOTSPOT_JNI_CALLSTATICCHARMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2433 HOTSPOT_JNI_CALLSTATICCHARMETHODV_RETURN(_ret_ref)); | |
2434 DEFINE_CALLSTATICMETHODV(jshort, Short, T_SHORT | |
2435 , HOTSPOT_JNI_CALLSTATICSHORTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2436 HOTSPOT_JNI_CALLSTATICSHORTMETHODV_RETURN(_ret_ref)); | |
2437 | |
2438 DEFINE_CALLSTATICMETHODV(jobject, Object, T_OBJECT | |
2439 , HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2440 HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_RETURN(_ret_ref)); | |
2441 DEFINE_CALLSTATICMETHODV(jint, Int, T_INT | |
2442 , HOTSPOT_JNI_CALLSTATICINTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2443 HOTSPOT_JNI_CALLSTATICINTMETHODV_RETURN(_ret_ref)); | |
2444 DEFINE_CALLSTATICMETHODV(jlong, Long, T_LONG | |
2445 , HOTSPOT_JNI_CALLSTATICLONGMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2446 HOTSPOT_JNI_CALLSTATICLONGMETHODV_RETURN(_ret_ref)); | |
2447 // Float and double probes don't return value because dtrace doesn't currently support it | |
2448 DEFINE_CALLSTATICMETHODV(jfloat, Float, T_FLOAT | |
2449 , HOTSPOT_JNI_CALLSTATICFLOATMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2450 HOTSPOT_JNI_CALLSTATICFLOATMETHODV_RETURN()); | |
2451 DEFINE_CALLSTATICMETHODV(jdouble, Double, T_DOUBLE | |
2452 , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_ENTRY(env, cls, (uintptr_t)methodID), | |
2453 HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_RETURN()); | |
2454 | |
2455 #define DEFINE_CALLSTATICMETHODA(ResultType, Result, Tag \ | |
2456 , EntryProbe, ResultProbe) \ | |
2457 \ | |
2458 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType \ | |
2459 , ResultProbe); \ | |
2460 \ | |
2461 JNI_ENTRY(ResultType, \ | |
2462 jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
2463 JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ | |
2464 \ | |
2465 EntryProbe; \ | |
2466 ResultType ret = 0;\ | |
2467 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ | |
2468 (const ResultType&)ret);\ | |
2469 \ | |
2470 JavaValue jvalue(Tag); \ | |
2471 JNI_ArgumentPusherArray ap(methodID, args); \ | |
2472 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | |
2473 ret = jvalue.get_##ResultType(); \ | |
2474 return ret;\ | |
2475 JNI_END | |
2476 | |
2477 // the runtime type of subword integral basic types is integer | |
2478 DEFINE_CALLSTATICMETHODA(jboolean, Boolean, T_BOOLEAN | |
2479 , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2480 HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_RETURN(_ret_ref)); | |
2481 DEFINE_CALLSTATICMETHODA(jbyte, Byte, T_BYTE | |
2482 , HOTSPOT_JNI_CALLSTATICBYTEMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2483 HOTSPOT_JNI_CALLSTATICBYTEMETHODA_RETURN(_ret_ref)); | |
2484 DEFINE_CALLSTATICMETHODA(jchar, Char, T_CHAR | |
2485 , HOTSPOT_JNI_CALLSTATICCHARMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2486 HOTSPOT_JNI_CALLSTATICCHARMETHODA_RETURN(_ret_ref)); | |
2487 DEFINE_CALLSTATICMETHODA(jshort, Short, T_SHORT | |
2488 , HOTSPOT_JNI_CALLSTATICSHORTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2489 HOTSPOT_JNI_CALLSTATICSHORTMETHODA_RETURN(_ret_ref)); | |
2490 | |
2491 DEFINE_CALLSTATICMETHODA(jobject, Object, T_OBJECT | |
2492 , HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2493 HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_RETURN(_ret_ref)); | |
2494 DEFINE_CALLSTATICMETHODA(jint, Int, T_INT | |
2495 , HOTSPOT_JNI_CALLSTATICINTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2496 HOTSPOT_JNI_CALLSTATICINTMETHODA_RETURN(_ret_ref)); | |
2497 DEFINE_CALLSTATICMETHODA(jlong, Long, T_LONG | |
2498 , HOTSPOT_JNI_CALLSTATICLONGMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2499 HOTSPOT_JNI_CALLSTATICLONGMETHODA_RETURN(_ret_ref)); | |
2500 // Float and double probes don't return value because dtrace doesn't currently support it | |
2501 DEFINE_CALLSTATICMETHODA(jfloat, Float, T_FLOAT | |
2502 , HOTSPOT_JNI_CALLSTATICFLOATMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2503 HOTSPOT_JNI_CALLSTATICFLOATMETHODA_RETURN()); | |
2504 DEFINE_CALLSTATICMETHODA(jdouble, Double, T_DOUBLE | |
2505 , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_ENTRY(env, cls, (uintptr_t)methodID), | |
2506 HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_RETURN()); | |
2507 | |
2508 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod | |
2509 , HOTSPOT_JNI_CALLSTATICVOIDMETHOD_RETURN()); | |
2510 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV | |
2511 , HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN()); | |
2512 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA | |
2513 , HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN()); | |
2514 #endif /* USDT2 */ | |
2515 | |
0 | 2516 JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...)) |
2517 JNIWrapper("CallStaticVoidMethod"); | |
4006 | 2518 #ifndef USDT2 |
0 | 2519 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethod__entry, env, cls, methodID); |
4006 | 2520 #else /* USDT2 */ |
2521 HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY( | |
2522 env, cls, (uintptr_t) methodID); | |
2523 #endif /* USDT2 */ | |
0 | 2524 DT_VOID_RETURN_MARK(CallStaticVoidMethod); |
2525 | |
2526 va_list args; | |
2527 va_start(args, methodID); | |
2528 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2529 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2530 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
2531 va_end(args); | |
2532 JNI_END | |
2533 | |
2534 | |
2535 JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) | |
2536 JNIWrapper("CallStaticVoidMethodV"); | |
4006 | 2537 #ifndef USDT2 |
0 | 2538 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); |
4006 | 2539 #else /* USDT2 */ |
2540 HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY( | |
2541 env, cls, (uintptr_t) methodID); | |
2542 #endif /* USDT2 */ | |
0 | 2543 DT_VOID_RETURN_MARK(CallStaticVoidMethodV); |
2544 | |
2545 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2546 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 2547 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
2548 JNI_END | |
2549 | |
2550 | |
2551 JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) | |
2552 JNIWrapper("CallStaticVoidMethodA"); | |
4006 | 2553 #ifndef USDT2 |
0 | 2554 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); |
4006 | 2555 #else /* USDT2 */ |
2556 HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY( | |
2557 env, cls, (uintptr_t) methodID); | |
2558 #endif /* USDT2 */ | |
0 | 2559 DT_VOID_RETURN_MARK(CallStaticVoidMethodA); |
2560 | |
2561 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2562 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 2563 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
2564 JNI_END | |
2565 | |
2566 | |
2567 // | |
2568 // Accessing Fields | |
2569 // | |
2570 | |
2571 | |
4006 | 2572 #ifndef USDT2 |
0 | 2573 DT_RETURN_MARK_DECL(GetFieldID, jfieldID); |
4006 | 2574 #else /* USDT2 */ |
2575 DT_RETURN_MARK_DECL(GetFieldID, jfieldID | |
2576 , HOTSPOT_JNI_GETFIELDID_RETURN((uintptr_t)_ret_ref)); | |
2577 #endif /* USDT2 */ | |
0 | 2578 |
2579 JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, | |
2580 const char *name, const char *sig)) | |
2581 JNIWrapper("GetFieldID"); | |
4006 | 2582 #ifndef USDT2 |
0 | 2583 DTRACE_PROBE4(hotspot_jni, GetFieldID__entry, env, clazz, name, sig); |
4006 | 2584 #else /* USDT2 */ |
2585 HOTSPOT_JNI_GETFIELDID_ENTRY( | |
2586 env, clazz, (char *) name, (char *) sig); | |
2587 #endif /* USDT2 */ | |
0 | 2588 jfieldID ret = 0; |
2589 DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); | |
2590 | |
2591 // The class should have been loaded (we have an instance of the class | |
2592 // passed in) so the field and signature should already be in the symbol | |
2593 // 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
|
2594 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2595 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2596 if (fieldname == NULL || signame == NULL) { |
0 | 2597 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2598 } | |
2599 KlassHandle k(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2600 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 2601 // Make sure class is initialized before handing id's out to fields |
6983 | 2602 k()->initialize(CHECK_NULL); |
0 | 2603 |
2604 fieldDescriptor fd; | |
6983 | 2605 if (!k()->oop_is_instance() || |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2606 !InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { |
0 | 2607 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2608 } | |
2609 | |
2610 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop | |
2611 // It may also have hash bits for k, if VerifyJNIFields is turned on. | |
2612 ret = jfieldIDWorkaround::to_instance_jfieldID(k(), fd.offset()); | |
2613 return ret; | |
2614 JNI_END | |
2615 | |
2616 | |
2617 JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)) | |
2618 JNIWrapper("GetObjectField"); | |
4006 | 2619 #ifndef USDT2 |
0 | 2620 DTRACE_PROBE3(hotspot_jni, GetObjectField__entry, env, obj, fieldID); |
4006 | 2621 #else /* USDT2 */ |
2622 HOTSPOT_JNI_GETOBJECTFIELD_ENTRY( | |
2623 env, obj, (uintptr_t) fieldID); | |
2624 #endif /* USDT2 */ | |
0 | 2625 oop o = JNIHandles::resolve_non_null(obj); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2626 Klass* k = o->klass(); |
0 | 2627 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2628 // Keep JVMTI addition small and only check enabled flag here. | |
2629 // jni_GetField_probe() assumes that is okay to create handles. | |
2630 if (JvmtiExport::should_post_field_access()) { | |
2631 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); | |
2632 } | |
2633 jobject ret = JNIHandles::make_local(env, o->obj_field(offset)); | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
2634 #if INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2635 // 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
|
2636 // 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
|
2637 // referent with the SATB barrier. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2638 if (UseG1GC) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2639 bool needs_barrier = false; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2640 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2641 if (ret != NULL && |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2642 offset == java_lang_ref_Reference::referent_offset && |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2643 InstanceKlass::cast(k)->reference_type() != REF_NONE) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2644 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
|
2645 needs_barrier = true; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2646 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2647 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2648 if (needs_barrier) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2649 oop referent = JNIHandles::resolve(ret); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2650 G1SATBCardTableModRefBS::enqueue(referent); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2651 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
2652 } |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7182
diff
changeset
|
2653 #endif // INCLUDE_ALL_GCS |
4006 | 2654 #ifndef USDT2 |
0 | 2655 DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); |
4006 | 2656 #else /* USDT2 */ |
2657 HOTSPOT_JNI_GETOBJECTFIELD_RETURN( | |
2658 ret); | |
2659 #endif /* USDT2 */ | |
0 | 2660 return ret; |
2661 JNI_END | |
2662 | |
2663 | |
4006 | 2664 #ifndef USDT2 |
0 | 2665 #define DEFINE_GETFIELD(Return,Fieldname,Result) \ |
2666 \ | |
2667 DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return);\ | |
2668 \ | |
2669 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ | |
2670 JNIWrapper("Get" XSTR(Result) "Field"); \ | |
2671 \ | |
2672 DTRACE_PROBE3(hotspot_jni, Get##Result##Field__entry, env, obj, fieldID);\ | |
2673 Return ret = 0;\ | |
2674 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | |
2675 \ | |
2676 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2677 Klass* k = o->klass(); \ |
0 | 2678 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2679 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2680 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | |
2681 /* and creates a ResetNoHandleMark. */ \ | |
2682 if (JvmtiExport::should_post_field_access()) { \ | |
2683 o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ | |
2684 } \ | |
2685 ret = o->Fieldname##_field(offset); \ | |
2686 return ret; \ | |
2687 JNI_END | |
2688 | |
2689 DEFINE_GETFIELD(jboolean, bool, Boolean) | |
2690 DEFINE_GETFIELD(jbyte, byte, Byte) | |
2691 DEFINE_GETFIELD(jchar, char, Char) | |
2692 DEFINE_GETFIELD(jshort, short, Short) | |
2693 DEFINE_GETFIELD(jint, int, Int) | |
2694 DEFINE_GETFIELD(jlong, long, Long) | |
2695 DEFINE_GETFIELD(jfloat, float, Float) | |
2696 DEFINE_GETFIELD(jdouble, double, Double) | |
2697 | |
4006 | 2698 #else /* USDT2 */ |
2699 | |
2700 #define DEFINE_GETFIELD(Return,Fieldname,Result \ | |
2701 , EntryProbe, ReturnProbe) \ | |
2702 \ | |
2703 DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return \ | |
2704 , ReturnProbe); \ | |
2705 \ | |
2706 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ | |
2707 JNIWrapper("Get" XSTR(Result) "Field"); \ | |
2708 \ | |
2709 EntryProbe; \ | |
2710 Return ret = 0;\ | |
2711 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | |
2712 \ | |
2713 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2714 Klass* k = o->klass(); \ |
4006 | 2715 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2716 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2717 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | |
2718 /* and creates a ResetNoHandleMark. */ \ | |
2719 if (JvmtiExport::should_post_field_access()) { \ | |
2720 o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ | |
2721 } \ | |
2722 ret = o->Fieldname##_field(offset); \ | |
2723 return ret; \ | |
2724 JNI_END | |
2725 | |
2726 DEFINE_GETFIELD(jboolean, bool, Boolean | |
2727 , HOTSPOT_JNI_GETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2728 HOTSPOT_JNI_GETBOOLEANFIELD_RETURN(_ret_ref)) | |
2729 DEFINE_GETFIELD(jbyte, byte, Byte | |
2730 , HOTSPOT_JNI_GETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2731 HOTSPOT_JNI_GETBYTEFIELD_RETURN(_ret_ref)) | |
2732 DEFINE_GETFIELD(jchar, char, Char | |
2733 , HOTSPOT_JNI_GETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2734 HOTSPOT_JNI_GETCHARFIELD_RETURN(_ret_ref)) | |
2735 DEFINE_GETFIELD(jshort, short, Short | |
2736 , HOTSPOT_JNI_GETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2737 HOTSPOT_JNI_GETSHORTFIELD_RETURN(_ret_ref)) | |
2738 DEFINE_GETFIELD(jint, int, Int | |
2739 , HOTSPOT_JNI_GETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2740 HOTSPOT_JNI_GETINTFIELD_RETURN(_ret_ref)) | |
2741 DEFINE_GETFIELD(jlong, long, Long | |
2742 , HOTSPOT_JNI_GETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2743 HOTSPOT_JNI_GETLONGFIELD_RETURN(_ret_ref)) | |
2744 // Float and double probes don't return value because dtrace doesn't currently support it | |
2745 DEFINE_GETFIELD(jfloat, float, Float | |
2746 , HOTSPOT_JNI_GETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2747 HOTSPOT_JNI_GETFLOATFIELD_RETURN()) | |
2748 DEFINE_GETFIELD(jdouble, double, Double | |
2749 , HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2750 HOTSPOT_JNI_GETDOUBLEFIELD_RETURN()) | |
2751 #endif /* USDT2 */ | |
2752 | |
0 | 2753 address jni_GetBooleanField_addr() { |
2754 return (address)jni_GetBooleanField; | |
2755 } | |
2756 address jni_GetByteField_addr() { | |
2757 return (address)jni_GetByteField; | |
2758 } | |
2759 address jni_GetCharField_addr() { | |
2760 return (address)jni_GetCharField; | |
2761 } | |
2762 address jni_GetShortField_addr() { | |
2763 return (address)jni_GetShortField; | |
2764 } | |
2765 address jni_GetIntField_addr() { | |
2766 return (address)jni_GetIntField; | |
2767 } | |
2768 address jni_GetLongField_addr() { | |
2769 return (address)jni_GetLongField; | |
2770 } | |
2771 address jni_GetFloatField_addr() { | |
2772 return (address)jni_GetFloatField; | |
2773 } | |
2774 address jni_GetDoubleField_addr() { | |
2775 return (address)jni_GetDoubleField; | |
2776 } | |
2777 | |
2778 JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject value)) | |
2779 JNIWrapper("SetObjectField"); | |
4006 | 2780 #ifndef USDT2 |
0 | 2781 DTRACE_PROBE4(hotspot_jni, SetObjectField__entry, env, obj, fieldID, value); |
4006 | 2782 #else /* USDT2 */ |
2783 HOTSPOT_JNI_SETOBJECTFIELD_ENTRY( | |
2784 env, obj, (uintptr_t) fieldID, value); | |
2785 #endif /* USDT2 */ | |
0 | 2786 oop o = JNIHandles::resolve_non_null(obj); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2787 Klass* k = o->klass(); |
0 | 2788 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2789 // Keep JVMTI addition small and only check enabled flag here. | |
2790 // jni_SetField_probe_nh() assumes that is not okay to create handles | |
2791 // and creates a ResetNoHandleMark. | |
2792 if (JvmtiExport::should_post_field_modification()) { | |
2793 jvalue field_value; | |
2794 field_value.l = value; | |
2795 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value); | |
2796 } | |
2797 o->obj_field_put(offset, JNIHandles::resolve(value)); | |
4006 | 2798 #ifndef USDT2 |
0 | 2799 DTRACE_PROBE(hotspot_jni, SetObjectField__return); |
4006 | 2800 #else /* USDT2 */ |
2801 HOTSPOT_JNI_SETOBJECTFIELD_RETURN( | |
2802 ); | |
2803 #endif /* USDT2 */ | |
0 | 2804 JNI_END |
2805 | |
4006 | 2806 #ifndef USDT2 |
0 | 2807 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType) \ |
2808 \ | |
2809 JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ | |
2810 JNIWrapper("Set" XSTR(Result) "Field"); \ | |
2811 \ | |
6837
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
2812 FP_SELECT_##Result( \ |
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
2813 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
|
2814 DTRACE_PROBE3(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID)); \ |
0 | 2815 \ |
2816 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2817 Klass* k = o->klass(); \ |
0 | 2818 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2819 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2820 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | |
2821 /* and creates a ResetNoHandleMark. */ \ | |
2822 if (JvmtiExport::should_post_field_modification()) { \ | |
2823 jvalue field_value; \ | |
2824 field_value.unionType = value; \ | |
2825 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ | |
2826 } \ | |
2827 o->Fieldname##_field_put(offset, value); \ | |
2828 DTRACE_PROBE(hotspot_jni, Set##Result##Field__return);\ | |
2829 JNI_END | |
2830 | |
2831 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z) | |
2832 DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b) | |
2833 DEFINE_SETFIELD(jchar, char, Char, 'C', c) | |
2834 DEFINE_SETFIELD(jshort, short, Short, 'S', s) | |
2835 DEFINE_SETFIELD(jint, int, Int, 'I', i) | |
2836 DEFINE_SETFIELD(jlong, long, Long, 'J', j) | |
2837 DEFINE_SETFIELD(jfloat, float, Float, 'F', f) | |
2838 DEFINE_SETFIELD(jdouble, double, Double, 'D', d) | |
2839 | |
4006 | 2840 #else /* USDT2 */ |
2841 | |
2842 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType \ | |
2843 , EntryProbe, ReturnProbe) \ | |
2844 \ | |
2845 JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ | |
2846 JNIWrapper("Set" XSTR(Result) "Field"); \ | |
2847 \ | |
2848 EntryProbe; \ | |
2849 \ | |
2850 oop o = JNIHandles::resolve_non_null(obj); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2851 Klass* k = o->klass(); \ |
4006 | 2852 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2853 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2854 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | |
2855 /* and creates a ResetNoHandleMark. */ \ | |
2856 if (JvmtiExport::should_post_field_modification()) { \ | |
2857 jvalue field_value; \ | |
2858 field_value.unionType = value; \ | |
2859 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ | |
2860 } \ | |
23614 | 2861 if (SigType == 'Z') { value = ((jboolean)value) & 1; } \ |
4006 | 2862 o->Fieldname##_field_put(offset, value); \ |
2863 ReturnProbe; \ | |
2864 JNI_END | |
2865 | |
2866 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z | |
2867 , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2868 HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) | |
2869 DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b | |
2870 , HOTSPOT_JNI_SETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2871 HOTSPOT_JNI_SETBYTEFIELD_RETURN()) | |
2872 DEFINE_SETFIELD(jchar, char, Char, 'C', c | |
2873 , HOTSPOT_JNI_SETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2874 HOTSPOT_JNI_SETCHARFIELD_RETURN()) | |
2875 DEFINE_SETFIELD(jshort, short, Short, 'S', s | |
2876 , HOTSPOT_JNI_SETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2877 HOTSPOT_JNI_SETSHORTFIELD_RETURN()) | |
2878 DEFINE_SETFIELD(jint, int, Int, 'I', i | |
2879 , HOTSPOT_JNI_SETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2880 HOTSPOT_JNI_SETINTFIELD_RETURN()) | |
2881 DEFINE_SETFIELD(jlong, long, Long, 'J', j | |
2882 , HOTSPOT_JNI_SETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), | |
2883 HOTSPOT_JNI_SETLONGFIELD_RETURN()) | |
2884 // Float and double probes don't return value because dtrace doesn't currently support it | |
2885 DEFINE_SETFIELD(jfloat, float, Float, 'F', f | |
2886 , HOTSPOT_JNI_SETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2887 HOTSPOT_JNI_SETFLOATFIELD_RETURN()) | |
2888 DEFINE_SETFIELD(jdouble, double, Double, 'D', d | |
2889 , HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), | |
2890 HOTSPOT_JNI_SETDOUBLEFIELD_RETURN()) | |
2891 #endif /* USDT2 */ | |
2892 | |
2893 #ifndef USDT2 | |
0 | 2894 DT_RETURN_MARK_DECL(ToReflectedField, jobject); |
4006 | 2895 #else /* USDT2 */ |
2896 DT_RETURN_MARK_DECL(ToReflectedField, jobject | |
2897 , HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN(_ret_ref)); | |
2898 #endif /* USDT2 */ | |
0 | 2899 |
2900 JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)) | |
2901 JNIWrapper("ToReflectedField"); | |
4006 | 2902 #ifndef USDT2 |
0 | 2903 DTRACE_PROBE4(hotspot_jni, ToReflectedField__entry, |
2904 env, cls, fieldID, isStatic); | |
4006 | 2905 #else /* USDT2 */ |
2906 HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY( | |
2907 env, cls, (uintptr_t) fieldID, isStatic); | |
2908 #endif /* USDT2 */ | |
0 | 2909 jobject ret = NULL; |
2910 DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); | |
2911 | |
2912 fieldDescriptor fd; | |
2913 bool found = false; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2914 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2915 |
2916 assert(jfieldIDWorkaround::is_static_jfieldID(fieldID) == (isStatic != 0), "invalid fieldID"); | |
2917 | |
2918 if (isStatic) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2919 // Static field. The fieldID a JNIid specifying the field holder and the offset within the Klass*. |
0 | 2920 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
2921 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
|
2922 found = id->find_local_field(&fd); |
0 | 2923 } else { |
2924 // Non-static field. The fieldID is really the offset of the field within the instanceOop. | |
2925 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
|
2926 found = InstanceKlass::cast(k)->find_field_from_offset(offset, false, &fd); |
0 | 2927 } |
2928 assert(found, "bad fieldID passed into jni_ToReflectedField"); | |
2929 oop reflected = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); | |
2930 ret = JNIHandles::make_local(env, reflected); | |
2931 return ret; | |
2932 JNI_END | |
2933 | |
2934 | |
2935 // | |
2936 // Accessing Static Fields | |
2937 // | |
4006 | 2938 #ifndef USDT2 |
0 | 2939 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID); |
4006 | 2940 #else /* USDT2 */ |
2941 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID | |
2942 , HOTSPOT_JNI_GETSTATICFIELDID_RETURN((uintptr_t)_ret_ref)); | |
2943 #endif /* USDT2 */ | |
0 | 2944 |
2945 JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, | |
2946 const char *name, const char *sig)) | |
2947 JNIWrapper("GetStaticFieldID"); | |
4006 | 2948 #ifndef USDT2 |
0 | 2949 DTRACE_PROBE4(hotspot_jni, GetStaticFieldID__entry, env, clazz, name, sig); |
4006 | 2950 #else /* USDT2 */ |
2951 HOTSPOT_JNI_GETSTATICFIELDID_ENTRY( | |
2952 env, clazz, (char *) name, (char *) sig); | |
2953 #endif /* USDT2 */ | |
0 | 2954 jfieldID ret = NULL; |
2955 DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); | |
2956 | |
2957 // The class should have been loaded (we have an instance of the class | |
2958 // passed in) so the field and signature should already be in the symbol | |
2959 // 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
|
2960 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2961 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2962 if (fieldname == NULL || signame == NULL) { |
0 | 2963 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2964 } | |
2965 KlassHandle k(THREAD, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2966 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 2967 // Make sure class is initialized before handing id's out to static fields |
6983 | 2968 k()->initialize(CHECK_NULL); |
0 | 2969 |
2970 fieldDescriptor fd; | |
6983 | 2971 if (!k()->oop_is_instance() || |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2972 !InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { |
0 | 2973 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2974 } | |
2975 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2976 // 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
|
2977 JNIid* id = fd.field_holder()->jni_id_for(fd.offset()); |
0 | 2978 debug_only(id->set_is_static_field_id();) |
2979 | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
2980 debug_only(id->verify(fd.field_holder())); |
0 | 2981 |
2982 ret = jfieldIDWorkaround::to_static_jfieldID(id); | |
2983 return ret; | |
2984 JNI_END | |
2985 | |
2986 | |
2987 JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)) | |
2988 JNIWrapper("GetStaticObjectField"); | |
4006 | 2989 #ifndef USDT2 |
0 | 2990 DTRACE_PROBE3(hotspot_jni, GetStaticObjectField__entry, env, clazz, fieldID); |
4006 | 2991 #else /* USDT2 */ |
2992 HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY( | |
2993 env, clazz, (uintptr_t) fieldID); | |
2994 #endif /* USDT2 */ | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
2995 #if INCLUDE_JNI_CHECK |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2996 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
|
2997 #endif // INCLUDE_JNI_CHECK |
0 | 2998 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
2999 assert(id->is_static_field_id(), "invalid static field id"); | |
3000 // Keep JVMTI addition small and only check enabled flag here. | |
3001 // jni_GetField_probe() assumes that is okay to create handles. | |
3002 if (JvmtiExport::should_post_field_access()) { | |
3003 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); | |
3004 } | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3005 jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset())); |
4006 | 3006 #ifndef USDT2 |
0 | 3007 DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret); |
4006 | 3008 #else /* USDT2 */ |
3009 HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN( | |
3010 ret); | |
3011 #endif /* USDT2 */ | |
0 | 3012 return ret; |
3013 JNI_END | |
3014 | |
4006 | 3015 #ifndef USDT2 |
0 | 3016 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result) \ |
3017 \ | |
3018 DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return);\ | |
3019 \ | |
3020 JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ | |
3021 JNIWrapper("GetStatic" XSTR(Result) "Field"); \ | |
3022 DTRACE_PROBE3(hotspot_jni, GetStatic##Result##Field__entry, env, clazz, fieldID);\ | |
3023 Return ret = 0;\ | |
3024 DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ | |
3025 (const Return&)ret);\ | |
3026 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3027 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3028 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3029 /* jni_GetField_probe() assumes that is okay to create handles. */ \ | |
3030 if (JvmtiExport::should_post_field_access()) { \ | |
3031 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ | |
3032 } \ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3033 ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ |
0 | 3034 return ret;\ |
3035 JNI_END | |
3036 | |
3037 DEFINE_GETSTATICFIELD(jboolean, bool, Boolean) | |
3038 DEFINE_GETSTATICFIELD(jbyte, byte, Byte) | |
3039 DEFINE_GETSTATICFIELD(jchar, char, Char) | |
3040 DEFINE_GETSTATICFIELD(jshort, short, Short) | |
3041 DEFINE_GETSTATICFIELD(jint, int, Int) | |
3042 DEFINE_GETSTATICFIELD(jlong, long, Long) | |
3043 DEFINE_GETSTATICFIELD(jfloat, float, Float) | |
3044 DEFINE_GETSTATICFIELD(jdouble, double, Double) | |
3045 | |
4006 | 3046 #else /* USDT2 */ |
3047 | |
3048 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result \ | |
3049 , EntryProbe, ReturnProbe) \ | |
3050 \ | |
3051 DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return \ | |
3052 , ReturnProbe); \ | |
3053 \ | |
3054 JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ | |
3055 JNIWrapper("GetStatic" XSTR(Result) "Field"); \ | |
3056 EntryProbe; \ | |
3057 Return ret = 0;\ | |
3058 DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ | |
3059 (const Return&)ret);\ | |
3060 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3061 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3062 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3063 /* jni_GetField_probe() assumes that is okay to create handles. */ \ | |
3064 if (JvmtiExport::should_post_field_access()) { \ | |
3065 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ | |
3066 } \ | |
3067 ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ | |
3068 return ret;\ | |
3069 JNI_END | |
3070 | |
3071 DEFINE_GETSTATICFIELD(jboolean, bool, Boolean | |
3072 , HOTSPOT_JNI_GETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBOOLEANFIELD_RETURN(_ret_ref)) | |
3073 DEFINE_GETSTATICFIELD(jbyte, byte, Byte | |
3074 , HOTSPOT_JNI_GETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBYTEFIELD_RETURN(_ret_ref) ) | |
3075 DEFINE_GETSTATICFIELD(jchar, char, Char | |
3076 , HOTSPOT_JNI_GETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICCHARFIELD_RETURN(_ret_ref) ) | |
3077 DEFINE_GETSTATICFIELD(jshort, short, Short | |
3078 , HOTSPOT_JNI_GETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICSHORTFIELD_RETURN(_ret_ref) ) | |
3079 DEFINE_GETSTATICFIELD(jint, int, Int | |
3080 , HOTSPOT_JNI_GETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICINTFIELD_RETURN(_ret_ref) ) | |
3081 DEFINE_GETSTATICFIELD(jlong, long, Long | |
3082 , HOTSPOT_JNI_GETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICLONGFIELD_RETURN(_ret_ref) ) | |
3083 // Float and double probes don't return value because dtrace doesn't currently support it | |
3084 DEFINE_GETSTATICFIELD(jfloat, float, Float | |
3085 , HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN() ) | |
3086 DEFINE_GETSTATICFIELD(jdouble, double, Double | |
3087 , HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN() ) | |
3088 #endif /* USDT2 */ | |
0 | 3089 |
3090 JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)) | |
3091 JNIWrapper("SetStaticObjectField"); | |
4006 | 3092 #ifndef USDT2 |
0 | 3093 DTRACE_PROBE4(hotspot_jni, SetStaticObjectField__entry, env, clazz, fieldID, value); |
4006 | 3094 #else /* USDT2 */ |
3095 HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY( | |
3096 env, clazz, (uintptr_t) fieldID, value); | |
3097 #endif /* USDT2 */ | |
0 | 3098 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
3099 assert(id->is_static_field_id(), "invalid static field id"); | |
3100 // Keep JVMTI addition small and only check enabled flag here. | |
3101 // jni_SetField_probe() assumes that is okay to create handles. | |
3102 if (JvmtiExport::should_post_field_modification()) { | |
3103 jvalue field_value; | |
3104 field_value.l = value; | |
3105 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value); | |
3106 } | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3107 id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value)); |
4006 | 3108 #ifndef USDT2 |
0 | 3109 DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return); |
4006 | 3110 #else /* USDT2 */ |
3111 HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN( | |
3112 ); | |
3113 #endif /* USDT2 */ | |
0 | 3114 JNI_END |
3115 | |
3116 | |
4006 | 3117 #ifndef USDT2 |
0 | 3118 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType) \ |
3119 \ | |
3120 JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ | |
3121 JNIWrapper("SetStatic" XSTR(Result) "Field"); \ | |
6837
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
3122 FP_SELECT_##Result( \ |
75982791ddb6
7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
coleenp
parents:
6831
diff
changeset
|
3123 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
|
3124 DTRACE_PROBE3(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID)); \ |
0 | 3125 \ |
3126 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3127 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3128 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3129 /* jni_SetField_probe() assumes that is okay to create handles. */ \ | |
3130 if (JvmtiExport::should_post_field_modification()) { \ | |
3131 jvalue field_value; \ | |
3132 field_value.unionType = value; \ | |
3133 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ | |
3134 } \ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
3135 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ |
0 | 3136 DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\ |
3137 JNI_END | |
3138 | |
3139 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z) | |
3140 DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b) | |
3141 DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c) | |
3142 DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s) | |
3143 DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i) | |
3144 DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j) | |
3145 DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f) | |
3146 DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d) | |
3147 | |
4006 | 3148 #else /* USDT2 */ |
3149 | |
3150 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType \ | |
3151 , EntryProbe, ReturnProbe) \ | |
3152 \ | |
3153 JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ | |
3154 JNIWrapper("SetStatic" XSTR(Result) "Field"); \ | |
3155 EntryProbe; \ | |
3156 \ | |
3157 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
3158 assert(id->is_static_field_id(), "invalid static field id"); \ | |
3159 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
3160 /* jni_SetField_probe() assumes that is okay to create handles. */ \ | |
3161 if (JvmtiExport::should_post_field_modification()) { \ | |
3162 jvalue field_value; \ | |
3163 field_value.unionType = value; \ | |
3164 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ | |
3165 } \ | |
23614 | 3166 if (SigType == 'Z') { value = ((jboolean)value) & 1; } \ |
4006 | 3167 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ |
3168 ReturnProbe;\ | |
3169 JNI_END | |
3170 | |
3171 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z | |
23467
c60b9a314312
8029726: On OS X some dtrace probe names are mismatched with Solaris
sla
parents:
23062
diff
changeset
|
3172 , HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), |
4006 | 3173 HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) |
3174 DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b | |
3175 , HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3176 HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN()) | |
3177 DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c | |
3178 , HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3179 HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN()) | |
3180 DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s | |
3181 , HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3182 HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN()) | |
3183 DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i | |
3184 , HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3185 HOTSPOT_JNI_SETSTATICINTFIELD_RETURN()) | |
3186 DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j | |
3187 , HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), | |
3188 HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN()) | |
3189 // Float and double probes don't return value because dtrace doesn't currently support it | |
3190 DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f | |
3191 , HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), | |
3192 HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN()) | |
3193 DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d | |
3194 , HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), | |
3195 HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN()) | |
3196 #endif /* USDT2 */ | |
0 | 3197 |
3198 // | |
3199 // String Operations | |
3200 // | |
3201 | |
3202 // Unicode Interface | |
3203 | |
4006 | 3204 #ifndef USDT2 |
0 | 3205 DT_RETURN_MARK_DECL(NewString, jstring); |
4006 | 3206 #else /* USDT2 */ |
3207 DT_RETURN_MARK_DECL(NewString, jstring | |
3208 , HOTSPOT_JNI_NEWSTRING_RETURN(_ret_ref)); | |
3209 #endif /* USDT2 */ | |
0 | 3210 |
3211 JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len)) | |
3212 JNIWrapper("NewString"); | |
4006 | 3213 #ifndef USDT2 |
0 | 3214 DTRACE_PROBE3(hotspot_jni, NewString__entry, env, unicodeChars, len); |
4006 | 3215 #else /* USDT2 */ |
3216 HOTSPOT_JNI_NEWSTRING_ENTRY( | |
3217 env, (uint16_t *) unicodeChars, len); | |
3218 #endif /* USDT2 */ | |
0 | 3219 jstring ret = NULL; |
3220 DT_RETURN_MARK(NewString, jstring, (const jstring&)ret); | |
3221 oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL); | |
3222 ret = (jstring) JNIHandles::make_local(env, string); | |
3223 return ret; | |
3224 JNI_END | |
3225 | |
3226 | |
3227 JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string)) | |
3228 JNIWrapper("GetStringLength"); | |
4006 | 3229 #ifndef USDT2 |
0 | 3230 DTRACE_PROBE2(hotspot_jni, GetStringLength__entry, env, string); |
4006 | 3231 #else /* USDT2 */ |
3232 HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY( | |
3233 env, string); | |
3234 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3235 jsize ret = 0; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3236 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
|
3237 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
|
3238 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
|
3239 } |
4006 | 3240 #ifndef USDT2 |
0 | 3241 DTRACE_PROBE1(hotspot_jni, GetStringLength__return, ret); |
4006 | 3242 #else /* USDT2 */ |
3243 HOTSPOT_JNI_GETSTRINGLENGTH_RETURN( | |
3244 ret); | |
3245 #endif /* USDT2 */ | |
0 | 3246 return ret; |
3247 JNI_END | |
3248 | |
3249 | |
3250 JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars( | |
3251 JNIEnv *env, jstring string, jboolean *isCopy)) | |
3252 JNIWrapper("GetStringChars"); | |
4006 | 3253 #ifndef USDT2 |
0 | 3254 DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); |
4006 | 3255 #else /* USDT2 */ |
3256 HOTSPOT_JNI_GETSTRINGCHARS_ENTRY( | |
3257 env, string, (uintptr_t *) isCopy); | |
3258 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3259 jchar* buf = NULL; |
0 | 3260 oop s = JNIHandles::resolve_non_null(string); |
3261 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
|
3262 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
|
3263 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
|
3264 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
|
3265 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
|
3266 /* 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
|
3267 if (buf != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3268 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
|
3269 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
|
3270 } |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3271 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
|
3272 //%note jni_5 |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3273 if (isCopy != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3274 *isCopy = JNI_TRUE; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3275 } |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3276 } |
0 | 3277 } |
4006 | 3278 #ifndef USDT2 |
0 | 3279 DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); |
4006 | 3280 #else /* USDT2 */ |
3281 HOTSPOT_JNI_GETSTRINGCHARS_RETURN( | |
3282 buf); | |
3283 #endif /* USDT2 */ | |
0 | 3284 return buf; |
3285 JNI_END | |
3286 | |
3287 | |
3288 JNI_QUICK_ENTRY(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)) | |
3289 JNIWrapper("ReleaseStringChars"); | |
4006 | 3290 #ifndef USDT2 |
0 | 3291 DTRACE_PROBE3(hotspot_jni, ReleaseStringChars__entry, env, str, chars); |
4006 | 3292 #else /* USDT2 */ |
3293 HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY( | |
3294 env, str, (uint16_t *) chars); | |
3295 #endif /* USDT2 */ | |
0 | 3296 //%note jni_6 |
3297 if (chars != NULL) { | |
3298 // Since String objects are supposed to be immutable, don't copy any | |
3299 // new data back. A bad user will have to go after the char array. | |
3300 FreeHeap((void*) chars); | |
3301 } | |
4006 | 3302 #ifndef USDT2 |
0 | 3303 DTRACE_PROBE(hotspot_jni, ReleaseStringChars__return); |
4006 | 3304 #else /* USDT2 */ |
3305 HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN( | |
3306 ); | |
3307 #endif /* USDT2 */ | |
0 | 3308 JNI_END |
3309 | |
3310 | |
3311 // UTF Interface | |
3312 | |
4006 | 3313 #ifndef USDT2 |
0 | 3314 DT_RETURN_MARK_DECL(NewStringUTF, jstring); |
4006 | 3315 #else /* USDT2 */ |
3316 DT_RETURN_MARK_DECL(NewStringUTF, jstring | |
3317 , HOTSPOT_JNI_NEWSTRINGUTF_RETURN(_ret_ref)); | |
3318 #endif /* USDT2 */ | |
0 | 3319 |
3320 JNI_ENTRY(jstring, jni_NewStringUTF(JNIEnv *env, const char *bytes)) | |
3321 JNIWrapper("NewStringUTF"); | |
4006 | 3322 #ifndef USDT2 |
0 | 3323 DTRACE_PROBE2(hotspot_jni, NewStringUTF__entry, env, bytes); |
4006 | 3324 #else /* USDT2 */ |
3325 HOTSPOT_JNI_NEWSTRINGUTF_ENTRY( | |
3326 env, (char *) bytes); | |
3327 #endif /* USDT2 */ | |
0 | 3328 jstring ret; |
3329 DT_RETURN_MARK(NewStringUTF, jstring, (const jstring&)ret); | |
3330 | |
3331 oop result = java_lang_String::create_oop_from_str((char*) bytes, CHECK_NULL); | |
3332 ret = (jstring) JNIHandles::make_local(env, result); | |
3333 return ret; | |
3334 JNI_END | |
3335 | |
3336 | |
3337 JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string)) | |
3338 JNIWrapper("GetStringUTFLength"); | |
4006 | 3339 #ifndef USDT2 |
0 | 3340 DTRACE_PROBE2(hotspot_jni, GetStringUTFLength__entry, env, string); |
4006 | 3341 #else /* USDT2 */ |
3342 HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY( | |
3343 env, string); | |
3344 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3345 jsize ret = 0; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3346 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
|
3347 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
|
3348 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
|
3349 } |
4006 | 3350 #ifndef USDT2 |
0 | 3351 DTRACE_PROBE1(hotspot_jni, GetStringUTFLength__return, ret); |
4006 | 3352 #else /* USDT2 */ |
3353 HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN( | |
3354 ret); | |
3355 #endif /* USDT2 */ | |
0 | 3356 return ret; |
3357 JNI_END | |
3358 | |
3359 | |
3360 JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) | |
3361 JNIWrapper("GetStringUTFChars"); | |
4006 | 3362 #ifndef USDT2 |
0 | 3363 DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy); |
4006 | 3364 #else /* USDT2 */ |
3365 HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY( | |
3366 env, string, (uintptr_t *) isCopy); | |
3367 #endif /* USDT2 */ | |
12819
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3368 char* result = NULL; |
1989
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1980
diff
changeset
|
3369 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
|
3370 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
|
3371 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
|
3372 /* 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
|
3373 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
|
3374 if (result != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3375 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
|
3376 if (isCopy != NULL) { |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3377 *isCopy = JNI_TRUE; |
f9be370a7d54
8025922: JNI access to Strings need to check if the value field is non-null
sla
parents:
12306
diff
changeset
|
3378 } |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3379 } |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3380 } |
4006 | 3381 #ifndef USDT2 |
0 | 3382 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); |
4006 | 3383 #else /* USDT2 */ |
3384 HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN( | |
3385 result); | |
3386 #endif /* USDT2 */ | |
0 | 3387 return result; |
3388 JNI_END | |
3389 | |
3390 | |
3391 JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars)) | |
3392 JNIWrapper("ReleaseStringUTFChars"); | |
4006 | 3393 #ifndef USDT2 |
0 | 3394 DTRACE_PROBE3(hotspot_jni, ReleaseStringUTFChars__entry, env, str, chars); |
4006 | 3395 #else /* USDT2 */ |
3396 HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY( | |
3397 env, str, (char *) chars); | |
3398 #endif /* USDT2 */ | |
0 | 3399 if (chars != NULL) { |
3400 FreeHeap((char*) chars); | |
3401 } | |
4006 | 3402 #ifndef USDT2 |
0 | 3403 DTRACE_PROBE(hotspot_jni, ReleaseStringUTFChars__return); |
4006 | 3404 #else /* USDT2 */ |
3405 HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN( | |
3406 ); | |
3407 #endif /* USDT2 */ | |
0 | 3408 JNI_END |
3409 | |
3410 | |
3411 JNI_QUICK_ENTRY(jsize, jni_GetArrayLength(JNIEnv *env, jarray array)) | |
3412 JNIWrapper("GetArrayLength"); | |
4006 | 3413 #ifndef USDT2 |
0 | 3414 DTRACE_PROBE2(hotspot_jni, GetArrayLength__entry, env, array); |
4006 | 3415 #else /* USDT2 */ |
3416 HOTSPOT_JNI_GETARRAYLENGTH_ENTRY( | |
3417 env, array); | |
3418 #endif /* USDT2 */ | |
0 | 3419 arrayOop a = arrayOop(JNIHandles::resolve_non_null(array)); |
3420 assert(a->is_array(), "must be array"); | |
3421 jsize ret = a->length(); | |
4006 | 3422 #ifndef USDT2 |
0 | 3423 DTRACE_PROBE1(hotspot_jni, GetArrayLength__return, ret); |
4006 | 3424 #else /* USDT2 */ |
3425 HOTSPOT_JNI_GETARRAYLENGTH_RETURN( | |
3426 ret); | |
3427 #endif /* USDT2 */ | |
0 | 3428 return ret; |
3429 JNI_END | |
3430 | |
3431 | |
3432 // | |
3433 // Object Array Operations | |
3434 // | |
3435 | |
4006 | 3436 #ifndef USDT2 |
0 | 3437 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray); |
4006 | 3438 #else /* USDT2 */ |
3439 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray | |
3440 , HOTSPOT_JNI_NEWOBJECTARRAY_RETURN(_ret_ref)); | |
3441 #endif /* USDT2 */ | |
0 | 3442 |
3443 JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)) | |
3444 JNIWrapper("NewObjectArray"); | |
4006 | 3445 #ifndef USDT2 |
0 | 3446 DTRACE_PROBE4(hotspot_jni, NewObjectArray__entry, env, length, elementClass, initialElement); |
4006 | 3447 #else /* USDT2 */ |
3448 HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY( | |
3449 env, length, elementClass, initialElement); | |
3450 #endif /* USDT2 */ | |
0 | 3451 jobjectArray ret = NULL; |
3452 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
|
3453 KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); |
6983 | 3454 Klass* ako = ek()->array_klass(CHECK_NULL); |
0 | 3455 KlassHandle ak = KlassHandle(THREAD, ako); |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3456 ObjArrayKlass::cast(ak())->initialize(CHECK_NULL); |
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3457 objArrayOop result = ObjArrayKlass::cast(ak())->allocate(length, CHECK_NULL); |
0 | 3458 oop initial_value = JNIHandles::resolve(initialElement); |
3459 if (initial_value != NULL) { // array already initialized with NULL | |
3460 for (int index = 0; index < length; index++) { | |
3461 result->obj_at_put(index, initial_value); | |
3462 } | |
3463 } | |
3464 ret = (jobjectArray) JNIHandles::make_local(env, result); | |
3465 return ret; | |
3466 JNI_END | |
3467 | |
4006 | 3468 #ifndef USDT2 |
0 | 3469 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject); |
4006 | 3470 #else /* USDT2 */ |
3471 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject | |
3472 , HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(_ret_ref)); | |
3473 #endif /* USDT2 */ | |
0 | 3474 |
3475 JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)) | |
3476 JNIWrapper("GetObjectArrayElement"); | |
4006 | 3477 #ifndef USDT2 |
0 | 3478 DTRACE_PROBE3(hotspot_jni, GetObjectArrayElement__entry, env, array, index); |
4006 | 3479 #else /* USDT2 */ |
3480 HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY( | |
3481 env, array, index); | |
3482 #endif /* USDT2 */ | |
0 | 3483 jobject ret = NULL; |
3484 DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); | |
3485 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); | |
3486 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
|
3487 ret = JNIHandles::make_local(env, a->obj_at(index)); |
0 | 3488 return ret; |
3489 } else { | |
3490 char buf[jintAsStringSize]; | |
3491 sprintf(buf, "%d", index); | |
3492 THROW_MSG_0(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), buf); | |
3493 } | |
3494 JNI_END | |
3495 | |
4006 | 3496 #ifndef USDT2 |
0 | 3497 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement); |
4006 | 3498 #else /* USDT2 */ |
3499 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement | |
3500 , HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN()); | |
3501 #endif /* USDT2 */ | |
0 | 3502 |
3503 JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value)) | |
3504 JNIWrapper("SetObjectArrayElement"); | |
4006 | 3505 #ifndef USDT2 |
0 | 3506 DTRACE_PROBE4(hotspot_jni, SetObjectArrayElement__entry, env, array, index, value); |
4006 | 3507 #else /* USDT2 */ |
3508 HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY( | |
3509 env, array, index, value); | |
3510 #endif /* USDT2 */ | |
0 | 3511 DT_VOID_RETURN_MARK(SetObjectArrayElement); |
3512 | |
3513 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); | |
3514 oop v = JNIHandles::resolve(value); | |
3515 if (a->is_within_bounds(index)) { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3516 if (v == NULL || v->is_a(ObjArrayKlass::cast(a->klass())->element_klass())) { |
0 | 3517 a->obj_at_put(index, v); |
3518 } else { | |
3519 THROW(vmSymbols::java_lang_ArrayStoreException()); | |
3520 } | |
3521 } else { | |
3522 char buf[jintAsStringSize]; | |
3523 sprintf(buf, "%d", index); | |
3524 THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), buf); | |
3525 } | |
3526 JNI_END | |
3527 | |
3528 | |
4006 | 3529 #ifndef USDT2 |
0 | 3530 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \ |
3531 \ | |
4006 | 3532 DT_RETURN_MARK_DECL(New##Result##Array, Return); \ |
0 | 3533 \ |
3534 JNI_ENTRY(Return, \ | |
3535 jni_New##Result##Array(JNIEnv *env, jsize len)) \ | |
3536 JNIWrapper("New" XSTR(Result) "Array"); \ | |
3537 DTRACE_PROBE2(hotspot_jni, New##Result##Array__entry, env, len);\ | |
3538 Return ret = NULL;\ | |
1034
08780c8a9f04
6893483: DTrace probe return values for a couple JNI methods are wrong
kamg
parents:
973
diff
changeset
|
3539 DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ |
0 | 3540 \ |
3541 oop obj= oopFactory::Allocator(len, CHECK_0); \ | |
3542 ret = (Return) JNIHandles::make_local(env, obj); \ | |
3543 return ret;\ | |
3544 JNI_END | |
3545 | |
3546 DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean) | |
3547 DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte) | |
3548 DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short) | |
3549 DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char) | |
3550 DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int) | |
3551 DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long) | |
3552 DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float) | |
3553 DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double) | |
3554 | |
4006 | 3555 #else /* USDT2 */ |
3556 | |
3557 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result \ | |
3558 ,EntryProbe,ReturnProbe) \ | |
3559 \ | |
3560 DT_RETURN_MARK_DECL(New##Result##Array, Return \ | |
3561 , ReturnProbe); \ | |
3562 \ | |
3563 JNI_ENTRY(Return, \ | |
3564 jni_New##Result##Array(JNIEnv *env, jsize len)) \ | |
3565 JNIWrapper("New" XSTR(Result) "Array"); \ | |
3566 EntryProbe; \ | |
3567 Return ret = NULL;\ | |
3568 DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ | |
3569 \ | |
3570 oop obj= oopFactory::Allocator(len, CHECK_0); \ | |
3571 ret = (Return) JNIHandles::make_local(env, obj); \ | |
3572 return ret;\ | |
3573 JNI_END | |
3574 | |
3575 DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean, | |
3576 HOTSPOT_JNI_NEWBOOLEANARRAY_ENTRY(env, len), | |
3577 HOTSPOT_JNI_NEWBOOLEANARRAY_RETURN(_ret_ref)) | |
3578 DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte, | |
3579 HOTSPOT_JNI_NEWBYTEARRAY_ENTRY(env, len), | |
3580 HOTSPOT_JNI_NEWBYTEARRAY_RETURN(_ret_ref)) | |
3581 DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short, | |
3582 HOTSPOT_JNI_NEWSHORTARRAY_ENTRY(env, len), | |
3583 HOTSPOT_JNI_NEWSHORTARRAY_RETURN(_ret_ref)) | |
3584 DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char, | |
3585 HOTSPOT_JNI_NEWCHARARRAY_ENTRY(env, len), | |
3586 HOTSPOT_JNI_NEWCHARARRAY_RETURN(_ret_ref)) | |
3587 DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int, | |
3588 HOTSPOT_JNI_NEWINTARRAY_ENTRY(env, len), | |
3589 HOTSPOT_JNI_NEWINTARRAY_RETURN(_ret_ref)) | |
3590 DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long, | |
3591 HOTSPOT_JNI_NEWLONGARRAY_ENTRY(env, len), | |
3592 HOTSPOT_JNI_NEWLONGARRAY_RETURN(_ret_ref)) | |
3593 DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float, | |
3594 HOTSPOT_JNI_NEWFLOATARRAY_ENTRY(env, len), | |
3595 HOTSPOT_JNI_NEWFLOATARRAY_RETURN(_ret_ref)) | |
3596 DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double, | |
3597 HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY(env, len), | |
3598 HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN(_ret_ref)) | |
3599 #endif /* USDT2 */ | |
0 | 3600 |
3601 // Return an address which will fault if the caller writes to it. | |
3602 | |
3603 static char* get_bad_address() { | |
3604 static char* bad_address = NULL; | |
3605 if (bad_address == NULL) { | |
3606 size_t size = os::vm_allocation_granularity(); | |
3607 bad_address = os::reserve_memory(size); | |
3608 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
|
3609 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
|
3610 /*is_committed*/false); |
20360 | 3611 MemTracker::record_virtual_memory_type((void*)bad_address, mtInternal); |
0 | 3612 } |
3613 } | |
3614 return bad_address; | |
3615 } | |
3616 | |
3617 | |
4006 | 3618 #ifndef USDT2 |
0 | 3619 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag) \ |
3620 \ | |
3621 JNI_QUICK_ENTRY(ElementType*, \ | |
3622 jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ | |
3623 JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ | |
3624 DTRACE_PROBE3(hotspot_jni, Get##Result##ArrayElements__entry, env, array, isCopy);\ | |
3625 /* allocate an chunk of memory in c land */ \ | |
3626 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3627 ElementType* result; \ | |
3628 int len = a->length(); \ | |
3629 if (len == 0) { \ | |
3630 /* Empty array: legal but useless, can't return NULL. \ | |
3631 * Return a pointer to something useless. \ | |
3632 * Avoid asserts in typeArrayOop. */ \ | |
3633 result = (ElementType*)get_bad_address(); \ | |
3634 } else { \ | |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3635 /* 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
|
3636 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
|
3637 if (result != NULL) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3638 /* 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
|
3639 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
|
3640 if (isCopy) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3641 *isCopy = JNI_TRUE; \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3642 } \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3643 } \ |
0 | 3644 } \ |
3645 DTRACE_PROBE1(hotspot_jni, Get##Result##ArrayElements__return, result);\ | |
3646 return result; \ | |
3647 JNI_END | |
3648 | |
3649 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | |
3650 DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) | |
3651 DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) | |
3652 DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) | |
3653 DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int) | |
3654 DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long) | |
3655 DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) | |
3656 DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) | |
3657 | |
4006 | 3658 #else /* USDT2 */ |
3659 | |
3660 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag \ | |
3661 , EntryProbe, ReturnProbe) \ | |
3662 \ | |
3663 JNI_QUICK_ENTRY(ElementType*, \ | |
3664 jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ | |
3665 JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ | |
3666 EntryProbe; \ | |
3667 /* allocate an chunk of memory in c land */ \ | |
3668 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3669 ElementType* result; \ | |
3670 int len = a->length(); \ | |
3671 if (len == 0) { \ | |
3672 /* Empty array: legal but useless, can't return NULL. \ | |
3673 * Return a pointer to something useless. \ | |
3674 * Avoid asserts in typeArrayOop. */ \ | |
3675 result = (ElementType*)get_bad_address(); \ | |
3676 } else { \ | |
12109
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3677 /* 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
|
3678 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
|
3679 if (result != NULL) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3680 /* 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
|
3681 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
|
3682 if (isCopy) { \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3683 *isCopy = JNI_TRUE; \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3684 } \ |
faf2631b9334
8022683: JNI GetStringUTFChars should return NULL on allocation failure not abort the VM
dsimms
parents:
11092
diff
changeset
|
3685 } \ |
4006 | 3686 } \ |
3687 ReturnProbe; \ | |
3688 return result; \ | |
3689 JNI_END | |
3690 | |
3691 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool | |
3692 , HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3693 HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_RETURN((uintptr_t*)result)) | |
3694 DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte | |
3695 , HOTSPOT_JNI_GETBYTEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3696 HOTSPOT_JNI_GETBYTEARRAYELEMENTS_RETURN((char*)result)) | |
3697 DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short | |
3698 , HOTSPOT_JNI_GETSHORTARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy), | |
3699 HOTSPOT_JNI_GETSHORTARRAYELEMENTS_RETURN((uint16_t*)result)) | |
3700 DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char | |
3701 , HOTSPOT_JNI_GETCHARARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy), | |
3702 HOTSPOT_JNI_GETCHARARRAYELEMENTS_RETURN(result)) | |
3703 DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int | |
3704 , HOTSPOT_JNI_GETINTARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3705 HOTSPOT_JNI_GETINTARRAYELEMENTS_RETURN((uint32_t*)result)) | |
3706 DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long | |
3707 , HOTSPOT_JNI_GETLONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3708 HOTSPOT_JNI_GETLONGARRAYELEMENTS_RETURN(((uintptr_t*)result))) | |
3709 // Float and double probes don't return value because dtrace doesn't currently support it | |
3710 DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float | |
3711 , HOTSPOT_JNI_GETFLOATARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3712 HOTSPOT_JNI_GETFLOATARRAYELEMENTS_RETURN(result)) | |
3713 DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double | |
3714 , HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), | |
3715 HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN(result)) | |
3716 #endif /* USDT2 */ | |
3717 | |
3718 #ifndef USDT2 | |
0 | 3719 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag) \ |
3720 \ | |
3721 JNI_QUICK_ENTRY(void, \ | |
3722 jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ | |
3723 ElementType *buf, jint mode)) \ | |
3724 JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ | |
3725 DTRACE_PROBE4(hotspot_jni, Release##Result##ArrayElements__entry, env, array, buf, mode);\ | |
3726 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3727 int len = a->length(); \ | |
3728 if (len != 0) { /* Empty array: nothing to free or copy. */ \ | |
3729 if ((mode == 0) || (mode == JNI_COMMIT)) { \ | |
3730 memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ | |
3731 } \ | |
3732 if ((mode == 0) || (mode == JNI_ABORT)) { \ | |
3733 FreeHeap(buf); \ | |
3734 } \ | |
3735 } \ | |
3736 DTRACE_PROBE(hotspot_jni, Release##Result##ArrayElements__return);\ | |
3737 JNI_END | |
3738 | |
3739 DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | |
3740 DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) | |
3741 DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) | |
3742 DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) | |
3743 DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int) | |
3744 DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long) | |
3745 DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) | |
3746 DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) | |
3747 | |
4006 | 3748 #else /* USDT2 */ |
3749 | |
3750 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag \ | |
3751 , EntryProbe, ReturnProbe);\ | |
3752 \ | |
3753 JNI_QUICK_ENTRY(void, \ | |
3754 jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ | |
3755 ElementType *buf, jint mode)) \ | |
3756 JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ | |
3757 EntryProbe; \ | |
3758 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3759 int len = a->length(); \ | |
3760 if (len != 0) { /* Empty array: nothing to free or copy. */ \ | |
3761 if ((mode == 0) || (mode == JNI_COMMIT)) { \ | |
3762 memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ | |
3763 } \ | |
3764 if ((mode == 0) || (mode == JNI_ABORT)) { \ | |
3765 FreeHeap(buf); \ | |
3766 } \ | |
3767 } \ | |
3768 ReturnProbe; \ | |
3769 JNI_END | |
3770 | |
3771 DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool | |
3772 , HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode), | |
3773 HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_RETURN()) | |
3774 DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte | |
3775 , HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_ENTRY(env, array, (char *) buf, mode), | |
3776 HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_RETURN()) | |
3777 DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short | |
3778 , HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode), | |
3779 HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_RETURN()) | |
3780 DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char | |
3781 , HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode), | |
3782 HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_RETURN()) | |
3783 DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int | |
3784 , HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_ENTRY(env, array, (uint32_t *) buf, mode), | |
3785 HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_RETURN()) | |
3786 DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long | |
3787 , HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode), | |
3788 HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_RETURN()) | |
3789 DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float | |
3790 , HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_ENTRY(env, array, (float *) buf, mode), | |
3791 HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_RETURN()) | |
3792 DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double | |
3793 , HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY(env, array, (double *) buf, mode), | |
3794 HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN()) | |
3795 #endif /* USDT2 */ | |
3796 | |
3797 #ifndef USDT2 | |
0 | 3798 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ |
3799 DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion);\ | |
3800 \ | |
3801 JNI_ENTRY(void, \ | |
3802 jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3803 jsize len, ElementType *buf)) \ | |
3804 JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ | |
3805 DTRACE_PROBE5(hotspot_jni, Get##Result##ArrayRegion__entry, env, array, start, len, buf);\ | |
3806 DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ | |
3807 typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3808 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ | |
3809 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3810 } else { \ | |
3811 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3812 int sc = TypeArrayKlass::cast(src->klass())->log2_element_size(); \ |
0 | 3813 memcpy((u_char*) buf, \ |
3814 (u_char*) src->Tag##_at_addr(start), \ | |
3815 len << sc); \ | |
3816 } \ | |
3817 } \ | |
3818 JNI_END | |
3819 | |
3820 DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool) | |
3821 DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) | |
3822 DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short) | |
3823 DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char) | |
3824 DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int) | |
3825 DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long) | |
3826 DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) | |
3827 DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) | |
3828 | |
4006 | 3829 #else /* USDT2 */ |
3830 | |
3831 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ | |
3832 , EntryProbe, ReturnProbe); \ | |
3833 DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion \ | |
3834 , ReturnProbe); \ | |
3835 \ | |
3836 JNI_ENTRY(void, \ | |
3837 jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3838 jsize len, ElementType *buf)) \ | |
3839 JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ | |
3840 EntryProbe; \ | |
3841 DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ | |
3842 typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3843 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ | |
3844 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3845 } else { \ | |
3846 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3847 int sc = TypeArrayKlass::cast(src->klass())->log2_element_size(); \ |
4006 | 3848 memcpy((u_char*) buf, \ |
3849 (u_char*) src->Tag##_at_addr(start), \ | |
3850 len << sc); \ | |
3851 } \ | |
3852 } \ | |
3853 JNI_END | |
3854 | |
3855 DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool | |
3856 , HOTSPOT_JNI_GETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), | |
3857 HOTSPOT_JNI_GETBOOLEANARRAYREGION_RETURN()); | |
3858 DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte | |
3859 , HOTSPOT_JNI_GETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf), | |
3860 HOTSPOT_JNI_GETBYTEARRAYREGION_RETURN()); | |
3861 DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short | |
3862 , HOTSPOT_JNI_GETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), | |
3863 HOTSPOT_JNI_GETSHORTARRAYREGION_RETURN()); | |
3864 DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char | |
3865 , HOTSPOT_JNI_GETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t*) buf), | |
3866 HOTSPOT_JNI_GETCHARARRAYREGION_RETURN()); | |
3867 DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int | |
3868 , HOTSPOT_JNI_GETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t*) buf), | |
3869 HOTSPOT_JNI_GETINTARRAYREGION_RETURN()); | |
3870 DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long | |
3871 , HOTSPOT_JNI_GETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), | |
3872 HOTSPOT_JNI_GETLONGARRAYREGION_RETURN()); | |
3873 DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float | |
3874 , HOTSPOT_JNI_GETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf), | |
3875 HOTSPOT_JNI_GETFLOATARRAYREGION_RETURN()); | |
3876 DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double | |
3877 , HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), | |
3878 HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN()); | |
3879 #endif /* USDT2 */ | |
3880 | |
3881 #ifndef USDT2 | |
0 | 3882 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ |
3883 DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion);\ | |
3884 \ | |
3885 JNI_ENTRY(void, \ | |
3886 jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3887 jsize len, const ElementType *buf)) \ | |
3888 JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ | |
3889 DTRACE_PROBE5(hotspot_jni, Set##Result##ArrayRegion__entry, env, array, start, len, buf);\ | |
3890 DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ | |
3891 typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3892 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ | |
3893 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3894 } else { \ | |
3895 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3896 int sc = TypeArrayKlass::cast(dst->klass())->log2_element_size(); \ |
0 | 3897 memcpy((u_char*) dst->Tag##_at_addr(start), \ |
3898 (u_char*) buf, \ | |
3899 len << sc); \ | |
3900 } \ | |
3901 } \ | |
3902 JNI_END | |
3903 | |
3904 DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool) | |
3905 DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) | |
3906 DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short) | |
3907 DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char) | |
3908 DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int) | |
3909 DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long) | |
3910 DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) | |
3911 DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) | |
3912 | |
4006 | 3913 #else /* USDT2 */ |
3914 | |
3915 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ | |
3916 , EntryProbe, ReturnProbe); \ | |
3917 DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion \ | |
3918 ,ReturnProbe); \ | |
3919 \ | |
3920 JNI_ENTRY(void, \ | |
3921 jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
3922 jsize len, const ElementType *buf)) \ | |
3923 JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ | |
3924 EntryProbe; \ | |
3925 DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ | |
3926 typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
3927 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ | |
3928 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
3929 } else { \ | |
3930 if (len > 0) { \ | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3931 int sc = TypeArrayKlass::cast(dst->klass())->log2_element_size(); \ |
4006 | 3932 memcpy((u_char*) dst->Tag##_at_addr(start), \ |
3933 (u_char*) buf, \ | |
3934 len << sc); \ | |
3935 } \ | |
3936 } \ | |
3937 JNI_END | |
3938 | |
3939 DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool | |
3940 , HOTSPOT_JNI_SETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *)buf), | |
3941 HOTSPOT_JNI_SETBOOLEANARRAYREGION_RETURN()) | |
3942 DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte | |
3943 , HOTSPOT_JNI_SETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf), | |
3944 HOTSPOT_JNI_SETBYTEARRAYREGION_RETURN()) | |
3945 DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short | |
3946 , HOTSPOT_JNI_SETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), | |
3947 HOTSPOT_JNI_SETSHORTARRAYREGION_RETURN()) | |
3948 DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char | |
3949 , HOTSPOT_JNI_SETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), | |
3950 HOTSPOT_JNI_SETCHARARRAYREGION_RETURN()) | |
3951 DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int | |
3952 , HOTSPOT_JNI_SETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t *) buf), | |
3953 HOTSPOT_JNI_SETINTARRAYREGION_RETURN()) | |
3954 DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long | |
3955 , HOTSPOT_JNI_SETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), | |
3956 HOTSPOT_JNI_SETLONGARRAYREGION_RETURN()) | |
3957 DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float | |
3958 , HOTSPOT_JNI_SETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf), | |
3959 HOTSPOT_JNI_SETFLOATARRAYREGION_RETURN()) | |
3960 DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double | |
3961 , HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), | |
3962 HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN()) | |
3963 #endif /* USDT2 */ | |
3964 | |
0 | 3965 |
3966 // | |
3967 // Interception of natives | |
3968 // | |
3969 | |
3970 // The RegisterNatives call being attempted tried to register with a method that | |
3971 // is not native. Ask JVM TI what prefixes have been specified. Then check | |
3972 // to see if the native method is now wrapped with the prefixes. See the | |
3973 // 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
|
3974 static Method* find_prefixed_native(KlassHandle k, |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
3975 Symbol* name, Symbol* signature, TRAPS) { |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
3976 #if INCLUDE_JVMTI |
0 | 3977 ResourceMark rm(THREAD); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
3978 Method* method; |
0 | 3979 int name_len = name->utf8_length(); |
3980 char* name_str = name->as_utf8(); | |
3981 int prefix_count; | |
3982 char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count); | |
3983 for (int i = 0; i < prefix_count; i++) { | |
3984 char* prefix = prefixes[i]; | |
3985 int prefix_len = (int)strlen(prefix); | |
3986 | |
3987 // try adding this prefix to the method name and see if it matches another method name | |
3988 int trial_len = name_len + prefix_len; | |
3989 char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1); | |
3990 strcpy(trial_name_str, prefix); | |
3991 strcat(trial_name_str, name_str); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
3992 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
|
3993 if (trial_name == NULL) { |
0 | 3994 continue; // no such symbol, so this prefix wasn't used, try the next prefix |
3995 } | |
6983 | 3996 method = k()->lookup_method(trial_name, signature); |
0 | 3997 if (method == NULL) { |
3998 continue; // signature doesn't match, try the next prefix | |
3999 } | |
4000 if (method->is_native()) { | |
4001 method->set_is_prefixed_native(); | |
4002 return method; // wahoo, we found a prefixed version of the method, return it | |
4003 } | |
4004 // found as non-native, so prefix is good, add it, probably just need more prefixes | |
4005 name_len = trial_len; | |
4006 name_str = trial_name_str; | |
4007 } | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
4008 #endif // INCLUDE_JVMTI |
0 | 4009 return NULL; // not found |
4010 } | |
4011 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4012 static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { |
6983 | 4013 Method* method = k()->lookup_method(name, signature); |
0 | 4014 if (method == NULL) { |
4015 ResourceMark rm; | |
4016 stringStream st; | |
4017 st.print("Method %s name or signature does not match", | |
6983 | 4018 Method::name_and_sig_as_C_string(k(), name, signature)); |
0 | 4019 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
4020 } | |
4021 if (!method->is_native()) { | |
4022 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) | |
4023 method = find_prefixed_native(k, name, signature, THREAD); | |
4024 if (method == NULL) { | |
4025 ResourceMark rm; | |
4026 stringStream st; | |
4027 st.print("Method %s is not declared as native", | |
6983 | 4028 Method::name_and_sig_as_C_string(k(), name, signature)); |
0 | 4029 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
4030 } | |
4031 } | |
4032 | |
4033 if (entry != NULL) { | |
4034 method->set_native_function(entry, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4035 Method::native_bind_event_is_interesting); |
0 | 4036 } else { |
4037 method->clear_native_function(); | |
4038 } | |
4039 if (PrintJNIResolving) { | |
4040 ResourceMark rm(THREAD); | |
4041 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
|
4042 method->method_holder()->external_name(), |
0 | 4043 method->name()->as_C_string()); |
4044 } | |
4045 return true; | |
4046 } | |
4047 | |
4006 | 4048 #ifndef USDT2 |
0 | 4049 DT_RETURN_MARK_DECL(RegisterNatives, jint); |
4006 | 4050 #else /* USDT2 */ |
4051 DT_RETURN_MARK_DECL(RegisterNatives, jint | |
4052 , HOTSPOT_JNI_REGISTERNATIVES_RETURN(_ret_ref)); | |
4053 #endif /* USDT2 */ | |
0 | 4054 |
4055 JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, | |
4056 const JNINativeMethod *methods, | |
4057 jint nMethods)) | |
4058 JNIWrapper("RegisterNatives"); | |
4006 | 4059 #ifndef USDT2 |
0 | 4060 DTRACE_PROBE4(hotspot_jni, RegisterNatives__entry, env, clazz, methods, nMethods); |
4006 | 4061 #else /* USDT2 */ |
4062 HOTSPOT_JNI_REGISTERNATIVES_ENTRY( | |
4063 env, clazz, (void *) methods, nMethods); | |
4064 #endif /* USDT2 */ | |
0 | 4065 jint ret = 0; |
4066 DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); | |
4067 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4068 KlassHandle h_k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
0 | 4069 |
4070 for (int index = 0; index < nMethods; index++) { | |
4071 const char* meth_name = methods[index].name; | |
4072 const char* meth_sig = methods[index].signature; | |
4073 int meth_name_len = (int)strlen(meth_name); | |
4074 | |
4075 // The class should have been loaded (we have an instance of the class | |
4076 // passed in) so the method and signature should already be in the symbol | |
4077 // 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
|
4078 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
|
4079 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
|
4080 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4081 if (name == NULL || signature == NULL) { |
0 | 4082 ResourceMark rm; |
4083 stringStream st; | |
6983 | 4084 st.print("Method %s.%s%s not found", h_k()->external_name(), meth_name, meth_sig); |
0 | 4085 // Must return negative value on failure |
4086 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); | |
4087 } | |
4088 | |
4089 bool res = register_native(h_k, name, signature, | |
4090 (address) methods[index].fnPtr, THREAD); | |
4091 if (!res) { | |
4092 ret = -1; | |
4093 break; | |
4094 } | |
4095 } | |
4096 return ret; | |
4097 JNI_END | |
4098 | |
4099 | |
4100 JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) | |
4101 JNIWrapper("UnregisterNatives"); | |
4006 | 4102 #ifndef USDT2 |
0 | 4103 DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); |
4006 | 4104 #else /* USDT2 */ |
4105 HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY( | |
4106 env, clazz); | |
4107 #endif /* USDT2 */ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4108 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); |
0 | 4109 //%note jni_2 |
6983 | 4110 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4111 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
|
4112 Method* m = InstanceKlass::cast(k)->methods()->at(index); |
0 | 4113 if (m->is_native()) { |
4114 m->clear_native_function(); | |
4115 m->set_signature_handler(NULL); | |
4116 } | |
4117 } | |
4118 } | |
4006 | 4119 #ifndef USDT2 |
0 | 4120 DTRACE_PROBE1(hotspot_jni, UnregisterNatives__return, 0); |
4006 | 4121 #else /* USDT2 */ |
4122 HOTSPOT_JNI_UNREGISTERNATIVES_RETURN( | |
4123 0); | |
4124 #endif /* USDT2 */ | |
0 | 4125 return 0; |
4126 JNI_END | |
4127 | |
4128 // | |
4129 // Monitor functions | |
4130 // | |
4131 | |
4006 | 4132 #ifndef USDT2 |
0 | 4133 DT_RETURN_MARK_DECL(MonitorEnter, jint); |
4006 | 4134 #else /* USDT2 */ |
4135 DT_RETURN_MARK_DECL(MonitorEnter, jint | |
4136 , HOTSPOT_JNI_MONITORENTER_RETURN(_ret_ref)); | |
4137 #endif /* USDT2 */ | |
0 | 4138 |
4139 JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) | |
4006 | 4140 #ifndef USDT2 |
0 | 4141 DTRACE_PROBE2(hotspot_jni, MonitorEnter__entry, env, jobj); |
4006 | 4142 #else /* USDT2 */ |
4143 HOTSPOT_JNI_MONITORENTER_ENTRY( | |
4144 env, jobj); | |
4145 #endif /* USDT2 */ | |
0 | 4146 jint ret = JNI_ERR; |
4147 DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret); | |
4148 | |
4149 // If the object is null, we can't do anything with it | |
4150 if (jobj == NULL) { | |
4151 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); | |
4152 } | |
4153 | |
4154 Handle obj(thread, JNIHandles::resolve_non_null(jobj)); | |
4155 ObjectSynchronizer::jni_enter(obj, CHECK_(JNI_ERR)); | |
4156 ret = JNI_OK; | |
4157 return ret; | |
4158 JNI_END | |
4159 | |
4006 | 4160 #ifndef USDT2 |
0 | 4161 DT_RETURN_MARK_DECL(MonitorExit, jint); |
4006 | 4162 #else /* USDT2 */ |
4163 DT_RETURN_MARK_DECL(MonitorExit, jint | |
4164 , HOTSPOT_JNI_MONITOREXIT_RETURN(_ret_ref)); | |
4165 #endif /* USDT2 */ | |
0 | 4166 |
4167 JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj)) | |
4006 | 4168 #ifndef USDT2 |
0 | 4169 DTRACE_PROBE2(hotspot_jni, MonitorExit__entry, env, jobj); |
4006 | 4170 #else /* USDT2 */ |
4171 HOTSPOT_JNI_MONITOREXIT_ENTRY( | |
4172 env, jobj); | |
4173 #endif /* USDT2 */ | |
0 | 4174 jint ret = JNI_ERR; |
4175 DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret); | |
4176 | |
4177 // Don't do anything with a null object | |
4178 if (jobj == NULL) { | |
4179 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); | |
4180 } | |
4181 | |
4182 Handle obj(THREAD, JNIHandles::resolve_non_null(jobj)); | |
4183 ObjectSynchronizer::jni_exit(obj(), CHECK_(JNI_ERR)); | |
4184 | |
4185 ret = JNI_OK; | |
4186 return ret; | |
4187 JNI_END | |
4188 | |
4189 // | |
4190 // Extensions | |
4191 // | |
4192 | |
4006 | 4193 #ifndef USDT2 |
0 | 4194 DT_VOID_RETURN_MARK_DECL(GetStringRegion); |
4006 | 4195 #else /* USDT2 */ |
4196 DT_VOID_RETURN_MARK_DECL(GetStringRegion | |
4197 , HOTSPOT_JNI_GETSTRINGREGION_RETURN()); | |
4198 #endif /* USDT2 */ | |
0 | 4199 |
4200 JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, jsize len, jchar *buf)) | |
4201 JNIWrapper("GetStringRegion"); | |
4006 | 4202 #ifndef USDT2 |
0 | 4203 DTRACE_PROBE5(hotspot_jni, GetStringRegion__entry, env, string, start, len, buf); |
4006 | 4204 #else /* USDT2 */ |
4205 HOTSPOT_JNI_GETSTRINGREGION_ENTRY( | |
4206 env, string, start, len, buf); | |
4207 #endif /* USDT2 */ | |
0 | 4208 DT_VOID_RETURN_MARK(GetStringRegion); |
4209 oop s = JNIHandles::resolve_non_null(string); | |
4210 int s_len = java_lang_String::length(s); | |
4211 if (start < 0 || len < 0 || start + len > s_len) { | |
4212 THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException()); | |
4213 } else { | |
4214 if (len > 0) { | |
4215 int s_offset = java_lang_String::offset(s); | |
4216 typeArrayOop s_value = java_lang_String::value(s); | |
4217 memcpy(buf, s_value->char_at_addr(s_offset+start), sizeof(jchar)*len); | |
4218 } | |
4219 } | |
4220 JNI_END | |
4221 | |
4006 | 4222 #ifndef USDT2 |
0 | 4223 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion); |
4006 | 4224 #else /* USDT2 */ |
4225 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion | |
4226 , HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN()); | |
4227 #endif /* USDT2 */ | |
0 | 4228 |
4229 JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, jsize len, char *buf)) | |
4230 JNIWrapper("GetStringUTFRegion"); | |
4006 | 4231 #ifndef USDT2 |
0 | 4232 DTRACE_PROBE5(hotspot_jni, GetStringUTFRegion__entry, env, string, start, len, buf); |
4006 | 4233 #else /* USDT2 */ |
4234 HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY( | |
4235 env, string, start, len, buf); | |
4236 #endif /* USDT2 */ | |
0 | 4237 DT_VOID_RETURN_MARK(GetStringUTFRegion); |
4238 oop s = JNIHandles::resolve_non_null(string); | |
4239 int s_len = java_lang_String::length(s); | |
4240 if (start < 0 || len < 0 || start + len > s_len) { | |
4241 THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException()); | |
4242 } else { | |
4243 //%note jni_7 | |
4244 if (len > 0) { | |
4245 ResourceMark rm(THREAD); | |
4246 char *utf_region = java_lang_String::as_utf8_string(s, start, len); | |
4247 int utf_len = (int)strlen(utf_region); | |
4248 memcpy(buf, utf_region, utf_len); | |
4249 buf[utf_len] = 0; | |
4250 } else { | |
4251 // JDK null-terminates the buffer even in len is zero | |
4252 if (buf != NULL) { | |
4253 buf[0] = 0; | |
4254 } | |
4255 } | |
4256 } | |
4257 JNI_END | |
4258 | |
4259 | |
4260 JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)) | |
4261 JNIWrapper("GetPrimitiveArrayCritical"); | |
4006 | 4262 #ifndef USDT2 |
0 | 4263 DTRACE_PROBE3(hotspot_jni, GetPrimitiveArrayCritical__entry, env, array, isCopy); |
4006 | 4264 #else /* USDT2 */ |
4265 HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY( | |
4266 env, array, (uintptr_t *) isCopy); | |
4267 #endif /* USDT2 */ | |
0 | 4268 GC_locker::lock_critical(thread); |
4269 if (isCopy != NULL) { | |
4270 *isCopy = JNI_FALSE; | |
4271 } | |
4272 oop a = JNIHandles::resolve_non_null(array); | |
4273 assert(a->is_array(), "just checking"); | |
4274 BasicType type; | |
4275 if (a->is_objArray()) { | |
4276 type = T_OBJECT; | |
4277 } else { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
4278 type = TypeArrayKlass::cast(a->klass())->element_type(); |
0 | 4279 } |
4280 void* ret = arrayOop(a)->base(type); | |
4006 | 4281 #ifndef USDT2 |
0 | 4282 DTRACE_PROBE1(hotspot_jni, GetPrimitiveArrayCritical__return, ret); |
4006 | 4283 #else /* USDT2 */ |
4284 HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN( | |
4285 ret); | |
4286 #endif /* USDT2 */ | |
0 | 4287 return ret; |
4288 JNI_END | |
4289 | |
4290 | |
4291 JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)) | |
4292 JNIWrapper("ReleasePrimitiveArrayCritical"); | |
4006 | 4293 #ifndef USDT2 |
0 | 4294 DTRACE_PROBE4(hotspot_jni, ReleasePrimitiveArrayCritical__entry, env, array, carray, mode); |
4006 | 4295 #else /* USDT2 */ |
4296 HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY( | |
4297 env, array, carray, mode); | |
4298 #endif /* USDT2 */ | |
0 | 4299 // The array, carray and mode arguments are ignored |
4300 GC_locker::unlock_critical(thread); | |
4006 | 4301 #ifndef USDT2 |
0 | 4302 DTRACE_PROBE(hotspot_jni, ReleasePrimitiveArrayCritical__return); |
4006 | 4303 #else /* USDT2 */ |
4304 HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN( | |
4305 ); | |
4306 #endif /* USDT2 */ | |
0 | 4307 JNI_END |
4308 | |
4309 | |
4310 JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy)) | |
4311 JNIWrapper("GetStringCritical"); | |
4006 | 4312 #ifndef USDT2 |
0 | 4313 DTRACE_PROBE3(hotspot_jni, GetStringCritical__entry, env, string, isCopy); |
4006 | 4314 #else /* USDT2 */ |
4315 HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY( | |
4316 env, string, (uintptr_t *) isCopy); | |
4317 #endif /* USDT2 */ | |
0 | 4318 GC_locker::lock_critical(thread); |
4319 if (isCopy != NULL) { | |
4320 *isCopy = JNI_FALSE; | |
4321 } | |
4322 oop s = JNIHandles::resolve_non_null(string); | |
4323 int s_len = java_lang_String::length(s); | |
4324 typeArrayOop s_value = java_lang_String::value(s); | |
4325 int s_offset = java_lang_String::offset(s); | |
4326 const jchar* ret; | |
4327 if (s_len > 0) { | |
4328 ret = s_value->char_at_addr(s_offset); | |
4329 } else { | |
4330 ret = (jchar*) s_value->base(T_CHAR); | |
4331 } | |
4006 | 4332 #ifndef USDT2 |
0 | 4333 DTRACE_PROBE1(hotspot_jni, GetStringCritical__return, ret); |
4006 | 4334 #else /* USDT2 */ |
4335 HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN( | |
4336 (uint16_t *) ret); | |
4337 #endif /* USDT2 */ | |
0 | 4338 return ret; |
4339 JNI_END | |
4340 | |
4341 | |
4342 JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars)) | |
4343 JNIWrapper("ReleaseStringCritical"); | |
4006 | 4344 #ifndef USDT2 |
0 | 4345 DTRACE_PROBE3(hotspot_jni, ReleaseStringCritical__entry, env, str, chars); |
4006 | 4346 #else /* USDT2 */ |
4347 HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY( | |
4348 env, str, (uint16_t *) chars); | |
4349 #endif /* USDT2 */ | |
0 | 4350 // The str and chars arguments are ignored |
4351 GC_locker::unlock_critical(thread); | |
4006 | 4352 #ifndef USDT2 |
0 | 4353 DTRACE_PROBE(hotspot_jni, ReleaseStringCritical__return); |
4006 | 4354 #else /* USDT2 */ |
4355 HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN( | |
4356 ); | |
4357 #endif /* USDT2 */ | |
0 | 4358 JNI_END |
4359 | |
4360 | |
4361 JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) | |
4362 JNIWrapper("jni_NewWeakGlobalRef"); | |
4006 | 4363 #ifndef USDT2 |
0 | 4364 DTRACE_PROBE2(hotspot_jni, NewWeakGlobalRef__entry, env, ref); |
4006 | 4365 #else /* USDT2 */ |
4366 HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY( | |
4367 env, ref); | |
4368 #endif /* USDT2 */ | |
0 | 4369 Handle ref_handle(thread, JNIHandles::resolve(ref)); |
4370 jweak ret = JNIHandles::make_weak_global(ref_handle); | |
4006 | 4371 #ifndef USDT2 |
0 | 4372 DTRACE_PROBE1(hotspot_jni, NewWeakGlobalRef__return, ret); |
4006 | 4373 #else /* USDT2 */ |
4374 HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN( | |
4375 ret); | |
4376 #endif /* USDT2 */ | |
0 | 4377 return ret; |
4378 JNI_END | |
4379 | |
4380 // Must be JNI_ENTRY (with HandleMark) | |
4381 JNI_ENTRY(void, jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref)) | |
4382 JNIWrapper("jni_DeleteWeakGlobalRef"); | |
4006 | 4383 #ifndef USDT2 |
0 | 4384 DTRACE_PROBE2(hotspot_jni, DeleteWeakGlobalRef__entry, env, ref); |
4006 | 4385 #else /* USDT2 */ |
4386 HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY( | |
4387 env, ref); | |
4388 #endif /* USDT2 */ | |
0 | 4389 JNIHandles::destroy_weak_global(ref); |
4006 | 4390 #ifndef USDT2 |
0 | 4391 DTRACE_PROBE(hotspot_jni, DeleteWeakGlobalRef__return); |
4006 | 4392 #else /* USDT2 */ |
4393 HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN( | |
4394 ); | |
4395 #endif /* USDT2 */ | |
0 | 4396 JNI_END |
4397 | |
4398 | |
4399 JNI_QUICK_ENTRY(jboolean, jni_ExceptionCheck(JNIEnv *env)) | |
4400 JNIWrapper("jni_ExceptionCheck"); | |
4006 | 4401 #ifndef USDT2 |
0 | 4402 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__entry, env); |
4006 | 4403 #else /* USDT2 */ |
4404 HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY( | |
4405 env); | |
4406 #endif /* USDT2 */ | |
0 | 4407 jni_check_async_exceptions(thread); |
4408 jboolean ret = (thread->has_pending_exception()) ? JNI_TRUE : JNI_FALSE; | |
4006 | 4409 #ifndef USDT2 |
0 | 4410 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__return, ret); |
4006 | 4411 #else /* USDT2 */ |
4412 HOTSPOT_JNI_EXCEPTIONCHECK_RETURN( | |
4413 ret); | |
4414 #endif /* USDT2 */ | |
0 | 4415 return ret; |
4416 JNI_END | |
4417 | |
4418 | |
4419 // Initialization state for three routines below relating to | |
4420 // java.nio.DirectBuffers | |
4421 static jint directBufferSupportInitializeStarted = 0; | |
4422 static volatile jint directBufferSupportInitializeEnded = 0; | |
4423 static volatile jint directBufferSupportInitializeFailed = 0; | |
4424 static jclass bufferClass = NULL; | |
4425 static jclass directBufferClass = NULL; | |
4426 static jclass directByteBufferClass = NULL; | |
4427 static jmethodID directByteBufferConstructor = NULL; | |
4428 static jfieldID directBufferAddressField = NULL; | |
4429 static jfieldID bufferCapacityField = NULL; | |
4430 | |
4431 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { | |
4432 Handle loader; // null (bootstrap) loader | |
4433 Handle protection_domain; // null protection domain | |
4434 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
4435 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4436 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
|
4437 |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4438 if (TraceClassResolution && result != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
4439 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
|
4440 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
4441 return result; |
0 | 4442 } |
4443 | |
4444 // These lookups are done with the NULL (bootstrap) ClassLoader to | |
4445 // circumvent any security checks that would be done by jni_FindClass. | |
4446 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env)) | |
4447 { | |
4448 if ((bufferClass = lookupOne(env, "java/nio/Buffer", thread)) == NULL) { return false; } | |
4449 if ((directBufferClass = lookupOne(env, "sun/nio/ch/DirectBuffer", thread)) == NULL) { return false; } | |
4450 if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; } | |
4451 return true; | |
4452 } | |
4453 JNI_END | |
4454 | |
4455 | |
4456 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { | |
4457 if (directBufferSupportInitializeFailed) { | |
4458 return false; | |
4459 } | |
4460 | |
4461 if (Atomic::cmpxchg(1, &directBufferSupportInitializeStarted, 0) == 0) { | |
4462 if (!lookupDirectBufferClasses(env)) { | |
4463 directBufferSupportInitializeFailed = 1; | |
4464 return false; | |
4465 } | |
4466 | |
4467 // Make global references for these | |
4468 bufferClass = (jclass) env->NewGlobalRef(bufferClass); | |
4469 directBufferClass = (jclass) env->NewGlobalRef(directBufferClass); | |
4470 directByteBufferClass = (jclass) env->NewGlobalRef(directByteBufferClass); | |
4471 | |
4472 // Get needed field and method IDs | |
4473 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
|
4474 if (env->ExceptionCheck()) { |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4475 env->ExceptionClear(); |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4476 directBufferSupportInitializeFailed = 1; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4477 return false; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4478 } |
0 | 4479 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
|
4480 if (env->ExceptionCheck()) { |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4481 env->ExceptionClear(); |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4482 directBufferSupportInitializeFailed = 1; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4483 return false; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4484 } |
0 | 4485 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
|
4486 if (env->ExceptionCheck()) { |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4487 env->ExceptionClear(); |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4488 directBufferSupportInitializeFailed = 1; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4489 return false; |
56cd09c4a5c9
8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
ccheung
parents:
17694
diff
changeset
|
4490 } |
0 | 4491 |
4492 if ((directByteBufferConstructor == NULL) || | |
4493 (directBufferAddressField == NULL) || | |
4494 (bufferCapacityField == NULL)) { | |
4495 directBufferSupportInitializeFailed = 1; | |
4496 return false; | |
4497 } | |
4498 | |
4499 directBufferSupportInitializeEnded = 1; | |
4500 } else { | |
4501 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
|
4502 // 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
|
4503 // 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
|
4504 // 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
|
4505 // 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
|
4506 // 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
|
4507 ThreadInVMfromNative tivn(thread); |
0 | 4508 os::yield_all(); |
4509 } | |
4510 } | |
4511 | |
4512 return !directBufferSupportInitializeFailed; | |
4513 } | |
4514 | |
4515 extern "C" jobject JNICALL jni_NewDirectByteBuffer(JNIEnv *env, void* address, jlong capacity) | |
4516 { | |
4517 // thread_from_jni_environment() will block if VM is gone. | |
4518 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
4519 | |
4520 JNIWrapper("jni_NewDirectByteBuffer"); | |
4006 | 4521 #ifndef USDT2 |
0 | 4522 DTRACE_PROBE3(hotspot_jni, NewDirectByteBuffer__entry, env, address, capacity); |
4006 | 4523 #else /* USDT2 */ |
4524 HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY( | |
4525 env, address, capacity); | |
4526 #endif /* USDT2 */ | |
0 | 4527 |
4528 if (!directBufferSupportInitializeEnded) { | |
4529 if (!initializeDirectBufferSupport(env, thread)) { | |
4006 | 4530 #ifndef USDT2 |
0 | 4531 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, NULL); |
4006 | 4532 #else /* USDT2 */ |
4533 HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN( | |
4534 NULL); | |
4535 #endif /* USDT2 */ | |
0 | 4536 return NULL; |
4537 } | |
4538 } | |
4539 | |
4540 // Being paranoid about accidental sign extension on address | |
4541 jlong addr = (jlong) ((uintptr_t) address); | |
4542 // NOTE that package-private DirectByteBuffer constructor currently | |
4543 // takes int capacity | |
4544 jint cap = (jint) capacity; | |
4545 jobject ret = env->NewObject(directByteBufferClass, directByteBufferConstructor, addr, cap); | |
4006 | 4546 #ifndef USDT2 |
0 | 4547 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, ret); |
4006 | 4548 #else /* USDT2 */ |
4549 HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN( | |
4550 ret); | |
4551 #endif /* USDT2 */ | |
0 | 4552 return ret; |
4553 } | |
4554 | |
4006 | 4555 #ifndef USDT2 |
0 | 4556 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*); |
4006 | 4557 #else /* USDT2 */ |
4558 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void* | |
4559 , HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN((void*) _ret_ref)); | |
4560 #endif /* USDT2 */ | |
0 | 4561 |
4562 extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) | |
4563 { | |
4564 // thread_from_jni_environment() will block if VM is gone. | |
4565 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
4566 | |
4567 JNIWrapper("jni_GetDirectBufferAddress"); | |
4006 | 4568 #ifndef USDT2 |
0 | 4569 DTRACE_PROBE2(hotspot_jni, GetDirectBufferAddress__entry, env, buf); |
4006 | 4570 #else /* USDT2 */ |
4571 HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY( | |
4572 env, buf); | |
4573 #endif /* USDT2 */ | |
0 | 4574 void* ret = NULL; |
4575 DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret); | |
4576 | |
4577 if (!directBufferSupportInitializeEnded) { | |
4578 if (!initializeDirectBufferSupport(env, thread)) { | |
4579 return 0; | |
4580 } | |
4581 } | |
4582 | |
4583 if ((buf != NULL) && (!env->IsInstanceOf(buf, directBufferClass))) { | |
4584 return 0; | |
4585 } | |
4586 | |
4587 ret = (void*)(intptr_t)env->GetLongField(buf, directBufferAddressField); | |
4588 return ret; | |
4589 } | |
4590 | |
4006 | 4591 #ifndef USDT2 |
0 | 4592 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong); |
4006 | 4593 #else /* USDT2 */ |
4594 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong | |
4595 , HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN(_ret_ref)); | |
4596 #endif /* USDT2 */ | |
0 | 4597 |
4598 extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) | |
4599 { | |
4600 // thread_from_jni_environment() will block if VM is gone. | |
4601 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
4602 | |
4603 JNIWrapper("jni_GetDirectBufferCapacity"); | |
4006 | 4604 #ifndef USDT2 |
0 | 4605 DTRACE_PROBE2(hotspot_jni, GetDirectBufferCapacity__entry, env, buf); |
4006 | 4606 #else /* USDT2 */ |
4607 HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY( | |
4608 env, buf); | |
4609 #endif /* USDT2 */ | |
0 | 4610 jlong ret = -1; |
4611 DT_RETURN_MARK(GetDirectBufferCapacity, jlong, (const jlong&)ret); | |
4612 | |
4613 if (!directBufferSupportInitializeEnded) { | |
4614 if (!initializeDirectBufferSupport(env, thread)) { | |
4615 ret = 0; | |
4616 return ret; | |
4617 } | |
4618 } | |
4619 | |
4620 if (buf == NULL) { | |
4621 return -1; | |
4622 } | |
4623 | |
4624 if (!env->IsInstanceOf(buf, directBufferClass)) { | |
4625 return -1; | |
4626 } | |
4627 | |
4628 // NOTE that capacity is currently an int in the implementation | |
4629 ret = env->GetIntField(buf, bufferCapacityField); | |
4630 return ret; | |
4631 } | |
4632 | |
4633 | |
4634 JNI_LEAF(jint, jni_GetVersion(JNIEnv *env)) | |
4635 JNIWrapper("GetVersion"); | |
4006 | 4636 #ifndef USDT2 |
0 | 4637 DTRACE_PROBE1(hotspot_jni, GetVersion__entry, env); |
4006 | 4638 #else /* USDT2 */ |
4639 HOTSPOT_JNI_GETVERSION_ENTRY( | |
4640 env); | |
4641 #endif /* USDT2 */ | |
4642 #ifndef USDT2 | |
0 | 4643 DTRACE_PROBE1(hotspot_jni, GetVersion__return, CurrentVersion); |
4006 | 4644 #else /* USDT2 */ |
4645 HOTSPOT_JNI_GETVERSION_RETURN( | |
4646 CurrentVersion); | |
4647 #endif /* USDT2 */ | |
0 | 4648 return CurrentVersion; |
4649 JNI_END | |
4650 | |
4651 extern struct JavaVM_ main_vm; | |
4652 | |
4653 JNI_LEAF(jint, jni_GetJavaVM(JNIEnv *env, JavaVM **vm)) | |
4654 JNIWrapper("jni_GetJavaVM"); | |
4006 | 4655 #ifndef USDT2 |
0 | 4656 DTRACE_PROBE2(hotspot_jni, GetJavaVM__entry, env, vm); |
4006 | 4657 #else /* USDT2 */ |
4658 HOTSPOT_JNI_GETJAVAVM_ENTRY( | |
4659 env, (void **) vm); | |
4660 #endif /* USDT2 */ | |
0 | 4661 *vm = (JavaVM *)(&main_vm); |
4006 | 4662 #ifndef USDT2 |
0 | 4663 DTRACE_PROBE1(hotspot_jni, GetJavaVM__return, JNI_OK); |
4006 | 4664 #else /* USDT2 */ |
4665 HOTSPOT_JNI_GETJAVAVM_RETURN( | |
4666 JNI_OK); | |
4667 #endif /* USDT2 */ | |
0 | 4668 return JNI_OK; |
4669 JNI_END | |
4670 | |
4671 // Structure containing all jni functions | |
4672 struct JNINativeInterface_ jni_NativeInterface = { | |
4673 NULL, | |
4674 NULL, | |
4675 NULL, | |
4676 | |
4677 NULL, | |
4678 | |
4679 jni_GetVersion, | |
4680 | |
4681 jni_DefineClass, | |
4682 jni_FindClass, | |
4683 | |
4684 jni_FromReflectedMethod, | |
4685 jni_FromReflectedField, | |
4686 | |
4687 jni_ToReflectedMethod, | |
4688 | |
4689 jni_GetSuperclass, | |
4690 jni_IsAssignableFrom, | |
4691 | |
4692 jni_ToReflectedField, | |
4693 | |
4694 jni_Throw, | |
4695 jni_ThrowNew, | |
4696 jni_ExceptionOccurred, | |
4697 jni_ExceptionDescribe, | |
4698 jni_ExceptionClear, | |
4699 jni_FatalError, | |
4700 | |
4701 jni_PushLocalFrame, | |
4702 jni_PopLocalFrame, | |
4703 | |
4704 jni_NewGlobalRef, | |
4705 jni_DeleteGlobalRef, | |
4706 jni_DeleteLocalRef, | |
4707 jni_IsSameObject, | |
4708 | |
4709 jni_NewLocalRef, | |
4710 jni_EnsureLocalCapacity, | |
4711 | |
4712 jni_AllocObject, | |
4713 jni_NewObject, | |
4714 jni_NewObjectV, | |
4715 jni_NewObjectA, | |
4716 | |
4717 jni_GetObjectClass, | |
4718 jni_IsInstanceOf, | |
4719 | |
4720 jni_GetMethodID, | |
4721 | |
4722 jni_CallObjectMethod, | |
4723 jni_CallObjectMethodV, | |
4724 jni_CallObjectMethodA, | |
4725 jni_CallBooleanMethod, | |
4726 jni_CallBooleanMethodV, | |
4727 jni_CallBooleanMethodA, | |
4728 jni_CallByteMethod, | |
4729 jni_CallByteMethodV, | |
4730 jni_CallByteMethodA, | |
4731 jni_CallCharMethod, | |
4732 jni_CallCharMethodV, | |
4733 jni_CallCharMethodA, | |
4734 jni_CallShortMethod, | |
4735 jni_CallShortMethodV, | |
4736 jni_CallShortMethodA, | |
4737 jni_CallIntMethod, | |
4738 jni_CallIntMethodV, | |
4739 jni_CallIntMethodA, | |
4740 jni_CallLongMethod, | |
4741 jni_CallLongMethodV, | |
4742 jni_CallLongMethodA, | |
4743 jni_CallFloatMethod, | |
4744 jni_CallFloatMethodV, | |
4745 jni_CallFloatMethodA, | |
4746 jni_CallDoubleMethod, | |
4747 jni_CallDoubleMethodV, | |
4748 jni_CallDoubleMethodA, | |
4749 jni_CallVoidMethod, | |
4750 jni_CallVoidMethodV, | |
4751 jni_CallVoidMethodA, | |
4752 | |
4753 jni_CallNonvirtualObjectMethod, | |
4754 jni_CallNonvirtualObjectMethodV, | |
4755 jni_CallNonvirtualObjectMethodA, | |
4756 jni_CallNonvirtualBooleanMethod, | |
4757 jni_CallNonvirtualBooleanMethodV, | |
4758 jni_CallNonvirtualBooleanMethodA, | |
4759 jni_CallNonvirtualByteMethod, | |
4760 jni_CallNonvirtualByteMethodV, | |
4761 jni_CallNonvirtualByteMethodA, | |
4762 jni_CallNonvirtualCharMethod, | |
4763 jni_CallNonvirtualCharMethodV, | |
4764 jni_CallNonvirtualCharMethodA, | |
4765 jni_CallNonvirtualShortMethod, | |
4766 jni_CallNonvirtualShortMethodV, | |
4767 jni_CallNonvirtualShortMethodA, | |
4768 jni_CallNonvirtualIntMethod, | |
4769 jni_CallNonvirtualIntMethodV, | |
4770 jni_CallNonvirtualIntMethodA, | |
4771 jni_CallNonvirtualLongMethod, | |
4772 jni_CallNonvirtualLongMethodV, | |
4773 jni_CallNonvirtualLongMethodA, | |
4774 jni_CallNonvirtualFloatMethod, | |
4775 jni_CallNonvirtualFloatMethodV, | |
4776 jni_CallNonvirtualFloatMethodA, | |
4777 jni_CallNonvirtualDoubleMethod, | |
4778 jni_CallNonvirtualDoubleMethodV, | |
4779 jni_CallNonvirtualDoubleMethodA, | |
4780 jni_CallNonvirtualVoidMethod, | |
4781 jni_CallNonvirtualVoidMethodV, | |
4782 jni_CallNonvirtualVoidMethodA, | |
4783 | |
4784 jni_GetFieldID, | |
4785 | |
4786 jni_GetObjectField, | |
4787 jni_GetBooleanField, | |
4788 jni_GetByteField, | |
4789 jni_GetCharField, | |
4790 jni_GetShortField, | |
4791 jni_GetIntField, | |
4792 jni_GetLongField, | |
4793 jni_GetFloatField, | |
4794 jni_GetDoubleField, | |
4795 | |
4796 jni_SetObjectField, | |
4797 jni_SetBooleanField, | |
4798 jni_SetByteField, | |
4799 jni_SetCharField, | |
4800 jni_SetShortField, | |
4801 jni_SetIntField, | |
4802 jni_SetLongField, | |
4803 jni_SetFloatField, | |
4804 jni_SetDoubleField, | |
4805 | |
4806 jni_GetStaticMethodID, | |
4807 | |
4808 jni_CallStaticObjectMethod, | |
4809 jni_CallStaticObjectMethodV, | |
4810 jni_CallStaticObjectMethodA, | |
4811 jni_CallStaticBooleanMethod, | |
4812 jni_CallStaticBooleanMethodV, | |
4813 jni_CallStaticBooleanMethodA, | |
4814 jni_CallStaticByteMethod, | |
4815 jni_CallStaticByteMethodV, | |
4816 jni_CallStaticByteMethodA, | |
4817 jni_CallStaticCharMethod, | |
4818 jni_CallStaticCharMethodV, | |
4819 jni_CallStaticCharMethodA, | |
4820 jni_CallStaticShortMethod, | |
4821 jni_CallStaticShortMethodV, | |
4822 jni_CallStaticShortMethodA, | |
4823 jni_CallStaticIntMethod, | |
4824 jni_CallStaticIntMethodV, | |
4825 jni_CallStaticIntMethodA, | |
4826 jni_CallStaticLongMethod, | |
4827 jni_CallStaticLongMethodV, | |
4828 jni_CallStaticLongMethodA, | |
4829 jni_CallStaticFloatMethod, | |
4830 jni_CallStaticFloatMethodV, | |
4831 jni_CallStaticFloatMethodA, | |
4832 jni_CallStaticDoubleMethod, | |
4833 jni_CallStaticDoubleMethodV, | |
4834 jni_CallStaticDoubleMethodA, | |
4835 jni_CallStaticVoidMethod, | |
4836 jni_CallStaticVoidMethodV, | |
4837 jni_CallStaticVoidMethodA, | |
4838 | |
4839 jni_GetStaticFieldID, | |
4840 | |
4841 jni_GetStaticObjectField, | |
4842 jni_GetStaticBooleanField, | |
4843 jni_GetStaticByteField, | |
4844 jni_GetStaticCharField, | |
4845 jni_GetStaticShortField, | |
4846 jni_GetStaticIntField, | |
4847 jni_GetStaticLongField, | |
4848 jni_GetStaticFloatField, | |
4849 jni_GetStaticDoubleField, | |
4850 | |
4851 jni_SetStaticObjectField, | |
4852 jni_SetStaticBooleanField, | |
4853 jni_SetStaticByteField, | |
4854 jni_SetStaticCharField, | |
4855 jni_SetStaticShortField, | |
4856 jni_SetStaticIntField, | |
4857 jni_SetStaticLongField, | |
4858 jni_SetStaticFloatField, | |
4859 jni_SetStaticDoubleField, | |
4860 | |
4861 jni_NewString, | |
4862 jni_GetStringLength, | |
4863 jni_GetStringChars, | |
4864 jni_ReleaseStringChars, | |
4865 | |
4866 jni_NewStringUTF, | |
4867 jni_GetStringUTFLength, | |
4868 jni_GetStringUTFChars, | |
4869 jni_ReleaseStringUTFChars, | |
4870 | |
4871 jni_GetArrayLength, | |
4872 | |
4873 jni_NewObjectArray, | |
4874 jni_GetObjectArrayElement, | |
4875 jni_SetObjectArrayElement, | |
4876 | |
4877 jni_NewBooleanArray, | |
4878 jni_NewByteArray, | |
4879 jni_NewCharArray, | |
4880 jni_NewShortArray, | |
4881 jni_NewIntArray, | |
4882 jni_NewLongArray, | |
4883 jni_NewFloatArray, | |
4884 jni_NewDoubleArray, | |
4885 | |
4886 jni_GetBooleanArrayElements, | |
4887 jni_GetByteArrayElements, | |
4888 jni_GetCharArrayElements, | |
4889 jni_GetShortArrayElements, | |
4890 jni_GetIntArrayElements, | |
4891 jni_GetLongArrayElements, | |
4892 jni_GetFloatArrayElements, | |
4893 jni_GetDoubleArrayElements, | |
4894 | |
4895 jni_ReleaseBooleanArrayElements, | |
4896 jni_ReleaseByteArrayElements, | |
4897 jni_ReleaseCharArrayElements, | |
4898 jni_ReleaseShortArrayElements, | |
4899 jni_ReleaseIntArrayElements, | |
4900 jni_ReleaseLongArrayElements, | |
4901 jni_ReleaseFloatArrayElements, | |
4902 jni_ReleaseDoubleArrayElements, | |
4903 | |
4904 jni_GetBooleanArrayRegion, | |
4905 jni_GetByteArrayRegion, | |
4906 jni_GetCharArrayRegion, | |
4907 jni_GetShortArrayRegion, | |
4908 jni_GetIntArrayRegion, | |
4909 jni_GetLongArrayRegion, | |
4910 jni_GetFloatArrayRegion, | |
4911 jni_GetDoubleArrayRegion, | |
4912 | |
4913 jni_SetBooleanArrayRegion, | |
4914 jni_SetByteArrayRegion, | |
4915 jni_SetCharArrayRegion, | |
4916 jni_SetShortArrayRegion, | |
4917 jni_SetIntArrayRegion, | |
4918 jni_SetLongArrayRegion, | |
4919 jni_SetFloatArrayRegion, | |
4920 jni_SetDoubleArrayRegion, | |
4921 | |
4922 jni_RegisterNatives, | |
4923 jni_UnregisterNatives, | |
4924 | |
4925 jni_MonitorEnter, | |
4926 jni_MonitorExit, | |
4927 | |
4928 jni_GetJavaVM, | |
4929 | |
4930 jni_GetStringRegion, | |
4931 jni_GetStringUTFRegion, | |
4932 | |
4933 jni_GetPrimitiveArrayCritical, | |
4934 jni_ReleasePrimitiveArrayCritical, | |
4935 | |
4936 jni_GetStringCritical, | |
4937 jni_ReleaseStringCritical, | |
4938 | |
4939 jni_NewWeakGlobalRef, | |
4940 jni_DeleteWeakGlobalRef, | |
4941 | |
4942 jni_ExceptionCheck, | |
4943 | |
4944 jni_NewDirectByteBuffer, | |
4945 jni_GetDirectBufferAddress, | |
4946 jni_GetDirectBufferCapacity, | |
4947 | |
4948 // New 1_6 features | |
4949 | |
4950 jni_GetObjectRefType | |
4951 }; | |
4952 | |
4953 | |
4954 // For jvmti use to modify jni function table. | |
4955 // Java threads in native contiues to run until it is transitioned | |
4956 // to VM at safepoint. Before the transition or before it is blocked | |
4957 // for safepoint it may access jni function table. VM could crash if | |
4958 // any java thread access the jni function table in the middle of memcpy. | |
4959 // To avoid this each function pointers are copied automically. | |
4960 void copy_jni_function_table(const struct JNINativeInterface_ *new_jni_NativeInterface) { | |
4961 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | |
4962 intptr_t *a = (intptr_t *) jni_functions(); | |
4963 intptr_t *b = (intptr_t *) new_jni_NativeInterface; | |
4964 for (uint i=0; i < sizeof(struct JNINativeInterface_)/sizeof(void *); i++) { | |
4965 Atomic::store_ptr(*b++, a++); | |
4966 } | |
4967 } | |
4968 | |
4969 void quicken_jni_functions() { | |
4970 // Replace Get<Primitive>Field with fast versions | |
4971 if (UseFastJNIAccessors && !JvmtiExport::can_post_field_access() | |
4972 && !VerifyJNIFields && !TraceJNICalls && !CountJNICalls && !CheckJNICalls | |
4973 #if defined(_WINDOWS) && defined(IA32) && defined(COMPILER2) | |
4974 // windows x86 currently needs SEH wrapper and the gain of the fast | |
4975 // versions currently isn't certain for server vm on uniprocessor. | |
4976 && os::is_MP() | |
4977 #endif | |
4978 ) { | |
4979 address func; | |
4980 func = JNI_FastGetField::generate_fast_get_boolean_field(); | |
4981 if (func != (address)-1) { | |
4982 jni_NativeInterface.GetBooleanField = (GetBooleanField_t)func; | |
4983 } | |
4984 func = JNI_FastGetField::generate_fast_get_byte_field(); | |
4985 if (func != (address)-1) { | |
4986 jni_NativeInterface.GetByteField = (GetByteField_t)func; | |
4987 } | |
4988 func = JNI_FastGetField::generate_fast_get_char_field(); | |
4989 if (func != (address)-1) { | |
4990 jni_NativeInterface.GetCharField = (GetCharField_t)func; | |
4991 } | |
4992 func = JNI_FastGetField::generate_fast_get_short_field(); | |
4993 if (func != (address)-1) { | |
4994 jni_NativeInterface.GetShortField = (GetShortField_t)func; | |
4995 } | |
4996 func = JNI_FastGetField::generate_fast_get_int_field(); | |
4997 if (func != (address)-1) { | |
4998 jni_NativeInterface.GetIntField = (GetIntField_t)func; | |
4999 } | |
5000 func = JNI_FastGetField::generate_fast_get_long_field(); | |
5001 if (func != (address)-1) { | |
5002 jni_NativeInterface.GetLongField = (GetLongField_t)func; | |
5003 } | |
5004 func = JNI_FastGetField::generate_fast_get_float_field(); | |
5005 if (func != (address)-1) { | |
5006 jni_NativeInterface.GetFloatField = (GetFloatField_t)func; | |
5007 } | |
5008 func = JNI_FastGetField::generate_fast_get_double_field(); | |
5009 if (func != (address)-1) { | |
5010 jni_NativeInterface.GetDoubleField = (GetDoubleField_t)func; | |
5011 } | |
5012 } | |
5013 } | |
5014 | |
5015 // Returns the function structure | |
5016 struct JNINativeInterface_* jni_functions() { | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
5017 #if INCLUDE_JNI_CHECK |
0 | 5018 if (CheckJNICalls) return jni_functions_check(); |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
5019 #endif // INCLUDE_JNI_CHECK |
0 | 5020 return &jni_NativeInterface; |
5021 } | |
5022 | |
5023 // Returns the function structure | |
5024 struct JNINativeInterface_* jni_functions_nocheck() { | |
5025 return &jni_NativeInterface; | |
5026 } | |
5027 | |
5028 | |
5029 // Invocation API | |
5030 | |
5031 | |
5032 // Forward declaration | |
5033 extern const struct JNIInvokeInterface_ jni_InvokeInterface; | |
5034 | |
5035 // Global invocation API vars | |
5036 volatile jint vm_created = 0; | |
5037 // Indicate whether it is safe to recreate VM | |
5038 volatile jint safe_to_recreate_vm = 1; | |
5039 struct JavaVM_ main_vm = {&jni_InvokeInterface}; | |
5040 | |
5041 | |
5042 #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */ | |
5043 enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL }; | |
5044 | |
4006 | 5045 #ifndef USDT2 |
0 | 5046 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*); |
5047 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint); | |
4006 | 5048 #else /* USDT2 */ |
5049 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint | |
5050 , HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN(_ret_ref)); | |
5051 #endif /* USDT2 */ | |
0 | 5052 |
5053 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { | |
4006 | 5054 #ifndef USDT2 |
0 | 5055 HS_DTRACE_PROBE1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, args_); |
4006 | 5056 #else /* USDT2 */ |
5057 HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY( | |
5058 args_); | |
5059 #endif /* USDT2 */ | |
0 | 5060 JDK1_1InitArgs *args = (JDK1_1InitArgs *)args_; |
5061 jint ret = JNI_ERR; | |
5062 DT_RETURN_MARK(GetDefaultJavaVMInitArgs, jint, (const jint&)ret); | |
5063 | |
5064 if (Threads::is_supported_jni_version(args->version)) { | |
5065 ret = JNI_OK; | |
5066 } | |
5067 // 1.1 style no longer supported in hotspot. | |
5068 // According the JNI spec, we should update args->version on return. | |
5069 // We also use the structure to communicate with launcher about default | |
5070 // stack size. | |
5071 if (args->version == JNI_VERSION_1_1) { | |
5072 args->version = JNI_VERSION_1_2; | |
5073 // javaStackSize is int in arguments structure | |
5074 assert(jlong(ThreadStackSize) * K < INT_MAX, "integer overflow"); | |
5075 args->javaStackSize = (jint)(ThreadStackSize * K); | |
5076 } | |
5077 return ret; | |
5078 } | |
5079 | |
3779 | 5080 #ifndef PRODUCT |
5081 | |
10405 | 5082 #include "gc_implementation/shared/gcTimer.hpp" |
4708 | 5083 #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
|
5084 #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
|
5085 #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
|
5086 #endif |
20318
fa62fb12cdca
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
20262
diff
changeset
|
5087 #include "memory/guardedMemory.hpp" |
3779 | 5088 #include "utilities/quickSort.hpp" |
12215 | 5089 #include "utilities/ostream.hpp" |
7171 | 5090 #if INCLUDE_VM_STRUCTS |
5091 #include "runtime/vmStructs.hpp" | |
5092 #endif | |
3779 | 5093 |
4708 | 5094 #define run_unit_test(unit_test_function_call) \ |
5095 tty->print_cr("Running test: " #unit_test_function_call); \ | |
5096 unit_test_function_call | |
5097 | |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5098 // Forward declaration |
22974
c2ce24504334
8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents:
20619
diff
changeset
|
5099 void TestOS_test(); |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5100 void TestReservedSpace_test(); |
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5101 void TestReserveMemorySpecial_test(); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12111
diff
changeset
|
5102 void TestVirtualSpace_test(); |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12305
diff
changeset
|
5103 void TestMetaspaceAux_test(); |
12902 | 5104 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
|
5105 void TestVirtualSpaceNode_test(); |
17898
1d01a7f3a336
8033426: Scale initial NewSize using NewRatio if not set on command line
sjohanss
parents:
17829
diff
changeset
|
5106 void TestNewSize_test(); |
20262
76b588255908
8035746: Add missing Klass::oop_is_instanceClassLoader() function
stefank
parents:
20255
diff
changeset
|
5107 void TestKlass_test(); |
20360 | 5108 void Test_linked_list(); |
20619
b12a2a9b05ca
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
20360
diff
changeset
|
5109 void TestChunkedList_test(); |
17694 | 5110 #if INCLUDE_ALL_GCS |
17648
a034dc5e910b
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
12979
diff
changeset
|
5111 void TestOldFreeSpaceCalculation_test(); |
12305
a19bea467577
7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
12269
diff
changeset
|
5112 void TestG1BiasedArray_test(); |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
20197
diff
changeset
|
5113 void TestBufferingOopClosure_test(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
17704
diff
changeset
|
5114 void TestCodeCacheRemSet_test(); |
20337 | 5115 void FreeRegionList_test(); |
12305
a19bea467577
7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
12269
diff
changeset
|
5116 #endif |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5117 |
3779 | 5118 void execute_internal_vm_tests() { |
5119 if (ExecuteInternalVMTests) { | |
4708 | 5120 tty->print_cr("Running internal VM tests"); |
22974
c2ce24504334
8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents:
20619
diff
changeset
|
5121 run_unit_test(TestOS_test()); |
12110
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5122 run_unit_test(TestReservedSpace_test()); |
4c84d351cca9
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
11092
diff
changeset
|
5123 run_unit_test(TestReserveMemorySpecial_test()); |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12111
diff
changeset
|
5124 run_unit_test(TestVirtualSpace_test()); |
12306
03f493ce3a71
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
brutisso
parents:
12305
diff
changeset
|
5125 run_unit_test(TestMetaspaceAux_test()); |
12902 | 5126 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
|
5127 run_unit_test(TestVirtualSpaceNode_test()); |
9060
cc32ccaaf47f
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
8793
diff
changeset
|
5128 run_unit_test(GlobalDefinitions::test_globals()); |
10405 | 5129 run_unit_test(GCTimerAllTest::all()); |
4708 | 5130 run_unit_test(arrayOopDesc::test_max_array_length()); |
5131 run_unit_test(CollectedHeap::test_is_in()); | |
5132 run_unit_test(QuickSort::test_quick_sort()); | |
20318
fa62fb12cdca
6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical.
dsimms
parents:
20262
diff
changeset
|
5133 run_unit_test(GuardedMemory::test_guarded_memory()); |
6162 | 5134 run_unit_test(AltHashing::test_alt_hash()); |
12215 | 5135 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
|
5136 run_unit_test(TestNewSize_test()); |
20262
76b588255908
8035746: Add missing Klass::oop_is_instanceClassLoader() function
stefank
parents:
20255
diff
changeset
|
5137 run_unit_test(TestKlass_test()); |
20360 | 5138 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
|
5139 run_unit_test(TestChunkedList_test()); |
7171 | 5140 #if INCLUDE_VM_STRUCTS |
5141 run_unit_test(VMStructs::test()); | |
5142 #endif | |
10333
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5143 #if INCLUDE_ALL_GCS |
17694 | 5144 run_unit_test(TestOldFreeSpaceCalculation_test()); |
12305
a19bea467577
7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
12269
diff
changeset
|
5145 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
|
5146 run_unit_test(HeapRegionRemSet::test_prt()); |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
20197
diff
changeset
|
5147 run_unit_test(TestBufferingOopClosure_test()); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
17704
diff
changeset
|
5148 run_unit_test(TestCodeCacheRemSet_test()); |
20337 | 5149 if (UseG1GC) { |
5150 run_unit_test(FreeRegionList_test()); | |
5151 } | |
10333
6702da6b6082
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
9060
diff
changeset
|
5152 #endif |
4070
6fd81579526f
7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents:
4006
diff
changeset
|
5153 tty->print_cr("All internal VM tests passed"); |
3779 | 5154 } |
5155 } | |
5156 | |
4708 | 5157 #undef run_unit_test |
5158 | |
3779 | 5159 #endif |
5160 | |
4006 | 5161 #ifndef USDT2 |
0 | 5162 HS_DTRACE_PROBE_DECL3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); |
5163 DT_RETURN_MARK_DECL(CreateJavaVM, jint); | |
4006 | 5164 #else /* USDT2 */ |
5165 DT_RETURN_MARK_DECL(CreateJavaVM, jint | |
5166 , HOTSPOT_JNI_CREATEJAVAVM_RETURN(_ret_ref)); | |
5167 #endif /* USDT2 */ | |
0 | 5168 |
5169 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) { | |
4006 | 5170 #ifndef USDT2 |
0 | 5171 HS_DTRACE_PROBE3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); |
4006 | 5172 #else /* USDT2 */ |
5173 HOTSPOT_JNI_CREATEJAVAVM_ENTRY( | |
5174 (void **) vm, penv, args); | |
5175 #endif /* USDT2 */ | |
0 | 5176 |
5177 jint result = JNI_ERR; | |
5178 DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result); | |
5179 | |
1078 | 5180 // We're about to use Atomic::xchg for synchronization. Some Zero |
5181 // platforms use the GCC builtin __sync_lock_test_and_set for this, | |
5182 // but __sync_lock_test_and_set is not guaranteed to do what we want | |
5183 // on all architectures. So we check it works before relying on it. | |
5184 #if defined(ZERO) && defined(ASSERT) | |
5185 { | |
5186 jint a = 0xcafebabe; | |
5187 jint b = Atomic::xchg(0xdeadbeef, &a); | |
5188 void *c = &a; | |
5189 void *d = Atomic::xchg_ptr(&b, &c); | |
1132 | 5190 assert(a == (jint) 0xdeadbeef && b == (jint) 0xcafebabe, "Atomic::xchg() works"); |
1078 | 5191 assert(c == &b && d == &a, "Atomic::xchg_ptr() works"); |
5192 } | |
5193 #endif // ZERO && ASSERT | |
5194 | |
0 | 5195 // At the moment it's only possible to have one Java VM, |
5196 // since some of the runtime state is in global variables. | |
5197 | |
5198 // We cannot use our mutex locks here, since they only work on | |
5199 // Threads. We do an atomic compare and exchange to ensure only | |
5200 // one thread can call this method at a time | |
5201 | |
5202 // We use Atomic::xchg rather than Atomic::add/dec since on some platforms | |
5203 // the add/dec implementations are dependent on whether we are running | |
5204 // on a multiprocessor, and at this stage of initialization the os::is_MP | |
5205 // function used to determine this will always return false. Atomic::xchg | |
5206 // does not have this problem. | |
5207 if (Atomic::xchg(1, &vm_created) == 1) { | |
11089
f323bbb0e6c1
8019833: Wrong JNI error code for preexisting JVM
coleenp
parents:
11059
diff
changeset
|
5208 return JNI_EEXIST; // already created, or create attempt in progress |
0 | 5209 } |
5210 if (Atomic::xchg(0, &safe_to_recreate_vm) == 0) { | |
5211 return JNI_ERR; // someone tried and failed and retry not allowed. | |
5212 } | |
5213 | |
5214 assert(vm_created == 1, "vm_created is true during the creation"); | |
5215 | |
5216 /** | |
5217 * Certain errors during initialization are recoverable and do not | |
5218 * prevent this method from being called again at a later time | |
5219 * (perhaps with different arguments). However, at a certain | |
5220 * point during initialization if an error occurs we cannot allow | |
5221 * this function to be called again (or it will crash). In those | |
5222 * situations, the 'canTryAgain' flag is set to false, which atomically | |
5223 * sets safe_to_recreate_vm to 1, such that any new call to | |
5224 * JNI_CreateJavaVM will immediately fail using the above logic. | |
5225 */ | |
5226 bool can_try_again = true; | |
5227 | |
5228 result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again); | |
5229 if (result == JNI_OK) { | |
5230 JavaThread *thread = JavaThread::current(); | |
5231 /* thread is thread_in_vm here */ | |
5232 *vm = (JavaVM *)(&main_vm); | |
5233 *(JNIEnv**)penv = thread->jni_environment(); | |
5234 | |
23404
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5235 #if INCLUDE_JVMCI |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5236 if (UseJVMCICompiler) { |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5237 // JVMCI is initialized on a CompilerThread |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5238 if (BootstrapJVMCI) { |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5239 JavaThread* THREAD = thread; |
24229
190f5f33b7d3
hosted use of JVMCI can crash VM under -Xint (JDK-8187315)
Doug Simon <doug.simon@oracle.com>
parents:
23974
diff
changeset
|
5240 JVMCICompiler* compiler = JVMCICompiler::instance(true, CATCH); |
23404
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5241 compiler->bootstrap(THREAD); |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5242 if (HAS_PENDING_EXCEPTION) { |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5243 HandleMark hm; |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5244 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); |
3ef45d0a6d77
Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
Roland Schatz <roland.schatz@oracle.com>
parents:
23386
diff
changeset
|
5245 } |
23385 | 5246 } |
13174
b00553202ec2
add NULL check so that -Xint option works again
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13086
diff
changeset
|
5247 } |
4368
d8d6b3de346b
Add another #ifdef GRAAL
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4137
diff
changeset
|
5248 #endif |
3650
0e8a2a629afb
Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3540
diff
changeset
|
5249 |
0 | 5250 // Tracks the time application was running before GC |
5251 RuntimeService::record_application_start(); | |
5252 | |
5253 // Notify JVMTI | |
5254 if (JvmtiExport::should_post_thread_life()) { | |
5255 JvmtiExport::post_thread_start(thread); | |
5256 } | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5257 |
10405 | 5258 EventThreadStart event; |
5259 if (event.should_commit()) { | |
5260 event.set_javalangthread(java_lang_Thread::thread_id(thread->threadObj())); | |
5261 event.commit(); | |
5262 } | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5263 |
11092
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5264 #ifndef PRODUCT |
17829
0118c8c7b80f
8038633: crash in VM_Version::get_processor_features() on startup
kvn
parents:
17753
diff
changeset
|
5265 #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
|
5266 #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
|
5267 #endif |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5268 |
0 | 5269 // 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
|
5270 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
|
5271 if (ReplayCompiles) ciReplay::replay(thread); |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5272 |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5273 // 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
|
5274 // 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
|
5275 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
|
5276 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
|
5277 #endif |
59b052799158
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
dcubed
parents:
11089
diff
changeset
|
5278 |
0 | 5279 // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. |
5280 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
5281 } else { | |
5282 if (can_try_again) { | |
5283 // reset safe_to_recreate_vm to 1 so that retrial would be possible | |
5284 safe_to_recreate_vm = 1; | |
5285 } | |
5286 | |
5287 // Creation failed. We must reset vm_created | |
5288 *vm = 0; | |
5289 *(JNIEnv**)penv = 0; | |
5290 // reset vm_created last to avoid race condition. Use OrderAccess to | |
5291 // control both compiler and architectural-based reordering. | |
5292 OrderAccess::release_store(&vm_created, 0); | |
5293 } | |
5294 | |
5295 return result; | |
5296 } | |
5297 | |
4006 | 5298 #ifndef USDT2 |
0 | 5299 HS_DTRACE_PROBE_DECL3(hotspot_jni, GetCreatedJavaVMs__entry, \ |
5300 JavaVM**, jsize, jsize*); | |
5301 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetCreatedJavaVMs__return, jint); | |
4006 | 5302 #endif /* !USDT2 */ |
0 | 5303 |
5304 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) { | |
5305 // See bug 4367188, the wrapper can sometimes cause VM crashes | |
5306 // JNIWrapper("GetCreatedJavaVMs"); | |
4006 | 5307 #ifndef USDT2 |
0 | 5308 HS_DTRACE_PROBE3(hotspot_jni, GetCreatedJavaVMs__entry, \ |
5309 vm_buf, bufLen, numVMs); | |
4006 | 5310 #else /* USDT2 */ |
5311 HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY( | |
5312 (void **) vm_buf, bufLen, (uintptr_t *) numVMs); | |
5313 #endif /* USDT2 */ | |
0 | 5314 if (vm_created) { |
5315 if (numVMs != NULL) *numVMs = 1; | |
5316 if (bufLen > 0) *vm_buf = (JavaVM *)(&main_vm); | |
5317 } else { | |
5318 if (numVMs != NULL) *numVMs = 0; | |
5319 } | |
4006 | 5320 #ifndef USDT2 |
0 | 5321 HS_DTRACE_PROBE1(hotspot_jni, GetCreatedJavaVMs__return, JNI_OK); |
4006 | 5322 #else /* USDT2 */ |
5323 HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN( | |
5324 JNI_OK); | |
5325 #endif /* USDT2 */ | |
0 | 5326 return JNI_OK; |
5327 } | |
5328 | |
5329 extern "C" { | |
5330 | |
4006 | 5331 #ifndef USDT2 |
0 | 5332 DT_RETURN_MARK_DECL(DestroyJavaVM, jint); |
4006 | 5333 #else /* USDT2 */ |
5334 DT_RETURN_MARK_DECL(DestroyJavaVM, jint | |
5335 , HOTSPOT_JNI_DESTROYJAVAVM_RETURN(_ret_ref)); | |
5336 #endif /* USDT2 */ | |
0 | 5337 |
5338 jint JNICALL jni_DestroyJavaVM(JavaVM *vm) { | |
4006 | 5339 #ifndef USDT2 |
0 | 5340 DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm); |
4006 | 5341 #else /* USDT2 */ |
5342 HOTSPOT_JNI_DESTROYJAVAVM_ENTRY( | |
5343 vm); | |
5344 #endif /* USDT2 */ | |
0 | 5345 jint res = JNI_ERR; |
5346 DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res); | |
5347 | |
5348 if (!vm_created) { | |
5349 res = JNI_ERR; | |
5350 return res; | |
5351 } | |
5352 | |
5353 JNIWrapper("DestroyJavaVM"); | |
5354 JNIEnv *env; | |
5355 JavaVMAttachArgs destroyargs; | |
5356 destroyargs.version = CurrentVersion; | |
5357 destroyargs.name = (char *)"DestroyJavaVM"; | |
5358 destroyargs.group = NULL; | |
5359 res = vm->AttachCurrentThread((void **)&env, (void *)&destroyargs); | |
5360 if (res != JNI_OK) { | |
5361 return res; | |
5362 } | |
5363 | |
5364 // Since this is not a JVM_ENTRY we have to set the thread state manually before entering. | |
5365 JavaThread* thread = JavaThread::current(); | |
5366 ThreadStateTransition::transition_from_native(thread, _thread_in_vm); | |
5367 if (Threads::destroy_vm()) { | |
5368 // Should not change thread state, VM is gone | |
5369 vm_created = false; | |
5370 res = JNI_OK; | |
5371 return res; | |
5372 } else { | |
5373 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
5374 res = JNI_ERR; | |
5375 return res; | |
5376 } | |
5377 } | |
5378 | |
5379 | |
5380 static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool daemon) { | |
5381 JavaVMAttachArgs *args = (JavaVMAttachArgs *) _args; | |
5382 | |
5383 // Check below commented out from JDK1.2fcs as well | |
5384 /* | |
5385 if (args && (args->version != JNI_VERSION_1_1 || args->version != JNI_VERSION_1_2)) { | |
5386 return JNI_EVERSION; | |
5387 } | |
5388 */ | |
5389 | |
5390 Thread* t = ThreadLocalStorage::get_thread_slow(); | |
5391 if (t != NULL) { | |
5392 // If the thread has been attached this operation is a no-op | |
5393 *(JNIEnv**)penv = ((JavaThread*) t)->jni_environment(); | |
5394 return JNI_OK; | |
5395 } | |
5396 | |
5397 // Create a thread and mark it as attaching so it will be skipped by the | |
5398 // ThreadsListEnumerator - see CR 6404306 | |
5399 JavaThread* thread = new JavaThread(true); | |
5400 | |
5401 // Set correct safepoint info. The thread is going to call into Java when | |
5402 // initializing the Java level thread object. Hence, the correct state must | |
5403 // be set in order for the Safepoint code to deal with it correctly. | |
5404 thread->set_thread_state(_thread_in_vm); | |
5405 // Must do this before initialize_thread_local_storage | |
5406 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
|
5407 |
0 | 5408 thread->initialize_thread_local_storage(); |
5409 | |
5410 if (!os::create_attached_thread(thread)) { | |
5411 delete thread; | |
5412 return JNI_ERR; | |
5413 } | |
1290
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5414 // Enable stack overflow checks |
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5415 thread->create_stack_guard_pages(); |
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
5416 |
0 | 5417 thread->initialize_tlab(); |
5418 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
5419 thread->cache_global_variables(); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
5420 |
0 | 5421 // Crucial that we do not have a safepoint check for this thread, since it has |
5422 // not been added to the Thread list yet. | |
5423 { Threads_lock->lock_without_safepoint_check(); | |
5424 // This must be inside this lock in order to get FullGCALot to work properly, i.e., to | |
5425 // avoid this thread trying to do a GC before it is added to the thread-list | |
5426 thread->set_active_handles(JNIHandleBlock::allocate_block()); | |
5427 Threads::add(thread, daemon); | |
5428 Threads_lock->unlock(); | |
5429 } | |
5430 // Create thread group and name info from attach arguments | |
5431 oop group = NULL; | |
5432 char* thread_name = NULL; | |
5433 if (args != NULL && Threads::is_supported_jni_version(args->version)) { | |
5434 group = JNIHandles::resolve(args->group); | |
5435 thread_name = args->name; // may be NULL | |
5436 } | |
5437 if (group == NULL) group = Universe::main_thread_group(); | |
5438 | |
5439 // Create Java level thread object and attach it to this thread | |
5440 bool attach_failed = false; | |
5441 { | |
5442 EXCEPTION_MARK; | |
5443 HandleMark hm(THREAD); | |
5444 Handle thread_group(THREAD, group); | |
5445 thread->allocate_threadObj(thread_group, thread_name, daemon, THREAD); | |
5446 if (HAS_PENDING_EXCEPTION) { | |
5447 CLEAR_PENDING_EXCEPTION; | |
5448 // cleanup outside the handle mark. | |
5449 attach_failed = true; | |
5450 } | |
5451 } | |
5452 | |
5453 if (attach_failed) { | |
5454 // Added missing cleanup | |
5455 thread->cleanup_failed_attach_current_thread(); | |
5456 return JNI_ERR; | |
5457 } | |
5458 | |
5459 // mark the thread as no longer attaching | |
5460 // this uses a fence to push the change through so we don't have | |
5461 // to regrab the threads_lock | |
4006 | 5462 thread->set_done_attaching_via_jni(); |
0 | 5463 |
5464 // Set java thread status. | |
5465 java_lang_Thread::set_thread_status(thread->threadObj(), | |
5466 java_lang_Thread::RUNNABLE); | |
5467 | |
5468 // Notify the debugger | |
5469 if (JvmtiExport::should_post_thread_life()) { | |
5470 JvmtiExport::post_thread_start(thread); | |
5471 } | |
5472 | |
10405 | 5473 EventThreadStart event; |
5474 if (event.should_commit()) { | |
5475 event.set_javalangthread(java_lang_Thread::thread_id(thread->threadObj())); | |
5476 event.commit(); | |
5477 } | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5478 |
0 | 5479 *(JNIEnv**)penv = thread->jni_environment(); |
5480 | |
5481 // Now leaving the VM, so change thread_state. This is normally automatically taken care | |
5482 // of in the JVM_ENTRY. But in this situation we have to do it manually. Notice, that by | |
5483 // using ThreadStateTransition::transition, we do a callback to the safepoint code if | |
5484 // needed. | |
5485 | |
5486 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
5487 | |
5488 // Perform any platform dependent FPU setup | |
5489 os::setup_fpu(); | |
5490 | |
5491 return JNI_OK; | |
5492 } | |
5493 | |
5494 | |
5495 jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) { | |
4006 | 5496 #ifndef USDT2 |
0 | 5497 DTRACE_PROBE3(hotspot_jni, AttachCurrentThread__entry, vm, penv, _args); |
4006 | 5498 #else /* USDT2 */ |
5499 HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY( | |
5500 vm, penv, _args); | |
5501 #endif /* USDT2 */ | |
0 | 5502 if (!vm_created) { |
4006 | 5503 #ifndef USDT2 |
0 | 5504 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, JNI_ERR); |
4006 | 5505 #else /* USDT2 */ |
5506 HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN( | |
5507 (uint32_t) JNI_ERR); | |
5508 #endif /* USDT2 */ | |
0 | 5509 return JNI_ERR; |
5510 } | |
5511 | |
5512 JNIWrapper("AttachCurrentThread"); | |
5513 jint ret = attach_current_thread(vm, penv, _args, false); | |
4006 | 5514 #ifndef USDT2 |
0 | 5515 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, ret); |
4006 | 5516 #else /* USDT2 */ |
5517 HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN( | |
5518 ret); | |
5519 #endif /* USDT2 */ | |
0 | 5520 return ret; |
5521 } | |
5522 | |
5523 | |
5524 jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { | |
4006 | 5525 #ifndef USDT2 |
0 | 5526 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__entry, vm); |
4006 | 5527 #else /* USDT2 */ |
5528 HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY( | |
5529 vm); | |
5530 #endif /* USDT2 */ | |
0 | 5531 VM_Exit::block_if_vm_exited(); |
5532 | |
5533 JNIWrapper("DetachCurrentThread"); | |
5534 | |
5535 // If the thread has been deattacted the operations is a no-op | |
5536 if (ThreadLocalStorage::thread() == NULL) { | |
4006 | 5537 #ifndef USDT2 |
0 | 5538 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); |
4006 | 5539 #else /* USDT2 */ |
5540 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( | |
5541 JNI_OK); | |
5542 #endif /* USDT2 */ | |
0 | 5543 return JNI_OK; |
5544 } | |
5545 | |
5546 JavaThread* thread = JavaThread::current(); | |
5547 if (thread->has_last_Java_frame()) { | |
4006 | 5548 #ifndef USDT2 |
0 | 5549 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_ERR); |
4006 | 5550 #else /* USDT2 */ |
5551 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( | |
5552 (uint32_t) JNI_ERR); | |
5553 #endif /* USDT2 */ | |
0 | 5554 // Can't detach a thread that's running java, that can't work. |
5555 return JNI_ERR; | |
5556 } | |
5557 | |
5558 // Safepoint support. Have to do call-back to safepoint code, if in the | |
5559 // middel of a safepoint operation | |
5560 ThreadStateTransition::transition_from_native(thread, _thread_in_vm); | |
5561 | |
5562 // XXX: Note that JavaThread::exit() call below removes the guards on the | |
5563 // stack pages set up via enable_stack_{red,yellow}_zone() calls | |
5564 // above in jni_AttachCurrentThread. Unfortunately, while the setting | |
5565 // of the guards is visible in jni_AttachCurrentThread above, | |
5566 // the removal of the guards is buried below in JavaThread::exit() | |
5567 // here. The abstraction should be more symmetrically either exposed | |
5568 // or hidden (e.g. it could probably be hidden in the same | |
5569 // (platform-dependent) methods where we do alternate stack | |
5570 // maintenance work?) | |
5571 thread->exit(false, JavaThread::jni_detach); | |
5572 delete thread; | |
5573 | |
4006 | 5574 #ifndef USDT2 |
0 | 5575 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); |
4006 | 5576 #else /* USDT2 */ |
5577 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( | |
5578 JNI_OK); | |
5579 #endif /* USDT2 */ | |
0 | 5580 return JNI_OK; |
5581 } | |
5582 | |
4006 | 5583 #ifndef USDT2 |
0 | 5584 DT_RETURN_MARK_DECL(GetEnv, jint); |
4006 | 5585 #else /* USDT2 */ |
5586 DT_RETURN_MARK_DECL(GetEnv, jint | |
5587 , HOTSPOT_JNI_GETENV_RETURN(_ret_ref)); | |
5588 #endif /* USDT2 */ | |
0 | 5589 |
5590 jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { | |
4006 | 5591 #ifndef USDT2 |
0 | 5592 DTRACE_PROBE3(hotspot_jni, GetEnv__entry, vm, penv, version); |
4006 | 5593 #else /* USDT2 */ |
5594 HOTSPOT_JNI_GETENV_ENTRY( | |
5595 vm, penv, version); | |
5596 #endif /* USDT2 */ | |
0 | 5597 jint ret = JNI_ERR; |
5598 DT_RETURN_MARK(GetEnv, jint, (const jint&)ret); | |
5599 | |
5600 if (!vm_created) { | |
5601 *penv = NULL; | |
5602 ret = JNI_EDETACHED; | |
5603 return ret; | |
5604 } | |
5605 | |
4800
94ec88ca68e2
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents:
4708
diff
changeset
|
5606 if (JniExportedInterface::GetExportedInterface(vm, penv, version, &ret)) { |
0 | 5607 return ret; |
5608 } | |
5609 | |
5610 #ifndef JVMPI_VERSION_1 | |
5611 // need these in order to be polite about older agents | |
5612 #define JVMPI_VERSION_1 ((jint)0x10000001) | |
5613 #define JVMPI_VERSION_1_1 ((jint)0x10000002) | |
5614 #define JVMPI_VERSION_1_2 ((jint)0x10000003) | |
5615 #endif // !JVMPI_VERSION_1 | |
5616 | |
5617 Thread* thread = ThreadLocalStorage::thread(); | |
5618 if (thread != NULL && thread->is_Java_thread()) { | |
5619 if (Threads::is_supported_jni_version_including_1_1(version)) { | |
5620 *(JNIEnv**)penv = ((JavaThread*) thread)->jni_environment(); | |
5621 ret = JNI_OK; | |
5622 return ret; | |
5623 | |
5624 } else if (version == JVMPI_VERSION_1 || | |
5625 version == JVMPI_VERSION_1_1 || | |
5626 version == JVMPI_VERSION_1_2) { | |
5627 tty->print_cr("ERROR: JVMPI, an experimental interface, is no longer supported."); | |
5628 tty->print_cr("Please use the supported interface: the JVM Tool Interface (JVM TI)."); | |
5629 ret = JNI_EVERSION; | |
5630 return ret; | |
5631 } else if (JvmtiExport::is_jvmdi_version(version)) { | |
5632 tty->print_cr("FATAL ERROR: JVMDI is no longer supported."); | |
5633 tty->print_cr("Please use the supported interface: the JVM Tool Interface (JVM TI)."); | |
5634 ret = JNI_EVERSION; | |
5635 return ret; | |
5636 } else { | |
5637 *penv = NULL; | |
5638 ret = JNI_EVERSION; | |
5639 return ret; | |
5640 } | |
5641 } else { | |
5642 *penv = NULL; | |
5643 ret = JNI_EDETACHED; | |
5644 return ret; | |
5645 } | |
5646 } | |
5647 | |
5648 | |
5649 jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) { | |
4006 | 5650 #ifndef USDT2 |
0 | 5651 DTRACE_PROBE3(hotspot_jni, AttachCurrentThreadAsDaemon__entry, vm, penv, _args); |
4006 | 5652 #else /* USDT2 */ |
5653 HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY( | |
5654 vm, penv, _args); | |
5655 #endif /* USDT2 */ | |
0 | 5656 if (!vm_created) { |
4006 | 5657 #ifndef USDT2 |
0 | 5658 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, JNI_ERR); |
4006 | 5659 #else /* USDT2 */ |
5660 HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN( | |
5661 (uint32_t) JNI_ERR); | |
5662 #endif /* USDT2 */ | |
0 | 5663 return JNI_ERR; |
5664 } | |
5665 | |
5666 JNIWrapper("AttachCurrentThreadAsDaemon"); | |
5667 jint ret = attach_current_thread(vm, penv, _args, true); | |
4006 | 5668 #ifndef USDT2 |
0 | 5669 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, ret); |
4006 | 5670 #else /* USDT2 */ |
5671 HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN( | |
5672 ret); | |
5673 #endif /* USDT2 */ | |
0 | 5674 return ret; |
5675 } | |
5676 | |
5677 | |
5678 } // End extern "C" | |
5679 | |
5680 const struct JNIInvokeInterface_ jni_InvokeInterface = { | |
5681 NULL, | |
5682 NULL, | |
5683 NULL, | |
5684 | |
5685 jni_DestroyJavaVM, | |
5686 jni_AttachCurrentThread, | |
5687 jni_DetachCurrentThread, | |
5688 jni_GetEnv, | |
5689 jni_AttachCurrentThreadAsDaemon | |
5690 }; |