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