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