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