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