comparison src/share/vm/classfile/javaClasses.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 8f2fb6bec986 fe34c5ab0b35
children be896a1983c0
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
39 #include "oops/instanceMirrorKlass.hpp" 39 #include "oops/instanceMirrorKlass.hpp"
40 #include "oops/klass.hpp" 40 #include "oops/klass.hpp"
41 #include "oops/method.hpp" 41 #include "oops/method.hpp"
42 #include "oops/symbol.hpp" 42 #include "oops/symbol.hpp"
43 #include "oops/typeArrayOop.hpp" 43 #include "oops/typeArrayOop.hpp"
44 #include "prims/jvmtiRedefineClassesTrace.hpp"
44 #include "runtime/fieldDescriptor.hpp" 45 #include "runtime/fieldDescriptor.hpp"
45 #include "runtime/handles.inline.hpp" 46 #include "runtime/handles.inline.hpp"
46 #include "runtime/interfaceSupport.hpp" 47 #include "runtime/interfaceSupport.hpp"
47 #include "runtime/java.hpp" 48 #include "runtime/java.hpp"
48 #include "runtime/javaCalls.hpp" 49 #include "runtime/javaCalls.hpp"
461 } 462 }
462 } 463 }
463 return true; 464 return true;
464 } 465 }
465 466
466 void java_lang_String::print(Handle java_string, outputStream* st) { 467 void java_lang_String::print(oop java_string, outputStream* st) {
467 oop obj = java_string(); 468 assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string");
468 assert(obj->klass() == SystemDictionary::String_klass(), "must be java_string"); 469 typeArrayOop value = java_lang_String::value(java_string);
469 typeArrayOop value = java_lang_String::value(obj); 470 int offset = java_lang_String::offset(java_string);
470 int offset = java_lang_String::offset(obj); 471 int length = java_lang_String::length(java_string);
471 int length = java_lang_String::length(obj);
472 472
473 int end = MIN2(length, 100); 473 int end = MIN2(length, 100);
474 if (value == NULL) { 474 if (value == NULL) {
475 // This can happen if, e.g., printing a String 475 // This can happen if, e.g., printing a String
476 // object before its initializer has been called 476 // object before its initializer has been called
547 fs.set_offset(real_offset); 547 fs.set_offset(real_offset);
548 } 548 }
549 } 549 }
550 } 550 }
551 } 551 }
552 create_mirror(k, Handle(NULL), CHECK); 552 create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
553 } 553 }
554 554
555 void java_lang_Class::initialize_mirror_fields(KlassHandle k, 555 void java_lang_Class::initialize_mirror_fields(KlassHandle k,
556 Handle mirror, 556 Handle mirror,
557 Handle protection_domain, 557 Handle protection_domain,
573 573
574 // Initialize static fields 574 // Initialize static fields
575 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); 575 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
576 } 576 }
577 577
578 void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) { 578 void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
579 Handle protection_domain, TRAPS) {
579 assert(k->java_mirror() == NULL, "should only assign mirror once"); 580 assert(k->java_mirror() == NULL, "should only assign mirror once");
580 // Use this moment of initialization to cache modifier_flags also, 581 // Use this moment of initialization to cache modifier_flags also,
581 // to support Class.getModifiers(). Instance classes recalculate 582 // to support Class.getModifiers(). Instance classes recalculate
582 // the cached flags after the class file is parsed, but before the 583 // the cached flags after the class file is parsed, but before the
583 // class is put into the system dictionary. 584 // class is put into the system dictionary.
628 java_lang_Class::set_klass(mirror(), NULL); 629 java_lang_Class::set_klass(mirror(), NULL);
629 return; 630 return;
630 } 631 }
631 } 632 }
632 633
634 // set the classLoader field in the java_lang_Class instance
635 assert(class_loader() == k->class_loader(), "should be same");
636 set_class_loader(mirror(), class_loader());
637
633 // Setup indirection from klass->mirror last 638 // Setup indirection from klass->mirror last
634 // after any exceptions can happen during allocations. 639 // after any exceptions can happen during allocations.
635 if (!k.is_null()) { 640 if (!k.is_null()) {
636 k->set_java_mirror(mirror()); 641 k->set_java_mirror(mirror());
637 } 642 }
688 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) { 693 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
689 assert(_signers_offset != 0, "must be set"); 694 assert(_signers_offset != 0, "must be set");
690 java_class->obj_field_put(_signers_offset, (oop)signers); 695 java_class->obj_field_put(_signers_offset, (oop)signers);
691 } 696 }
692 697
698
699 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
700 // jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet.
701 if (_class_loader_offset != 0) {
702 java_class->obj_field_put(_class_loader_offset, loader);
703 }
704 }
705
706 oop java_lang_Class::class_loader(oop java_class) {
707 assert(_class_loader_offset != 0, "must be set");
708 return java_class->obj_field(_class_loader_offset);
709 }
693 710
694 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { 711 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
695 // This should be improved by adding a field at the Java level or by 712 // This should be improved by adding a field at the Java level or by
696 // introducing a new VM klass (see comment in ClassFileParser) 713 // introducing a new VM klass (see comment in ClassFileParser)
697 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0); 714 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
847 Klass* klass_oop = SystemDictionary::Class_klass(); 864 Klass* klass_oop = SystemDictionary::Class_klass();
848 // The classRedefinedCount field is only present starting in 1.5, 865 // The classRedefinedCount field is only present starting in 1.5,
849 // so don't go fatal. 866 // so don't go fatal.
850 compute_optional_offset(classRedefinedCount_offset, 867 compute_optional_offset(classRedefinedCount_offset,
851 klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); 868 klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
869
870 // Needs to be optional because the old build runs Queens during bootstrapping
871 // and jdk8-9 doesn't have coordinated pushes yet.
872 compute_optional_offset(_class_loader_offset,
873 klass_oop, vmSymbols::classLoader_name(),
874 vmSymbols::classloader_signature());
852 875
853 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); 876 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
854 } 877 }
855 878
856 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { 879 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
2757 Metadata* java_lang_invoke_MemberName::vmtarget(oop mname) { 2780 Metadata* java_lang_invoke_MemberName::vmtarget(oop mname) {
2758 assert(is_instance(mname), "wrong type"); 2781 assert(is_instance(mname), "wrong type");
2759 return (Metadata*)mname->address_field(_vmtarget_offset); 2782 return (Metadata*)mname->address_field(_vmtarget_offset);
2760 } 2783 }
2761 2784
2785 bool java_lang_invoke_MemberName::is_method(oop mname) {
2786 assert(is_instance(mname), "must be MemberName");
2787 return (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0;
2788 }
2789
2762 #if INCLUDE_JVMTI 2790 #if INCLUDE_JVMTI
2763 // Can be executed on VM thread only 2791 // Can be executed on VM thread only
2764 void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Metadata* ref) { 2792 void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Method* old_method,
2765 assert((is_instance(mname) && (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0), "wrong type"); 2793 Method* new_method, bool* trace_name_printed) {
2794 assert(is_method(mname), "wrong type");
2766 assert(Thread::current()->is_VM_thread(), "not VM thread"); 2795 assert(Thread::current()->is_VM_thread(), "not VM thread");
2767 mname->address_field_put(_vmtarget_offset, (address)ref); 2796
2797 Method* target = (Method*)mname->address_field(_vmtarget_offset);
2798 if (target == old_method) {
2799 mname->address_field_put(_vmtarget_offset, (address)new_method);
2800
2801 if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
2802 if (!(*trace_name_printed)) {
2803 // RC_TRACE_MESG macro has an embedded ResourceMark
2804 RC_TRACE_MESG(("adjust: name=%s",
2805 old_method->method_holder()->external_name()));
2806 *trace_name_printed = true;
2807 }
2808 // RC_TRACE macro has an embedded ResourceMark
2809 RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
2810 new_method->name()->as_C_string(),
2811 new_method->signature()->as_C_string()));
2812 }
2813 }
2768 } 2814 }
2769 #endif // INCLUDE_JVMTI 2815 #endif // INCLUDE_JVMTI
2770 2816
2771 void java_lang_invoke_MemberName::set_vmtarget(oop mname, Metadata* ref) { 2817 void java_lang_invoke_MemberName::set_vmtarget(oop mname, Metadata* ref) {
2772 assert(is_instance(mname), "wrong type"); 2818 assert(is_instance(mname), "wrong type");
3087 3133
3088 int java_lang_Class::_klass_offset; 3134 int java_lang_Class::_klass_offset;
3089 int java_lang_Class::_array_klass_offset; 3135 int java_lang_Class::_array_klass_offset;
3090 int java_lang_Class::_oop_size_offset; 3136 int java_lang_Class::_oop_size_offset;
3091 int java_lang_Class::_static_oop_field_count_offset; 3137 int java_lang_Class::_static_oop_field_count_offset;
3138 int java_lang_Class::_class_loader_offset;
3092 int java_lang_Class::_protection_domain_offset; 3139 int java_lang_Class::_protection_domain_offset;
3093 int java_lang_Class::_init_lock_offset; 3140 int java_lang_Class::_init_lock_offset;
3094 int java_lang_Class::_signers_offset; 3141 int java_lang_Class::_signers_offset;
3095 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL; 3142 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
3096 int java_lang_Throwable::backtrace_offset; 3143 int java_lang_Throwable::backtrace_offset;