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