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