< prev index next >

src/share/vm/ci/ciEnv.cpp

Print this page




 686 }
 687 
 688 // ------------------------------------------------------------------
 689 // ciEnv::get_field_by_index
 690 //
 691 // Get a field by index from a klass's constant pool.
 692 ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
 693                                    int index) {
 694   GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
 695 }
 696 
 697 // ------------------------------------------------------------------
 698 // ciEnv::lookup_method
 699 //
 700 // Perform an appropriate method lookup based on accessor, holder,
 701 // name, signature, and bytecode.
 702 Method* ciEnv::lookup_method(InstanceKlass*  accessor,
 703                                InstanceKlass*  holder,
 704                                Symbol*       name,
 705                                Symbol*       sig,
 706                                Bytecodes::Code bc) {

 707   EXCEPTION_CONTEXT;
 708   KlassHandle h_accessor(THREAD, accessor);
 709   KlassHandle h_holder(THREAD, holder);
 710   LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
 711   methodHandle dest_method;
 712   LinkInfo link_info(h_holder, name, sig, h_accessor, /*check_access*/true);
 713   switch (bc) {
 714   case Bytecodes::_invokestatic:
 715     dest_method =
 716       LinkResolver::resolve_static_call_or_null(link_info);
 717     break;
 718   case Bytecodes::_invokespecial:
 719     dest_method =
 720       LinkResolver::resolve_special_call_or_null(link_info);
 721     break;
 722   case Bytecodes::_invokeinterface:
 723     dest_method =
 724       LinkResolver::linktime_resolve_interface_method_or_null(link_info);
 725     break;
 726   case Bytecodes::_invokevirtual:
 727     dest_method =
 728       LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
 729     break;
 730   default: ShouldNotReachHere();
 731   }
 732 


 778       // Short-circuit lookups for JSR 292-related call sites.
 779       // That is, do not rely only on name-based lookups, because they may fail
 780       // if the names are not resolvable in the boot class loader (7056328).
 781       switch (bc) {
 782       case Bytecodes::_invokevirtual:
 783       case Bytecodes::_invokeinterface:
 784       case Bytecodes::_invokespecial:
 785       case Bytecodes::_invokestatic:
 786         {
 787           Method* m = ConstantPool::method_at_if_loaded(cpool, index);
 788           if (m != NULL) {
 789             return get_method(m);
 790           }
 791         }
 792         break;
 793       }
 794     }
 795 
 796     if (holder_is_accessible) {  // Our declared holder is loaded.
 797       InstanceKlass* lookup = declared_holder->get_instanceKlass();
 798       Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);


 799       if (m != NULL &&
 800           (bc == Bytecodes::_invokestatic
 801            ?  m->method_holder()->is_not_initialized()
 802            : !m->method_holder()->is_loaded())) {
 803         m = NULL;
 804       }
 805 #ifdef ASSERT
 806       if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {
 807         m = NULL;
 808       }
 809 #endif
 810       if (m != NULL) {
 811         // We found the method.
 812         return get_method(m);
 813       }
 814     }
 815 
 816     // Either the declared holder was not loaded, or the method could
 817     // not be found.  Create a dummy ciMethod to represent the failed
 818     // lookup.




 686 }
 687 
 688 // ------------------------------------------------------------------
 689 // ciEnv::get_field_by_index
 690 //
 691 // Get a field by index from a klass's constant pool.
 692 ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
 693                                    int index) {
 694   GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
 695 }
 696 
 697 // ------------------------------------------------------------------
 698 // ciEnv::lookup_method
 699 //
 700 // Perform an appropriate method lookup based on accessor, holder,
 701 // name, signature, and bytecode.
 702 Method* ciEnv::lookup_method(InstanceKlass*  accessor,
 703                                InstanceKlass*  holder,
 704                                Symbol*       name,
 705                                Symbol*       sig,
 706                                Bytecodes::Code bc,
 707                                constantTag    tag) {
 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, LinkInfo::needs_access_check, tag);
 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       constantTag tag = cpool->tag_ref_at(index);
 800       assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?");
 801       Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc, tag);
 802       if (m != NULL &&
 803           (bc == Bytecodes::_invokestatic
 804            ?  m->method_holder()->is_not_initialized()
 805            : !m->method_holder()->is_loaded())) {
 806         m = NULL;
 807       }
 808 #ifdef ASSERT
 809       if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {
 810         m = NULL;
 811       }
 812 #endif
 813       if (m != NULL) {
 814         // We found the method.
 815         return get_method(m);
 816       }
 817     }
 818 
 819     // Either the declared holder was not loaded, or the method could
 820     // not be found.  Create a dummy ciMethod to represent the failed
 821     // lookup.


< prev index next >