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