Mercurial > hg > truffle
annotate src/share/vm/prims/jni.cpp @ 3500:6111c168756f
IdealGraphPrinter can now output bytecodes, enabled by default (GraalOptions.PrintIdealGraphBytecodes)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 08 Aug 2011 15:19:09 +0200 |
parents | be4ca325525a |
children | 85625aff715b |
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" | |
2925
b78b4ae0757c
Also call Compiler shutdown hook in case of System.exit call. Draft VMExits.Sandbox class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2901
diff
changeset
|
32 #include "graal/graalCompiler.hpp" |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
33 #ifndef SERIALGC |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
34 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
35 #endif // SERIALGC |
1972 | 36 #include "memory/allocation.inline.hpp" |
37 #include "memory/gcLocker.inline.hpp" | |
38 #include "memory/oopFactory.hpp" | |
39 #include "memory/universe.inline.hpp" | |
40 #include "oops/instanceKlass.hpp" | |
41 #include "oops/instanceOop.hpp" | |
42 #include "oops/markOop.hpp" | |
43 #include "oops/methodOop.hpp" | |
44 #include "oops/objArrayKlass.hpp" | |
45 #include "oops/objArrayOop.hpp" | |
46 #include "oops/oop.inline.hpp" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
47 #include "oops/symbol.hpp" |
1972 | 48 #include "oops/typeArrayKlass.hpp" |
49 #include "oops/typeArrayOop.hpp" | |
50 #include "prims/jni.h" | |
51 #include "prims/jniCheck.hpp" | |
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" | |
70 #include "utilities/defaultStream.hpp" | |
71 #include "utilities/dtrace.hpp" | |
72 #include "utilities/events.hpp" | |
73 #include "utilities/histogram.hpp" | |
74 #ifdef TARGET_ARCH_x86 | |
75 # include "jniTypes_x86.hpp" | |
76 #endif | |
77 #ifdef TARGET_ARCH_sparc | |
78 # include "jniTypes_sparc.hpp" | |
79 #endif | |
80 #ifdef TARGET_ARCH_zero | |
81 # include "jniTypes_zero.hpp" | |
82 #endif | |
83 #ifdef TARGET_OS_FAMILY_linux | |
84 # include "os_linux.inline.hpp" | |
85 # include "thread_linux.inline.hpp" | |
86 #endif | |
87 #ifdef TARGET_OS_FAMILY_solaris | |
88 # include "os_solaris.inline.hpp" | |
89 # include "thread_solaris.inline.hpp" | |
90 #endif | |
91 #ifdef TARGET_OS_FAMILY_windows | |
92 # include "os_windows.inline.hpp" | |
93 # include "thread_windows.inline.hpp" | |
94 #endif | |
0 | 95 |
96 static jint CurrentVersion = JNI_VERSION_1_6; | |
97 | |
98 | |
99 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace | |
100 // '-return' probe regardless of the return path is taken out of the function. | |
101 // Methods that have multiple return paths use this to avoid having to | |
102 // instrument each return path. Methods that use CHECK or THROW must use this | |
103 // since those macros can cause an immedate uninstrumented return. | |
104 // | |
105 // In order to get the return value, a reference to the variable containing | |
106 // the return value must be passed to the contructor of the object, and | |
107 // the return value must be set before return (since the mark object has | |
108 // a reference to it). | |
109 // | |
110 // Example: | |
111 // DT_RETURN_MARK_DECL(SomeFunc, int); | |
112 // JNI_ENTRY(int, SomeFunc, ...) | |
113 // int return_value = 0; | |
114 // DT_RETURN_MARK(SomeFunc, int, (const int&)return_value); | |
115 // foo(CHECK_0) | |
116 // return_value = 5; | |
117 // return return_value; | |
118 // JNI_END | |
119 #define DT_RETURN_MARK_DECL(name, type) \ | |
120 HS_DTRACE_PROBE_DECL1(hotspot_jni, name##__return, type); \ | |
121 DTRACE_ONLY( \ | |
122 class DTraceReturnProbeMark_##name { \ | |
123 public: \ | |
124 const type& _ret_ref; \ | |
125 DTraceReturnProbeMark_##name(const type& v) : _ret_ref(v) {} \ | |
126 ~DTraceReturnProbeMark_##name() { \ | |
127 HS_DTRACE_PROBE1(hotspot_jni, name##__return, _ret_ref); \ | |
128 } \ | |
129 } \ | |
130 ) | |
131 // Void functions are simpler since there's no return value | |
132 #define DT_VOID_RETURN_MARK_DECL(name) \ | |
133 HS_DTRACE_PROBE_DECL0(hotspot_jni, name##__return); \ | |
134 DTRACE_ONLY( \ | |
135 class DTraceReturnProbeMark_##name { \ | |
136 public: \ | |
137 ~DTraceReturnProbeMark_##name() { \ | |
138 HS_DTRACE_PROBE0(hotspot_jni, name##__return); \ | |
139 } \ | |
140 } \ | |
141 ) | |
142 | |
143 | |
144 // Place these macros in the function to mark the return. Non-void | |
145 // functions need the type and address of the return value. | |
146 #define DT_RETURN_MARK(name, type, ref) \ | |
147 DTRACE_ONLY( DTraceReturnProbeMark_##name dtrace_return_mark(ref) ) | |
148 #define DT_VOID_RETURN_MARK(name) \ | |
149 DTRACE_ONLY( DTraceReturnProbeMark_##name dtrace_return_mark ) | |
150 | |
151 | |
152 // Use these to select distinct code for floating-point vs. non-floating point | |
153 // situations. Used from within common macros where we need slightly | |
154 // different behavior for Float/Double | |
155 #define FP_SELECT_Boolean(intcode, fpcode) intcode | |
156 #define FP_SELECT_Byte(intcode, fpcode) intcode | |
157 #define FP_SELECT_Char(intcode, fpcode) intcode | |
158 #define FP_SELECT_Short(intcode, fpcode) intcode | |
159 #define FP_SELECT_Object(intcode, fpcode) intcode | |
160 #define FP_SELECT_Int(intcode, fpcode) intcode | |
161 #define FP_SELECT_Long(intcode, fpcode) intcode | |
162 #define FP_SELECT_Float(intcode, fpcode) fpcode | |
163 #define FP_SELECT_Double(intcode, fpcode) fpcode | |
164 #define FP_SELECT(TypeName, intcode, fpcode) \ | |
165 FP_SELECT_##TypeName(intcode, fpcode) | |
166 | |
167 #define COMMA , | |
168 | |
169 // Choose DT_RETURN_MARK macros based on the type: float/double -> void | |
170 // (dtrace doesn't do FP yet) | |
171 #define DT_RETURN_MARK_DECL_FOR(TypeName, name, type) \ | |
172 FP_SELECT(TypeName, \ | |
173 DT_RETURN_MARK_DECL(name, type), DT_VOID_RETURN_MARK_DECL(name) ) | |
174 #define DT_RETURN_MARK_FOR(TypeName, name, type, ref) \ | |
175 FP_SELECT(TypeName, \ | |
176 DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) ) | |
177 | |
178 | |
179 // out-of-line helpers for class jfieldIDWorkaround: | |
180 | |
181 bool jfieldIDWorkaround::is_valid_jfieldID(klassOop k, jfieldID id) { | |
182 if (jfieldIDWorkaround::is_instance_jfieldID(k, id)) { | |
183 uintptr_t as_uint = (uintptr_t) id; | |
184 intptr_t offset = raw_instance_offset(id); | |
185 if (is_checked_jfieldID(id)) { | |
186 if (!klass_hash_ok(k, id)) { | |
187 return false; | |
188 } | |
189 } | |
190 return instanceKlass::cast(k)->contains_field_offset(offset); | |
191 } else { | |
192 JNIid* result = (JNIid*) id; | |
193 #ifdef ASSERT | |
194 return result != NULL && result->is_static_field_id(); | |
195 #else | |
196 return result != NULL; | |
197 #endif | |
198 } | |
199 } | |
200 | |
201 | |
202 intptr_t jfieldIDWorkaround::encode_klass_hash(klassOop k, intptr_t offset) { | |
203 if (offset <= small_offset_mask) { | |
204 klassOop field_klass = k; | |
205 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
|
206 // 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
|
207 // 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
|
208 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
|
209 instanceKlass::cast(super_klass)->contains_field_offset(offset)) { |
0 | 210 field_klass = super_klass; // super contains the field also |
211 super_klass = Klass::cast(field_klass)->super(); | |
212 } | |
213 debug_only(No_Safepoint_Verifier nosafepoint;) | |
214 uintptr_t klass_hash = field_klass->identity_hash(); | |
215 return ((klass_hash & klass_mask) << klass_shift) | checked_mask_in_place; | |
216 } else { | |
217 #if 0 | |
218 #ifndef PRODUCT | |
219 { | |
220 ResourceMark rm; | |
221 warning("VerifyJNIFields: long offset %d in %s", offset, Klass::cast(k)->external_name()); | |
222 } | |
223 #endif | |
224 #endif | |
225 return 0; | |
226 } | |
227 } | |
228 | |
229 bool jfieldIDWorkaround::klass_hash_ok(klassOop k, jfieldID id) { | |
230 uintptr_t as_uint = (uintptr_t) id; | |
231 intptr_t klass_hash = (as_uint >> klass_shift) & klass_mask; | |
232 do { | |
233 debug_only(No_Safepoint_Verifier nosafepoint;) | |
234 // Could use a non-blocking query for identity_hash here... | |
235 if ((k->identity_hash() & klass_mask) == klass_hash) | |
236 return true; | |
237 k = Klass::cast(k)->super(); | |
238 } while (k != NULL); | |
239 return false; | |
240 } | |
241 | |
242 void jfieldIDWorkaround::verify_instance_jfieldID(klassOop k, jfieldID id) { | |
243 guarantee(jfieldIDWorkaround::is_instance_jfieldID(k, id), "must be an instance field" ); | |
244 uintptr_t as_uint = (uintptr_t) id; | |
245 intptr_t offset = raw_instance_offset(id); | |
246 if (VerifyJNIFields) { | |
247 if (is_checked_jfieldID(id)) { | |
248 guarantee(klass_hash_ok(k, id), | |
249 "Bug in native code: jfieldID class must match object"); | |
250 } else { | |
251 #if 0 | |
252 #ifndef PRODUCT | |
253 if (Verbose) { | |
254 ResourceMark rm; | |
255 warning("VerifyJNIFields: unverified offset %d for %s", offset, Klass::cast(k)->external_name()); | |
256 } | |
257 #endif | |
258 #endif | |
259 } | |
260 } | |
261 guarantee(instanceKlass::cast(k)->contains_field_offset(offset), | |
262 "Bug in native code: jfieldID offset must address interior of object"); | |
263 } | |
264 | |
265 // Pick a reasonable higher bound for local capacity requested | |
266 // for EnsureLocalCapacity and PushLocalFrame. We don't want it too | |
267 // high because a test (or very unusual application) may try to allocate | |
268 // that many handles and run out of swap space. An implementation is | |
269 // permitted to allocate more handles than the ensured capacity, so this | |
270 // value is set high enough to prevent compatibility problems. | |
271 const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K; | |
272 | |
273 | |
274 // Wrapper to trace JNI functions | |
275 | |
276 #ifdef ASSERT | |
277 Histogram* JNIHistogram; | |
278 static volatile jint JNIHistogram_lock = 0; | |
279 | |
280 class JNITraceWrapper : public StackObj { | |
281 public: | |
282 JNITraceWrapper(const char* format, ...) { | |
283 if (TraceJNICalls) { | |
284 va_list ap; | |
285 va_start(ap, format); | |
286 tty->print("JNI "); | |
287 tty->vprint_cr(format, ap); | |
288 va_end(ap); | |
289 } | |
290 } | |
291 }; | |
292 | |
293 class JNIHistogramElement : public HistogramElement { | |
294 public: | |
295 JNIHistogramElement(const char* name); | |
296 }; | |
297 | |
298 JNIHistogramElement::JNIHistogramElement(const char* elementName) { | |
299 _name = elementName; | |
300 uintx count = 0; | |
301 | |
302 while (Atomic::cmpxchg(1, &JNIHistogram_lock, 0) != 0) { | |
303 while (OrderAccess::load_acquire(&JNIHistogram_lock) != 0) { | |
304 count +=1; | |
305 if ( (WarnOnStalledSpinLock > 0) | |
306 && (count % WarnOnStalledSpinLock == 0)) { | |
307 warning("JNIHistogram_lock seems to be stalled"); | |
308 } | |
309 } | |
310 } | |
311 | |
312 | |
313 if(JNIHistogram == NULL) | |
314 JNIHistogram = new Histogram("JNI Call Counts",100); | |
315 | |
316 JNIHistogram->add_element(this); | |
317 Atomic::dec(&JNIHistogram_lock); | |
318 } | |
319 | |
320 #define JNICountWrapper(arg) \ | |
321 static JNIHistogramElement* e = new JNIHistogramElement(arg); \ | |
322 /* There is a MT-race condition in VC++. So we need to make sure that that e has been initialized */ \ | |
323 if (e != NULL) e->increment_count() | |
324 #define JNIWrapper(arg) JNICountWrapper(arg); JNITraceWrapper(arg) | |
325 #else | |
326 #define JNIWrapper(arg) | |
327 #endif | |
328 | |
329 | |
330 // Implementation of JNI entries | |
331 | |
332 DT_RETURN_MARK_DECL(DefineClass, jclass); | |
333 | |
334 JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderRef, | |
335 const jbyte *buf, jsize bufLen)) | |
336 JNIWrapper("DefineClass"); | |
337 | |
338 DTRACE_PROBE5(hotspot_jni, DefineClass__entry, | |
339 env, name, loaderRef, buf, bufLen); | |
340 jclass cls = NULL; | |
341 DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); | |
342 | |
343 // Since exceptions can be thrown, class initialization can take place | |
344 // if name is NULL no check for class name in .class stream has to be made. | |
345 if (name != NULL) { | |
346 const int str_len = (int)strlen(name); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
347 if (str_len > Symbol::max_length()) { |
0 | 348 // It's impossible to create this class; the name cannot fit |
349 // into the constant pool. | |
350 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | |
351 } | |
352 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
353 TempNewSymbol class_name = SymbolTable::new_symbol(name, THREAD); |
0 | 354 |
355 ResourceMark rm(THREAD); | |
356 ClassFileStream st((u1*) buf, bufLen, NULL); | |
357 Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); | |
358 | |
359 if (UsePerfData && !class_loader.is_null()) { | |
360 // check whether the current caller thread holds the lock or not. | |
361 // If not, increment the corresponding counter | |
362 if (ObjectSynchronizer:: | |
363 query_lock_ownership((JavaThread*)THREAD, class_loader) != | |
364 ObjectSynchronizer::owner_self) { | |
365 ClassLoader::sync_JNIDefineClassLockFreeCounter()->inc(); | |
366 } | |
367 } | |
368 klassOop k = SystemDictionary::resolve_from_stream(class_name, class_loader, | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
657
diff
changeset
|
369 Handle(), &st, true, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
657
diff
changeset
|
370 CHECK_NULL); |
0 | 371 |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
372 if (TraceClassResolution && k != NULL) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
373 trace_class_resolution(k); |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
374 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
375 |
0 | 376 cls = (jclass)JNIHandles::make_local( |
377 env, Klass::cast(k)->java_mirror()); | |
378 return cls; | |
379 JNI_END | |
380 | |
381 | |
382 | |
383 static bool first_time_FindClass = true; | |
384 | |
385 DT_RETURN_MARK_DECL(FindClass, jclass); | |
386 | |
387 JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) | |
388 JNIWrapper("FindClass"); | |
389 DTRACE_PROBE2(hotspot_jni, FindClass__entry, env, name); | |
390 | |
391 jclass result = NULL; | |
392 DT_RETURN_MARK(FindClass, jclass, (const jclass&)result); | |
393 | |
394 // Remember if we are the first invocation of jni_FindClass | |
395 bool first_time = first_time_FindClass; | |
396 first_time_FindClass = false; | |
397 | |
398 // Sanity check the name: it cannot be null or larger than the maximum size | |
399 // 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
|
400 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
0 | 401 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
402 } | |
403 | |
404 //%note jni_3 | |
405 Handle loader; | |
406 Handle protection_domain; | |
407 // Find calling class | |
408 instanceKlassHandle k (THREAD, thread->security_get_caller_class(0)); | |
409 if (k.not_null()) { | |
410 loader = Handle(THREAD, k->class_loader()); | |
411 // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed | |
412 // in the correct class context. | |
413 if (loader.is_null() && | |
414 k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) { | |
415 JavaValue result(T_OBJECT); | |
416 JavaCalls::call_static(&result, k, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
417 vmSymbols::getFromClass_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
418 vmSymbols::void_class_signature(), |
0 | 419 thread); |
420 if (HAS_PENDING_EXCEPTION) { | |
421 Handle ex(thread, thread->pending_exception()); | |
422 CLEAR_PENDING_EXCEPTION; | |
423 THROW_HANDLE_0(ex); | |
424 } | |
425 oop mirror = (oop) result.get_jobject(); | |
426 loader = Handle(THREAD, | |
427 instanceKlass::cast(java_lang_Class::as_klassOop(mirror))->class_loader()); | |
428 protection_domain = Handle(THREAD, | |
429 instanceKlass::cast(java_lang_Class::as_klassOop(mirror))->protection_domain()); | |
430 } | |
431 } else { | |
432 // We call ClassLoader.getSystemClassLoader to obtain the system class loader. | |
433 loader = Handle(THREAD, SystemDictionary::java_system_loader()); | |
434 } | |
435 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
436 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
0 | 437 result = find_class_from_class_loader(env, sym, true, loader, |
438 protection_domain, true, thread); | |
439 | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
440 if (TraceClassResolution && result != NULL) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
441 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
|
442 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
443 |
0 | 444 // If we were the first invocation of jni_FindClass, we enable compilation again |
445 // rather than just allowing invocation counter to overflow and decay. | |
446 // Controlled by flag DelayCompilationDuringStartup. | |
447 if (first_time && !CompileTheWorld) | |
448 CompilationPolicy::completed_vm_startup(); | |
449 | |
450 return result; | |
451 JNI_END | |
452 | |
453 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID); | |
454 | |
455 JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) | |
456 JNIWrapper("FromReflectedMethod"); | |
457 DTRACE_PROBE2(hotspot_jni, FromReflectedMethod__entry, env, method); | |
458 jmethodID ret = NULL; | |
459 DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret); | |
460 | |
461 // method is a handle to a java.lang.reflect.Method object | |
462 oop reflected = JNIHandles::resolve_non_null(method); | |
463 oop mirror = NULL; | |
464 int slot = 0; | |
465 | |
1142 | 466 if (reflected->klass() == SystemDictionary::reflect_Constructor_klass()) { |
0 | 467 mirror = java_lang_reflect_Constructor::clazz(reflected); |
468 slot = java_lang_reflect_Constructor::slot(reflected); | |
469 } else { | |
1142 | 470 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); |
0 | 471 mirror = java_lang_reflect_Method::clazz(reflected); |
472 slot = java_lang_reflect_Method::slot(reflected); | |
473 } | |
474 klassOop k = java_lang_Class::as_klassOop(mirror); | |
475 | |
476 KlassHandle k1(THREAD, k); | |
477 // Make sure class is initialized before handing id's out to methods | |
478 Klass::cast(k1())->initialize(CHECK_NULL); | |
479 methodOop m = instanceKlass::cast(k1())->method_with_idnum(slot); | |
480 ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted | |
481 return ret; | |
482 JNI_END | |
483 | |
484 DT_RETURN_MARK_DECL(FromReflectedField, jfieldID); | |
485 | |
486 JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) | |
487 JNIWrapper("FromReflectedField"); | |
488 DTRACE_PROBE2(hotspot_jni, FromReflectedField__entry, env, field); | |
489 jfieldID ret = NULL; | |
490 DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); | |
491 | |
492 // field is a handle to a java.lang.reflect.Field object | |
493 oop reflected = JNIHandles::resolve_non_null(field); | |
494 oop mirror = java_lang_reflect_Field::clazz(reflected); | |
495 klassOop k = java_lang_Class::as_klassOop(mirror); | |
496 int slot = java_lang_reflect_Field::slot(reflected); | |
497 int modifiers = java_lang_reflect_Field::modifiers(reflected); | |
498 | |
499 KlassHandle k1(THREAD, k); | |
500 // Make sure class is initialized before handing id's out to fields | |
501 Klass::cast(k1())->initialize(CHECK_NULL); | |
502 | |
503 // First check if this is a static field | |
504 if (modifiers & JVM_ACC_STATIC) { | |
505 intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot ); | |
506 JNIid* id = instanceKlass::cast(k1())->jni_id_for(offset); | |
507 assert(id != NULL, "corrupt Field object"); | |
508 debug_only(id->set_is_static_field_id();) | |
509 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop | |
510 ret = jfieldIDWorkaround::to_static_jfieldID(id); | |
511 return ret; | |
512 } | |
513 | |
514 // The slot is the index of the field description in the field-array | |
515 // The jfieldID is the offset of the field within the object | |
516 // It may also have hash bits for k, if VerifyJNIFields is turned on. | |
517 intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot ); | |
518 assert(instanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); | |
519 ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); | |
520 return ret; | |
521 JNI_END | |
522 | |
523 DT_RETURN_MARK_DECL(ToReflectedMethod, jobject); | |
524 | |
525 JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID method_id, jboolean isStatic)) | |
526 JNIWrapper("ToReflectedMethod"); | |
527 DTRACE_PROBE4(hotspot_jni, ToReflectedMethod__entry, env, cls, method_id, isStatic); | |
528 jobject ret = NULL; | |
529 DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); | |
530 | |
531 methodHandle m (THREAD, JNIHandles::resolve_jmethod_id(method_id)); | |
532 assert(m->is_static() == (isStatic != 0), "jni_ToReflectedMethod access flags doesn't match"); | |
533 oop reflection_method; | |
534 if (m->is_initializer()) { | |
535 reflection_method = Reflection::new_constructor(m, CHECK_NULL); | |
536 } else { | |
537 reflection_method = Reflection::new_method(m, UseNewReflection, false, CHECK_NULL); | |
538 } | |
539 ret = JNIHandles::make_local(env, reflection_method); | |
540 return ret; | |
541 JNI_END | |
542 | |
543 DT_RETURN_MARK_DECL(GetSuperclass, jclass); | |
544 | |
545 JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) | |
546 JNIWrapper("GetSuperclass"); | |
547 DTRACE_PROBE2(hotspot_jni, GetSuperclass__entry, env, sub); | |
548 jclass obj = NULL; | |
549 DT_RETURN_MARK(GetSuperclass, jclass, (const jclass&)obj); | |
550 | |
551 oop mirror = JNIHandles::resolve_non_null(sub); | |
552 // primitive classes return NULL | |
553 if (java_lang_Class::is_primitive(mirror)) return NULL; | |
554 | |
555 // Rules of Class.getSuperClass as implemented by KLass::java_super: | |
556 // arrays return Object | |
557 // interfaces return NULL | |
558 // proper classes return Klass::super() | |
559 klassOop k = java_lang_Class::as_klassOop(mirror); | |
560 if (Klass::cast(k)->is_interface()) return NULL; | |
561 | |
562 // return mirror for superclass | |
563 klassOop super = Klass::cast(k)->java_super(); | |
564 // super2 is the value computed by the compiler's getSuperClass intrinsic: | |
565 debug_only(klassOop super2 = ( Klass::cast(k)->oop_is_javaArray() | |
1142 | 566 ? SystemDictionary::Object_klass() |
0 | 567 : Klass::cast(k)->super() ) ); |
568 assert(super == super2, | |
569 "java_super computation depends on interface, array, other super"); | |
570 obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(Klass::cast(super)->java_mirror()); | |
571 return obj; | |
572 JNI_END | |
573 | |
574 JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass super)) | |
575 JNIWrapper("IsSubclassOf"); | |
576 DTRACE_PROBE3(hotspot_jni, IsAssignableFrom__entry, env, sub, super); | |
577 oop sub_mirror = JNIHandles::resolve_non_null(sub); | |
578 oop super_mirror = JNIHandles::resolve_non_null(super); | |
579 if (java_lang_Class::is_primitive(sub_mirror) || | |
580 java_lang_Class::is_primitive(super_mirror)) { | |
581 jboolean ret = (sub_mirror == super_mirror); | |
582 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); | |
583 return ret; | |
584 } | |
585 klassOop sub_klass = java_lang_Class::as_klassOop(sub_mirror); | |
586 klassOop super_klass = java_lang_Class::as_klassOop(super_mirror); | |
587 assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); | |
588 jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ? | |
589 JNI_TRUE : JNI_FALSE; | |
590 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); | |
591 return ret; | |
592 JNI_END | |
593 | |
594 DT_RETURN_MARK_DECL(Throw, jint); | |
595 | |
596 JNI_ENTRY(jint, jni_Throw(JNIEnv *env, jthrowable obj)) | |
597 JNIWrapper("Throw"); | |
598 DTRACE_PROBE2(hotspot_jni, Throw__entry, env, obj); | |
599 jint ret = JNI_OK; | |
600 DT_RETURN_MARK(Throw, jint, (const jint&)ret); | |
601 | |
602 THROW_OOP_(JNIHandles::resolve(obj), JNI_OK); | |
603 ShouldNotReachHere(); | |
604 JNI_END | |
605 | |
606 DT_RETURN_MARK_DECL(ThrowNew, jint); | |
607 | |
608 JNI_ENTRY(jint, jni_ThrowNew(JNIEnv *env, jclass clazz, const char *message)) | |
609 JNIWrapper("ThrowNew"); | |
610 DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message); | |
611 jint ret = JNI_OK; | |
612 DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); | |
613 | |
614 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
|
615 Symbol* name = k->name(); |
0 | 616 Handle class_loader (THREAD, k->class_loader()); |
617 Handle protection_domain (THREAD, k->protection_domain()); | |
618 THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK); | |
619 ShouldNotReachHere(); | |
620 JNI_END | |
621 | |
622 | |
623 // JNI functions only transform a pending async exception to a synchronous | |
624 // exception in ExceptionOccurred and ExceptionCheck calls, since | |
625 // delivering an async exception in other places won't change the native | |
626 // code's control flow and would be harmful when native code further calls | |
627 // JNI functions with a pending exception. Async exception is also checked | |
628 // during the call, so ExceptionOccurred/ExceptionCheck won't return | |
629 // false but deliver the async exception at the very end during | |
630 // state transition. | |
631 | |
632 static void jni_check_async_exceptions(JavaThread *thread) { | |
633 assert(thread == Thread::current(), "must be itself"); | |
634 thread->check_and_handle_async_exceptions(); | |
635 } | |
636 | |
637 JNI_ENTRY_NO_PRESERVE(jthrowable, jni_ExceptionOccurred(JNIEnv *env)) | |
638 JNIWrapper("ExceptionOccurred"); | |
639 DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__entry, env); | |
640 jni_check_async_exceptions(thread); | |
641 oop exception = thread->pending_exception(); | |
642 jthrowable ret = (jthrowable) JNIHandles::make_local(env, exception); | |
643 DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__return, ret); | |
644 return ret; | |
645 JNI_END | |
646 | |
647 | |
648 JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) | |
649 JNIWrapper("ExceptionDescribe"); | |
650 DTRACE_PROBE1(hotspot_jni, ExceptionDescribe__entry, env); | |
651 if (thread->has_pending_exception()) { | |
652 Handle ex(thread, thread->pending_exception()); | |
653 thread->clear_pending_exception(); | |
1142 | 654 if (ex->is_a(SystemDictionary::ThreadDeath_klass())) { |
0 | 655 // Don't print anything if we are being killed. |
656 } else { | |
657 jio_fprintf(defaultStream::error_stream(), "Exception "); | |
658 if (thread != NULL && thread->threadObj() != NULL) { | |
659 ResourceMark rm(THREAD); | |
660 jio_fprintf(defaultStream::error_stream(), | |
661 "in thread \"%s\" ", thread->get_thread_name()); | |
662 } | |
1142 | 663 if (ex->is_a(SystemDictionary::Throwable_klass())) { |
0 | 664 JavaValue result(T_VOID); |
665 JavaCalls::call_virtual(&result, | |
666 ex, | |
667 KlassHandle(THREAD, | |
1142 | 668 SystemDictionary::Throwable_klass()), |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
669 vmSymbols::printStackTrace_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
670 vmSymbols::void_method_signature(), |
0 | 671 THREAD); |
672 // If an exception is thrown in the call it gets thrown away. Not much | |
673 // we can do with it. The native code that calls this, does not check | |
674 // for the exception - hence, it might still be in the thread when DestroyVM gets | |
675 // called, potentially causing a few asserts to trigger - since no pending exception | |
676 // is expected. | |
677 CLEAR_PENDING_EXCEPTION; | |
678 } else { | |
679 ResourceMark rm(THREAD); | |
680 jio_fprintf(defaultStream::error_stream(), | |
681 ". Uncaught exception of type %s.", | |
682 Klass::cast(ex->klass())->external_name()); | |
683 } | |
684 } | |
685 } | |
686 DTRACE_PROBE(hotspot_jni, ExceptionDescribe__return); | |
687 JNI_END | |
688 | |
689 | |
690 JNI_QUICK_ENTRY(void, jni_ExceptionClear(JNIEnv *env)) | |
691 JNIWrapper("ExceptionClear"); | |
692 DTRACE_PROBE1(hotspot_jni, ExceptionClear__entry, env); | |
693 | |
694 // The jni code might be using this API to clear java thrown exception. | |
695 // So just mark jvmti thread exception state as exception caught. | |
696 JvmtiThreadState *state = JavaThread::current()->jvmti_thread_state(); | |
697 if (state != NULL && state->is_exception_detected()) { | |
698 state->set_exception_caught(); | |
699 } | |
700 thread->clear_pending_exception(); | |
701 DTRACE_PROBE(hotspot_jni, ExceptionClear__return); | |
702 JNI_END | |
703 | |
704 | |
705 JNI_ENTRY(void, jni_FatalError(JNIEnv *env, const char *msg)) | |
706 JNIWrapper("FatalError"); | |
707 DTRACE_PROBE2(hotspot_jni, FatalError__entry, env, msg); | |
708 tty->print_cr("FATAL ERROR in native method: %s", msg); | |
709 thread->print_stack(); | |
227
8d852b81e775
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
113
diff
changeset
|
710 os::abort(); // Dump core and abort |
0 | 711 JNI_END |
712 | |
713 | |
714 JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity)) | |
715 JNIWrapper("PushLocalFrame"); | |
716 DTRACE_PROBE2(hotspot_jni, PushLocalFrame__entry, env, capacity); | |
717 //%note jni_11 | |
718 if (capacity < 0 && capacity > MAX_REASONABLE_LOCAL_CAPACITY) { | |
719 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR); | |
720 return JNI_ERR; | |
721 } | |
722 JNIHandleBlock* old_handles = thread->active_handles(); | |
723 JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread); | |
724 assert(new_handles != NULL, "should not be NULL"); | |
725 new_handles->set_pop_frame_link(old_handles); | |
726 thread->set_active_handles(new_handles); | |
727 jint ret = JNI_OK; | |
728 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, ret); | |
729 return ret; | |
730 JNI_END | |
731 | |
732 | |
733 JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result)) | |
734 JNIWrapper("PopLocalFrame"); | |
735 DTRACE_PROBE2(hotspot_jni, PopLocalFrame__entry, env, result); | |
736 //%note jni_11 | |
737 Handle result_handle(thread, JNIHandles::resolve(result)); | |
738 JNIHandleBlock* old_handles = thread->active_handles(); | |
739 JNIHandleBlock* new_handles = old_handles->pop_frame_link(); | |
740 if (new_handles != NULL) { | |
741 // As a sanity check we only release the handle blocks if the pop_frame_link is not NULL. | |
742 // This way code will still work if PopLocalFrame is called without a corresponding | |
743 // PushLocalFrame call. Note that we set the pop_frame_link to NULL explicitly, otherwise | |
744 // the release_block call will release the blocks. | |
745 thread->set_active_handles(new_handles); | |
746 old_handles->set_pop_frame_link(NULL); // clear link we won't release new_handles below | |
747 JNIHandleBlock::release_block(old_handles, thread); // may block | |
748 result = JNIHandles::make_local(thread, result_handle()); | |
749 } | |
750 DTRACE_PROBE1(hotspot_jni, PopLocalFrame__return, result); | |
751 return result; | |
752 JNI_END | |
753 | |
754 | |
755 JNI_ENTRY(jobject, jni_NewGlobalRef(JNIEnv *env, jobject ref)) | |
756 JNIWrapper("NewGlobalRef"); | |
757 DTRACE_PROBE2(hotspot_jni, NewGlobalRef__entry, env, ref); | |
758 Handle ref_handle(thread, JNIHandles::resolve(ref)); | |
759 jobject ret = JNIHandles::make_global(ref_handle); | |
760 DTRACE_PROBE1(hotspot_jni, NewGlobalRef__return, ret); | |
761 return ret; | |
762 JNI_END | |
763 | |
764 // Must be JNI_ENTRY (with HandleMark) | |
765 JNI_ENTRY_NO_PRESERVE(void, jni_DeleteGlobalRef(JNIEnv *env, jobject ref)) | |
766 JNIWrapper("DeleteGlobalRef"); | |
767 DTRACE_PROBE2(hotspot_jni, DeleteGlobalRef__entry, env, ref); | |
768 JNIHandles::destroy_global(ref); | |
769 DTRACE_PROBE(hotspot_jni, DeleteGlobalRef__return); | |
770 JNI_END | |
771 | |
772 JNI_QUICK_ENTRY(void, jni_DeleteLocalRef(JNIEnv *env, jobject obj)) | |
773 JNIWrapper("DeleteLocalRef"); | |
774 DTRACE_PROBE2(hotspot_jni, DeleteLocalRef__entry, env, obj); | |
775 JNIHandles::destroy_local(obj); | |
776 DTRACE_PROBE(hotspot_jni, DeleteLocalRef__return); | |
777 JNI_END | |
778 | |
779 JNI_QUICK_ENTRY(jboolean, jni_IsSameObject(JNIEnv *env, jobject r1, jobject r2)) | |
780 JNIWrapper("IsSameObject"); | |
781 DTRACE_PROBE3(hotspot_jni, IsSameObject__entry, env, r1, r2); | |
782 oop a = JNIHandles::resolve(r1); | |
783 oop b = JNIHandles::resolve(r2); | |
784 jboolean ret = (a == b) ? JNI_TRUE : JNI_FALSE; | |
785 DTRACE_PROBE1(hotspot_jni, IsSameObject__return, ret); | |
786 return ret; | |
787 JNI_END | |
788 | |
789 | |
790 JNI_ENTRY(jobject, jni_NewLocalRef(JNIEnv *env, jobject ref)) | |
791 JNIWrapper("NewLocalRef"); | |
792 DTRACE_PROBE2(hotspot_jni, NewLocalRef__entry, env, ref); | |
793 jobject ret = JNIHandles::make_local(env, JNIHandles::resolve(ref)); | |
794 DTRACE_PROBE1(hotspot_jni, NewLocalRef__return, ret); | |
795 return ret; | |
796 JNI_END | |
797 | |
798 JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity)) | |
799 JNIWrapper("EnsureLocalCapacity"); | |
800 DTRACE_PROBE2(hotspot_jni, EnsureLocalCapacity__entry, env, capacity); | |
801 jint ret; | |
802 if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) { | |
803 ret = JNI_OK; | |
804 } else { | |
805 ret = JNI_ERR; | |
806 } | |
807 DTRACE_PROBE1(hotspot_jni, EnsureLocalCapacity__return, ret); | |
808 return ret; | |
809 JNI_END | |
810 | |
811 // Return the Handle Type | |
812 JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj)) | |
813 JNIWrapper("GetObjectRefType"); | |
814 DTRACE_PROBE2(hotspot_jni, GetObjectRefType__entry, env, obj); | |
815 jobjectRefType ret; | |
816 if (JNIHandles::is_local_handle(thread, obj) || | |
817 JNIHandles::is_frame_handle(thread, obj)) | |
818 ret = JNILocalRefType; | |
819 else if (JNIHandles::is_global_handle(obj)) | |
820 ret = JNIGlobalRefType; | |
821 else if (JNIHandles::is_weak_global_handle(obj)) | |
822 ret = JNIWeakGlobalRefType; | |
823 else | |
824 ret = JNIInvalidRefType; | |
825 DTRACE_PROBE1(hotspot_jni, GetObjectRefType__return, ret); | |
826 return ret; | |
827 JNI_END | |
828 | |
829 | |
830 class JNI_ArgumentPusher : public SignatureIterator { | |
831 protected: | |
832 JavaCallArguments* _arguments; | |
833 | |
834 virtual void get_bool () = 0; | |
835 virtual void get_char () = 0; | |
836 virtual void get_short () = 0; | |
837 virtual void get_byte () = 0; | |
838 virtual void get_int () = 0; | |
839 virtual void get_long () = 0; | |
840 virtual void get_float () = 0; | |
841 virtual void get_double () = 0; | |
842 virtual void get_object () = 0; | |
843 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
844 JNI_ArgumentPusher(Symbol* signature) : SignatureIterator(signature) { |
0 | 845 this->_return_type = T_ILLEGAL; |
846 _arguments = NULL; | |
847 } | |
848 | |
849 public: | |
850 virtual void iterate( uint64_t fingerprint ) = 0; | |
851 | |
852 void set_java_argument_object(JavaCallArguments *arguments) { _arguments = arguments; } | |
853 | |
854 inline void do_bool() { if (!is_return_type()) get_bool(); } | |
855 inline void do_char() { if (!is_return_type()) get_char(); } | |
856 inline void do_short() { if (!is_return_type()) get_short(); } | |
857 inline void do_byte() { if (!is_return_type()) get_byte(); } | |
858 inline void do_int() { if (!is_return_type()) get_int(); } | |
859 inline void do_long() { if (!is_return_type()) get_long(); } | |
860 inline void do_float() { if (!is_return_type()) get_float(); } | |
861 inline void do_double() { if (!is_return_type()) get_double(); } | |
862 inline void do_object(int begin, int end) { if (!is_return_type()) get_object(); } | |
863 inline void do_array(int begin, int end) { if (!is_return_type()) get_object(); } // do_array uses get_object -- there is no get_array | |
864 inline void do_void() { } | |
865 | |
866 JavaCallArguments* arguments() { return _arguments; } | |
867 void push_receiver(Handle h) { _arguments->push_oop(h); } | |
868 }; | |
869 | |
870 | |
871 class JNI_ArgumentPusherVaArg : public JNI_ArgumentPusher { | |
872 protected: | |
873 va_list _ap; | |
874 | |
875 inline void get_bool() { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg | |
876 inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg | |
877 inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg | |
878 inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg | |
879 inline void get_int() { _arguments->push_int(va_arg(_ap, jint)); } | |
880 | |
881 // each of these paths is exercized by the various jck Call[Static,Nonvirtual,][Void,Int,..]Method[A,V,] tests | |
882 | |
883 inline void get_long() { _arguments->push_long(va_arg(_ap, jlong)); } | |
884 inline void get_float() { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg | |
885 inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); } | |
886 inline void get_object() { jobject l = va_arg(_ap, jobject); | |
887 _arguments->push_oop(Handle((oop *)l, false)); } | |
888 | |
889 inline void set_ap(va_list rap) { | |
890 #ifdef va_copy | |
891 va_copy(_ap, rap); | |
892 #elif defined (__va_copy) | |
893 __va_copy(_ap, rap); | |
894 #else | |
895 _ap = rap; | |
896 #endif | |
897 } | |
898 | |
899 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
900 JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
901 : JNI_ArgumentPusher(signature) { |
0 | 902 set_ap(rap); |
903 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
904 JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
905 : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) { |
0 | 906 set_ap(rap); |
907 } | |
908 | |
909 // Optimized path if we have the bitvector form of signature | |
910 void iterate( uint64_t fingerprint ) { | |
911 if ( fingerprint == UCONST64(-1) ) SignatureIterator::iterate();// Must be too many arguments | |
912 else { | |
913 _return_type = (BasicType)((fingerprint >> static_feature_size) & | |
914 result_feature_mask); | |
915 | |
916 assert(fingerprint, "Fingerprint should not be 0"); | |
917 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | |
918 while ( 1 ) { | |
919 switch ( fingerprint & parameter_feature_mask ) { | |
920 case bool_parm: | |
921 case char_parm: | |
922 case short_parm: | |
923 case byte_parm: | |
924 case int_parm: | |
925 get_int(); | |
926 break; | |
927 case obj_parm: | |
928 get_object(); | |
929 break; | |
930 case long_parm: | |
931 get_long(); | |
932 break; | |
933 case float_parm: | |
934 get_float(); | |
935 break; | |
936 case double_parm: | |
937 get_double(); | |
938 break; | |
939 case done_parm: | |
940 return; | |
941 break; | |
942 default: | |
943 ShouldNotReachHere(); | |
944 break; | |
945 } | |
946 fingerprint >>= parameter_feature_size; | |
947 } | |
948 } | |
949 } | |
950 }; | |
951 | |
952 | |
953 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher { | |
954 protected: | |
955 const jvalue *_ap; | |
956 | |
957 inline void get_bool() { _arguments->push_int((jint)(_ap++)->z); } | |
958 inline void get_char() { _arguments->push_int((jint)(_ap++)->c); } | |
959 inline void get_short() { _arguments->push_int((jint)(_ap++)->s); } | |
960 inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); } | |
961 inline void get_int() { _arguments->push_int((jint)(_ap++)->i); } | |
962 | |
963 inline void get_long() { _arguments->push_long((_ap++)->j); } | |
964 inline void get_float() { _arguments->push_float((_ap++)->f); } | |
965 inline void get_double() { _arguments->push_double((_ap++)->d);} | |
966 inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); } | |
967 | |
968 inline void set_ap(const jvalue *rap) { _ap = rap; } | |
969 | |
970 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
971 JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
972 : JNI_ArgumentPusher(signature) { |
0 | 973 set_ap(rap); |
974 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
975 JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
976 : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) { |
0 | 977 set_ap(rap); |
978 } | |
979 | |
980 // Optimized path if we have the bitvector form of signature | |
981 void iterate( uint64_t fingerprint ) { | |
982 if ( fingerprint == UCONST64(-1) ) SignatureIterator::iterate(); // Must be too many arguments | |
983 else { | |
984 _return_type = (BasicType)((fingerprint >> static_feature_size) & | |
985 result_feature_mask); | |
986 assert(fingerprint, "Fingerprint should not be 0"); | |
987 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | |
988 while ( 1 ) { | |
989 switch ( fingerprint & parameter_feature_mask ) { | |
990 case bool_parm: | |
991 get_bool(); | |
992 break; | |
993 case char_parm: | |
994 get_char(); | |
995 break; | |
996 case short_parm: | |
997 get_short(); | |
998 break; | |
999 case byte_parm: | |
1000 get_byte(); | |
1001 break; | |
1002 case int_parm: | |
1003 get_int(); | |
1004 break; | |
1005 case obj_parm: | |
1006 get_object(); | |
1007 break; | |
1008 case long_parm: | |
1009 get_long(); | |
1010 break; | |
1011 case float_parm: | |
1012 get_float(); | |
1013 break; | |
1014 case double_parm: | |
1015 get_double(); | |
1016 break; | |
1017 case done_parm: | |
1018 return; | |
1019 break; | |
1020 default: | |
1021 ShouldNotReachHere(); | |
1022 break; | |
1023 } | |
1024 fingerprint >>= parameter_feature_size; | |
1025 } | |
1026 } | |
1027 } | |
1028 }; | |
1029 | |
1030 | |
1031 enum JNICallType { | |
1032 JNI_STATIC, | |
1033 JNI_VIRTUAL, | |
1034 JNI_NONVIRTUAL | |
1035 }; | |
1036 | |
1037 static methodHandle jni_resolve_interface_call(Handle recv, methodHandle method, TRAPS) { | |
1038 assert(!method.is_null() , "method should not be null"); | |
1039 | |
1040 KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) | |
1041 if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); | |
1042 KlassHandle spec_klass (THREAD, method->method_holder()); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1043 Symbol* name = method->name(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1044 Symbol* signature = method->signature(); |
0 | 1045 CallInfo info; |
1046 LinkResolver::resolve_interface_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); | |
1047 return info.selected_method(); | |
1048 } | |
1049 | |
1050 static methodHandle jni_resolve_virtual_call(Handle recv, methodHandle method, TRAPS) { | |
1051 assert(!method.is_null() , "method should not be null"); | |
1052 | |
1053 KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) | |
1054 if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); | |
1055 KlassHandle spec_klass (THREAD, method->method_holder()); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1056 Symbol* name = method->name(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1057 Symbol* signature = method->signature(); |
0 | 1058 CallInfo info; |
1059 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); | |
1060 return info.selected_method(); | |
1061 } | |
1062 | |
1063 | |
1064 | |
1065 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | |
1066 methodHandle method(THREAD, JNIHandles::resolve_jmethod_id(method_id)); | |
1067 | |
1068 // Create object to hold arguments for the JavaCall, and associate it with | |
1069 // the jni parser | |
1070 ResourceMark rm(THREAD); | |
1071 int number_of_parameters = method->size_of_parameters(); | |
1072 JavaCallArguments java_args(number_of_parameters); | |
1073 args->set_java_argument_object(&java_args); | |
1074 | |
1075 assert(method->is_static(), "method should be static"); | |
1076 | |
1077 // Fill out JavaCallArguments object | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1078 args->iterate( Fingerprinter(method).fingerprint() ); |
0 | 1079 // Initialize result type |
1080 result->set_type(args->get_ret_type()); | |
1081 | |
1082 // Invoke the method. Result is returned as oop. | |
1083 JavaCalls::call(result, method, &java_args, CHECK); | |
1084 | |
1085 // Convert result | |
1086 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | |
1087 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | |
1088 } | |
1089 } | |
1090 | |
1091 | |
1092 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | |
1093 oop recv = JNIHandles::resolve(receiver); | |
1094 if (recv == NULL) { | |
1095 THROW(vmSymbols::java_lang_NullPointerException()); | |
1096 } | |
1097 Handle h_recv(THREAD, recv); | |
1098 | |
1099 int number_of_parameters; | |
1100 methodOop selected_method; | |
1101 { | |
1102 methodOop m = JNIHandles::resolve_jmethod_id(method_id); | |
1103 number_of_parameters = m->size_of_parameters(); | |
1104 klassOop holder = m->method_holder(); | |
1105 if (!(Klass::cast(holder))->is_interface()) { | |
1106 // non-interface call -- for that little speed boost, don't handlize | |
1107 debug_only(No_Safepoint_Verifier nosafepoint;) | |
1108 if (call_type == JNI_VIRTUAL) { | |
1109 // jni_GetMethodID makes sure class is linked and initialized | |
1110 // so m should have a valid vtable index. | |
1111 int vtbl_index = m->vtable_index(); | |
1112 if (vtbl_index != methodOopDesc::nonvirtual_vtable_index) { | |
1113 klassOop k = h_recv->klass(); | |
1114 // k might be an arrayKlassOop but all vtables start at | |
1115 // the same place. The cast is to avoid virtual call and assertion. | |
1116 instanceKlass *ik = (instanceKlass*)k->klass_part(); | |
1117 selected_method = ik->method_at_vtable(vtbl_index); | |
1118 } else { | |
1119 // final method | |
1120 selected_method = m; | |
1121 } | |
1122 } else { | |
1123 // JNI_NONVIRTUAL call | |
1124 selected_method = m; | |
1125 } | |
1126 } else { | |
1127 // interface call | |
1128 KlassHandle h_holder(THREAD, holder); | |
1129 | |
1130 int itbl_index = m->cached_itable_index(); | |
1131 if (itbl_index == -1) { | |
1132 itbl_index = klassItable::compute_itable_index(m); | |
1133 m->set_cached_itable_index(itbl_index); | |
1134 // the above may have grabbed a lock, 'm' and anything non-handlized can't be used again | |
1135 } | |
1136 klassOop k = h_recv->klass(); | |
1137 selected_method = instanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); | |
1138 } | |
1139 } | |
1140 | |
1141 methodHandle method(THREAD, selected_method); | |
1142 | |
1143 // Create object to hold arguments for the JavaCall, and associate it with | |
1144 // the jni parser | |
1145 ResourceMark rm(THREAD); | |
1146 JavaCallArguments java_args(number_of_parameters); | |
1147 args->set_java_argument_object(&java_args); | |
1148 | |
1149 // handle arguments | |
1150 assert(!method->is_static(), "method should not be static"); | |
1151 args->push_receiver(h_recv); // Push jobject handle | |
1152 | |
1153 // Fill out JavaCallArguments object | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1154 args->iterate( Fingerprinter(method).fingerprint() ); |
0 | 1155 // Initialize result type |
1156 result->set_type(args->get_ret_type()); | |
1157 | |
1158 // Invoke the method. Result is returned as oop. | |
1159 JavaCalls::call(result, method, &java_args, CHECK); | |
1160 | |
1161 // Convert result | |
1162 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | |
1163 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | |
1164 } | |
1165 } | |
1166 | |
1167 | |
1168 static instanceOop alloc_object(jclass clazz, TRAPS) { | |
1169 KlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | |
1170 Klass::cast(k())->check_valid_for_instantiation(false, CHECK_NULL); | |
1171 instanceKlass::cast(k())->initialize(CHECK_NULL); | |
1172 instanceOop ih = instanceKlass::cast(k())->allocate_instance(THREAD); | |
1173 return ih; | |
1174 } | |
1175 | |
1176 DT_RETURN_MARK_DECL(AllocObject, jobject); | |
1177 | |
1178 JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) | |
1179 JNIWrapper("AllocObject"); | |
1180 | |
1181 DTRACE_PROBE2(hotspot_jni, AllocObject__entry, env, clazz); | |
1182 jobject ret = NULL; | |
1183 DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); | |
1184 | |
1185 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1186 ret = JNIHandles::make_local(env, i); | |
1187 return ret; | |
1188 JNI_END | |
1189 | |
1190 DT_RETURN_MARK_DECL(NewObjectA, jobject); | |
1191 | |
1192 JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args)) | |
1193 JNIWrapper("NewObjectA"); | |
1194 DTRACE_PROBE3(hotspot_jni, NewObjectA__entry, env, clazz, methodID); | |
1195 jobject obj = NULL; | |
1196 DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); | |
1197 | |
1198 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1199 obj = JNIHandles::make_local(env, i); | |
1200 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1201 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1202 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1203 return obj; | |
1204 JNI_END | |
1205 | |
1206 DT_RETURN_MARK_DECL(NewObjectV, jobject); | |
1207 | |
1208 JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)) | |
1209 JNIWrapper("NewObjectV"); | |
1210 DTRACE_PROBE3(hotspot_jni, NewObjectV__entry, env, clazz, methodID); | |
1211 jobject obj = NULL; | |
1212 DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); | |
1213 | |
1214 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1215 obj = JNIHandles::make_local(env, i); | |
1216 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1217 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1218 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1219 return obj; | |
1220 JNI_END | |
1221 | |
1222 DT_RETURN_MARK_DECL(NewObject, jobject); | |
1223 | |
1224 JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)) | |
1225 JNIWrapper("NewObject"); | |
1226 DTRACE_PROBE3(hotspot_jni, NewObject__entry, env, clazz, methodID); | |
1227 jobject obj = NULL; | |
1228 DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); | |
1229 | |
1230 instanceOop i = alloc_object(clazz, CHECK_NULL); | |
1231 obj = JNIHandles::make_local(env, i); | |
1232 va_list args; | |
1233 va_start(args, methodID); | |
1234 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1235 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1236 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1237 va_end(args); | |
1238 return obj; | |
1239 JNI_END | |
1240 | |
1241 | |
1242 JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj)) | |
1243 JNIWrapper("GetObjectClass"); | |
1244 DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); | |
1245 klassOop k = JNIHandles::resolve_non_null(obj)->klass(); | |
1246 jclass ret = | |
1247 (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); | |
1248 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); | |
1249 return ret; | |
1250 JNI_END | |
1251 | |
1252 JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)) | |
1253 JNIWrapper("IsInstanceOf"); | |
1254 DTRACE_PROBE3(hotspot_jni, IsInstanceOf__entry, env, obj, clazz); | |
1255 jboolean ret = JNI_TRUE; | |
1256 if (obj != NULL) { | |
1257 ret = JNI_FALSE; | |
1258 klassOop k = java_lang_Class::as_klassOop( | |
1259 JNIHandles::resolve_non_null(clazz)); | |
1260 if (k != NULL) { | |
1261 ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; | |
1262 } | |
1263 } | |
1264 DTRACE_PROBE1(hotspot_jni, IsInstanceOf__return, ret); | |
1265 return ret; | |
1266 JNI_END | |
1267 | |
1268 | |
1269 static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, | |
1270 const char *sig, bool is_static, TRAPS) { | |
1271 // %%%% This code should probably just call into a method in the LinkResolver | |
1272 // | |
1273 // The class should have been loaded (we have an instance of the class | |
1274 // passed in) so the method and signature should already be in the symbol | |
1275 // 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
|
1276 const char *name_to_probe = (name_str == NULL) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1277 ? vmSymbols::object_initializer_name()->as_C_string() |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1278 : name_str; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1279 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
|
1280 TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1281 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1282 if (name == NULL || signature == NULL) { |
0 | 1283 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
1284 } | |
1285 | |
1286 // Throw a NoSuchMethodError exception if we have an instance of a | |
1287 // primitive java.lang.Class | |
1288 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) { | |
1289 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | |
1290 } | |
1291 | |
1292 KlassHandle klass(THREAD, | |
1293 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | |
1294 | |
1295 // Make sure class is linked and initialized before handing id's out to | |
1296 // methodOops. | |
1297 Klass::cast(klass())->initialize(CHECK_NULL); | |
1298 | |
1299 methodOop m; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1300 if (name == vmSymbols::object_initializer_name() || |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1301 name == vmSymbols::class_initializer_name()) { |
0 | 1302 // Never search superclasses for constructors |
1303 if (klass->oop_is_instance()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1304 m = instanceKlass::cast(klass())->find_method(name, signature); |
0 | 1305 } else { |
1306 m = NULL; | |
1307 } | |
1308 } else { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1309 m = klass->lookup_method(name, signature); |
0 | 1310 // Look up interfaces |
1311 if (m == NULL && klass->oop_is_instance()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1312 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
|
1313 signature); |
0 | 1314 } |
1315 } | |
1316 if (m == NULL || (m->is_static() != is_static)) { | |
1317 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | |
1318 } | |
1319 return m->jmethod_id(); | |
1320 } | |
1321 | |
1322 | |
1323 JNI_ENTRY(jmethodID, jni_GetMethodID(JNIEnv *env, jclass clazz, | |
1324 const char *name, const char *sig)) | |
1325 JNIWrapper("GetMethodID"); | |
1326 DTRACE_PROBE4(hotspot_jni, GetMethodID__entry, env, clazz, name, sig); | |
1327 jmethodID ret = get_method_id(env, clazz, name, sig, false, thread); | |
1328 DTRACE_PROBE1(hotspot_jni, GetMethodID__return, ret); | |
1329 return ret; | |
1330 JNI_END | |
1331 | |
1332 | |
1333 JNI_ENTRY(jmethodID, jni_GetStaticMethodID(JNIEnv *env, jclass clazz, | |
1334 const char *name, const char *sig)) | |
1335 JNIWrapper("GetStaticMethodID"); | |
1336 DTRACE_PROBE4(hotspot_jni, GetStaticMethodID__entry, env, clazz, name, sig); | |
1337 jmethodID ret = get_method_id(env, clazz, name, sig, true, thread); | |
1338 DTRACE_PROBE1(hotspot_jni, GetStaticMethodID__return, ret); | |
1339 return ret; | |
1340 JNI_END | |
1341 | |
1342 | |
1343 | |
1344 // | |
1345 // Calling Methods | |
1346 // | |
1347 | |
1348 | |
1349 #define DEFINE_CALLMETHOD(ResultType, Result, Tag) \ | |
1350 \ | |
1351 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType);\ | |
1352 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType);\ | |
1353 DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType);\ | |
1354 \ | |
1355 JNI_ENTRY(ResultType, \ | |
1356 jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ | |
1357 JNIWrapper("Call" XSTR(Result) "Method"); \ | |
1358 \ | |
1359 DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID);\ | |
1360 ResultType ret = 0;\ | |
1361 DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ | |
1362 (const ResultType&)ret);\ | |
1363 \ | |
1364 va_list args; \ | |
1365 va_start(args, methodID); \ | |
1366 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1367 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1368 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1369 va_end(args); \ | |
1370 ret = jvalue.get_##ResultType(); \ | |
1371 return ret;\ | |
1372 JNI_END \ | |
1373 \ | |
1374 \ | |
1375 JNI_ENTRY(ResultType, \ | |
1376 jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ | |
1377 JNIWrapper("Call" XSTR(Result) "MethodV"); \ | |
1378 \ | |
1379 DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID);\ | |
1380 ResultType ret = 0;\ | |
1381 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ | |
1382 (const ResultType&)ret);\ | |
1383 \ | |
1384 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1385 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1386 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1387 ret = jvalue.get_##ResultType(); \ | |
1388 return ret;\ | |
1389 JNI_END \ | |
1390 \ | |
1391 \ | |
1392 JNI_ENTRY(ResultType, \ | |
1393 jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ | |
1394 JNIWrapper("Call" XSTR(Result) "MethodA"); \ | |
1395 DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID);\ | |
1396 ResultType ret = 0;\ | |
1397 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ | |
1398 (const ResultType&)ret);\ | |
1399 \ | |
1400 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1401 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 1402 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1403 ret = jvalue.get_##ResultType(); \ | |
1404 return ret;\ | |
1405 JNI_END | |
1406 | |
1407 // the runtime type of subword integral basic types is integer | |
1408 DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN) | |
1409 DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE) | |
1410 DEFINE_CALLMETHOD(jchar, Char, T_CHAR) | |
1411 DEFINE_CALLMETHOD(jshort, Short, T_SHORT) | |
1412 | |
1413 DEFINE_CALLMETHOD(jobject, Object, T_OBJECT) | |
1414 DEFINE_CALLMETHOD(jint, Int, T_INT) | |
1415 DEFINE_CALLMETHOD(jlong, Long, T_LONG) | |
1416 DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT) | |
1417 DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE) | |
1418 | |
1419 DT_VOID_RETURN_MARK_DECL(CallVoidMethod); | |
1420 DT_VOID_RETURN_MARK_DECL(CallVoidMethodV); | |
1421 DT_VOID_RETURN_MARK_DECL(CallVoidMethodA); | |
1422 | |
1423 JNI_ENTRY(void, jni_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)) | |
1424 JNIWrapper("CallVoidMethod"); | |
1425 DTRACE_PROBE3(hotspot_jni, CallVoidMethod__entry, env, obj, methodID); | |
1426 DT_VOID_RETURN_MARK(CallVoidMethod); | |
1427 | |
1428 va_list args; | |
1429 va_start(args, methodID); | |
1430 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1431 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1432 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1433 va_end(args); | |
1434 JNI_END | |
1435 | |
1436 | |
1437 JNI_ENTRY(void, jni_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) | |
1438 JNIWrapper("CallVoidMethodV"); | |
1439 DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); | |
1440 DT_VOID_RETURN_MARK(CallVoidMethodV); | |
1441 | |
1442 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1443 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1444 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1445 JNI_END | |
1446 | |
1447 | |
1448 JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) | |
1449 JNIWrapper("CallVoidMethodA"); | |
1450 DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); | |
1451 DT_VOID_RETURN_MARK(CallVoidMethodA); | |
1452 | |
1453 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1454 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1455 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1456 JNI_END | |
1457 | |
1458 | |
1459 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ | |
1460 \ | |
1461 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\ | |
1462 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType);\ | |
1463 DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType);\ | |
1464 \ | |
1465 JNI_ENTRY(ResultType, \ | |
1466 jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ | |
1467 JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ | |
1468 \ | |
1469 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##Method__entry, env, obj, cls, methodID);\ | |
1470 ResultType ret;\ | |
1471 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ | |
1472 (const ResultType&)ret);\ | |
1473 \ | |
1474 va_list args; \ | |
1475 va_start(args, methodID); \ | |
1476 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1477 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1478 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1479 va_end(args); \ | |
1480 ret = jvalue.get_##ResultType(); \ | |
1481 return ret;\ | |
1482 JNI_END \ | |
1483 \ | |
1484 JNI_ENTRY(ResultType, \ | |
1485 jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ | |
1486 JNIWrapper("CallNonvitual" XSTR(Result) "#MethodV"); \ | |
1487 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodV__entry, env, obj, cls, methodID);\ | |
1488 ResultType ret;\ | |
1489 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ | |
1490 (const ResultType&)ret);\ | |
1491 \ | |
1492 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1493 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1494 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1495 ret = jvalue.get_##ResultType(); \ | |
1496 return ret;\ | |
1497 JNI_END \ | |
1498 \ | |
1499 JNI_ENTRY(ResultType, \ | |
1500 jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
1501 JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ | |
1502 DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodA__entry, env, obj, cls, methodID);\ | |
1503 ResultType ret;\ | |
1504 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ | |
1505 (const ResultType&)ret);\ | |
1506 \ | |
1507 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1508 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 1509 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1510 ret = jvalue.get_##ResultType(); \ | |
1511 return ret;\ | |
1512 JNI_END | |
1513 | |
1514 // the runtime type of subword integral basic types is integer | |
1515 DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN) | |
1516 DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE) | |
1517 DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR) | |
1518 DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT) | |
1519 | |
1520 DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT) | |
1521 DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT) | |
1522 DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG) | |
1523 DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT) | |
1524 DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE) | |
1525 | |
1526 | |
1527 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod); | |
1528 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV); | |
1529 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA); | |
1530 | |
1531 JNI_ENTRY(void, jni_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) | |
1532 JNIWrapper("CallNonvirtualVoidMethod"); | |
1533 | |
1534 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethod__entry, | |
1535 env, obj, cls, methodID); | |
1536 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); | |
1537 | |
1538 va_list args; | |
1539 va_start(args, methodID); | |
1540 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1541 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1542 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
1543 va_end(args); | |
1544 JNI_END | |
1545 | |
1546 | |
1547 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) | |
1548 JNIWrapper("CallNonvirtualVoidMethodV"); | |
1549 | |
1550 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, | |
1551 env, obj, cls, methodID); | |
1552 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); | |
1553 | |
1554 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1555 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1556 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
1557 JNI_END | |
1558 | |
1559 | |
1560 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) | |
1561 JNIWrapper("CallNonvirtualVoidMethodA"); | |
1562 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, | |
1563 env, obj, cls, methodID); | |
1564 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); | |
1565 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1566 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1567 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
1568 JNI_END | |
1569 | |
1570 | |
1571 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ | |
1572 \ | |
1573 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType);\ | |
1574 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType);\ | |
1575 DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType);\ | |
1576 \ | |
1577 JNI_ENTRY(ResultType, \ | |
1578 jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ | |
1579 JNIWrapper("CallStatic" XSTR(Result) "Method"); \ | |
1580 \ | |
1581 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##Method__entry, env, cls, methodID);\ | |
1582 ResultType ret = 0;\ | |
1583 DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ | |
1584 (const ResultType&)ret);\ | |
1585 \ | |
1586 va_list args; \ | |
1587 va_start(args, methodID); \ | |
1588 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1589 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1590 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
1591 va_end(args); \ | |
1592 ret = jvalue.get_##ResultType(); \ | |
1593 return ret;\ | |
1594 JNI_END \ | |
1595 \ | |
1596 JNI_ENTRY(ResultType, \ | |
1597 jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ | |
1598 JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ | |
1599 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodV__entry, env, cls, methodID);\ | |
1600 ResultType ret = 0;\ | |
1601 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ | |
1602 (const ResultType&)ret);\ | |
1603 \ | |
1604 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1605 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
0 | 1606 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
1607 ret = jvalue.get_##ResultType(); \ | |
1608 return ret;\ | |
1609 JNI_END \ | |
1610 \ | |
1611 JNI_ENTRY(ResultType, \ | |
1612 jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ | |
1613 JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ | |
1614 DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodA__entry, env, cls, methodID);\ | |
1615 ResultType ret = 0;\ | |
1616 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ | |
1617 (const ResultType&)ret);\ | |
1618 \ | |
1619 JavaValue jvalue(Tag); \ | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1620 JNI_ArgumentPusherArray ap(methodID, args); \ |
0 | 1621 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
1622 ret = jvalue.get_##ResultType(); \ | |
1623 return ret;\ | |
1624 JNI_END | |
1625 | |
1626 // the runtime type of subword integral basic types is integer | |
1627 DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN) | |
1628 DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE) | |
1629 DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR) | |
1630 DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT) | |
1631 | |
1632 DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT) | |
1633 DEFINE_CALLSTATICMETHOD(jint, Int, T_INT) | |
1634 DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG) | |
1635 DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT) | |
1636 DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE) | |
1637 | |
1638 | |
1639 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod); | |
1640 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV); | |
1641 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA); | |
1642 | |
1643 JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...)) | |
1644 JNIWrapper("CallStaticVoidMethod"); | |
1645 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethod__entry, env, cls, methodID); | |
1646 DT_VOID_RETURN_MARK(CallStaticVoidMethod); | |
1647 | |
1648 va_list args; | |
1649 va_start(args, methodID); | |
1650 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1651 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1652 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
1653 va_end(args); | |
1654 JNI_END | |
1655 | |
1656 | |
1657 JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) | |
1658 JNIWrapper("CallStaticVoidMethodV"); | |
1659 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); | |
1660 DT_VOID_RETURN_MARK(CallStaticVoidMethodV); | |
1661 | |
1662 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1663 JNI_ArgumentPusherVaArg ap(methodID, args); |
0 | 1664 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
1665 JNI_END | |
1666 | |
1667 | |
1668 JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) | |
1669 JNIWrapper("CallStaticVoidMethodA"); | |
1670 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); | |
1671 DT_VOID_RETURN_MARK(CallStaticVoidMethodA); | |
1672 | |
1673 JavaValue jvalue(T_VOID); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1674 JNI_ArgumentPusherArray ap(methodID, args); |
0 | 1675 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
1676 JNI_END | |
1677 | |
1678 | |
1679 // | |
1680 // Accessing Fields | |
1681 // | |
1682 | |
1683 | |
1684 DT_RETURN_MARK_DECL(GetFieldID, jfieldID); | |
1685 | |
1686 JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, | |
1687 const char *name, const char *sig)) | |
1688 JNIWrapper("GetFieldID"); | |
1689 DTRACE_PROBE4(hotspot_jni, GetFieldID__entry, env, clazz, name, sig); | |
1690 jfieldID ret = 0; | |
1691 DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); | |
1692 | |
1693 // The class should have been loaded (we have an instance of the class | |
1694 // passed in) so the field and signature should already be in the symbol | |
1695 // 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
|
1696 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1697 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1698 if (fieldname == NULL || signame == NULL) { |
0 | 1699 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1700 } | |
1701 KlassHandle k(THREAD, | |
1702 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | |
1703 // Make sure class is initialized before handing id's out to fields | |
1704 Klass::cast(k())->initialize(CHECK_NULL); | |
1705 | |
1706 fieldDescriptor fd; | |
1707 if (!Klass::cast(k())->oop_is_instance() || | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1708 !instanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { |
0 | 1709 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1710 } | |
1711 | |
1712 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop | |
1713 // It may also have hash bits for k, if VerifyJNIFields is turned on. | |
1714 ret = jfieldIDWorkaround::to_instance_jfieldID(k(), fd.offset()); | |
1715 return ret; | |
1716 JNI_END | |
1717 | |
1718 | |
1719 JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)) | |
1720 JNIWrapper("GetObjectField"); | |
1721 DTRACE_PROBE3(hotspot_jni, GetObjectField__entry, env, obj, fieldID); | |
1722 oop o = JNIHandles::resolve_non_null(obj); | |
1723 klassOop k = o->klass(); | |
1724 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | |
1725 // Keep JVMTI addition small and only check enabled flag here. | |
1726 // jni_GetField_probe() assumes that is okay to create handles. | |
1727 if (JvmtiExport::should_post_field_access()) { | |
1728 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); | |
1729 } | |
1730 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
|
1731 #ifndef SERIALGC |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1732 // 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
|
1733 // 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
|
1734 // referent with the SATB barrier. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1735 if (UseG1GC) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1736 bool needs_barrier = false; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1737 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1738 if (ret != NULL && |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1739 offset == java_lang_ref_Reference::referent_offset && |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1740 instanceKlass::cast(k)->reference_type() != REF_NONE) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1741 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
|
1742 needs_barrier = true; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1743 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1744 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1745 if (needs_barrier) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1746 oop referent = JNIHandles::resolve(ret); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1747 G1SATBCardTableModRefBS::enqueue(referent); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1748 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1749 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2376
diff
changeset
|
1750 #endif // SERIALGC |
0 | 1751 DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); |
1752 return ret; | |
1753 JNI_END | |
1754 | |
1755 | |
1756 #define DEFINE_GETFIELD(Return,Fieldname,Result) \ | |
1757 \ | |
1758 DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return);\ | |
1759 \ | |
1760 JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ | |
1761 JNIWrapper("Get" XSTR(Result) "Field"); \ | |
1762 \ | |
1763 DTRACE_PROBE3(hotspot_jni, Get##Result##Field__entry, env, obj, fieldID);\ | |
1764 Return ret = 0;\ | |
1765 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | |
1766 \ | |
1767 oop o = JNIHandles::resolve_non_null(obj); \ | |
1768 klassOop k = o->klass(); \ | |
1769 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ | |
1770 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
1771 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | |
1772 /* and creates a ResetNoHandleMark. */ \ | |
1773 if (JvmtiExport::should_post_field_access()) { \ | |
1774 o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ | |
1775 } \ | |
1776 ret = o->Fieldname##_field(offset); \ | |
1777 return ret; \ | |
1778 JNI_END | |
1779 | |
1780 DEFINE_GETFIELD(jboolean, bool, Boolean) | |
1781 DEFINE_GETFIELD(jbyte, byte, Byte) | |
1782 DEFINE_GETFIELD(jchar, char, Char) | |
1783 DEFINE_GETFIELD(jshort, short, Short) | |
1784 DEFINE_GETFIELD(jint, int, Int) | |
1785 DEFINE_GETFIELD(jlong, long, Long) | |
1786 DEFINE_GETFIELD(jfloat, float, Float) | |
1787 DEFINE_GETFIELD(jdouble, double, Double) | |
1788 | |
1789 address jni_GetBooleanField_addr() { | |
1790 return (address)jni_GetBooleanField; | |
1791 } | |
1792 address jni_GetByteField_addr() { | |
1793 return (address)jni_GetByteField; | |
1794 } | |
1795 address jni_GetCharField_addr() { | |
1796 return (address)jni_GetCharField; | |
1797 } | |
1798 address jni_GetShortField_addr() { | |
1799 return (address)jni_GetShortField; | |
1800 } | |
1801 address jni_GetIntField_addr() { | |
1802 return (address)jni_GetIntField; | |
1803 } | |
1804 address jni_GetLongField_addr() { | |
1805 return (address)jni_GetLongField; | |
1806 } | |
1807 address jni_GetFloatField_addr() { | |
1808 return (address)jni_GetFloatField; | |
1809 } | |
1810 address jni_GetDoubleField_addr() { | |
1811 return (address)jni_GetDoubleField; | |
1812 } | |
1813 | |
1814 JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject value)) | |
1815 JNIWrapper("SetObjectField"); | |
1816 DTRACE_PROBE4(hotspot_jni, SetObjectField__entry, env, obj, fieldID, value); | |
1817 oop o = JNIHandles::resolve_non_null(obj); | |
1818 klassOop k = o->klass(); | |
1819 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | |
1820 // Keep JVMTI addition small and only check enabled flag here. | |
1821 // jni_SetField_probe_nh() assumes that is not okay to create handles | |
1822 // and creates a ResetNoHandleMark. | |
1823 if (JvmtiExport::should_post_field_modification()) { | |
1824 jvalue field_value; | |
1825 field_value.l = value; | |
1826 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value); | |
1827 } | |
1828 o->obj_field_put(offset, JNIHandles::resolve(value)); | |
1829 DTRACE_PROBE(hotspot_jni, SetObjectField__return); | |
1830 JNI_END | |
1831 | |
1832 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType) \ | |
1833 \ | |
1834 JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ | |
1835 JNIWrapper("Set" XSTR(Result) "Field"); \ | |
1836 \ | |
1837 HS_DTRACE_PROBE_CDECL_N(hotspot_jni, Set##Result##Field__entry, \ | |
1838 ( JNIEnv*, jobject, jfieldID FP_SELECT_##Result(COMMA Argument,/*empty*/) ) ); \ | |
1839 HS_DTRACE_PROBE_N(hotspot_jni, Set##Result##Field__entry, \ | |
1840 ( env, obj, fieldID FP_SELECT_##Result(COMMA value,/*empty*/) ) ); \ | |
1841 \ | |
1842 oop o = JNIHandles::resolve_non_null(obj); \ | |
1843 klassOop k = o->klass(); \ | |
1844 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ | |
1845 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
1846 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | |
1847 /* and creates a ResetNoHandleMark. */ \ | |
1848 if (JvmtiExport::should_post_field_modification()) { \ | |
1849 jvalue field_value; \ | |
1850 field_value.unionType = value; \ | |
1851 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ | |
1852 } \ | |
1853 o->Fieldname##_field_put(offset, value); \ | |
1854 DTRACE_PROBE(hotspot_jni, Set##Result##Field__return);\ | |
1855 JNI_END | |
1856 | |
1857 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z) | |
1858 DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b) | |
1859 DEFINE_SETFIELD(jchar, char, Char, 'C', c) | |
1860 DEFINE_SETFIELD(jshort, short, Short, 'S', s) | |
1861 DEFINE_SETFIELD(jint, int, Int, 'I', i) | |
1862 DEFINE_SETFIELD(jlong, long, Long, 'J', j) | |
1863 DEFINE_SETFIELD(jfloat, float, Float, 'F', f) | |
1864 DEFINE_SETFIELD(jdouble, double, Double, 'D', d) | |
1865 | |
1866 DT_RETURN_MARK_DECL(ToReflectedField, jobject); | |
1867 | |
1868 JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)) | |
1869 JNIWrapper("ToReflectedField"); | |
1870 DTRACE_PROBE4(hotspot_jni, ToReflectedField__entry, | |
1871 env, cls, fieldID, isStatic); | |
1872 jobject ret = NULL; | |
1873 DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); | |
1874 | |
1875 fieldDescriptor fd; | |
1876 bool found = false; | |
1877 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); | |
1878 | |
1879 assert(jfieldIDWorkaround::is_static_jfieldID(fieldID) == (isStatic != 0), "invalid fieldID"); | |
1880 | |
1881 if (isStatic) { | |
1882 // Static field. The fieldID a JNIid specifying the field holder and the offset within the klassOop. | |
1883 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); | |
1884 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
|
1885 found = id->find_local_field(&fd); |
0 | 1886 } else { |
1887 // Non-static field. The fieldID is really the offset of the field within the instanceOop. | |
1888 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | |
1889 found = instanceKlass::cast(k)->find_field_from_offset(offset, false, &fd); | |
1890 } | |
1891 assert(found, "bad fieldID passed into jni_ToReflectedField"); | |
1892 oop reflected = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); | |
1893 ret = JNIHandles::make_local(env, reflected); | |
1894 return ret; | |
1895 JNI_END | |
1896 | |
1897 | |
1898 // | |
1899 // Accessing Static Fields | |
1900 // | |
1901 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID); | |
1902 | |
1903 JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, | |
1904 const char *name, const char *sig)) | |
1905 JNIWrapper("GetStaticFieldID"); | |
1906 DTRACE_PROBE4(hotspot_jni, GetStaticFieldID__entry, env, clazz, name, sig); | |
1907 jfieldID ret = NULL; | |
1908 DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); | |
1909 | |
1910 // The class should have been loaded (we have an instance of the class | |
1911 // passed in) so the field and signature should already be in the symbol | |
1912 // 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
|
1913 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1914 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1915 if (fieldname == NULL || signame == NULL) { |
0 | 1916 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1917 } | |
1918 KlassHandle k(THREAD, | |
1919 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | |
1920 // Make sure class is initialized before handing id's out to static fields | |
1921 Klass::cast(k())->initialize(CHECK_NULL); | |
1922 | |
1923 fieldDescriptor fd; | |
1924 if (!Klass::cast(k())->oop_is_instance() || | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1925 !instanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { |
0 | 1926 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1927 } | |
1928 | |
1929 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop | |
1930 JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset()); | |
1931 debug_only(id->set_is_static_field_id();) | |
1932 | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
1933 debug_only(id->verify(fd.field_holder())); |
0 | 1934 |
1935 ret = jfieldIDWorkaround::to_static_jfieldID(id); | |
1936 return ret; | |
1937 JNI_END | |
1938 | |
1939 | |
1940 JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)) | |
1941 JNIWrapper("GetStaticObjectField"); | |
1942 DTRACE_PROBE3(hotspot_jni, GetStaticObjectField__entry, env, clazz, fieldID); | |
1943 #ifndef JNICHECK_KERNEL | |
1944 DEBUG_ONLY(klassOop param_k = jniCheck::validate_class(thread, clazz);) | |
1945 #endif // JNICHECK_KERNEL | |
1946 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); | |
1947 assert(id->is_static_field_id(), "invalid static field id"); | |
1948 // Keep JVMTI addition small and only check enabled flag here. | |
1949 // jni_GetField_probe() assumes that is okay to create handles. | |
1950 if (JvmtiExport::should_post_field_access()) { | |
1951 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); | |
1952 } | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
1953 jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset())); |
0 | 1954 DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret); |
1955 return ret; | |
1956 JNI_END | |
1957 | |
1958 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result) \ | |
1959 \ | |
1960 DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return);\ | |
1961 \ | |
1962 JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ | |
1963 JNIWrapper("GetStatic" XSTR(Result) "Field"); \ | |
1964 DTRACE_PROBE3(hotspot_jni, GetStatic##Result##Field__entry, env, clazz, fieldID);\ | |
1965 Return ret = 0;\ | |
1966 DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ | |
1967 (const Return&)ret);\ | |
1968 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
1969 assert(id->is_static_field_id(), "invalid static field id"); \ | |
1970 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
1971 /* jni_GetField_probe() assumes that is okay to create handles. */ \ | |
1972 if (JvmtiExport::should_post_field_access()) { \ | |
1973 JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ | |
1974 } \ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
1975 ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ |
0 | 1976 return ret;\ |
1977 JNI_END | |
1978 | |
1979 DEFINE_GETSTATICFIELD(jboolean, bool, Boolean) | |
1980 DEFINE_GETSTATICFIELD(jbyte, byte, Byte) | |
1981 DEFINE_GETSTATICFIELD(jchar, char, Char) | |
1982 DEFINE_GETSTATICFIELD(jshort, short, Short) | |
1983 DEFINE_GETSTATICFIELD(jint, int, Int) | |
1984 DEFINE_GETSTATICFIELD(jlong, long, Long) | |
1985 DEFINE_GETSTATICFIELD(jfloat, float, Float) | |
1986 DEFINE_GETSTATICFIELD(jdouble, double, Double) | |
1987 | |
1988 | |
1989 JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)) | |
1990 JNIWrapper("SetStaticObjectField"); | |
1991 DTRACE_PROBE4(hotspot_jni, SetStaticObjectField__entry, env, clazz, fieldID, value); | |
1992 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); | |
1993 assert(id->is_static_field_id(), "invalid static field id"); | |
1994 // Keep JVMTI addition small and only check enabled flag here. | |
1995 // jni_SetField_probe() assumes that is okay to create handles. | |
1996 if (JvmtiExport::should_post_field_modification()) { | |
1997 jvalue field_value; | |
1998 field_value.l = value; | |
1999 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value); | |
2000 } | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
2001 id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value)); |
0 | 2002 DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return); |
2003 JNI_END | |
2004 | |
2005 | |
2006 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType) \ | |
2007 \ | |
2008 JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ | |
2009 JNIWrapper("SetStatic" XSTR(Result) "Field"); \ | |
2010 HS_DTRACE_PROBE_CDECL_N(hotspot_jni, SetStatic##Result##Field__entry,\ | |
2011 ( JNIEnv*, jclass, jfieldID FP_SELECT_##Result(COMMA Argument,/*empty*/) ) ); \ | |
2012 HS_DTRACE_PROBE_N(hotspot_jni, SetStatic##Result##Field__entry, \ | |
2013 ( env, clazz, fieldID FP_SELECT_##Result(COMMA value,/*empty*/) ) ); \ | |
2014 \ | |
2015 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ | |
2016 assert(id->is_static_field_id(), "invalid static field id"); \ | |
2017 /* Keep JVMTI addition small and only check enabled flag here. */ \ | |
2018 /* jni_SetField_probe() assumes that is okay to create handles. */ \ | |
2019 if (JvmtiExport::should_post_field_modification()) { \ | |
2020 jvalue field_value; \ | |
2021 field_value.unionType = value; \ | |
2022 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ | |
2023 } \ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
2024 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ |
0 | 2025 DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\ |
2026 JNI_END | |
2027 | |
2028 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z) | |
2029 DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b) | |
2030 DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c) | |
2031 DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s) | |
2032 DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i) | |
2033 DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j) | |
2034 DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f) | |
2035 DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d) | |
2036 | |
2037 | |
2038 // | |
2039 // String Operations | |
2040 // | |
2041 | |
2042 // Unicode Interface | |
2043 | |
2044 DT_RETURN_MARK_DECL(NewString, jstring); | |
2045 | |
2046 JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len)) | |
2047 JNIWrapper("NewString"); | |
2048 DTRACE_PROBE3(hotspot_jni, NewString__entry, env, unicodeChars, len); | |
2049 jstring ret = NULL; | |
2050 DT_RETURN_MARK(NewString, jstring, (const jstring&)ret); | |
2051 oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL); | |
2052 ret = (jstring) JNIHandles::make_local(env, string); | |
2053 return ret; | |
2054 JNI_END | |
2055 | |
2056 | |
2057 JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string)) | |
2058 JNIWrapper("GetStringLength"); | |
2059 DTRACE_PROBE2(hotspot_jni, GetStringLength__entry, env, string); | |
2060 jsize ret = java_lang_String::length(JNIHandles::resolve_non_null(string)); | |
2061 DTRACE_PROBE1(hotspot_jni, GetStringLength__return, ret); | |
2062 return ret; | |
2063 JNI_END | |
2064 | |
2065 | |
2066 JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars( | |
2067 JNIEnv *env, jstring string, jboolean *isCopy)) | |
2068 JNIWrapper("GetStringChars"); | |
2069 DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); | |
2070 //%note jni_5 | |
2071 if (isCopy != NULL) { | |
2072 *isCopy = JNI_TRUE; | |
2073 } | |
2074 oop s = JNIHandles::resolve_non_null(string); | |
2075 int s_len = java_lang_String::length(s); | |
2076 typeArrayOop s_value = java_lang_String::value(s); | |
2077 int s_offset = java_lang_String::offset(s); | |
2078 jchar* buf = NEW_C_HEAP_ARRAY(jchar, s_len + 1); // add one for zero termination | |
2079 if (s_len > 0) { | |
2080 memcpy(buf, s_value->char_at_addr(s_offset), sizeof(jchar)*s_len); | |
2081 } | |
2082 buf[s_len] = 0; | |
2083 DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); | |
2084 return buf; | |
2085 JNI_END | |
2086 | |
2087 | |
2088 JNI_QUICK_ENTRY(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)) | |
2089 JNIWrapper("ReleaseStringChars"); | |
2090 DTRACE_PROBE3(hotspot_jni, ReleaseStringChars__entry, env, str, chars); | |
2091 //%note jni_6 | |
2092 if (chars != NULL) { | |
2093 // Since String objects are supposed to be immutable, don't copy any | |
2094 // new data back. A bad user will have to go after the char array. | |
2095 FreeHeap((void*) chars); | |
2096 } | |
2097 DTRACE_PROBE(hotspot_jni, ReleaseStringChars__return); | |
2098 JNI_END | |
2099 | |
2100 | |
2101 // UTF Interface | |
2102 | |
2103 DT_RETURN_MARK_DECL(NewStringUTF, jstring); | |
2104 | |
2105 JNI_ENTRY(jstring, jni_NewStringUTF(JNIEnv *env, const char *bytes)) | |
2106 JNIWrapper("NewStringUTF"); | |
2107 DTRACE_PROBE2(hotspot_jni, NewStringUTF__entry, env, bytes); | |
2108 jstring ret; | |
2109 DT_RETURN_MARK(NewStringUTF, jstring, (const jstring&)ret); | |
2110 | |
2111 oop result = java_lang_String::create_oop_from_str((char*) bytes, CHECK_NULL); | |
2112 ret = (jstring) JNIHandles::make_local(env, result); | |
2113 return ret; | |
2114 JNI_END | |
2115 | |
2116 | |
2117 JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string)) | |
2118 JNIWrapper("GetStringUTFLength"); | |
2119 DTRACE_PROBE2(hotspot_jni, GetStringUTFLength__entry, env, string); | |
2120 jsize ret = java_lang_String::utf8_length(JNIHandles::resolve_non_null(string)); | |
2121 DTRACE_PROBE1(hotspot_jni, GetStringUTFLength__return, ret); | |
2122 return ret; | |
2123 JNI_END | |
2124 | |
2125 | |
2126 JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) | |
2127 JNIWrapper("GetStringUTFChars"); | |
2128 DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy); | |
1989
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1980
diff
changeset
|
2129 oop java_string = JNIHandles::resolve_non_null(string); |
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1980
diff
changeset
|
2130 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
|
2131 char* result = AllocateHeap(length + 1, "GetStringUTFChars"); |
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1980
diff
changeset
|
2132 java_lang_String::as_utf8_string(java_string, result, (int) length + 1); |
0 | 2133 if (isCopy != NULL) *isCopy = JNI_TRUE; |
2134 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); | |
2135 return result; | |
2136 JNI_END | |
2137 | |
2138 | |
2139 JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars)) | |
2140 JNIWrapper("ReleaseStringUTFChars"); | |
2141 DTRACE_PROBE3(hotspot_jni, ReleaseStringUTFChars__entry, env, str, chars); | |
2142 if (chars != NULL) { | |
2143 FreeHeap((char*) chars); | |
2144 } | |
2145 DTRACE_PROBE(hotspot_jni, ReleaseStringUTFChars__return); | |
2146 JNI_END | |
2147 | |
2148 | |
2149 JNI_QUICK_ENTRY(jsize, jni_GetArrayLength(JNIEnv *env, jarray array)) | |
2150 JNIWrapper("GetArrayLength"); | |
2151 DTRACE_PROBE2(hotspot_jni, GetArrayLength__entry, env, array); | |
2152 arrayOop a = arrayOop(JNIHandles::resolve_non_null(array)); | |
2153 assert(a->is_array(), "must be array"); | |
2154 jsize ret = a->length(); | |
2155 DTRACE_PROBE1(hotspot_jni, GetArrayLength__return, ret); | |
2156 return ret; | |
2157 JNI_END | |
2158 | |
2159 | |
2160 // | |
2161 // Object Array Operations | |
2162 // | |
2163 | |
2164 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray); | |
2165 | |
2166 JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)) | |
2167 JNIWrapper("NewObjectArray"); | |
2168 DTRACE_PROBE4(hotspot_jni, NewObjectArray__entry, env, length, elementClass, initialElement); | |
2169 jobjectArray ret = NULL; | |
2170 DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); | |
2171 KlassHandle ek(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(elementClass))); | |
2172 klassOop ako = Klass::cast(ek())->array_klass(CHECK_NULL); | |
2173 KlassHandle ak = KlassHandle(THREAD, ako); | |
2174 objArrayKlass::cast(ak())->initialize(CHECK_NULL); | |
2175 objArrayOop result = objArrayKlass::cast(ak())->allocate(length, CHECK_NULL); | |
2176 oop initial_value = JNIHandles::resolve(initialElement); | |
2177 if (initial_value != NULL) { // array already initialized with NULL | |
2178 for (int index = 0; index < length; index++) { | |
2179 result->obj_at_put(index, initial_value); | |
2180 } | |
2181 } | |
2182 ret = (jobjectArray) JNIHandles::make_local(env, result); | |
2183 return ret; | |
2184 JNI_END | |
2185 | |
2186 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject); | |
2187 | |
2188 JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)) | |
2189 JNIWrapper("GetObjectArrayElement"); | |
2190 DTRACE_PROBE3(hotspot_jni, GetObjectArrayElement__entry, env, array, index); | |
2191 jobject ret = NULL; | |
2192 DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); | |
2193 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); | |
2194 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
|
2195 ret = JNIHandles::make_local(env, a->obj_at(index)); |
0 | 2196 return ret; |
2197 } else { | |
2198 char buf[jintAsStringSize]; | |
2199 sprintf(buf, "%d", index); | |
2200 THROW_MSG_0(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), buf); | |
2201 } | |
2202 JNI_END | |
2203 | |
2204 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement); | |
2205 | |
2206 JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value)) | |
2207 JNIWrapper("SetObjectArrayElement"); | |
2208 DTRACE_PROBE4(hotspot_jni, SetObjectArrayElement__entry, env, array, index, value); | |
2209 DT_VOID_RETURN_MARK(SetObjectArrayElement); | |
2210 | |
2211 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); | |
2212 oop v = JNIHandles::resolve(value); | |
2213 if (a->is_within_bounds(index)) { | |
2214 if (v == NULL || v->is_a(objArrayKlass::cast(a->klass())->element_klass())) { | |
2215 a->obj_at_put(index, v); | |
2216 } else { | |
2217 THROW(vmSymbols::java_lang_ArrayStoreException()); | |
2218 } | |
2219 } else { | |
2220 char buf[jintAsStringSize]; | |
2221 sprintf(buf, "%d", index); | |
2222 THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), buf); | |
2223 } | |
2224 JNI_END | |
2225 | |
2226 | |
2227 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \ | |
2228 \ | |
1034
08780c8a9f04
6893483: DTrace probe return values for a couple JNI methods are wrong
kamg
parents:
973
diff
changeset
|
2229 DT_RETURN_MARK_DECL(New##Result##Array, Return);\ |
0 | 2230 \ |
2231 JNI_ENTRY(Return, \ | |
2232 jni_New##Result##Array(JNIEnv *env, jsize len)) \ | |
2233 JNIWrapper("New" XSTR(Result) "Array"); \ | |
2234 DTRACE_PROBE2(hotspot_jni, New##Result##Array__entry, env, len);\ | |
2235 Return ret = NULL;\ | |
1034
08780c8a9f04
6893483: DTrace probe return values for a couple JNI methods are wrong
kamg
parents:
973
diff
changeset
|
2236 DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ |
0 | 2237 \ |
2238 oop obj= oopFactory::Allocator(len, CHECK_0); \ | |
2239 ret = (Return) JNIHandles::make_local(env, obj); \ | |
2240 return ret;\ | |
2241 JNI_END | |
2242 | |
2243 DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean) | |
2244 DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte) | |
2245 DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short) | |
2246 DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char) | |
2247 DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int) | |
2248 DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long) | |
2249 DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float) | |
2250 DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double) | |
2251 | |
2252 | |
2253 // Return an address which will fault if the caller writes to it. | |
2254 | |
2255 static char* get_bad_address() { | |
2256 static char* bad_address = NULL; | |
2257 if (bad_address == NULL) { | |
2258 size_t size = os::vm_allocation_granularity(); | |
2259 bad_address = os::reserve_memory(size); | |
2260 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
|
2261 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
|
2262 /*is_committed*/false); |
0 | 2263 } |
2264 } | |
2265 return bad_address; | |
2266 } | |
2267 | |
2268 | |
2269 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag) \ | |
2270 \ | |
2271 JNI_QUICK_ENTRY(ElementType*, \ | |
2272 jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ | |
2273 JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ | |
2274 DTRACE_PROBE3(hotspot_jni, Get##Result##ArrayElements__entry, env, array, isCopy);\ | |
2275 /* allocate an chunk of memory in c land */ \ | |
2276 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
2277 ElementType* result; \ | |
2278 int len = a->length(); \ | |
2279 if (len == 0) { \ | |
2280 /* Empty array: legal but useless, can't return NULL. \ | |
2281 * Return a pointer to something useless. \ | |
2282 * Avoid asserts in typeArrayOop. */ \ | |
2283 result = (ElementType*)get_bad_address(); \ | |
2284 } else { \ | |
2285 result = NEW_C_HEAP_ARRAY(ElementType, len); \ | |
2286 /* copy the array to the c chunk */ \ | |
2287 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ | |
2288 } \ | |
2289 if (isCopy) *isCopy = JNI_TRUE; \ | |
2290 DTRACE_PROBE1(hotspot_jni, Get##Result##ArrayElements__return, result);\ | |
2291 return result; \ | |
2292 JNI_END | |
2293 | |
2294 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | |
2295 DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) | |
2296 DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) | |
2297 DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) | |
2298 DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int) | |
2299 DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long) | |
2300 DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) | |
2301 DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) | |
2302 | |
2303 | |
2304 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag) \ | |
2305 \ | |
2306 JNI_QUICK_ENTRY(void, \ | |
2307 jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ | |
2308 ElementType *buf, jint mode)) \ | |
2309 JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ | |
2310 DTRACE_PROBE4(hotspot_jni, Release##Result##ArrayElements__entry, env, array, buf, mode);\ | |
2311 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
2312 int len = a->length(); \ | |
2313 if (len != 0) { /* Empty array: nothing to free or copy. */ \ | |
2314 if ((mode == 0) || (mode == JNI_COMMIT)) { \ | |
2315 memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ | |
2316 } \ | |
2317 if ((mode == 0) || (mode == JNI_ABORT)) { \ | |
2318 FreeHeap(buf); \ | |
2319 } \ | |
2320 } \ | |
2321 DTRACE_PROBE(hotspot_jni, Release##Result##ArrayElements__return);\ | |
2322 JNI_END | |
2323 | |
2324 DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | |
2325 DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) | |
2326 DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) | |
2327 DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) | |
2328 DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int) | |
2329 DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long) | |
2330 DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) | |
2331 DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) | |
2332 | |
2333 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ | |
2334 DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion);\ | |
2335 \ | |
2336 JNI_ENTRY(void, \ | |
2337 jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
2338 jsize len, ElementType *buf)) \ | |
2339 JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ | |
2340 DTRACE_PROBE5(hotspot_jni, Get##Result##ArrayRegion__entry, env, array, start, len, buf);\ | |
2341 DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ | |
2342 typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
2343 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ | |
2344 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
2345 } else { \ | |
2346 if (len > 0) { \ | |
2347 int sc = typeArrayKlass::cast(src->klass())->log2_element_size(); \ | |
2348 memcpy((u_char*) buf, \ | |
2349 (u_char*) src->Tag##_at_addr(start), \ | |
2350 len << sc); \ | |
2351 } \ | |
2352 } \ | |
2353 JNI_END | |
2354 | |
2355 DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool) | |
2356 DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) | |
2357 DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short) | |
2358 DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char) | |
2359 DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int) | |
2360 DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long) | |
2361 DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) | |
2362 DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) | |
2363 | |
2364 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ | |
2365 DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion);\ | |
2366 \ | |
2367 JNI_ENTRY(void, \ | |
2368 jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ | |
2369 jsize len, const ElementType *buf)) \ | |
2370 JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ | |
2371 DTRACE_PROBE5(hotspot_jni, Set##Result##ArrayRegion__entry, env, array, start, len, buf);\ | |
2372 DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ | |
2373 typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ | |
2374 if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ | |
2375 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ | |
2376 } else { \ | |
2377 if (len > 0) { \ | |
2378 int sc = typeArrayKlass::cast(dst->klass())->log2_element_size(); \ | |
2379 memcpy((u_char*) dst->Tag##_at_addr(start), \ | |
2380 (u_char*) buf, \ | |
2381 len << sc); \ | |
2382 } \ | |
2383 } \ | |
2384 JNI_END | |
2385 | |
2386 DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool) | |
2387 DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) | |
2388 DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short) | |
2389 DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char) | |
2390 DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int) | |
2391 DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long) | |
2392 DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) | |
2393 DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) | |
2394 | |
2395 | |
2396 // | |
2397 // Interception of natives | |
2398 // | |
2399 | |
2400 // The RegisterNatives call being attempted tried to register with a method that | |
2401 // is not native. Ask JVM TI what prefixes have been specified. Then check | |
2402 // to see if the native method is now wrapped with the prefixes. See the | |
2403 // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. | |
2404 static methodOop find_prefixed_native(KlassHandle k, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2405 Symbol* name, Symbol* signature, TRAPS) { |
0 | 2406 ResourceMark rm(THREAD); |
2407 methodOop method; | |
2408 int name_len = name->utf8_length(); | |
2409 char* name_str = name->as_utf8(); | |
2410 int prefix_count; | |
2411 char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count); | |
2412 for (int i = 0; i < prefix_count; i++) { | |
2413 char* prefix = prefixes[i]; | |
2414 int prefix_len = (int)strlen(prefix); | |
2415 | |
2416 // try adding this prefix to the method name and see if it matches another method name | |
2417 int trial_len = name_len + prefix_len; | |
2418 char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1); | |
2419 strcpy(trial_name_str, prefix); | |
2420 strcat(trial_name_str, name_str); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2421 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
|
2422 if (trial_name == NULL) { |
0 | 2423 continue; // no such symbol, so this prefix wasn't used, try the next prefix |
2424 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2425 method = Klass::cast(k())->lookup_method(trial_name, signature); |
0 | 2426 if (method == NULL) { |
2427 continue; // signature doesn't match, try the next prefix | |
2428 } | |
2429 if (method->is_native()) { | |
2430 method->set_is_prefixed_native(); | |
2431 return method; // wahoo, we found a prefixed version of the method, return it | |
2432 } | |
2433 // found as non-native, so prefix is good, add it, probably just need more prefixes | |
2434 name_len = trial_len; | |
2435 name_str = trial_name_str; | |
2436 } | |
2437 return NULL; // not found | |
2438 } | |
2439 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2440 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
|
2441 methodOop method = Klass::cast(k())->lookup_method(name, signature); |
0 | 2442 if (method == NULL) { |
2443 ResourceMark rm; | |
2444 stringStream st; | |
2445 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
|
2446 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); |
0 | 2447 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
2448 } | |
2449 if (!method->is_native()) { | |
2450 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) | |
2451 method = find_prefixed_native(k, name, signature, THREAD); | |
2452 if (method == NULL) { | |
2453 ResourceMark rm; | |
2454 stringStream st; | |
2455 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
|
2456 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); |
0 | 2457 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
2458 } | |
2459 } | |
2460 | |
2461 if (entry != NULL) { | |
2462 method->set_native_function(entry, | |
2463 methodOopDesc::native_bind_event_is_interesting); | |
2464 } else { | |
2465 method->clear_native_function(); | |
2466 } | |
2467 if (PrintJNIResolving) { | |
2468 ResourceMark rm(THREAD); | |
2469 tty->print_cr("[Registering JNI native method %s.%s]", | |
2470 Klass::cast(method->method_holder())->external_name(), | |
2471 method->name()->as_C_string()); | |
2472 } | |
2473 return true; | |
2474 } | |
2475 | |
2476 DT_RETURN_MARK_DECL(RegisterNatives, jint); | |
2477 | |
2478 JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, | |
2479 const JNINativeMethod *methods, | |
2480 jint nMethods)) | |
2481 JNIWrapper("RegisterNatives"); | |
2482 DTRACE_PROBE4(hotspot_jni, RegisterNatives__entry, env, clazz, methods, nMethods); | |
2483 jint ret = 0; | |
2484 DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); | |
2485 | |
2486 KlassHandle h_k(thread, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | |
2487 | |
2488 for (int index = 0; index < nMethods; index++) { | |
2489 const char* meth_name = methods[index].name; | |
2490 const char* meth_sig = methods[index].signature; | |
2491 int meth_name_len = (int)strlen(meth_name); | |
2492 | |
2493 // The class should have been loaded (we have an instance of the class | |
2494 // passed in) so the method and signature should already be in the symbol | |
2495 // 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
|
2496 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
|
2497 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
|
2498 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2499 if (name == NULL || signature == NULL) { |
0 | 2500 ResourceMark rm; |
2501 stringStream st; | |
2502 st.print("Method %s.%s%s not found", Klass::cast(h_k())->external_name(), meth_name, meth_sig); | |
2503 // Must return negative value on failure | |
2504 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); | |
2505 } | |
2506 | |
2507 bool res = register_native(h_k, name, signature, | |
2508 (address) methods[index].fnPtr, THREAD); | |
2509 if (!res) { | |
2510 ret = -1; | |
2511 break; | |
2512 } | |
2513 } | |
2514 return ret; | |
2515 JNI_END | |
2516 | |
2517 | |
2518 JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) | |
2519 JNIWrapper("UnregisterNatives"); | |
2520 DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); | |
2521 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)); | |
2522 //%note jni_2 | |
2523 if (Klass::cast(k)->oop_is_instance()) { | |
2524 for (int index = 0; index < instanceKlass::cast(k)->methods()->length(); index++) { | |
2525 methodOop m = methodOop(instanceKlass::cast(k)->methods()->obj_at(index)); | |
2526 if (m->is_native()) { | |
2527 m->clear_native_function(); | |
2528 m->set_signature_handler(NULL); | |
2529 } | |
2530 } | |
2531 } | |
2532 DTRACE_PROBE1(hotspot_jni, UnregisterNatives__return, 0); | |
2533 return 0; | |
2534 JNI_END | |
2535 | |
2536 // | |
2537 // Monitor functions | |
2538 // | |
2539 | |
2540 DT_RETURN_MARK_DECL(MonitorEnter, jint); | |
2541 | |
2542 JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) | |
2543 DTRACE_PROBE2(hotspot_jni, MonitorEnter__entry, env, jobj); | |
2544 jint ret = JNI_ERR; | |
2545 DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret); | |
2546 | |
2547 // If the object is null, we can't do anything with it | |
2548 if (jobj == NULL) { | |
2549 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); | |
2550 } | |
2551 | |
2552 Handle obj(thread, JNIHandles::resolve_non_null(jobj)); | |
2553 ObjectSynchronizer::jni_enter(obj, CHECK_(JNI_ERR)); | |
2554 ret = JNI_OK; | |
2555 return ret; | |
2556 JNI_END | |
2557 | |
2558 DT_RETURN_MARK_DECL(MonitorExit, jint); | |
2559 | |
2560 JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj)) | |
2561 DTRACE_PROBE2(hotspot_jni, MonitorExit__entry, env, jobj); | |
2562 jint ret = JNI_ERR; | |
2563 DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret); | |
2564 | |
2565 // Don't do anything with a null object | |
2566 if (jobj == NULL) { | |
2567 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); | |
2568 } | |
2569 | |
2570 Handle obj(THREAD, JNIHandles::resolve_non_null(jobj)); | |
2571 ObjectSynchronizer::jni_exit(obj(), CHECK_(JNI_ERR)); | |
2572 | |
2573 ret = JNI_OK; | |
2574 return ret; | |
2575 JNI_END | |
2576 | |
2577 // | |
2578 // Extensions | |
2579 // | |
2580 | |
2581 DT_VOID_RETURN_MARK_DECL(GetStringRegion); | |
2582 | |
2583 JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, jsize len, jchar *buf)) | |
2584 JNIWrapper("GetStringRegion"); | |
2585 DTRACE_PROBE5(hotspot_jni, GetStringRegion__entry, env, string, start, len, buf); | |
2586 DT_VOID_RETURN_MARK(GetStringRegion); | |
2587 oop s = JNIHandles::resolve_non_null(string); | |
2588 int s_len = java_lang_String::length(s); | |
2589 if (start < 0 || len < 0 || start + len > s_len) { | |
2590 THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException()); | |
2591 } else { | |
2592 if (len > 0) { | |
2593 int s_offset = java_lang_String::offset(s); | |
2594 typeArrayOop s_value = java_lang_String::value(s); | |
2595 memcpy(buf, s_value->char_at_addr(s_offset+start), sizeof(jchar)*len); | |
2596 } | |
2597 } | |
2598 JNI_END | |
2599 | |
2600 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion); | |
2601 | |
2602 JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, jsize len, char *buf)) | |
2603 JNIWrapper("GetStringUTFRegion"); | |
2604 DTRACE_PROBE5(hotspot_jni, GetStringUTFRegion__entry, env, string, start, len, buf); | |
2605 DT_VOID_RETURN_MARK(GetStringUTFRegion); | |
2606 oop s = JNIHandles::resolve_non_null(string); | |
2607 int s_len = java_lang_String::length(s); | |
2608 if (start < 0 || len < 0 || start + len > s_len) { | |
2609 THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException()); | |
2610 } else { | |
2611 //%note jni_7 | |
2612 if (len > 0) { | |
2613 ResourceMark rm(THREAD); | |
2614 char *utf_region = java_lang_String::as_utf8_string(s, start, len); | |
2615 int utf_len = (int)strlen(utf_region); | |
2616 memcpy(buf, utf_region, utf_len); | |
2617 buf[utf_len] = 0; | |
2618 } else { | |
2619 // JDK null-terminates the buffer even in len is zero | |
2620 if (buf != NULL) { | |
2621 buf[0] = 0; | |
2622 } | |
2623 } | |
2624 } | |
2625 JNI_END | |
2626 | |
2627 | |
2628 JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)) | |
2629 JNIWrapper("GetPrimitiveArrayCritical"); | |
2630 DTRACE_PROBE3(hotspot_jni, GetPrimitiveArrayCritical__entry, env, array, isCopy); | |
2631 GC_locker::lock_critical(thread); | |
2632 if (isCopy != NULL) { | |
2633 *isCopy = JNI_FALSE; | |
2634 } | |
2635 oop a = JNIHandles::resolve_non_null(array); | |
2636 assert(a->is_array(), "just checking"); | |
2637 BasicType type; | |
2638 if (a->is_objArray()) { | |
2639 type = T_OBJECT; | |
2640 } else { | |
2641 type = typeArrayKlass::cast(a->klass())->element_type(); | |
2642 } | |
2643 void* ret = arrayOop(a)->base(type); | |
2644 DTRACE_PROBE1(hotspot_jni, GetPrimitiveArrayCritical__return, ret); | |
2645 return ret; | |
2646 JNI_END | |
2647 | |
2648 | |
2649 JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)) | |
2650 JNIWrapper("ReleasePrimitiveArrayCritical"); | |
2651 DTRACE_PROBE4(hotspot_jni, ReleasePrimitiveArrayCritical__entry, env, array, carray, mode); | |
2652 // The array, carray and mode arguments are ignored | |
2653 GC_locker::unlock_critical(thread); | |
2654 DTRACE_PROBE(hotspot_jni, ReleasePrimitiveArrayCritical__return); | |
2655 JNI_END | |
2656 | |
2657 | |
2658 JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy)) | |
2659 JNIWrapper("GetStringCritical"); | |
2660 DTRACE_PROBE3(hotspot_jni, GetStringCritical__entry, env, string, isCopy); | |
2661 GC_locker::lock_critical(thread); | |
2662 if (isCopy != NULL) { | |
2663 *isCopy = JNI_FALSE; | |
2664 } | |
2665 oop s = JNIHandles::resolve_non_null(string); | |
2666 int s_len = java_lang_String::length(s); | |
2667 typeArrayOop s_value = java_lang_String::value(s); | |
2668 int s_offset = java_lang_String::offset(s); | |
2669 const jchar* ret; | |
2670 if (s_len > 0) { | |
2671 ret = s_value->char_at_addr(s_offset); | |
2672 } else { | |
2673 ret = (jchar*) s_value->base(T_CHAR); | |
2674 } | |
2675 DTRACE_PROBE1(hotspot_jni, GetStringCritical__return, ret); | |
2676 return ret; | |
2677 JNI_END | |
2678 | |
2679 | |
2680 JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars)) | |
2681 JNIWrapper("ReleaseStringCritical"); | |
2682 DTRACE_PROBE3(hotspot_jni, ReleaseStringCritical__entry, env, str, chars); | |
2683 // The str and chars arguments are ignored | |
2684 GC_locker::unlock_critical(thread); | |
2685 DTRACE_PROBE(hotspot_jni, ReleaseStringCritical__return); | |
2686 JNI_END | |
2687 | |
2688 | |
2689 JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) | |
2690 JNIWrapper("jni_NewWeakGlobalRef"); | |
2691 DTRACE_PROBE2(hotspot_jni, NewWeakGlobalRef__entry, env, ref); | |
2692 Handle ref_handle(thread, JNIHandles::resolve(ref)); | |
2693 jweak ret = JNIHandles::make_weak_global(ref_handle); | |
2694 DTRACE_PROBE1(hotspot_jni, NewWeakGlobalRef__return, ret); | |
2695 return ret; | |
2696 JNI_END | |
2697 | |
2698 // Must be JNI_ENTRY (with HandleMark) | |
2699 JNI_ENTRY(void, jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref)) | |
2700 JNIWrapper("jni_DeleteWeakGlobalRef"); | |
2701 DTRACE_PROBE2(hotspot_jni, DeleteWeakGlobalRef__entry, env, ref); | |
2702 JNIHandles::destroy_weak_global(ref); | |
2703 DTRACE_PROBE(hotspot_jni, DeleteWeakGlobalRef__return); | |
2704 JNI_END | |
2705 | |
2706 | |
2707 JNI_QUICK_ENTRY(jboolean, jni_ExceptionCheck(JNIEnv *env)) | |
2708 JNIWrapper("jni_ExceptionCheck"); | |
2709 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__entry, env); | |
2710 jni_check_async_exceptions(thread); | |
2711 jboolean ret = (thread->has_pending_exception()) ? JNI_TRUE : JNI_FALSE; | |
2712 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__return, ret); | |
2713 return ret; | |
2714 JNI_END | |
2715 | |
2716 | |
2717 // Initialization state for three routines below relating to | |
2718 // java.nio.DirectBuffers | |
2719 static jint directBufferSupportInitializeStarted = 0; | |
2720 static volatile jint directBufferSupportInitializeEnded = 0; | |
2721 static volatile jint directBufferSupportInitializeFailed = 0; | |
2722 static jclass bufferClass = NULL; | |
2723 static jclass directBufferClass = NULL; | |
2724 static jclass directByteBufferClass = NULL; | |
2725 static jmethodID directByteBufferConstructor = NULL; | |
2726 static jfieldID directBufferAddressField = NULL; | |
2727 static jfieldID bufferCapacityField = NULL; | |
2728 | |
2729 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { | |
2730 Handle loader; // null (bootstrap) loader | |
2731 Handle protection_domain; // null protection domain | |
2732 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
2733 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
2734 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
|
2735 |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
2736 if (TraceClassResolution && result != NULL) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
2737 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
|
2738 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
2739 return result; |
0 | 2740 } |
2741 | |
2742 // These lookups are done with the NULL (bootstrap) ClassLoader to | |
2743 // circumvent any security checks that would be done by jni_FindClass. | |
2744 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env)) | |
2745 { | |
2746 if ((bufferClass = lookupOne(env, "java/nio/Buffer", thread)) == NULL) { return false; } | |
2747 if ((directBufferClass = lookupOne(env, "sun/nio/ch/DirectBuffer", thread)) == NULL) { return false; } | |
2748 if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; } | |
2749 return true; | |
2750 } | |
2751 JNI_END | |
2752 | |
2753 | |
2754 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { | |
2755 if (directBufferSupportInitializeFailed) { | |
2756 return false; | |
2757 } | |
2758 | |
2759 if (Atomic::cmpxchg(1, &directBufferSupportInitializeStarted, 0) == 0) { | |
2760 if (!lookupDirectBufferClasses(env)) { | |
2761 directBufferSupportInitializeFailed = 1; | |
2762 return false; | |
2763 } | |
2764 | |
2765 // Make global references for these | |
2766 bufferClass = (jclass) env->NewGlobalRef(bufferClass); | |
2767 directBufferClass = (jclass) env->NewGlobalRef(directBufferClass); | |
2768 directByteBufferClass = (jclass) env->NewGlobalRef(directByteBufferClass); | |
2769 | |
2770 // Get needed field and method IDs | |
2771 directByteBufferConstructor = env->GetMethodID(directByteBufferClass, "<init>", "(JI)V"); | |
2772 directBufferAddressField = env->GetFieldID(bufferClass, "address", "J"); | |
2773 bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I"); | |
2774 | |
2775 if ((directByteBufferConstructor == NULL) || | |
2776 (directBufferAddressField == NULL) || | |
2777 (bufferCapacityField == NULL)) { | |
2778 directBufferSupportInitializeFailed = 1; | |
2779 return false; | |
2780 } | |
2781 | |
2782 directBufferSupportInitializeEnded = 1; | |
2783 } else { | |
2784 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
|
2785 // 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
|
2786 // 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
|
2787 // 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
|
2788 // 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
|
2789 // 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
|
2790 ThreadInVMfromNative tivn(thread); |
0 | 2791 os::yield_all(); |
2792 } | |
2793 } | |
2794 | |
2795 return !directBufferSupportInitializeFailed; | |
2796 } | |
2797 | |
2798 extern "C" jobject JNICALL jni_NewDirectByteBuffer(JNIEnv *env, void* address, jlong capacity) | |
2799 { | |
2800 // thread_from_jni_environment() will block if VM is gone. | |
2801 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
2802 | |
2803 JNIWrapper("jni_NewDirectByteBuffer"); | |
2804 DTRACE_PROBE3(hotspot_jni, NewDirectByteBuffer__entry, env, address, capacity); | |
2805 | |
2806 if (!directBufferSupportInitializeEnded) { | |
2807 if (!initializeDirectBufferSupport(env, thread)) { | |
2808 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, NULL); | |
2809 return NULL; | |
2810 } | |
2811 } | |
2812 | |
2813 // Being paranoid about accidental sign extension on address | |
2814 jlong addr = (jlong) ((uintptr_t) address); | |
2815 // NOTE that package-private DirectByteBuffer constructor currently | |
2816 // takes int capacity | |
2817 jint cap = (jint) capacity; | |
2818 jobject ret = env->NewObject(directByteBufferClass, directByteBufferConstructor, addr, cap); | |
2819 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, ret); | |
2820 return ret; | |
2821 } | |
2822 | |
2823 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*); | |
2824 | |
2825 extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) | |
2826 { | |
2827 // thread_from_jni_environment() will block if VM is gone. | |
2828 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
2829 | |
2830 JNIWrapper("jni_GetDirectBufferAddress"); | |
2831 DTRACE_PROBE2(hotspot_jni, GetDirectBufferAddress__entry, env, buf); | |
2832 void* ret = NULL; | |
2833 DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret); | |
2834 | |
2835 if (!directBufferSupportInitializeEnded) { | |
2836 if (!initializeDirectBufferSupport(env, thread)) { | |
2837 return 0; | |
2838 } | |
2839 } | |
2840 | |
2841 if ((buf != NULL) && (!env->IsInstanceOf(buf, directBufferClass))) { | |
2842 return 0; | |
2843 } | |
2844 | |
2845 ret = (void*)(intptr_t)env->GetLongField(buf, directBufferAddressField); | |
2846 return ret; | |
2847 } | |
2848 | |
2849 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong); | |
2850 | |
2851 extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) | |
2852 { | |
2853 // thread_from_jni_environment() will block if VM is gone. | |
2854 JavaThread* thread = JavaThread::thread_from_jni_environment(env); | |
2855 | |
2856 JNIWrapper("jni_GetDirectBufferCapacity"); | |
2857 DTRACE_PROBE2(hotspot_jni, GetDirectBufferCapacity__entry, env, buf); | |
2858 jlong ret = -1; | |
2859 DT_RETURN_MARK(GetDirectBufferCapacity, jlong, (const jlong&)ret); | |
2860 | |
2861 if (!directBufferSupportInitializeEnded) { | |
2862 if (!initializeDirectBufferSupport(env, thread)) { | |
2863 ret = 0; | |
2864 return ret; | |
2865 } | |
2866 } | |
2867 | |
2868 if (buf == NULL) { | |
2869 return -1; | |
2870 } | |
2871 | |
2872 if (!env->IsInstanceOf(buf, directBufferClass)) { | |
2873 return -1; | |
2874 } | |
2875 | |
2876 // NOTE that capacity is currently an int in the implementation | |
2877 ret = env->GetIntField(buf, bufferCapacityField); | |
2878 return ret; | |
2879 } | |
2880 | |
2881 | |
2882 JNI_LEAF(jint, jni_GetVersion(JNIEnv *env)) | |
2883 JNIWrapper("GetVersion"); | |
2884 DTRACE_PROBE1(hotspot_jni, GetVersion__entry, env); | |
2885 DTRACE_PROBE1(hotspot_jni, GetVersion__return, CurrentVersion); | |
2886 return CurrentVersion; | |
2887 JNI_END | |
2888 | |
2889 extern struct JavaVM_ main_vm; | |
2890 | |
2891 JNI_LEAF(jint, jni_GetJavaVM(JNIEnv *env, JavaVM **vm)) | |
2892 JNIWrapper("jni_GetJavaVM"); | |
2893 DTRACE_PROBE2(hotspot_jni, GetJavaVM__entry, env, vm); | |
2894 *vm = (JavaVM *)(&main_vm); | |
2895 DTRACE_PROBE1(hotspot_jni, GetJavaVM__return, JNI_OK); | |
2896 return JNI_OK; | |
2897 JNI_END | |
2898 | |
2899 // Structure containing all jni functions | |
2900 struct JNINativeInterface_ jni_NativeInterface = { | |
2901 NULL, | |
2902 NULL, | |
2903 NULL, | |
2904 | |
2905 NULL, | |
2906 | |
2907 jni_GetVersion, | |
2908 | |
2909 jni_DefineClass, | |
2910 jni_FindClass, | |
2911 | |
2912 jni_FromReflectedMethod, | |
2913 jni_FromReflectedField, | |
2914 | |
2915 jni_ToReflectedMethod, | |
2916 | |
2917 jni_GetSuperclass, | |
2918 jni_IsAssignableFrom, | |
2919 | |
2920 jni_ToReflectedField, | |
2921 | |
2922 jni_Throw, | |
2923 jni_ThrowNew, | |
2924 jni_ExceptionOccurred, | |
2925 jni_ExceptionDescribe, | |
2926 jni_ExceptionClear, | |
2927 jni_FatalError, | |
2928 | |
2929 jni_PushLocalFrame, | |
2930 jni_PopLocalFrame, | |
2931 | |
2932 jni_NewGlobalRef, | |
2933 jni_DeleteGlobalRef, | |
2934 jni_DeleteLocalRef, | |
2935 jni_IsSameObject, | |
2936 | |
2937 jni_NewLocalRef, | |
2938 jni_EnsureLocalCapacity, | |
2939 | |
2940 jni_AllocObject, | |
2941 jni_NewObject, | |
2942 jni_NewObjectV, | |
2943 jni_NewObjectA, | |
2944 | |
2945 jni_GetObjectClass, | |
2946 jni_IsInstanceOf, | |
2947 | |
2948 jni_GetMethodID, | |
2949 | |
2950 jni_CallObjectMethod, | |
2951 jni_CallObjectMethodV, | |
2952 jni_CallObjectMethodA, | |
2953 jni_CallBooleanMethod, | |
2954 jni_CallBooleanMethodV, | |
2955 jni_CallBooleanMethodA, | |
2956 jni_CallByteMethod, | |
2957 jni_CallByteMethodV, | |
2958 jni_CallByteMethodA, | |
2959 jni_CallCharMethod, | |
2960 jni_CallCharMethodV, | |
2961 jni_CallCharMethodA, | |
2962 jni_CallShortMethod, | |
2963 jni_CallShortMethodV, | |
2964 jni_CallShortMethodA, | |
2965 jni_CallIntMethod, | |
2966 jni_CallIntMethodV, | |
2967 jni_CallIntMethodA, | |
2968 jni_CallLongMethod, | |
2969 jni_CallLongMethodV, | |
2970 jni_CallLongMethodA, | |
2971 jni_CallFloatMethod, | |
2972 jni_CallFloatMethodV, | |
2973 jni_CallFloatMethodA, | |
2974 jni_CallDoubleMethod, | |
2975 jni_CallDoubleMethodV, | |
2976 jni_CallDoubleMethodA, | |
2977 jni_CallVoidMethod, | |
2978 jni_CallVoidMethodV, | |
2979 jni_CallVoidMethodA, | |
2980 | |
2981 jni_CallNonvirtualObjectMethod, | |
2982 jni_CallNonvirtualObjectMethodV, | |
2983 jni_CallNonvirtualObjectMethodA, | |
2984 jni_CallNonvirtualBooleanMethod, | |
2985 jni_CallNonvirtualBooleanMethodV, | |
2986 jni_CallNonvirtualBooleanMethodA, | |
2987 jni_CallNonvirtualByteMethod, | |
2988 jni_CallNonvirtualByteMethodV, | |
2989 jni_CallNonvirtualByteMethodA, | |
2990 jni_CallNonvirtualCharMethod, | |
2991 jni_CallNonvirtualCharMethodV, | |
2992 jni_CallNonvirtualCharMethodA, | |
2993 jni_CallNonvirtualShortMethod, | |
2994 jni_CallNonvirtualShortMethodV, | |
2995 jni_CallNonvirtualShortMethodA, | |
2996 jni_CallNonvirtualIntMethod, | |
2997 jni_CallNonvirtualIntMethodV, | |
2998 jni_CallNonvirtualIntMethodA, | |
2999 jni_CallNonvirtualLongMethod, | |
3000 jni_CallNonvirtualLongMethodV, | |
3001 jni_CallNonvirtualLongMethodA, | |
3002 jni_CallNonvirtualFloatMethod, | |
3003 jni_CallNonvirtualFloatMethodV, | |
3004 jni_CallNonvirtualFloatMethodA, | |
3005 jni_CallNonvirtualDoubleMethod, | |
3006 jni_CallNonvirtualDoubleMethodV, | |
3007 jni_CallNonvirtualDoubleMethodA, | |
3008 jni_CallNonvirtualVoidMethod, | |
3009 jni_CallNonvirtualVoidMethodV, | |
3010 jni_CallNonvirtualVoidMethodA, | |
3011 | |
3012 jni_GetFieldID, | |
3013 | |
3014 jni_GetObjectField, | |
3015 jni_GetBooleanField, | |
3016 jni_GetByteField, | |
3017 jni_GetCharField, | |
3018 jni_GetShortField, | |
3019 jni_GetIntField, | |
3020 jni_GetLongField, | |
3021 jni_GetFloatField, | |
3022 jni_GetDoubleField, | |
3023 | |
3024 jni_SetObjectField, | |
3025 jni_SetBooleanField, | |
3026 jni_SetByteField, | |
3027 jni_SetCharField, | |
3028 jni_SetShortField, | |
3029 jni_SetIntField, | |
3030 jni_SetLongField, | |
3031 jni_SetFloatField, | |
3032 jni_SetDoubleField, | |
3033 | |
3034 jni_GetStaticMethodID, | |
3035 | |
3036 jni_CallStaticObjectMethod, | |
3037 jni_CallStaticObjectMethodV, | |
3038 jni_CallStaticObjectMethodA, | |
3039 jni_CallStaticBooleanMethod, | |
3040 jni_CallStaticBooleanMethodV, | |
3041 jni_CallStaticBooleanMethodA, | |
3042 jni_CallStaticByteMethod, | |
3043 jni_CallStaticByteMethodV, | |
3044 jni_CallStaticByteMethodA, | |
3045 jni_CallStaticCharMethod, | |
3046 jni_CallStaticCharMethodV, | |
3047 jni_CallStaticCharMethodA, | |
3048 jni_CallStaticShortMethod, | |
3049 jni_CallStaticShortMethodV, | |
3050 jni_CallStaticShortMethodA, | |
3051 jni_CallStaticIntMethod, | |
3052 jni_CallStaticIntMethodV, | |
3053 jni_CallStaticIntMethodA, | |
3054 jni_CallStaticLongMethod, | |
3055 jni_CallStaticLongMethodV, | |
3056 jni_CallStaticLongMethodA, | |
3057 jni_CallStaticFloatMethod, | |
3058 jni_CallStaticFloatMethodV, | |
3059 jni_CallStaticFloatMethodA, | |
3060 jni_CallStaticDoubleMethod, | |
3061 jni_CallStaticDoubleMethodV, | |
3062 jni_CallStaticDoubleMethodA, | |
3063 jni_CallStaticVoidMethod, | |
3064 jni_CallStaticVoidMethodV, | |
3065 jni_CallStaticVoidMethodA, | |
3066 | |
3067 jni_GetStaticFieldID, | |
3068 | |
3069 jni_GetStaticObjectField, | |
3070 jni_GetStaticBooleanField, | |
3071 jni_GetStaticByteField, | |
3072 jni_GetStaticCharField, | |
3073 jni_GetStaticShortField, | |
3074 jni_GetStaticIntField, | |
3075 jni_GetStaticLongField, | |
3076 jni_GetStaticFloatField, | |
3077 jni_GetStaticDoubleField, | |
3078 | |
3079 jni_SetStaticObjectField, | |
3080 jni_SetStaticBooleanField, | |
3081 jni_SetStaticByteField, | |
3082 jni_SetStaticCharField, | |
3083 jni_SetStaticShortField, | |
3084 jni_SetStaticIntField, | |
3085 jni_SetStaticLongField, | |
3086 jni_SetStaticFloatField, | |
3087 jni_SetStaticDoubleField, | |
3088 | |
3089 jni_NewString, | |
3090 jni_GetStringLength, | |
3091 jni_GetStringChars, | |
3092 jni_ReleaseStringChars, | |
3093 | |
3094 jni_NewStringUTF, | |
3095 jni_GetStringUTFLength, | |
3096 jni_GetStringUTFChars, | |
3097 jni_ReleaseStringUTFChars, | |
3098 | |
3099 jni_GetArrayLength, | |
3100 | |
3101 jni_NewObjectArray, | |
3102 jni_GetObjectArrayElement, | |
3103 jni_SetObjectArrayElement, | |
3104 | |
3105 jni_NewBooleanArray, | |
3106 jni_NewByteArray, | |
3107 jni_NewCharArray, | |
3108 jni_NewShortArray, | |
3109 jni_NewIntArray, | |
3110 jni_NewLongArray, | |
3111 jni_NewFloatArray, | |
3112 jni_NewDoubleArray, | |
3113 | |
3114 jni_GetBooleanArrayElements, | |
3115 jni_GetByteArrayElements, | |
3116 jni_GetCharArrayElements, | |
3117 jni_GetShortArrayElements, | |
3118 jni_GetIntArrayElements, | |
3119 jni_GetLongArrayElements, | |
3120 jni_GetFloatArrayElements, | |
3121 jni_GetDoubleArrayElements, | |
3122 | |
3123 jni_ReleaseBooleanArrayElements, | |
3124 jni_ReleaseByteArrayElements, | |
3125 jni_ReleaseCharArrayElements, | |
3126 jni_ReleaseShortArrayElements, | |
3127 jni_ReleaseIntArrayElements, | |
3128 jni_ReleaseLongArrayElements, | |
3129 jni_ReleaseFloatArrayElements, | |
3130 jni_ReleaseDoubleArrayElements, | |
3131 | |
3132 jni_GetBooleanArrayRegion, | |
3133 jni_GetByteArrayRegion, | |
3134 jni_GetCharArrayRegion, | |
3135 jni_GetShortArrayRegion, | |
3136 jni_GetIntArrayRegion, | |
3137 jni_GetLongArrayRegion, | |
3138 jni_GetFloatArrayRegion, | |
3139 jni_GetDoubleArrayRegion, | |
3140 | |
3141 jni_SetBooleanArrayRegion, | |
3142 jni_SetByteArrayRegion, | |
3143 jni_SetCharArrayRegion, | |
3144 jni_SetShortArrayRegion, | |
3145 jni_SetIntArrayRegion, | |
3146 jni_SetLongArrayRegion, | |
3147 jni_SetFloatArrayRegion, | |
3148 jni_SetDoubleArrayRegion, | |
3149 | |
3150 jni_RegisterNatives, | |
3151 jni_UnregisterNatives, | |
3152 | |
3153 jni_MonitorEnter, | |
3154 jni_MonitorExit, | |
3155 | |
3156 jni_GetJavaVM, | |
3157 | |
3158 jni_GetStringRegion, | |
3159 jni_GetStringUTFRegion, | |
3160 | |
3161 jni_GetPrimitiveArrayCritical, | |
3162 jni_ReleasePrimitiveArrayCritical, | |
3163 | |
3164 jni_GetStringCritical, | |
3165 jni_ReleaseStringCritical, | |
3166 | |
3167 jni_NewWeakGlobalRef, | |
3168 jni_DeleteWeakGlobalRef, | |
3169 | |
3170 jni_ExceptionCheck, | |
3171 | |
3172 jni_NewDirectByteBuffer, | |
3173 jni_GetDirectBufferAddress, | |
3174 jni_GetDirectBufferCapacity, | |
3175 | |
3176 // New 1_6 features | |
3177 | |
3178 jni_GetObjectRefType | |
3179 }; | |
3180 | |
3181 | |
3182 // For jvmti use to modify jni function table. | |
3183 // Java threads in native contiues to run until it is transitioned | |
3184 // to VM at safepoint. Before the transition or before it is blocked | |
3185 // for safepoint it may access jni function table. VM could crash if | |
3186 // any java thread access the jni function table in the middle of memcpy. | |
3187 // To avoid this each function pointers are copied automically. | |
3188 void copy_jni_function_table(const struct JNINativeInterface_ *new_jni_NativeInterface) { | |
3189 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | |
3190 intptr_t *a = (intptr_t *) jni_functions(); | |
3191 intptr_t *b = (intptr_t *) new_jni_NativeInterface; | |
3192 for (uint i=0; i < sizeof(struct JNINativeInterface_)/sizeof(void *); i++) { | |
3193 Atomic::store_ptr(*b++, a++); | |
3194 } | |
3195 } | |
3196 | |
3197 void quicken_jni_functions() { | |
3198 // Replace Get<Primitive>Field with fast versions | |
3199 if (UseFastJNIAccessors && !JvmtiExport::can_post_field_access() | |
3200 && !VerifyJNIFields && !TraceJNICalls && !CountJNICalls && !CheckJNICalls | |
3201 #if defined(_WINDOWS) && defined(IA32) && defined(COMPILER2) | |
3202 // windows x86 currently needs SEH wrapper and the gain of the fast | |
3203 // versions currently isn't certain for server vm on uniprocessor. | |
3204 && os::is_MP() | |
3205 #endif | |
3206 ) { | |
3207 address func; | |
3208 func = JNI_FastGetField::generate_fast_get_boolean_field(); | |
3209 if (func != (address)-1) { | |
3210 jni_NativeInterface.GetBooleanField = (GetBooleanField_t)func; | |
3211 } | |
3212 func = JNI_FastGetField::generate_fast_get_byte_field(); | |
3213 if (func != (address)-1) { | |
3214 jni_NativeInterface.GetByteField = (GetByteField_t)func; | |
3215 } | |
3216 func = JNI_FastGetField::generate_fast_get_char_field(); | |
3217 if (func != (address)-1) { | |
3218 jni_NativeInterface.GetCharField = (GetCharField_t)func; | |
3219 } | |
3220 func = JNI_FastGetField::generate_fast_get_short_field(); | |
3221 if (func != (address)-1) { | |
3222 jni_NativeInterface.GetShortField = (GetShortField_t)func; | |
3223 } | |
3224 func = JNI_FastGetField::generate_fast_get_int_field(); | |
3225 if (func != (address)-1) { | |
3226 jni_NativeInterface.GetIntField = (GetIntField_t)func; | |
3227 } | |
3228 func = JNI_FastGetField::generate_fast_get_long_field(); | |
3229 if (func != (address)-1) { | |
3230 jni_NativeInterface.GetLongField = (GetLongField_t)func; | |
3231 } | |
3232 func = JNI_FastGetField::generate_fast_get_float_field(); | |
3233 if (func != (address)-1) { | |
3234 jni_NativeInterface.GetFloatField = (GetFloatField_t)func; | |
3235 } | |
3236 func = JNI_FastGetField::generate_fast_get_double_field(); | |
3237 if (func != (address)-1) { | |
3238 jni_NativeInterface.GetDoubleField = (GetDoubleField_t)func; | |
3239 } | |
3240 } | |
3241 } | |
3242 | |
3243 // Returns the function structure | |
3244 struct JNINativeInterface_* jni_functions() { | |
3245 #ifndef JNICHECK_KERNEL | |
3246 if (CheckJNICalls) return jni_functions_check(); | |
3247 #else // JNICHECK_KERNEL | |
3248 if (CheckJNICalls) warning("-Xcheck:jni is not supported in kernel vm."); | |
3249 #endif // JNICHECK_KERNEL | |
3250 return &jni_NativeInterface; | |
3251 } | |
3252 | |
3253 // Returns the function structure | |
3254 struct JNINativeInterface_* jni_functions_nocheck() { | |
3255 return &jni_NativeInterface; | |
3256 } | |
3257 | |
3258 | |
3259 // Invocation API | |
3260 | |
3261 | |
3262 // Forward declaration | |
3263 extern const struct JNIInvokeInterface_ jni_InvokeInterface; | |
3264 | |
3265 // Global invocation API vars | |
3266 volatile jint vm_created = 0; | |
3267 // Indicate whether it is safe to recreate VM | |
3268 volatile jint safe_to_recreate_vm = 1; | |
3269 struct JavaVM_ main_vm = {&jni_InvokeInterface}; | |
3270 | |
3271 | |
3272 #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */ | |
3273 enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL }; | |
3274 | |
3275 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*); | |
3276 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint); | |
3277 | |
3278 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { | |
3279 HS_DTRACE_PROBE1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, args_); | |
3280 JDK1_1InitArgs *args = (JDK1_1InitArgs *)args_; | |
3281 jint ret = JNI_ERR; | |
3282 DT_RETURN_MARK(GetDefaultJavaVMInitArgs, jint, (const jint&)ret); | |
3283 | |
3284 if (Threads::is_supported_jni_version(args->version)) { | |
3285 ret = JNI_OK; | |
3286 } | |
3287 // 1.1 style no longer supported in hotspot. | |
3288 // According the JNI spec, we should update args->version on return. | |
3289 // We also use the structure to communicate with launcher about default | |
3290 // stack size. | |
3291 if (args->version == JNI_VERSION_1_1) { | |
3292 args->version = JNI_VERSION_1_2; | |
3293 // javaStackSize is int in arguments structure | |
3294 assert(jlong(ThreadStackSize) * K < INT_MAX, "integer overflow"); | |
3295 args->javaStackSize = (jint)(ThreadStackSize * K); | |
3296 } | |
3297 return ret; | |
3298 } | |
3299 | |
3300 HS_DTRACE_PROBE_DECL3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); | |
3301 DT_RETURN_MARK_DECL(CreateJavaVM, jint); | |
3302 | |
3303 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) { | |
3304 HS_DTRACE_PROBE3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); | |
3305 | |
3306 jint result = JNI_ERR; | |
3307 DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result); | |
3308 | |
1078 | 3309 // We're about to use Atomic::xchg for synchronization. Some Zero |
3310 // platforms use the GCC builtin __sync_lock_test_and_set for this, | |
3311 // but __sync_lock_test_and_set is not guaranteed to do what we want | |
3312 // on all architectures. So we check it works before relying on it. | |
3313 #if defined(ZERO) && defined(ASSERT) | |
3314 { | |
3315 jint a = 0xcafebabe; | |
3316 jint b = Atomic::xchg(0xdeadbeef, &a); | |
3317 void *c = &a; | |
3318 void *d = Atomic::xchg_ptr(&b, &c); | |
1132 | 3319 assert(a == (jint) 0xdeadbeef && b == (jint) 0xcafebabe, "Atomic::xchg() works"); |
1078 | 3320 assert(c == &b && d == &a, "Atomic::xchg_ptr() works"); |
3321 } | |
3322 #endif // ZERO && ASSERT | |
3323 | |
0 | 3324 // At the moment it's only possible to have one Java VM, |
3325 // since some of the runtime state is in global variables. | |
3326 | |
3327 // We cannot use our mutex locks here, since they only work on | |
3328 // Threads. We do an atomic compare and exchange to ensure only | |
3329 // one thread can call this method at a time | |
3330 | |
3331 // We use Atomic::xchg rather than Atomic::add/dec since on some platforms | |
3332 // the add/dec implementations are dependent on whether we are running | |
3333 // on a multiprocessor, and at this stage of initialization the os::is_MP | |
3334 // function used to determine this will always return false. Atomic::xchg | |
3335 // does not have this problem. | |
3336 if (Atomic::xchg(1, &vm_created) == 1) { | |
3337 return JNI_ERR; // already created, or create attempt in progress | |
3338 } | |
3339 if (Atomic::xchg(0, &safe_to_recreate_vm) == 0) { | |
3340 return JNI_ERR; // someone tried and failed and retry not allowed. | |
3341 } | |
3342 | |
3343 assert(vm_created == 1, "vm_created is true during the creation"); | |
3344 | |
3345 /** | |
3346 * Certain errors during initialization are recoverable and do not | |
3347 * prevent this method from being called again at a later time | |
3348 * (perhaps with different arguments). However, at a certain | |
3349 * point during initialization if an error occurs we cannot allow | |
3350 * this function to be called again (or it will crash). In those | |
3351 * situations, the 'canTryAgain' flag is set to false, which atomically | |
3352 * sets safe_to_recreate_vm to 1, such that any new call to | |
3353 * JNI_CreateJavaVM will immediately fail using the above logic. | |
3354 */ | |
3355 bool can_try_again = true; | |
3356 | |
3357 result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again); | |
3358 if (result == JNI_OK) { | |
3359 JavaThread *thread = JavaThread::current(); | |
3360 /* thread is thread_in_vm here */ | |
3361 *vm = (JavaVM *)(&main_vm); | |
3362 *(JNIEnv**)penv = thread->jni_environment(); | |
3363 | |
3364 // Tracks the time application was running before GC | |
3365 RuntimeService::record_application_start(); | |
3366 | |
3367 // Notify JVMTI | |
3368 if (JvmtiExport::should_post_thread_life()) { | |
3369 JvmtiExport::post_thread_start(thread); | |
3370 } | |
1454
7cf1952ec5fb
Added flag -XX:BootstrapC1X that precompiles Object::<init> and then every method in the compilation queue until it is empty.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1290
diff
changeset
|
3371 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
3372 if (BootstrapGraal) { |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2491
diff
changeset
|
3373 CompileBroker::bootstrap_graal(); |
1454
7cf1952ec5fb
Added flag -XX:BootstrapC1X that precompiles Object::<init> and then every method in the compilation queue until it is empty.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1290
diff
changeset
|
3374 } |
7cf1952ec5fb
Added flag -XX:BootstrapC1X that precompiles Object::<init> and then every method in the compilation queue until it is empty.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1290
diff
changeset
|
3375 |
0 | 3376 // Check if we should compile all classes on bootclasspath |
3377 NOT_PRODUCT(if (CompileTheWorld) ClassLoader::compile_the_world();) | |
3378 // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. | |
3379 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
3380 } else { | |
3381 if (can_try_again) { | |
3382 // reset safe_to_recreate_vm to 1 so that retrial would be possible | |
3383 safe_to_recreate_vm = 1; | |
3384 } | |
3385 | |
3386 // Creation failed. We must reset vm_created | |
3387 *vm = 0; | |
3388 *(JNIEnv**)penv = 0; | |
3389 // reset vm_created last to avoid race condition. Use OrderAccess to | |
3390 // control both compiler and architectural-based reordering. | |
3391 OrderAccess::release_store(&vm_created, 0); | |
3392 } | |
3393 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1290
diff
changeset
|
3394 NOT_PRODUCT(test_error_handler(ErrorHandlerTest)); |
0 | 3395 return result; |
3396 } | |
3397 | |
3398 HS_DTRACE_PROBE_DECL3(hotspot_jni, GetCreatedJavaVMs__entry, \ | |
3399 JavaVM**, jsize, jsize*); | |
3400 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetCreatedJavaVMs__return, jint); | |
3401 | |
3402 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) { | |
3403 // See bug 4367188, the wrapper can sometimes cause VM crashes | |
3404 // JNIWrapper("GetCreatedJavaVMs"); | |
3405 HS_DTRACE_PROBE3(hotspot_jni, GetCreatedJavaVMs__entry, \ | |
3406 vm_buf, bufLen, numVMs); | |
3407 if (vm_created) { | |
3408 if (numVMs != NULL) *numVMs = 1; | |
3409 if (bufLen > 0) *vm_buf = (JavaVM *)(&main_vm); | |
3410 } else { | |
3411 if (numVMs != NULL) *numVMs = 0; | |
3412 } | |
3413 HS_DTRACE_PROBE1(hotspot_jni, GetCreatedJavaVMs__return, JNI_OK); | |
3414 return JNI_OK; | |
3415 } | |
3416 | |
3417 extern "C" { | |
3418 | |
3419 DT_RETURN_MARK_DECL(DestroyJavaVM, jint); | |
3420 | |
3421 jint JNICALL jni_DestroyJavaVM(JavaVM *vm) { | |
3422 DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm); | |
3423 jint res = JNI_ERR; | |
3424 DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res); | |
3425 | |
3426 if (!vm_created) { | |
3427 res = JNI_ERR; | |
3428 return res; | |
3429 } | |
3430 | |
3431 JNIWrapper("DestroyJavaVM"); | |
3432 JNIEnv *env; | |
3433 JavaVMAttachArgs destroyargs; | |
3434 destroyargs.version = CurrentVersion; | |
3435 destroyargs.name = (char *)"DestroyJavaVM"; | |
3436 destroyargs.group = NULL; | |
3437 res = vm->AttachCurrentThread((void **)&env, (void *)&destroyargs); | |
3438 if (res != JNI_OK) { | |
3439 return res; | |
3440 } | |
3441 | |
3442 // Since this is not a JVM_ENTRY we have to set the thread state manually before entering. | |
3443 JavaThread* thread = JavaThread::current(); | |
3444 ThreadStateTransition::transition_from_native(thread, _thread_in_vm); | |
3445 if (Threads::destroy_vm()) { | |
3446 // Should not change thread state, VM is gone | |
3447 vm_created = false; | |
3448 res = JNI_OK; | |
3449 return res; | |
3450 } else { | |
3451 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
3452 res = JNI_ERR; | |
3453 return res; | |
3454 } | |
3455 } | |
3456 | |
3457 | |
3458 static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool daemon) { | |
3459 JavaVMAttachArgs *args = (JavaVMAttachArgs *) _args; | |
3460 | |
3461 // Check below commented out from JDK1.2fcs as well | |
3462 /* | |
3463 if (args && (args->version != JNI_VERSION_1_1 || args->version != JNI_VERSION_1_2)) { | |
3464 return JNI_EVERSION; | |
3465 } | |
3466 */ | |
3467 | |
3468 Thread* t = ThreadLocalStorage::get_thread_slow(); | |
3469 if (t != NULL) { | |
3470 // If the thread has been attached this operation is a no-op | |
3471 *(JNIEnv**)penv = ((JavaThread*) t)->jni_environment(); | |
3472 return JNI_OK; | |
3473 } | |
3474 | |
3475 // Create a thread and mark it as attaching so it will be skipped by the | |
3476 // ThreadsListEnumerator - see CR 6404306 | |
3477 JavaThread* thread = new JavaThread(true); | |
3478 | |
3479 // Set correct safepoint info. The thread is going to call into Java when | |
3480 // initializing the Java level thread object. Hence, the correct state must | |
3481 // be set in order for the Safepoint code to deal with it correctly. | |
3482 thread->set_thread_state(_thread_in_vm); | |
3483 // Must do this before initialize_thread_local_storage | |
3484 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
|
3485 |
0 | 3486 thread->initialize_thread_local_storage(); |
3487 | |
3488 if (!os::create_attached_thread(thread)) { | |
3489 delete thread; | |
3490 return JNI_ERR; | |
3491 } | |
1290
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
3492 // Enable stack overflow checks |
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
3493 thread->create_stack_guard_pages(); |
c8a467bf56ad
6914050: jvm assertion "guard pages must be in use" in -Xcomp mode
coleenp
parents:
1142
diff
changeset
|
3494 |
0 | 3495 thread->initialize_tlab(); |
3496 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
3497 thread->cache_global_variables(); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
3498 |
0 | 3499 // Crucial that we do not have a safepoint check for this thread, since it has |
3500 // not been added to the Thread list yet. | |
3501 { Threads_lock->lock_without_safepoint_check(); | |
3502 // This must be inside this lock in order to get FullGCALot to work properly, i.e., to | |
3503 // avoid this thread trying to do a GC before it is added to the thread-list | |
3504 thread->set_active_handles(JNIHandleBlock::allocate_block()); | |
3505 Threads::add(thread, daemon); | |
3506 Threads_lock->unlock(); | |
3507 } | |
3508 // Create thread group and name info from attach arguments | |
3509 oop group = NULL; | |
3510 char* thread_name = NULL; | |
3511 if (args != NULL && Threads::is_supported_jni_version(args->version)) { | |
3512 group = JNIHandles::resolve(args->group); | |
3513 thread_name = args->name; // may be NULL | |
3514 } | |
3515 if (group == NULL) group = Universe::main_thread_group(); | |
3516 | |
3517 // Create Java level thread object and attach it to this thread | |
3518 bool attach_failed = false; | |
3519 { | |
3520 EXCEPTION_MARK; | |
3521 HandleMark hm(THREAD); | |
3522 Handle thread_group(THREAD, group); | |
3523 thread->allocate_threadObj(thread_group, thread_name, daemon, THREAD); | |
3524 if (HAS_PENDING_EXCEPTION) { | |
3525 CLEAR_PENDING_EXCEPTION; | |
3526 // cleanup outside the handle mark. | |
3527 attach_failed = true; | |
3528 } | |
3529 } | |
3530 | |
3531 if (attach_failed) { | |
3532 // Added missing cleanup | |
3533 thread->cleanup_failed_attach_current_thread(); | |
3534 return JNI_ERR; | |
3535 } | |
3536 | |
3537 // mark the thread as no longer attaching | |
3538 // this uses a fence to push the change through so we don't have | |
3539 // to regrab the threads_lock | |
3540 thread->set_attached(); | |
3541 | |
3542 // Set java thread status. | |
3543 java_lang_Thread::set_thread_status(thread->threadObj(), | |
3544 java_lang_Thread::RUNNABLE); | |
3545 | |
3546 // Notify the debugger | |
3547 if (JvmtiExport::should_post_thread_life()) { | |
3548 JvmtiExport::post_thread_start(thread); | |
3549 } | |
3550 | |
3551 *(JNIEnv**)penv = thread->jni_environment(); | |
3552 | |
3553 // Now leaving the VM, so change thread_state. This is normally automatically taken care | |
3554 // of in the JVM_ENTRY. But in this situation we have to do it manually. Notice, that by | |
3555 // using ThreadStateTransition::transition, we do a callback to the safepoint code if | |
3556 // needed. | |
3557 | |
3558 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); | |
3559 | |
3560 // Perform any platform dependent FPU setup | |
3561 os::setup_fpu(); | |
3562 | |
3563 return JNI_OK; | |
3564 } | |
3565 | |
3566 | |
3567 jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) { | |
3568 DTRACE_PROBE3(hotspot_jni, AttachCurrentThread__entry, vm, penv, _args); | |
3569 if (!vm_created) { | |
3570 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, JNI_ERR); | |
3571 return JNI_ERR; | |
3572 } | |
3573 | |
3574 JNIWrapper("AttachCurrentThread"); | |
3575 jint ret = attach_current_thread(vm, penv, _args, false); | |
3576 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, ret); | |
3577 return ret; | |
3578 } | |
3579 | |
3580 | |
3581 jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { | |
3582 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__entry, vm); | |
3583 VM_Exit::block_if_vm_exited(); | |
3584 | |
3585 JNIWrapper("DetachCurrentThread"); | |
3586 | |
3587 // If the thread has been deattacted the operations is a no-op | |
3588 if (ThreadLocalStorage::thread() == NULL) { | |
3589 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); | |
3590 return JNI_OK; | |
3591 } | |
3592 | |
3593 JavaThread* thread = JavaThread::current(); | |
3594 if (thread->has_last_Java_frame()) { | |
3595 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_ERR); | |
3596 // Can't detach a thread that's running java, that can't work. | |
3597 return JNI_ERR; | |
3598 } | |
3599 | |
3600 // Safepoint support. Have to do call-back to safepoint code, if in the | |
3601 // middel of a safepoint operation | |
3602 ThreadStateTransition::transition_from_native(thread, _thread_in_vm); | |
3603 | |
3604 // XXX: Note that JavaThread::exit() call below removes the guards on the | |
3605 // stack pages set up via enable_stack_{red,yellow}_zone() calls | |
3606 // above in jni_AttachCurrentThread. Unfortunately, while the setting | |
3607 // of the guards is visible in jni_AttachCurrentThread above, | |
3608 // the removal of the guards is buried below in JavaThread::exit() | |
3609 // here. The abstraction should be more symmetrically either exposed | |
3610 // or hidden (e.g. it could probably be hidden in the same | |
3611 // (platform-dependent) methods where we do alternate stack | |
3612 // maintenance work?) | |
3613 thread->exit(false, JavaThread::jni_detach); | |
3614 delete thread; | |
3615 | |
3616 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); | |
3617 return JNI_OK; | |
3618 } | |
3619 | |
3620 DT_RETURN_MARK_DECL(GetEnv, jint); | |
3621 | |
3622 jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { | |
3623 DTRACE_PROBE3(hotspot_jni, GetEnv__entry, vm, penv, version); | |
3624 jint ret = JNI_ERR; | |
3625 DT_RETURN_MARK(GetEnv, jint, (const jint&)ret); | |
3626 | |
3627 if (!vm_created) { | |
3628 *penv = NULL; | |
3629 ret = JNI_EDETACHED; | |
3630 return ret; | |
3631 } | |
3632 | |
3633 if (JvmtiExport::is_jvmti_version(version)) { | |
3634 ret = JvmtiExport::get_jvmti_interface(vm, penv, version); | |
3635 return ret; | |
3636 } | |
3637 | |
3638 #ifndef JVMPI_VERSION_1 | |
3639 // need these in order to be polite about older agents | |
3640 #define JVMPI_VERSION_1 ((jint)0x10000001) | |
3641 #define JVMPI_VERSION_1_1 ((jint)0x10000002) | |
3642 #define JVMPI_VERSION_1_2 ((jint)0x10000003) | |
3643 #endif // !JVMPI_VERSION_1 | |
3644 | |
3645 Thread* thread = ThreadLocalStorage::thread(); | |
3646 if (thread != NULL && thread->is_Java_thread()) { | |
3647 if (Threads::is_supported_jni_version_including_1_1(version)) { | |
3648 *(JNIEnv**)penv = ((JavaThread*) thread)->jni_environment(); | |
3649 ret = JNI_OK; | |
3650 return ret; | |
3651 | |
3652 } else if (version == JVMPI_VERSION_1 || | |
3653 version == JVMPI_VERSION_1_1 || | |
3654 version == JVMPI_VERSION_1_2) { | |
3655 tty->print_cr("ERROR: JVMPI, an experimental interface, is no longer supported."); | |
3656 tty->print_cr("Please use the supported interface: the JVM Tool Interface (JVM TI)."); | |
3657 ret = JNI_EVERSION; | |
3658 return ret; | |
3659 } else if (JvmtiExport::is_jvmdi_version(version)) { | |
3660 tty->print_cr("FATAL ERROR: JVMDI is no longer supported."); | |
3661 tty->print_cr("Please use the supported interface: the JVM Tool Interface (JVM TI)."); | |
3662 ret = JNI_EVERSION; | |
3663 return ret; | |
3664 } else { | |
3665 *penv = NULL; | |
3666 ret = JNI_EVERSION; | |
3667 return ret; | |
3668 } | |
3669 } else { | |
3670 *penv = NULL; | |
3671 ret = JNI_EDETACHED; | |
3672 return ret; | |
3673 } | |
3674 } | |
3675 | |
3676 | |
3677 jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) { | |
3678 DTRACE_PROBE3(hotspot_jni, AttachCurrentThreadAsDaemon__entry, vm, penv, _args); | |
3679 if (!vm_created) { | |
3680 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, JNI_ERR); | |
3681 return JNI_ERR; | |
3682 } | |
3683 | |
3684 JNIWrapper("AttachCurrentThreadAsDaemon"); | |
3685 jint ret = attach_current_thread(vm, penv, _args, true); | |
3686 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, ret); | |
3687 return ret; | |
3688 } | |
3689 | |
3690 | |
3691 } // End extern "C" | |
3692 | |
3693 const struct JNIInvokeInterface_ jni_InvokeInterface = { | |
3694 NULL, | |
3695 NULL, | |
3696 NULL, | |
3697 | |
3698 jni_DestroyJavaVM, | |
3699 jni_AttachCurrentThread, | |
3700 jni_DetachCurrentThread, | |
3701 jni_GetEnv, | |
3702 jni_AttachCurrentThreadAsDaemon | |
3703 }; |