< prev index next >

src/share/vm/ci/ciMethod.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 770     return NULL;
 771   }
 772   return CURRENT_THREAD_ENV->get_method(target());
 773 }
 774 
 775 // ------------------------------------------------------------------
 776 // ciMethod::resolve_invoke
 777 //
 778 // Given a known receiver klass, find the target for the call.
 779 // Return NULL if the call has no target or the target is abstract.
 780 ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access) {
 781    check_is_loaded();
 782    VM_ENTRY_MARK;
 783 
 784    KlassHandle caller_klass (THREAD, caller->get_Klass());
 785    KlassHandle h_recv       (THREAD, exact_receiver->get_Klass());
 786    KlassHandle h_resolved   (THREAD, holder()->get_Klass());
 787    Symbol* h_name      = name()->get_symbol();
 788    Symbol* h_signature = signature()->get_symbol();
 789 
 790    LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass, check_access);

 791    methodHandle m;
 792    // Only do exact lookup if receiver klass has been linked.  Otherwise,
 793    // the vtable has not been setup, and the LinkResolver will fail.
 794    if (h_recv->is_array_klass()
 795         ||
 796        InstanceKlass::cast(h_recv())->is_linked() && !exact_receiver->is_interface()) {
 797      if (holder()->is_interface()) {
 798        m = LinkResolver::resolve_interface_call_or_null(h_recv, link_info);
 799      } else {
 800        m = LinkResolver::resolve_virtual_call_or_null(h_recv, link_info);
 801      }
 802    }
 803 
 804    if (m.is_null()) {
 805      // Return NULL only if there was a problem with lookup (uninitialized class, etc.)
 806      return NULL;
 807    }
 808 
 809    ciMethod* result = this;
 810    if (m() != get_Method()) {


   1 /*
   2  * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 770     return NULL;
 771   }
 772   return CURRENT_THREAD_ENV->get_method(target());
 773 }
 774 
 775 // ------------------------------------------------------------------
 776 // ciMethod::resolve_invoke
 777 //
 778 // Given a known receiver klass, find the target for the call.
 779 // Return NULL if the call has no target or the target is abstract.
 780 ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access) {
 781    check_is_loaded();
 782    VM_ENTRY_MARK;
 783 
 784    KlassHandle caller_klass (THREAD, caller->get_Klass());
 785    KlassHandle h_recv       (THREAD, exact_receiver->get_Klass());
 786    KlassHandle h_resolved   (THREAD, holder()->get_Klass());
 787    Symbol* h_name      = name()->get_symbol();
 788    Symbol* h_signature = signature()->get_symbol();
 789 
 790    LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass,
 791                       check_access ? LinkInfo::needs_access_check : LinkInfo::skip_access_check);
 792    methodHandle m;
 793    // Only do exact lookup if receiver klass has been linked.  Otherwise,
 794    // the vtable has not been setup, and the LinkResolver will fail.
 795    if (h_recv->is_array_klass()
 796         ||
 797        InstanceKlass::cast(h_recv())->is_linked() && !exact_receiver->is_interface()) {
 798      if (holder()->is_interface()) {
 799        m = LinkResolver::resolve_interface_call_or_null(h_recv, link_info);
 800      } else {
 801        m = LinkResolver::resolve_virtual_call_or_null(h_recv, link_info);
 802      }
 803    }
 804 
 805    if (m.is_null()) {
 806      // Return NULL only if there was a problem with lookup (uninitialized class, etc.)
 807      return NULL;
 808    }
 809 
 810    ciMethod* result = this;
 811    if (m() != get_Method()) {


< prev index next >