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