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