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