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