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