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