Mercurial > hg > truffle
comparison src/share/vm/prims/jni.cpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | d2a62e0f25eb |
children | d8ce2825b193 fb19af007ffc |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
39 #include "memory/oopFactory.hpp" | 39 #include "memory/oopFactory.hpp" |
40 #include "memory/universe.inline.hpp" | 40 #include "memory/universe.inline.hpp" |
41 #include "oops/instanceKlass.hpp" | 41 #include "oops/instanceKlass.hpp" |
42 #include "oops/instanceOop.hpp" | 42 #include "oops/instanceOop.hpp" |
43 #include "oops/markOop.hpp" | 43 #include "oops/markOop.hpp" |
44 #include "oops/methodOop.hpp" | 44 #include "oops/method.hpp" |
45 #include "oops/objArrayKlass.hpp" | 45 #include "oops/objArrayKlass.hpp" |
46 #include "oops/objArrayOop.hpp" | 46 #include "oops/objArrayOop.hpp" |
47 #include "oops/oop.inline.hpp" | 47 #include "oops/oop.inline.hpp" |
48 #include "oops/symbol.hpp" | 48 #include "oops/symbol.hpp" |
49 #include "oops/typeArrayKlass.hpp" | 49 #include "oops/typeArrayKlass.hpp" |
206 DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) ) | 206 DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) ) |
207 | 207 |
208 | 208 |
209 // out-of-line helpers for class jfieldIDWorkaround: | 209 // out-of-line helpers for class jfieldIDWorkaround: |
210 | 210 |
211 bool jfieldIDWorkaround::is_valid_jfieldID(klassOop k, jfieldID id) { | 211 bool jfieldIDWorkaround::is_valid_jfieldID(Klass* k, jfieldID id) { |
212 if (jfieldIDWorkaround::is_instance_jfieldID(k, id)) { | 212 if (jfieldIDWorkaround::is_instance_jfieldID(k, id)) { |
213 uintptr_t as_uint = (uintptr_t) id; | 213 uintptr_t as_uint = (uintptr_t) id; |
214 intptr_t offset = raw_instance_offset(id); | 214 intptr_t offset = raw_instance_offset(id); |
215 if (is_checked_jfieldID(id)) { | 215 if (is_checked_jfieldID(id)) { |
216 if (!klass_hash_ok(k, id)) { | 216 if (!klass_hash_ok(k, id)) { |
217 return false; | 217 return false; |
218 } | 218 } |
219 } | 219 } |
220 return instanceKlass::cast(k)->contains_field_offset(offset); | 220 return InstanceKlass::cast(k)->contains_field_offset(offset); |
221 } else { | 221 } else { |
222 JNIid* result = (JNIid*) id; | 222 JNIid* result = (JNIid*) id; |
223 #ifdef ASSERT | 223 #ifdef ASSERT |
224 return result != NULL && result->is_static_field_id(); | 224 return result != NULL && result->is_static_field_id(); |
225 #else | 225 #else |
227 #endif | 227 #endif |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 intptr_t jfieldIDWorkaround::encode_klass_hash(klassOop k, intptr_t offset) { | 232 intptr_t jfieldIDWorkaround::encode_klass_hash(Klass* k, intptr_t offset) { |
233 if (offset <= small_offset_mask) { | 233 if (offset <= small_offset_mask) { |
234 klassOop field_klass = k; | 234 Klass* field_klass = k; |
235 klassOop super_klass = Klass::cast(field_klass)->super(); | 235 Klass* super_klass = Klass::cast(field_klass)->super(); |
236 // With compressed oops the most super class with nonstatic fields would | 236 // With compressed oops the most super class with nonstatic fields would |
237 // be the owner of fields embedded in the header. | 237 // be the owner of fields embedded in the header. |
238 while (instanceKlass::cast(super_klass)->has_nonstatic_fields() && | 238 while (InstanceKlass::cast(super_klass)->has_nonstatic_fields() && |
239 instanceKlass::cast(super_klass)->contains_field_offset(offset)) { | 239 InstanceKlass::cast(super_klass)->contains_field_offset(offset)) { |
240 field_klass = super_klass; // super contains the field also | 240 field_klass = super_klass; // super contains the field also |
241 super_klass = Klass::cast(field_klass)->super(); | 241 super_klass = Klass::cast(field_klass)->super(); |
242 } | 242 } |
243 debug_only(No_Safepoint_Verifier nosafepoint;) | 243 debug_only(No_Safepoint_Verifier nosafepoint;) |
244 uintptr_t klass_hash = field_klass->identity_hash(); | 244 uintptr_t klass_hash = field_klass->identity_hash(); |
254 #endif | 254 #endif |
255 return 0; | 255 return 0; |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 bool jfieldIDWorkaround::klass_hash_ok(klassOop k, jfieldID id) { | 259 bool jfieldIDWorkaround::klass_hash_ok(Klass* k, jfieldID id) { |
260 uintptr_t as_uint = (uintptr_t) id; | 260 uintptr_t as_uint = (uintptr_t) id; |
261 intptr_t klass_hash = (as_uint >> klass_shift) & klass_mask; | 261 intptr_t klass_hash = (as_uint >> klass_shift) & klass_mask; |
262 do { | 262 do { |
263 debug_only(No_Safepoint_Verifier nosafepoint;) | 263 debug_only(No_Safepoint_Verifier nosafepoint;) |
264 // Could use a non-blocking query for identity_hash here... | 264 // Could use a non-blocking query for identity_hash here... |
267 k = Klass::cast(k)->super(); | 267 k = Klass::cast(k)->super(); |
268 } while (k != NULL); | 268 } while (k != NULL); |
269 return false; | 269 return false; |
270 } | 270 } |
271 | 271 |
272 void jfieldIDWorkaround::verify_instance_jfieldID(klassOop k, jfieldID id) { | 272 void jfieldIDWorkaround::verify_instance_jfieldID(Klass* k, jfieldID id) { |
273 guarantee(jfieldIDWorkaround::is_instance_jfieldID(k, id), "must be an instance field" ); | 273 guarantee(jfieldIDWorkaround::is_instance_jfieldID(k, id), "must be an instance field" ); |
274 uintptr_t as_uint = (uintptr_t) id; | 274 uintptr_t as_uint = (uintptr_t) id; |
275 intptr_t offset = raw_instance_offset(id); | 275 intptr_t offset = raw_instance_offset(id); |
276 if (VerifyJNIFields) { | 276 if (VerifyJNIFields) { |
277 if (is_checked_jfieldID(id)) { | 277 if (is_checked_jfieldID(id)) { |
286 } | 286 } |
287 #endif | 287 #endif |
288 #endif | 288 #endif |
289 } | 289 } |
290 } | 290 } |
291 guarantee(instanceKlass::cast(k)->contains_field_offset(offset), | 291 guarantee(InstanceKlass::cast(k)->contains_field_offset(offset), |
292 "Bug in native code: jfieldID offset must address interior of object"); | 292 "Bug in native code: jfieldID offset must address interior of object"); |
293 } | 293 } |
294 | 294 |
295 // Pick a reasonable higher bound for local capacity requested | 295 // Pick a reasonable higher bound for local capacity requested |
296 // for EnsureLocalCapacity and PushLocalFrame. We don't want it too | 296 // for EnsureLocalCapacity and PushLocalFrame. We don't want it too |
403 query_lock_ownership((JavaThread*)THREAD, class_loader) != | 403 query_lock_ownership((JavaThread*)THREAD, class_loader) != |
404 ObjectSynchronizer::owner_self) { | 404 ObjectSynchronizer::owner_self) { |
405 ClassLoader::sync_JNIDefineClassLockFreeCounter()->inc(); | 405 ClassLoader::sync_JNIDefineClassLockFreeCounter()->inc(); |
406 } | 406 } |
407 } | 407 } |
408 klassOop k = SystemDictionary::resolve_from_stream(class_name, class_loader, | 408 Klass* k = SystemDictionary::resolve_from_stream(class_name, class_loader, |
409 Handle(), &st, true, | 409 Handle(), &st, true, |
410 CHECK_NULL); | 410 CHECK_NULL); |
411 | 411 |
412 if (TraceClassResolution && k != NULL) { | 412 if (TraceClassResolution && k != NULL) { |
413 trace_class_resolution(k); | 413 trace_class_resolution(k); |
472 CLEAR_PENDING_EXCEPTION; | 472 CLEAR_PENDING_EXCEPTION; |
473 THROW_HANDLE_0(ex); | 473 THROW_HANDLE_0(ex); |
474 } | 474 } |
475 oop mirror = (oop) result.get_jobject(); | 475 oop mirror = (oop) result.get_jobject(); |
476 loader = Handle(THREAD, | 476 loader = Handle(THREAD, |
477 instanceKlass::cast(java_lang_Class::as_klassOop(mirror))->class_loader()); | 477 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->class_loader()); |
478 protection_domain = Handle(THREAD, | 478 protection_domain = Handle(THREAD, |
479 instanceKlass::cast(java_lang_Class::as_klassOop(mirror))->protection_domain()); | 479 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->protection_domain()); |
480 } | 480 } |
481 } else { | 481 } else { |
482 // We call ClassLoader.getSystemClassLoader to obtain the system class loader. | 482 // We call ClassLoader.getSystemClassLoader to obtain the system class loader. |
483 loader = Handle(THREAD, SystemDictionary::java_system_loader()); | 483 loader = Handle(THREAD, SystemDictionary::java_system_loader()); |
484 } | 484 } |
486 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); | 486 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
487 result = find_class_from_class_loader(env, sym, true, loader, | 487 result = find_class_from_class_loader(env, sym, true, loader, |
488 protection_domain, true, thread); | 488 protection_domain, true, thread); |
489 | 489 |
490 if (TraceClassResolution && result != NULL) { | 490 if (TraceClassResolution && result != NULL) { |
491 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); | 491 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
492 } | 492 } |
493 | 493 |
494 // If we were the first invocation of jni_FindClass, we enable compilation again | 494 // If we were the first invocation of jni_FindClass, we enable compilation again |
495 // rather than just allowing invocation counter to overflow and decay. | 495 // rather than just allowing invocation counter to overflow and decay. |
496 // Controlled by flag DelayCompilationDuringStartup. | 496 // Controlled by flag DelayCompilationDuringStartup. |
529 } else { | 529 } else { |
530 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); | 530 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); |
531 mirror = java_lang_reflect_Method::clazz(reflected); | 531 mirror = java_lang_reflect_Method::clazz(reflected); |
532 slot = java_lang_reflect_Method::slot(reflected); | 532 slot = java_lang_reflect_Method::slot(reflected); |
533 } | 533 } |
534 klassOop k = java_lang_Class::as_klassOop(mirror); | 534 Klass* k = java_lang_Class::as_Klass(mirror); |
535 | 535 |
536 KlassHandle k1(THREAD, k); | 536 KlassHandle k1(THREAD, k); |
537 // Make sure class is initialized before handing id's out to methods | 537 // Make sure class is initialized before handing id's out to methods |
538 Klass::cast(k1())->initialize(CHECK_NULL); | 538 Klass::cast(k1())->initialize(CHECK_NULL); |
539 methodOop m = instanceKlass::cast(k1())->method_with_idnum(slot); | 539 Method* m = InstanceKlass::cast(k1())->method_with_idnum(slot); |
540 ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted | 540 ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted |
541 return ret; | 541 return ret; |
542 JNI_END | 542 JNI_END |
543 | 543 |
544 #ifndef USDT2 | 544 #ifndef USDT2 |
560 DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); | 560 DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); |
561 | 561 |
562 // field is a handle to a java.lang.reflect.Field object | 562 // field is a handle to a java.lang.reflect.Field object |
563 oop reflected = JNIHandles::resolve_non_null(field); | 563 oop reflected = JNIHandles::resolve_non_null(field); |
564 oop mirror = java_lang_reflect_Field::clazz(reflected); | 564 oop mirror = java_lang_reflect_Field::clazz(reflected); |
565 klassOop k = java_lang_Class::as_klassOop(mirror); | 565 Klass* k = java_lang_Class::as_Klass(mirror); |
566 int slot = java_lang_reflect_Field::slot(reflected); | 566 int slot = java_lang_reflect_Field::slot(reflected); |
567 int modifiers = java_lang_reflect_Field::modifiers(reflected); | 567 int modifiers = java_lang_reflect_Field::modifiers(reflected); |
568 | 568 |
569 KlassHandle k1(THREAD, k); | 569 KlassHandle k1(THREAD, k); |
570 // Make sure class is initialized before handing id's out to fields | 570 // Make sure class is initialized before handing id's out to fields |
571 Klass::cast(k1())->initialize(CHECK_NULL); | 571 Klass::cast(k1())->initialize(CHECK_NULL); |
572 | 572 |
573 // First check if this is a static field | 573 // First check if this is a static field |
574 if (modifiers & JVM_ACC_STATIC) { | 574 if (modifiers & JVM_ACC_STATIC) { |
575 intptr_t offset = instanceKlass::cast(k1())->field_offset( slot ); | 575 intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); |
576 JNIid* id = instanceKlass::cast(k1())->jni_id_for(offset); | 576 JNIid* id = InstanceKlass::cast(k1())->jni_id_for(offset); |
577 assert(id != NULL, "corrupt Field object"); | 577 assert(id != NULL, "corrupt Field object"); |
578 debug_only(id->set_is_static_field_id();) | 578 debug_only(id->set_is_static_field_id();) |
579 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop | 579 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass* |
580 ret = jfieldIDWorkaround::to_static_jfieldID(id); | 580 ret = jfieldIDWorkaround::to_static_jfieldID(id); |
581 return ret; | 581 return ret; |
582 } | 582 } |
583 | 583 |
584 // The slot is the index of the field description in the field-array | 584 // The slot is the index of the field description in the field-array |
585 // The jfieldID is the offset of the field within the object | 585 // The jfieldID is the offset of the field within the object |
586 // It may also have hash bits for k, if VerifyJNIFields is turned on. | 586 // It may also have hash bits for k, if VerifyJNIFields is turned on. |
587 intptr_t offset = instanceKlass::cast(k1())->field_offset( slot ); | 587 intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); |
588 assert(instanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); | 588 assert(InstanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); |
589 ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); | 589 ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); |
590 return ret; | 590 return ret; |
591 JNI_END | 591 JNI_END |
592 | 592 |
593 #ifndef USDT2 | 593 #ifndef USDT2 |
606 env, cls, (uintptr_t) method_id, isStatic); | 606 env, cls, (uintptr_t) method_id, isStatic); |
607 #endif /* USDT2 */ | 607 #endif /* USDT2 */ |
608 jobject ret = NULL; | 608 jobject ret = NULL; |
609 DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); | 609 DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); |
610 | 610 |
611 methodHandle m (THREAD, JNIHandles::resolve_jmethod_id(method_id)); | 611 methodHandle m (THREAD, Method::resolve_jmethod_id(method_id)); |
612 assert(m->is_static() == (isStatic != 0), "jni_ToReflectedMethod access flags doesn't match"); | 612 assert(m->is_static() == (isStatic != 0), "jni_ToReflectedMethod access flags doesn't match"); |
613 oop reflection_method; | 613 oop reflection_method; |
614 if (m->is_initializer()) { | 614 if (m->is_initializer()) { |
615 reflection_method = Reflection::new_constructor(m, CHECK_NULL); | 615 reflection_method = Reflection::new_constructor(m, CHECK_NULL); |
616 } else { | 616 } else { |
644 | 644 |
645 // Rules of Class.getSuperClass as implemented by KLass::java_super: | 645 // Rules of Class.getSuperClass as implemented by KLass::java_super: |
646 // arrays return Object | 646 // arrays return Object |
647 // interfaces return NULL | 647 // interfaces return NULL |
648 // proper classes return Klass::super() | 648 // proper classes return Klass::super() |
649 klassOop k = java_lang_Class::as_klassOop(mirror); | 649 Klass* k = java_lang_Class::as_Klass(mirror); |
650 if (Klass::cast(k)->is_interface()) return NULL; | 650 if (Klass::cast(k)->is_interface()) return NULL; |
651 | 651 |
652 // return mirror for superclass | 652 // return mirror for superclass |
653 klassOop super = Klass::cast(k)->java_super(); | 653 Klass* super = Klass::cast(k)->java_super(); |
654 // super2 is the value computed by the compiler's getSuperClass intrinsic: | 654 // super2 is the value computed by the compiler's getSuperClass intrinsic: |
655 debug_only(klassOop super2 = ( Klass::cast(k)->oop_is_javaArray() | 655 debug_only(Klass* super2 = ( Klass::cast(k)->oop_is_array() |
656 ? SystemDictionary::Object_klass() | 656 ? SystemDictionary::Object_klass() |
657 : Klass::cast(k)->super() ) ); | 657 : Klass::cast(k)->super() ) ); |
658 assert(super == super2, | 658 assert(super == super2, |
659 "java_super computation depends on interface, array, other super"); | 659 "java_super computation depends on interface, array, other super"); |
660 obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(Klass::cast(super)->java_mirror()); | 660 obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(Klass::cast(super)->java_mirror()); |
680 HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN( | 680 HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN( |
681 ret); | 681 ret); |
682 #endif /* USDT2 */ | 682 #endif /* USDT2 */ |
683 return ret; | 683 return ret; |
684 } | 684 } |
685 klassOop sub_klass = java_lang_Class::as_klassOop(sub_mirror); | 685 Klass* sub_klass = java_lang_Class::as_Klass(sub_mirror); |
686 klassOop super_klass = java_lang_Class::as_klassOop(super_mirror); | 686 Klass* super_klass = java_lang_Class::as_Klass(super_mirror); |
687 assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); | 687 assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); |
688 jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ? | 688 jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ? |
689 JNI_TRUE : JNI_FALSE; | 689 JNI_TRUE : JNI_FALSE; |
690 #ifndef USDT2 | 690 #ifndef USDT2 |
691 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); | 691 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); |
734 env, clazz, (char *) message); | 734 env, clazz, (char *) message); |
735 #endif /* USDT2 */ | 735 #endif /* USDT2 */ |
736 jint ret = JNI_OK; | 736 jint ret = JNI_OK; |
737 DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); | 737 DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); |
738 | 738 |
739 instanceKlass* k = instanceKlass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 739 InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
740 Symbol* name = k->name(); | 740 Symbol* name = k->name(); |
741 Handle class_loader (THREAD, k->class_loader()); | 741 Handle class_loader (THREAD, k->class_loader()); |
742 Handle protection_domain (THREAD, k->protection_domain()); | 742 Handle protection_domain (THREAD, k->protection_domain()); |
743 THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK); | 743 THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK); |
744 ShouldNotReachHere(); | 744 ShouldNotReachHere(); |
1155 JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap) | 1155 JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap) |
1156 : JNI_ArgumentPusher(signature) { | 1156 : JNI_ArgumentPusher(signature) { |
1157 set_ap(rap); | 1157 set_ap(rap); |
1158 } | 1158 } |
1159 JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap) | 1159 JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap) |
1160 : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) { | 1160 : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) { |
1161 set_ap(rap); | 1161 set_ap(rap); |
1162 } | 1162 } |
1163 | 1163 |
1164 // Optimized path if we have the bitvector form of signature | 1164 // Optimized path if we have the bitvector form of signature |
1165 void iterate( uint64_t fingerprint ) { | 1165 void iterate( uint64_t fingerprint ) { |
1226 JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap) | 1226 JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap) |
1227 : JNI_ArgumentPusher(signature) { | 1227 : JNI_ArgumentPusher(signature) { |
1228 set_ap(rap); | 1228 set_ap(rap); |
1229 } | 1229 } |
1230 JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap) | 1230 JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap) |
1231 : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) { | 1231 : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) { |
1232 set_ap(rap); | 1232 set_ap(rap); |
1233 } | 1233 } |
1234 | 1234 |
1235 // Optimized path if we have the bitvector form of signature | 1235 // Optimized path if we have the bitvector form of signature |
1236 void iterate( uint64_t fingerprint ) { | 1236 void iterate( uint64_t fingerprint ) { |
1316 } | 1316 } |
1317 | 1317 |
1318 | 1318 |
1319 | 1319 |
1320 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | 1320 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { |
1321 methodHandle method(THREAD, JNIHandles::resolve_jmethod_id(method_id)); | 1321 methodHandle method(THREAD, Method::resolve_jmethod_id(method_id)); |
1322 | 1322 |
1323 // Create object to hold arguments for the JavaCall, and associate it with | 1323 // Create object to hold arguments for the JavaCall, and associate it with |
1324 // the jni parser | 1324 // the jni parser |
1325 ResourceMark rm(THREAD); | 1325 ResourceMark rm(THREAD); |
1326 int number_of_parameters = method->size_of_parameters(); | 1326 int number_of_parameters = method->size_of_parameters(); |
1350 THROW(vmSymbols::java_lang_NullPointerException()); | 1350 THROW(vmSymbols::java_lang_NullPointerException()); |
1351 } | 1351 } |
1352 Handle h_recv(THREAD, recv); | 1352 Handle h_recv(THREAD, recv); |
1353 | 1353 |
1354 int number_of_parameters; | 1354 int number_of_parameters; |
1355 methodOop selected_method; | 1355 Method* selected_method; |
1356 { | 1356 { |
1357 methodOop m = JNIHandles::resolve_jmethod_id(method_id); | 1357 Method* m = Method::resolve_jmethod_id(method_id); |
1358 number_of_parameters = m->size_of_parameters(); | 1358 number_of_parameters = m->size_of_parameters(); |
1359 klassOop holder = m->method_holder(); | 1359 Klass* holder = m->method_holder(); |
1360 if (!(Klass::cast(holder))->is_interface()) { | 1360 if (!(Klass::cast(holder))->is_interface()) { |
1361 // non-interface call -- for that little speed boost, don't handlize | 1361 // non-interface call -- for that little speed boost, don't handlize |
1362 debug_only(No_Safepoint_Verifier nosafepoint;) | 1362 debug_only(No_Safepoint_Verifier nosafepoint;) |
1363 if (call_type == JNI_VIRTUAL) { | 1363 if (call_type == JNI_VIRTUAL) { |
1364 // jni_GetMethodID makes sure class is linked and initialized | 1364 // jni_GetMethodID makes sure class is linked and initialized |
1365 // so m should have a valid vtable index. | 1365 // so m should have a valid vtable index. |
1366 int vtbl_index = m->vtable_index(); | 1366 int vtbl_index = m->vtable_index(); |
1367 if (vtbl_index != methodOopDesc::nonvirtual_vtable_index) { | 1367 if (vtbl_index != Method::nonvirtual_vtable_index) { |
1368 klassOop k = h_recv->klass(); | 1368 Klass* k = h_recv->klass(); |
1369 // k might be an arrayKlassOop but all vtables start at | 1369 // k might be an arrayKlassOop but all vtables start at |
1370 // the same place. The cast is to avoid virtual call and assertion. | 1370 // the same place. The cast is to avoid virtual call and assertion. |
1371 instanceKlass *ik = (instanceKlass*)k->klass_part(); | 1371 InstanceKlass *ik = (InstanceKlass*)k; |
1372 selected_method = ik->method_at_vtable(vtbl_index); | 1372 selected_method = ik->method_at_vtable(vtbl_index); |
1373 } else { | 1373 } else { |
1374 // final method | 1374 // final method |
1375 selected_method = m; | 1375 selected_method = m; |
1376 } | 1376 } |
1386 if (itbl_index == -1) { | 1386 if (itbl_index == -1) { |
1387 itbl_index = klassItable::compute_itable_index(m); | 1387 itbl_index = klassItable::compute_itable_index(m); |
1388 m->set_cached_itable_index(itbl_index); | 1388 m->set_cached_itable_index(itbl_index); |
1389 // the above may have grabbed a lock, 'm' and anything non-handlized can't be used again | 1389 // the above may have grabbed a lock, 'm' and anything non-handlized can't be used again |
1390 } | 1390 } |
1391 klassOop k = h_recv->klass(); | 1391 Klass* k = h_recv->klass(); |
1392 selected_method = instanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); | 1392 selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); |
1393 } | 1393 } |
1394 } | 1394 } |
1395 | 1395 |
1396 methodHandle method(THREAD, selected_method); | 1396 methodHandle method(THREAD, selected_method); |
1397 | 1397 |
1419 } | 1419 } |
1420 } | 1420 } |
1421 | 1421 |
1422 | 1422 |
1423 static instanceOop alloc_object(jclass clazz, TRAPS) { | 1423 static instanceOop alloc_object(jclass clazz, TRAPS) { |
1424 KlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 1424 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
1425 Klass::cast(k())->check_valid_for_instantiation(false, CHECK_NULL); | 1425 Klass::cast(k())->check_valid_for_instantiation(false, CHECK_NULL); |
1426 instanceKlass::cast(k())->initialize(CHECK_NULL); | 1426 InstanceKlass::cast(k())->initialize(CHECK_NULL); |
1427 instanceOop ih = instanceKlass::cast(k())->allocate_instance(THREAD); | 1427 instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD); |
1428 return ih; | 1428 return ih; |
1429 } | 1429 } |
1430 | 1430 |
1431 #ifndef USDT2 | 1431 #ifndef USDT2 |
1432 DT_RETURN_MARK_DECL(AllocObject, jobject); | 1432 DT_RETURN_MARK_DECL(AllocObject, jobject); |
1540 DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); | 1540 DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); |
1541 #else /* USDT2 */ | 1541 #else /* USDT2 */ |
1542 HOTSPOT_JNI_GETOBJECTCLASS_ENTRY( | 1542 HOTSPOT_JNI_GETOBJECTCLASS_ENTRY( |
1543 env, obj); | 1543 env, obj); |
1544 #endif /* USDT2 */ | 1544 #endif /* USDT2 */ |
1545 klassOop k = JNIHandles::resolve_non_null(obj)->klass(); | 1545 Klass* k = JNIHandles::resolve_non_null(obj)->klass(); |
1546 jclass ret = | 1546 jclass ret = |
1547 (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); | 1547 (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); |
1548 #ifndef USDT2 | 1548 #ifndef USDT2 |
1549 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); | 1549 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); |
1550 #else /* USDT2 */ | 1550 #else /* USDT2 */ |
1563 env, obj, clazz); | 1563 env, obj, clazz); |
1564 #endif /* USDT2 */ | 1564 #endif /* USDT2 */ |
1565 jboolean ret = JNI_TRUE; | 1565 jboolean ret = JNI_TRUE; |
1566 if (obj != NULL) { | 1566 if (obj != NULL) { |
1567 ret = JNI_FALSE; | 1567 ret = JNI_FALSE; |
1568 klassOop k = java_lang_Class::as_klassOop( | 1568 Klass* k = java_lang_Class::as_Klass( |
1569 JNIHandles::resolve_non_null(clazz)); | 1569 JNIHandles::resolve_non_null(clazz)); |
1570 if (k != NULL) { | 1570 if (k != NULL) { |
1571 ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; | 1571 ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; |
1572 } | 1572 } |
1573 } | 1573 } |
1603 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) { | 1603 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) { |
1604 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | 1604 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
1605 } | 1605 } |
1606 | 1606 |
1607 KlassHandle klass(THREAD, | 1607 KlassHandle klass(THREAD, |
1608 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 1608 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
1609 | 1609 |
1610 // Make sure class is linked and initialized before handing id's out to | 1610 // Make sure class is linked and initialized before handing id's out to |
1611 // methodOops. | 1611 // Method*s. |
1612 Klass::cast(klass())->initialize(CHECK_NULL); | 1612 Klass::cast(klass())->initialize(CHECK_NULL); |
1613 | 1613 |
1614 methodOop m; | 1614 Method* m; |
1615 if (name == vmSymbols::object_initializer_name() || | 1615 if (name == vmSymbols::object_initializer_name() || |
1616 name == vmSymbols::class_initializer_name()) { | 1616 name == vmSymbols::class_initializer_name()) { |
1617 // Never search superclasses for constructors | 1617 // Never search superclasses for constructors |
1618 if (klass->oop_is_instance()) { | 1618 if (klass->oop_is_instance()) { |
1619 m = instanceKlass::cast(klass())->find_method(name, signature); | 1619 m = InstanceKlass::cast(klass())->find_method(name, signature); |
1620 } else { | 1620 } else { |
1621 m = NULL; | 1621 m = NULL; |
1622 } | 1622 } |
1623 } else { | 1623 } else { |
1624 m = klass->lookup_method(name, signature); | 1624 m = klass->lookup_method(name, signature); |
1625 // Look up interfaces | 1625 // Look up interfaces |
1626 if (m == NULL && klass->oop_is_instance()) { | 1626 if (m == NULL && klass->oop_is_instance()) { |
1627 m = instanceKlass::cast(klass())->lookup_method_in_all_interfaces(name, | 1627 m = InstanceKlass::cast(klass())->lookup_method_in_all_interfaces(name, |
1628 signature); | 1628 signature); |
1629 } | 1629 } |
1630 } | 1630 } |
1631 if (m == NULL || (m->is_static() != is_static)) { | 1631 if (m == NULL || (m->is_static() != is_static)) { |
1632 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | 1632 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
2422 (const ResultType&)ret);\ | 2422 (const ResultType&)ret);\ |
2423 \ | 2423 \ |
2424 JavaValue jvalue(Tag); \ | 2424 JavaValue jvalue(Tag); \ |
2425 JNI_ArgumentPusherVaArg ap(methodID, args); \ | 2425 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
2426 /* Make sure class is initialized before trying to invoke its method */ \ | 2426 /* Make sure class is initialized before trying to invoke its method */ \ |
2427 KlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls))); \ | 2427 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \ |
2428 Klass::cast(k())->initialize(CHECK_0); \ | 2428 Klass::cast(k())->initialize(CHECK_0); \ |
2429 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | 2429 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
2430 va_end(args); \ | 2430 va_end(args); \ |
2431 ret = jvalue.get_##ResultType(); \ | 2431 ret = jvalue.get_##ResultType(); \ |
2432 return ret;\ | 2432 return ret;\ |
2606 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); | 2606 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
2607 if (fieldname == NULL || signame == NULL) { | 2607 if (fieldname == NULL || signame == NULL) { |
2608 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 2608 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2609 } | 2609 } |
2610 KlassHandle k(THREAD, | 2610 KlassHandle k(THREAD, |
2611 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 2611 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
2612 // Make sure class is initialized before handing id's out to fields | 2612 // Make sure class is initialized before handing id's out to fields |
2613 Klass::cast(k())->initialize(CHECK_NULL); | 2613 Klass::cast(k())->initialize(CHECK_NULL); |
2614 | 2614 |
2615 fieldDescriptor fd; | 2615 fieldDescriptor fd; |
2616 if (!Klass::cast(k())->oop_is_instance() || | 2616 if (!Klass::cast(k())->oop_is_instance() || |
2617 !instanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { | 2617 !InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { |
2618 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 2618 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2619 } | 2619 } |
2620 | 2620 |
2621 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop | 2621 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop |
2622 // It may also have hash bits for k, if VerifyJNIFields is turned on. | 2622 // It may also have hash bits for k, if VerifyJNIFields is turned on. |
2632 #else /* USDT2 */ | 2632 #else /* USDT2 */ |
2633 HOTSPOT_JNI_GETOBJECTFIELD_ENTRY( | 2633 HOTSPOT_JNI_GETOBJECTFIELD_ENTRY( |
2634 env, obj, (uintptr_t) fieldID); | 2634 env, obj, (uintptr_t) fieldID); |
2635 #endif /* USDT2 */ | 2635 #endif /* USDT2 */ |
2636 oop o = JNIHandles::resolve_non_null(obj); | 2636 oop o = JNIHandles::resolve_non_null(obj); |
2637 klassOop k = o->klass(); | 2637 Klass* k = o->klass(); |
2638 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | 2638 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2639 // Keep JVMTI addition small and only check enabled flag here. | 2639 // Keep JVMTI addition small and only check enabled flag here. |
2640 // jni_GetField_probe() assumes that is okay to create handles. | 2640 // jni_GetField_probe() assumes that is okay to create handles. |
2641 if (JvmtiExport::should_post_field_access()) { | 2641 if (JvmtiExport::should_post_field_access()) { |
2642 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); | 2642 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); |
2649 if (UseG1GC) { | 2649 if (UseG1GC) { |
2650 bool needs_barrier = false; | 2650 bool needs_barrier = false; |
2651 | 2651 |
2652 if (ret != NULL && | 2652 if (ret != NULL && |
2653 offset == java_lang_ref_Reference::referent_offset && | 2653 offset == java_lang_ref_Reference::referent_offset && |
2654 instanceKlass::cast(k)->reference_type() != REF_NONE) { | 2654 InstanceKlass::cast(k)->reference_type() != REF_NONE) { |
2655 assert(instanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); | 2655 assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); |
2656 needs_barrier = true; | 2656 needs_barrier = true; |
2657 } | 2657 } |
2658 | 2658 |
2659 if (needs_barrier) { | 2659 if (needs_barrier) { |
2660 oop referent = JNIHandles::resolve(ret); | 2660 oop referent = JNIHandles::resolve(ret); |
2683 DTRACE_PROBE3(hotspot_jni, Get##Result##Field__entry, env, obj, fieldID);\ | 2683 DTRACE_PROBE3(hotspot_jni, Get##Result##Field__entry, env, obj, fieldID);\ |
2684 Return ret = 0;\ | 2684 Return ret = 0;\ |
2685 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | 2685 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ |
2686 \ | 2686 \ |
2687 oop o = JNIHandles::resolve_non_null(obj); \ | 2687 oop o = JNIHandles::resolve_non_null(obj); \ |
2688 klassOop k = o->klass(); \ | 2688 Klass* k = o->klass(); \ |
2689 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ | 2689 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2690 /* Keep JVMTI addition small and only check enabled flag here. */ \ | 2690 /* Keep JVMTI addition small and only check enabled flag here. */ \ |
2691 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | 2691 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ |
2692 /* and creates a ResetNoHandleMark. */ \ | 2692 /* and creates a ResetNoHandleMark. */ \ |
2693 if (JvmtiExport::should_post_field_access()) { \ | 2693 if (JvmtiExport::should_post_field_access()) { \ |
2720 EntryProbe; \ | 2720 EntryProbe; \ |
2721 Return ret = 0;\ | 2721 Return ret = 0;\ |
2722 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ | 2722 DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ |
2723 \ | 2723 \ |
2724 oop o = JNIHandles::resolve_non_null(obj); \ | 2724 oop o = JNIHandles::resolve_non_null(obj); \ |
2725 klassOop k = o->klass(); \ | 2725 Klass* k = o->klass(); \ |
2726 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ | 2726 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2727 /* Keep JVMTI addition small and only check enabled flag here. */ \ | 2727 /* Keep JVMTI addition small and only check enabled flag here. */ \ |
2728 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ | 2728 /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ |
2729 /* and creates a ResetNoHandleMark. */ \ | 2729 /* and creates a ResetNoHandleMark. */ \ |
2730 if (JvmtiExport::should_post_field_access()) { \ | 2730 if (JvmtiExport::should_post_field_access()) { \ |
2793 #else /* USDT2 */ | 2793 #else /* USDT2 */ |
2794 HOTSPOT_JNI_SETOBJECTFIELD_ENTRY( | 2794 HOTSPOT_JNI_SETOBJECTFIELD_ENTRY( |
2795 env, obj, (uintptr_t) fieldID, value); | 2795 env, obj, (uintptr_t) fieldID, value); |
2796 #endif /* USDT2 */ | 2796 #endif /* USDT2 */ |
2797 oop o = JNIHandles::resolve_non_null(obj); | 2797 oop o = JNIHandles::resolve_non_null(obj); |
2798 klassOop k = o->klass(); | 2798 Klass* k = o->klass(); |
2799 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | 2799 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2800 // Keep JVMTI addition small and only check enabled flag here. | 2800 // Keep JVMTI addition small and only check enabled flag here. |
2801 // jni_SetField_probe_nh() assumes that is not okay to create handles | 2801 // jni_SetField_probe_nh() assumes that is not okay to create handles |
2802 // and creates a ResetNoHandleMark. | 2802 // and creates a ResetNoHandleMark. |
2803 if (JvmtiExport::should_post_field_modification()) { | 2803 if (JvmtiExport::should_post_field_modification()) { |
2824 ( JNIEnv*, jobject, jfieldID FP_SELECT_##Result(COMMA Argument,/*empty*/) ) ); \ | 2824 ( JNIEnv*, jobject, jfieldID FP_SELECT_##Result(COMMA Argument,/*empty*/) ) ); \ |
2825 HS_DTRACE_PROBE_N(hotspot_jni, Set##Result##Field__entry, \ | 2825 HS_DTRACE_PROBE_N(hotspot_jni, Set##Result##Field__entry, \ |
2826 ( env, obj, fieldID FP_SELECT_##Result(COMMA value,/*empty*/) ) ); \ | 2826 ( env, obj, fieldID FP_SELECT_##Result(COMMA value,/*empty*/) ) ); \ |
2827 \ | 2827 \ |
2828 oop o = JNIHandles::resolve_non_null(obj); \ | 2828 oop o = JNIHandles::resolve_non_null(obj); \ |
2829 klassOop k = o->klass(); \ | 2829 Klass* k = o->klass(); \ |
2830 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ | 2830 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2831 /* Keep JVMTI addition small and only check enabled flag here. */ \ | 2831 /* Keep JVMTI addition small and only check enabled flag here. */ \ |
2832 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | 2832 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ |
2833 /* and creates a ResetNoHandleMark. */ \ | 2833 /* and creates a ResetNoHandleMark. */ \ |
2834 if (JvmtiExport::should_post_field_modification()) { \ | 2834 if (JvmtiExport::should_post_field_modification()) { \ |
2858 JNIWrapper("Set" XSTR(Result) "Field"); \ | 2858 JNIWrapper("Set" XSTR(Result) "Field"); \ |
2859 \ | 2859 \ |
2860 EntryProbe; \ | 2860 EntryProbe; \ |
2861 \ | 2861 \ |
2862 oop o = JNIHandles::resolve_non_null(obj); \ | 2862 oop o = JNIHandles::resolve_non_null(obj); \ |
2863 klassOop k = o->klass(); \ | 2863 Klass* k = o->klass(); \ |
2864 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ | 2864 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ |
2865 /* Keep JVMTI addition small and only check enabled flag here. */ \ | 2865 /* Keep JVMTI addition small and only check enabled flag here. */ \ |
2866 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ | 2866 /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ |
2867 /* and creates a ResetNoHandleMark. */ \ | 2867 /* and creates a ResetNoHandleMark. */ \ |
2868 if (JvmtiExport::should_post_field_modification()) { \ | 2868 if (JvmtiExport::should_post_field_modification()) { \ |
2920 jobject ret = NULL; | 2920 jobject ret = NULL; |
2921 DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); | 2921 DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); |
2922 | 2922 |
2923 fieldDescriptor fd; | 2923 fieldDescriptor fd; |
2924 bool found = false; | 2924 bool found = false; |
2925 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); | 2925 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2926 | 2926 |
2927 assert(jfieldIDWorkaround::is_static_jfieldID(fieldID) == (isStatic != 0), "invalid fieldID"); | 2927 assert(jfieldIDWorkaround::is_static_jfieldID(fieldID) == (isStatic != 0), "invalid fieldID"); |
2928 | 2928 |
2929 if (isStatic) { | 2929 if (isStatic) { |
2930 // Static field. The fieldID a JNIid specifying the field holder and the offset within the klassOop. | 2930 // Static field. The fieldID a JNIid specifying the field holder and the offset within the Klass*. |
2931 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); | 2931 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
2932 assert(id->is_static_field_id(), "invalid static field id"); | 2932 assert(id->is_static_field_id(), "invalid static field id"); |
2933 found = id->find_local_field(&fd); | 2933 found = id->find_local_field(&fd); |
2934 } else { | 2934 } else { |
2935 // Non-static field. The fieldID is really the offset of the field within the instanceOop. | 2935 // Non-static field. The fieldID is really the offset of the field within the instanceOop. |
2936 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); | 2936 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); |
2937 found = instanceKlass::cast(k)->find_field_from_offset(offset, false, &fd); | 2937 found = InstanceKlass::cast(k)->find_field_from_offset(offset, false, &fd); |
2938 } | 2938 } |
2939 assert(found, "bad fieldID passed into jni_ToReflectedField"); | 2939 assert(found, "bad fieldID passed into jni_ToReflectedField"); |
2940 oop reflected = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); | 2940 oop reflected = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); |
2941 ret = JNIHandles::make_local(env, reflected); | 2941 ret = JNIHandles::make_local(env, reflected); |
2942 return ret; | 2942 return ret; |
2972 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); | 2972 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
2973 if (fieldname == NULL || signame == NULL) { | 2973 if (fieldname == NULL || signame == NULL) { |
2974 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 2974 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2975 } | 2975 } |
2976 KlassHandle k(THREAD, | 2976 KlassHandle k(THREAD, |
2977 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 2977 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
2978 // Make sure class is initialized before handing id's out to static fields | 2978 // Make sure class is initialized before handing id's out to static fields |
2979 Klass::cast(k())->initialize(CHECK_NULL); | 2979 Klass::cast(k())->initialize(CHECK_NULL); |
2980 | 2980 |
2981 fieldDescriptor fd; | 2981 fieldDescriptor fd; |
2982 if (!Klass::cast(k())->oop_is_instance() || | 2982 if (!Klass::cast(k())->oop_is_instance() || |
2983 !instanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { | 2983 !InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { |
2984 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 2984 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
2985 } | 2985 } |
2986 | 2986 |
2987 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop | 2987 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass* |
2988 JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset()); | 2988 JNIid* id = InstanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset()); |
2989 debug_only(id->set_is_static_field_id();) | 2989 debug_only(id->set_is_static_field_id();) |
2990 | 2990 |
2991 debug_only(id->verify(fd.field_holder())); | 2991 debug_only(id->verify(fd.field_holder())); |
2992 | 2992 |
2993 ret = jfieldIDWorkaround::to_static_jfieldID(id); | 2993 ret = jfieldIDWorkaround::to_static_jfieldID(id); |
3002 #else /* USDT2 */ | 3002 #else /* USDT2 */ |
3003 HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY( | 3003 HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY( |
3004 env, clazz, (uintptr_t) fieldID); | 3004 env, clazz, (uintptr_t) fieldID); |
3005 #endif /* USDT2 */ | 3005 #endif /* USDT2 */ |
3006 #ifndef JNICHECK_KERNEL | 3006 #ifndef JNICHECK_KERNEL |
3007 DEBUG_ONLY(klassOop param_k = jniCheck::validate_class(thread, clazz);) | 3007 DEBUG_ONLY(Klass* param_k = jniCheck::validate_class(thread, clazz);) |
3008 #endif // JNICHECK_KERNEL | 3008 #endif // JNICHECK_KERNEL |
3009 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); | 3009 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); |
3010 assert(id->is_static_field_id(), "invalid static field id"); | 3010 assert(id->is_static_field_id(), "invalid static field id"); |
3011 // Keep JVMTI addition small and only check enabled flag here. | 3011 // Keep JVMTI addition small and only check enabled flag here. |
3012 // jni_GetField_probe() assumes that is okay to create handles. | 3012 // jni_GetField_probe() assumes that is okay to create handles. |
3437 HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY( | 3437 HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY( |
3438 env, length, elementClass, initialElement); | 3438 env, length, elementClass, initialElement); |
3439 #endif /* USDT2 */ | 3439 #endif /* USDT2 */ |
3440 jobjectArray ret = NULL; | 3440 jobjectArray ret = NULL; |
3441 DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); | 3441 DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); |
3442 KlassHandle ek(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(elementClass))); | 3442 KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); |
3443 klassOop ako = Klass::cast(ek())->array_klass(CHECK_NULL); | 3443 Klass* ako = Klass::cast(ek())->array_klass(CHECK_NULL); |
3444 KlassHandle ak = KlassHandle(THREAD, ako); | 3444 KlassHandle ak = KlassHandle(THREAD, ako); |
3445 objArrayKlass::cast(ak())->initialize(CHECK_NULL); | 3445 objArrayKlass::cast(ak())->initialize(CHECK_NULL); |
3446 objArrayOop result = objArrayKlass::cast(ak())->allocate(length, CHECK_NULL); | 3446 objArrayOop result = objArrayKlass::cast(ak())->allocate(length, CHECK_NULL); |
3447 oop initial_value = JNIHandles::resolve(initialElement); | 3447 oop initial_value = JNIHandles::resolve(initialElement); |
3448 if (initial_value != NULL) { // array already initialized with NULL | 3448 if (initial_value != NULL) { // array already initialized with NULL |
3947 | 3947 |
3948 // The RegisterNatives call being attempted tried to register with a method that | 3948 // The RegisterNatives call being attempted tried to register with a method that |
3949 // is not native. Ask JVM TI what prefixes have been specified. Then check | 3949 // is not native. Ask JVM TI what prefixes have been specified. Then check |
3950 // to see if the native method is now wrapped with the prefixes. See the | 3950 // to see if the native method is now wrapped with the prefixes. See the |
3951 // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. | 3951 // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. |
3952 static methodOop find_prefixed_native(KlassHandle k, | 3952 static Method* find_prefixed_native(KlassHandle k, |
3953 Symbol* name, Symbol* signature, TRAPS) { | 3953 Symbol* name, Symbol* signature, TRAPS) { |
3954 ResourceMark rm(THREAD); | 3954 ResourceMark rm(THREAD); |
3955 methodOop method; | 3955 Method* method; |
3956 int name_len = name->utf8_length(); | 3956 int name_len = name->utf8_length(); |
3957 char* name_str = name->as_utf8(); | 3957 char* name_str = name->as_utf8(); |
3958 int prefix_count; | 3958 int prefix_count; |
3959 char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count); | 3959 char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count); |
3960 for (int i = 0; i < prefix_count; i++) { | 3960 for (int i = 0; i < prefix_count; i++) { |
3984 } | 3984 } |
3985 return NULL; // not found | 3985 return NULL; // not found |
3986 } | 3986 } |
3987 | 3987 |
3988 static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { | 3988 static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { |
3989 methodOop method = Klass::cast(k())->lookup_method(name, signature); | 3989 Method* method = Klass::cast(k())->lookup_method(name, signature); |
3990 if (method == NULL) { | 3990 if (method == NULL) { |
3991 ResourceMark rm; | 3991 ResourceMark rm; |
3992 stringStream st; | 3992 stringStream st; |
3993 st.print("Method %s name or signature does not match", | 3993 st.print("Method %s name or signature does not match", |
3994 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); | 3994 Method::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); |
3995 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); | 3995 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
3996 } | 3996 } |
3997 if (!method->is_native()) { | 3997 if (!method->is_native()) { |
3998 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) | 3998 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) |
3999 method = find_prefixed_native(k, name, signature, THREAD); | 3999 method = find_prefixed_native(k, name, signature, THREAD); |
4000 if (method == NULL) { | 4000 if (method == NULL) { |
4001 ResourceMark rm; | 4001 ResourceMark rm; |
4002 stringStream st; | 4002 stringStream st; |
4003 st.print("Method %s is not declared as native", | 4003 st.print("Method %s is not declared as native", |
4004 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); | 4004 Method::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); |
4005 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); | 4005 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
4006 } | 4006 } |
4007 } | 4007 } |
4008 | 4008 |
4009 if (entry != NULL) { | 4009 if (entry != NULL) { |
4010 method->set_native_function(entry, | 4010 method->set_native_function(entry, |
4011 methodOopDesc::native_bind_event_is_interesting); | 4011 Method::native_bind_event_is_interesting); |
4012 } else { | 4012 } else { |
4013 method->clear_native_function(); | 4013 method->clear_native_function(); |
4014 } | 4014 } |
4015 if (PrintJNIResolving) { | 4015 if (PrintJNIResolving) { |
4016 ResourceMark rm(THREAD); | 4016 ResourceMark rm(THREAD); |
4039 env, clazz, (void *) methods, nMethods); | 4039 env, clazz, (void *) methods, nMethods); |
4040 #endif /* USDT2 */ | 4040 #endif /* USDT2 */ |
4041 jint ret = 0; | 4041 jint ret = 0; |
4042 DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); | 4042 DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); |
4043 | 4043 |
4044 KlassHandle h_k(thread, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 4044 KlassHandle h_k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); |
4045 | 4045 |
4046 for (int index = 0; index < nMethods; index++) { | 4046 for (int index = 0; index < nMethods; index++) { |
4047 const char* meth_name = methods[index].name; | 4047 const char* meth_name = methods[index].name; |
4048 const char* meth_sig = methods[index].signature; | 4048 const char* meth_sig = methods[index].signature; |
4049 int meth_name_len = (int)strlen(meth_name); | 4049 int meth_name_len = (int)strlen(meth_name); |
4079 DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); | 4079 DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); |
4080 #else /* USDT2 */ | 4080 #else /* USDT2 */ |
4081 HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY( | 4081 HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY( |
4082 env, clazz); | 4082 env, clazz); |
4083 #endif /* USDT2 */ | 4083 #endif /* USDT2 */ |
4084 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)); | 4084 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); |
4085 //%note jni_2 | 4085 //%note jni_2 |
4086 if (Klass::cast(k)->oop_is_instance()) { | 4086 if (Klass::cast(k)->oop_is_instance()) { |
4087 for (int index = 0; index < instanceKlass::cast(k)->methods()->length(); index++) { | 4087 for (int index = 0; index < InstanceKlass::cast(k)->methods()->length(); index++) { |
4088 methodOop m = methodOop(instanceKlass::cast(k)->methods()->obj_at(index)); | 4088 Method* m = InstanceKlass::cast(k)->methods()->at(index); |
4089 if (m->is_native()) { | 4089 if (m->is_native()) { |
4090 m->clear_native_function(); | 4090 m->clear_native_function(); |
4091 m->set_signature_handler(NULL); | 4091 m->set_signature_handler(NULL); |
4092 } | 4092 } |
4093 } | 4093 } |
4410 | 4410 |
4411 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); | 4411 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
4412 jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); | 4412 jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); |
4413 | 4413 |
4414 if (TraceClassResolution && result != NULL) { | 4414 if (TraceClassResolution && result != NULL) { |
4415 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); | 4415 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
4416 } | 4416 } |
4417 return result; | 4417 return result; |
4418 } | 4418 } |
4419 | 4419 |
4420 // These lookups are done with the NULL (bootstrap) ClassLoader to | 4420 // These lookups are done with the NULL (bootstrap) ClassLoader to |