687 }
688
689 // ------------------------------------------------------------------
690 // ciEnv::get_field_by_index
691 //
692 // Get a field by index from a klass's constant pool.
693 ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
694 int index) {
695 GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
696 }
697
698 // ------------------------------------------------------------------
699 // ciEnv::lookup_method
700 //
701 // Perform an appropriate method lookup based on accessor, holder,
702 // name, signature, and bytecode.
703 Method* ciEnv::lookup_method(InstanceKlass* accessor,
704 InstanceKlass* holder,
705 Symbol* name,
706 Symbol* sig,
707 Bytecodes::Code bc) {
708 EXCEPTION_CONTEXT;
709 KlassHandle h_accessor(THREAD, accessor);
710 KlassHandle h_holder(THREAD, holder);
711 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
712 methodHandle dest_method;
713 LinkInfo link_info(h_holder, name, sig, h_accessor, /*check_access*/true);
714 switch (bc) {
715 case Bytecodes::_invokestatic:
716 dest_method =
717 LinkResolver::resolve_static_call_or_null(link_info);
718 break;
719 case Bytecodes::_invokespecial:
720 dest_method =
721 LinkResolver::resolve_special_call_or_null(link_info);
722 break;
723 case Bytecodes::_invokeinterface:
724 dest_method =
725 LinkResolver::linktime_resolve_interface_method_or_null(link_info);
726 break;
727 case Bytecodes::_invokevirtual:
728 dest_method =
729 LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
730 break;
731 default: ShouldNotReachHere();
732 }
733
779 // Short-circuit lookups for JSR 292-related call sites.
780 // That is, do not rely only on name-based lookups, because they may fail
781 // if the names are not resolvable in the boot class loader (7056328).
782 switch (bc) {
783 case Bytecodes::_invokevirtual:
784 case Bytecodes::_invokeinterface:
785 case Bytecodes::_invokespecial:
786 case Bytecodes::_invokestatic:
787 {
788 Method* m = ConstantPool::method_at_if_loaded(cpool, index);
789 if (m != NULL) {
790 return get_method(m);
791 }
792 }
793 break;
794 }
795 }
796
797 if (holder_is_accessible) { // Our declared holder is loaded.
798 InstanceKlass* lookup = declared_holder->get_instanceKlass();
799 Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
800 if (m != NULL &&
801 (bc == Bytecodes::_invokestatic
802 ? m->method_holder()->is_not_initialized()
803 : !m->method_holder()->is_loaded())) {
804 m = NULL;
805 }
806 #ifdef ASSERT
807 if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {
808 m = NULL;
809 }
810 #endif
811 if (m != NULL) {
812 // We found the method.
813 return get_method(m);
814 }
815 }
816
817 // Either the declared holder was not loaded, or the method could
818 // not be found. Create a dummy ciMethod to represent the failed
819 // lookup.
|
687 }
688
689 // ------------------------------------------------------------------
690 // ciEnv::get_field_by_index
691 //
692 // Get a field by index from a klass's constant pool.
693 ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
694 int index) {
695 GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
696 }
697
698 // ------------------------------------------------------------------
699 // ciEnv::lookup_method
700 //
701 // Perform an appropriate method lookup based on accessor, holder,
702 // name, signature, and bytecode.
703 Method* ciEnv::lookup_method(InstanceKlass* accessor,
704 InstanceKlass* holder,
705 Symbol* name,
706 Symbol* sig,
707 Bytecodes::Code bc,
708 constantTag tag) {
709 EXCEPTION_CONTEXT;
710 KlassHandle h_accessor(THREAD, accessor);
711 KlassHandle h_holder(THREAD, holder);
712 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
713 methodHandle dest_method;
714 LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag);
715 switch (bc) {
716 case Bytecodes::_invokestatic:
717 dest_method =
718 LinkResolver::resolve_static_call_or_null(link_info);
719 break;
720 case Bytecodes::_invokespecial:
721 dest_method =
722 LinkResolver::resolve_special_call_or_null(link_info);
723 break;
724 case Bytecodes::_invokeinterface:
725 dest_method =
726 LinkResolver::linktime_resolve_interface_method_or_null(link_info);
727 break;
728 case Bytecodes::_invokevirtual:
729 dest_method =
730 LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
731 break;
732 default: ShouldNotReachHere();
733 }
734
780 // Short-circuit lookups for JSR 292-related call sites.
781 // That is, do not rely only on name-based lookups, because they may fail
782 // if the names are not resolvable in the boot class loader (7056328).
783 switch (bc) {
784 case Bytecodes::_invokevirtual:
785 case Bytecodes::_invokeinterface:
786 case Bytecodes::_invokespecial:
787 case Bytecodes::_invokestatic:
788 {
789 Method* m = ConstantPool::method_at_if_loaded(cpool, index);
790 if (m != NULL) {
791 return get_method(m);
792 }
793 }
794 break;
795 }
796 }
797
798 if (holder_is_accessible) { // Our declared holder is loaded.
799 InstanceKlass* lookup = declared_holder->get_instanceKlass();
800 constantTag tag = cpool->tag_ref_at(index);
801 assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?");
802 Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc, tag);
803 if (m != NULL &&
804 (bc == Bytecodes::_invokestatic
805 ? m->method_holder()->is_not_initialized()
806 : !m->method_holder()->is_loaded())) {
807 m = NULL;
808 }
809 #ifdef ASSERT
810 if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {
811 m = NULL;
812 }
813 #endif
814 if (m != NULL) {
815 // We found the method.
816 return get_method(m);
817 }
818 }
819
820 // Either the declared holder was not loaded, or the method could
821 // not be found. Create a dummy ciMethod to represent the failed
822 // lookup.
|