hotspot/src/share/vm/interpreter/linkResolver.cpp
changeset 35900 d64cf9290fc4
parent 35495 e27da438fa13
child 35901 f5028c67e7cb
equal deleted inserted replaced
35899:0dbc821628fc 35900:d64cf9290fc4
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   166     // Could be an Object method inherited into an interface, but still a vtable call.
   166     // Could be an Object method inherited into an interface, but still a vtable call.
   167     kind = CallInfo::vtable_call;
   167     kind = CallInfo::vtable_call;
   168   } else if (!resolved_klass->is_interface()) {
   168   } else if (!resolved_klass->is_interface()) {
   169     // A default or miranda method.  Compute the vtable index.
   169     // A default or miranda method.  Compute the vtable index.
   170     ResourceMark rm;
   170     ResourceMark rm;
   171     klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable();
   171     klassVtable* vt = resolved_klass->vtable();
   172     index = LinkResolver::vtable_index_of_interface_method(resolved_klass,
   172     index = LinkResolver::vtable_index_of_interface_method(resolved_klass,
   173                            resolved_method);
   173                            resolved_method);
   174     assert(index >= 0 , "we should have valid vtable index at this point");
   174     assert(index >= 0 , "we should have valid vtable index at this point");
   175 
   175 
   176     kind = CallInfo::vtable_call;
   176     kind = CallInfo::vtable_call;
  1225   if (resolved_method->method_holder()->is_interface()) { // default or miranda method
  1225   if (resolved_method->method_holder()->is_interface()) { // default or miranda method
  1226     vtable_index = vtable_index_of_interface_method(resolved_klass,
  1226     vtable_index = vtable_index_of_interface_method(resolved_klass,
  1227                            resolved_method);
  1227                            resolved_method);
  1228     assert(vtable_index >= 0 , "we should have valid vtable index at this point");
  1228     assert(vtable_index >= 0 , "we should have valid vtable index at this point");
  1229 
  1229 
  1230     InstanceKlass* inst = InstanceKlass::cast(recv_klass());
  1230     selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));
  1231     selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
       
  1232   } else {
  1231   } else {
  1233     // at this point we are sure that resolved_method is virtual and not
  1232     // at this point we are sure that resolved_method is virtual and not
  1234     // a default or miranda method; therefore, it must have a valid vtable index.
  1233     // a default or miranda method; therefore, it must have a valid vtable index.
  1235     assert(!resolved_method->has_itable_index(), "");
  1234     assert(!resolved_method->has_itable_index(), "");
  1236     vtable_index = resolved_method->vtable_index();
  1235     vtable_index = resolved_method->vtable_index();
  1241     // method, and it can never be changed by an override.
  1240     // method, and it can never be changed by an override.
  1242     if (vtable_index == Method::nonvirtual_vtable_index) {
  1241     if (vtable_index == Method::nonvirtual_vtable_index) {
  1243       assert(resolved_method->can_be_statically_bound(), "cannot override this method");
  1242       assert(resolved_method->can_be_statically_bound(), "cannot override this method");
  1244       selected_method = resolved_method;
  1243       selected_method = resolved_method;
  1245     } else {
  1244     } else {
  1246       // recv_klass might be an arrayKlassOop but all vtables start at
  1245       selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));
  1247       // the same place. The cast is to avoid virtual call and assertion.
       
  1248       InstanceKlass* inst = (InstanceKlass*)recv_klass();
       
  1249       selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
       
  1250     }
  1246     }
  1251   }
  1247   }
  1252 
  1248 
  1253   // check if method exists
  1249   // check if method exists
  1254   if (selected_method.is_null()) {
  1250   if (selected_method.is_null()) {