src/share/vm/interpreter/linkResolver.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/interpreter

src/share/vm/interpreter/linkResolver.cpp

Print this page


   1 /*

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


 140   }
 141   _resolved_klass  = resolved_klass;
 142   _selected_klass  = resolved_klass;
 143   _resolved_method = resolved_method;
 144   _selected_method = resolved_method;
 145   // classify:
 146   CallKind kind = CallInfo::unknown_kind;
 147   int index = resolved_method->vtable_index();
 148   if (resolved_method->can_be_statically_bound()) {
 149     kind = CallInfo::direct_call;
 150   } else if (!resolved_method_holder->is_interface()) {
 151     // Could be an Object method inherited into an interface, but still a vtable call.
 152     kind = CallInfo::vtable_call;
 153   } else if (!resolved_klass->is_interface()) {
 154     // A miranda method.  Compute the vtable index.
 155     ResourceMark rm;
 156     klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable();
 157     index = vt->index_of_miranda(resolved_method->name(),
 158                                  resolved_method->signature());
 159     kind = CallInfo::vtable_call;












 160   } else {
 161     // A regular interface call.
 162     kind = CallInfo::itable_call;
 163     index = resolved_method->itable_index();
 164   }
 165   assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index));
 166   _call_kind  = kind;
 167   _call_index = index;
 168   _resolved_appendix = Handle();
 169   DEBUG_ONLY(verify());
 170 }
 171 
 172 #ifdef ASSERT
 173 void CallInfo::verify() {
 174   switch (call_kind()) {  // the meaning and allowed value of index depends on kind
 175   case CallInfo::direct_call:
 176     if (_call_index == Method::nonvirtual_vtable_index)  break;
 177     // else fall through to check vtable index:
 178   case CallInfo::vtable_call:
 179     assert(resolved_klass()->verify_vtable_index(_call_index), "");


   1 /*
   2  * Copyright (c) 1997, 2013, 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  *


 141   }
 142   _resolved_klass  = resolved_klass;
 143   _selected_klass  = resolved_klass;
 144   _resolved_method = resolved_method;
 145   _selected_method = resolved_method;
 146   // classify:
 147   CallKind kind = CallInfo::unknown_kind;
 148   int index = resolved_method->vtable_index();
 149   if (resolved_method->can_be_statically_bound()) {
 150     kind = CallInfo::direct_call;
 151   } else if (!resolved_method_holder->is_interface()) {
 152     // Could be an Object method inherited into an interface, but still a vtable call.
 153     kind = CallInfo::vtable_call;
 154   } else if (!resolved_klass->is_interface()) {
 155     // A miranda method.  Compute the vtable index.
 156     ResourceMark rm;
 157     klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable();
 158     index = vt->index_of_miranda(resolved_method->name(),
 159                                  resolved_method->signature());
 160     kind = CallInfo::vtable_call;
 161   } else if (resolved_method -> has_vtable_index()) {
 162     // Can occur if an interface redeclares a method of Object.
 163     // Ensure that this is really the case.
 164     DEBUG_ONLY(KlassHandle object_klass = SystemDictionary::Object_klass());
 165     DEBUG_ONLY(Method * object_resolved_method = object_klass()->vtable()->method_at(index));
 166     assert(object_resolved_method->name() == resolved_method->name(),
 167       err_msg("Object and interface method names should match at vtable index %d, %s != %s",
 168       index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()));
 169     assert(object_resolved_method->signature() == resolved_method->signature(),
 170       err_msg("Object and interface method signatures should match at vtable index %d, %s != %s",
 171       index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string()));
 172     kind = CallInfo::vtable_call;
 173   } else {
 174     // A regular interface call.
 175     kind = CallInfo::itable_call;
 176     index = resolved_method->itable_index();
 177   }
 178   assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index));
 179   _call_kind  = kind;
 180   _call_index = index;
 181   _resolved_appendix = Handle();
 182   DEBUG_ONLY(verify());
 183 }
 184 
 185 #ifdef ASSERT
 186 void CallInfo::verify() {
 187   switch (call_kind()) {  // the meaning and allowed value of index depends on kind
 188   case CallInfo::direct_call:
 189     if (_call_index == Method::nonvirtual_vtable_index)  break;
 190     // else fall through to check vtable index:
 191   case CallInfo::vtable_call:
 192     assert(resolved_klass()->verify_vtable_index(_call_index), "");


src/share/vm/interpreter/linkResolver.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File