Mercurial > hg > truffle
comparison src/share/vm/classfile/javaClasses.cpp @ 20415:47e3110c47e8
6642881: Improve performance of Class.getClassLoader()
Summary: Add classLoader to java/lang/Class instance for fast access
Reviewed-by: alanb, lfoltan, rriggs, vlivanov, twisti, jfranck
author | coleenp |
---|---|
date | Fri, 05 Sep 2014 16:01:29 -0400 |
parents | 27188ae8bbbb |
children | 7d68a5b1069d |
comparison
equal
deleted
inserted
replaced
20407:9be4ca335650 | 20415:47e3110c47e8 |
---|---|
546 fs.set_offset(real_offset); | 546 fs.set_offset(real_offset); |
547 } | 547 } |
548 } | 548 } |
549 } | 549 } |
550 } | 550 } |
551 create_mirror(k, Handle(NULL), CHECK); | 551 create_mirror(k, Handle(NULL), Handle(NULL), CHECK); |
552 } | 552 } |
553 | 553 |
554 void java_lang_Class::initialize_mirror_fields(KlassHandle k, | 554 void java_lang_Class::initialize_mirror_fields(KlassHandle k, |
555 Handle mirror, | 555 Handle mirror, |
556 Handle protection_domain, | 556 Handle protection_domain, |
566 | 566 |
567 // Initialize static fields | 567 // Initialize static fields |
568 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); | 568 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); |
569 } | 569 } |
570 | 570 |
571 void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) { | 571 void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, |
572 Handle protection_domain, TRAPS) { | |
572 assert(k->java_mirror() == NULL, "should only assign mirror once"); | 573 assert(k->java_mirror() == NULL, "should only assign mirror once"); |
573 // Use this moment of initialization to cache modifier_flags also, | 574 // Use this moment of initialization to cache modifier_flags also, |
574 // to support Class.getModifiers(). Instance classes recalculate | 575 // to support Class.getModifiers(). Instance classes recalculate |
575 // the cached flags after the class file is parsed, but before the | 576 // the cached flags after the class file is parsed, but before the |
576 // class is put into the system dictionary. | 577 // class is put into the system dictionary. |
621 java_lang_Class::set_klass(mirror(), NULL); | 622 java_lang_Class::set_klass(mirror(), NULL); |
622 return; | 623 return; |
623 } | 624 } |
624 } | 625 } |
625 | 626 |
627 // set the classLoader field in the java_lang_Class instance | |
628 set_class_loader(mirror(), class_loader()); | |
629 | |
626 // Setup indirection from klass->mirror last | 630 // Setup indirection from klass->mirror last |
627 // after any exceptions can happen during allocations. | 631 // after any exceptions can happen during allocations. |
628 if (!k.is_null()) { | 632 if (!k.is_null()) { |
629 k->set_java_mirror(mirror()); | 633 k->set_java_mirror(mirror()); |
630 } | 634 } |
681 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) { | 685 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) { |
682 assert(_signers_offset != 0, "must be set"); | 686 assert(_signers_offset != 0, "must be set"); |
683 java_class->obj_field_put(_signers_offset, (oop)signers); | 687 java_class->obj_field_put(_signers_offset, (oop)signers); |
684 } | 688 } |
685 | 689 |
690 | |
691 void java_lang_Class::set_class_loader(oop java_class, oop loader) { | |
692 // jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet. | |
693 if (_class_loader_offset != 0) { | |
694 java_class->obj_field_put(_class_loader_offset, loader); | |
695 } | |
696 } | |
697 | |
698 oop java_lang_Class::class_loader(oop java_class) { | |
699 assert(_class_loader_offset != 0, "must be set"); | |
700 return java_class->obj_field(_class_loader_offset); | |
701 } | |
686 | 702 |
687 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { | 703 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { |
688 // This should be improved by adding a field at the Java level or by | 704 // This should be improved by adding a field at the Java level or by |
689 // introducing a new VM klass (see comment in ClassFileParser) | 705 // introducing a new VM klass (see comment in ClassFileParser) |
690 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0); | 706 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0); |
840 Klass* klass_oop = SystemDictionary::Class_klass(); | 856 Klass* klass_oop = SystemDictionary::Class_klass(); |
841 // The classRedefinedCount field is only present starting in 1.5, | 857 // The classRedefinedCount field is only present starting in 1.5, |
842 // so don't go fatal. | 858 // so don't go fatal. |
843 compute_optional_offset(classRedefinedCount_offset, | 859 compute_optional_offset(classRedefinedCount_offset, |
844 klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); | 860 klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); |
861 | |
862 // Needs to be optional because the old build runs Queens during bootstrapping | |
863 // and jdk8-9 doesn't have coordinated pushes yet. | |
864 compute_optional_offset(_class_loader_offset, | |
865 klass_oop, vmSymbols::classLoader_name(), | |
866 vmSymbols::classloader_signature()); | |
845 | 867 |
846 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); | 868 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
847 } | 869 } |
848 | 870 |
849 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { | 871 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { |
3080 | 3102 |
3081 int java_lang_Class::_klass_offset; | 3103 int java_lang_Class::_klass_offset; |
3082 int java_lang_Class::_array_klass_offset; | 3104 int java_lang_Class::_array_klass_offset; |
3083 int java_lang_Class::_oop_size_offset; | 3105 int java_lang_Class::_oop_size_offset; |
3084 int java_lang_Class::_static_oop_field_count_offset; | 3106 int java_lang_Class::_static_oop_field_count_offset; |
3107 int java_lang_Class::_class_loader_offset; | |
3085 int java_lang_Class::_protection_domain_offset; | 3108 int java_lang_Class::_protection_domain_offset; |
3086 int java_lang_Class::_init_lock_offset; | 3109 int java_lang_Class::_init_lock_offset; |
3087 int java_lang_Class::_signers_offset; | 3110 int java_lang_Class::_signers_offset; |
3088 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL; | 3111 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL; |
3089 int java_lang_Throwable::backtrace_offset; | 3112 int java_lang_Throwable::backtrace_offset; |