702 // ------------------------------------------------------------------ |
702 // ------------------------------------------------------------------ |
703 // ciEnv::lookup_method |
703 // ciEnv::lookup_method |
704 // |
704 // |
705 // Perform an appropriate method lookup based on accessor, holder, |
705 // Perform an appropriate method lookup based on accessor, holder, |
706 // name, signature, and bytecode. |
706 // name, signature, and bytecode. |
707 Method* ciEnv::lookup_method(InstanceKlass* accessor, |
707 Method* ciEnv::lookup_method(ciInstanceKlass* accessor, |
708 InstanceKlass* holder, |
708 ciKlass* holder, |
709 Symbol* name, |
709 Symbol* name, |
710 Symbol* sig, |
710 Symbol* sig, |
711 Bytecodes::Code bc, |
711 Bytecodes::Code bc, |
712 constantTag tag) { |
712 constantTag tag) { |
713 EXCEPTION_CONTEXT; |
713 // Accessibility checks are performed in ciEnv::get_method_by_index_impl. |
714 KlassHandle h_accessor(THREAD, accessor); |
714 assert(check_klass_accessibility(accessor, holder->get_Klass()), "holder not accessible"); |
715 KlassHandle h_holder(THREAD, holder); |
715 |
716 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL)); |
716 KlassHandle h_accessor(accessor->get_instanceKlass()); |
|
717 KlassHandle h_holder(holder->get_Klass()); |
717 methodHandle dest_method; |
718 methodHandle dest_method; |
718 LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag); |
719 LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag); |
719 switch (bc) { |
720 switch (bc) { |
720 case Bytecodes::_invokestatic: |
721 case Bytecodes::_invokestatic: |
721 dest_method = |
722 dest_method = |
770 return get_unloaded_method(holder, name, signature, accessor); |
771 return get_unloaded_method(holder, name, signature, accessor); |
771 } else { |
772 } else { |
772 const int holder_index = cpool->klass_ref_index_at(index); |
773 const int holder_index = cpool->klass_ref_index_at(index); |
773 bool holder_is_accessible; |
774 bool holder_is_accessible; |
774 ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); |
775 ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); |
775 ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder); |
|
776 |
776 |
777 // Get the method's name and signature. |
777 // Get the method's name and signature. |
778 Symbol* name_sym = cpool->name_ref_at(index); |
778 Symbol* name_sym = cpool->name_ref_at(index); |
779 Symbol* sig_sym = cpool->signature_ref_at(index); |
779 Symbol* sig_sym = cpool->signature_ref_at(index); |
780 |
780 |
798 break; |
798 break; |
799 } |
799 } |
800 } |
800 } |
801 |
801 |
802 if (holder_is_accessible) { // Our declared holder is loaded. |
802 if (holder_is_accessible) { // Our declared holder is loaded. |
803 InstanceKlass* lookup = declared_holder->get_instanceKlass(); |
|
804 constantTag tag = cpool->tag_ref_at(index); |
803 constantTag tag = cpool->tag_ref_at(index); |
805 assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?"); |
804 assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?"); |
806 Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc, tag); |
805 Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag); |
807 if (m != NULL && |
806 if (m != NULL && |
808 (bc == Bytecodes::_invokestatic |
807 (bc == Bytecodes::_invokestatic |
809 ? m->method_holder()->is_not_initialized() |
808 ? m->method_holder()->is_not_initialized() |
810 : !m->method_holder()->is_loaded())) { |
809 : !m->method_holder()->is_loaded())) { |
811 m = NULL; |
810 m = NULL; |
824 // Either the declared holder was not loaded, or the method could |
823 // Either the declared holder was not loaded, or the method could |
825 // not be found. Create a dummy ciMethod to represent the failed |
824 // not be found. Create a dummy ciMethod to represent the failed |
826 // lookup. |
825 // lookup. |
827 ciSymbol* name = get_symbol(name_sym); |
826 ciSymbol* name = get_symbol(name_sym); |
828 ciSymbol* signature = get_symbol(sig_sym); |
827 ciSymbol* signature = get_symbol(sig_sym); |
829 return get_unloaded_method(declared_holder, name, signature, accessor); |
828 return get_unloaded_method(holder, name, signature, accessor); |
830 } |
829 } |
831 } |
830 } |
832 |
831 |
833 |
832 |
834 // ------------------------------------------------------------------ |
833 // ------------------------------------------------------------------ |