< prev index next >

src/share/vm/interpreter/linkResolver.cpp

Print this page
rev 8978 : imported patch remove_err_msg
rev 8979 : [mq]: vmerr_static


 162   } else if (!resolved_method_holder->is_interface()) {
 163     // Could be an Object method inherited into an interface, but still a vtable call.
 164     kind = CallInfo::vtable_call;
 165   } else if (!resolved_klass->is_interface()) {
 166     // A default or miranda method.  Compute the vtable index.
 167     ResourceMark rm;
 168     klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable();
 169     index = LinkResolver::vtable_index_of_interface_method(resolved_klass,
 170                            resolved_method);
 171     assert(index >= 0 , "we should have valid vtable index at this point");
 172 
 173     kind = CallInfo::vtable_call;
 174   } else if (resolved_method->has_vtable_index()) {
 175     // Can occur if an interface redeclares a method of Object.
 176 
 177 #ifdef ASSERT
 178     // Ensure that this is really the case.
 179     KlassHandle object_klass = SystemDictionary::Object_klass();
 180     Method * object_resolved_method = object_klass()->vtable()->method_at(index);
 181     assert(object_resolved_method->name() == resolved_method->name(),
 182       err_msg("Object and interface method names should match at vtable index %d, %s != %s",
 183       index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()));
 184     assert(object_resolved_method->signature() == resolved_method->signature(),
 185       err_msg("Object and interface method signatures should match at vtable index %d, %s != %s",
 186       index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string()));
 187 #endif // ASSERT
 188 
 189     kind = CallInfo::vtable_call;
 190   } else {
 191     // A regular interface call.
 192     kind = CallInfo::itable_call;
 193     index = resolved_method->itable_index();
 194   }
 195   assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index));
 196   _call_kind  = kind;
 197   _call_index = index;
 198   _resolved_appendix = Handle();
 199   DEBUG_ONLY(verify());
 200 }
 201 
 202 #ifdef ASSERT
 203 void CallInfo::verify() {
 204   switch (call_kind()) {  // the meaning and allowed value of index depends on kind
 205   case CallInfo::direct_call:
 206     if (_call_index == Method::nonvirtual_vtable_index)  break;
 207     // else fall through to check vtable index:
 208   case CallInfo::vtable_call:
 209     assert(resolved_klass()->verify_vtable_index(_call_index), "");
 210     break;
 211   case CallInfo::itable_call:
 212     assert(resolved_method()->method_holder()->verify_itable_index(_call_index), "");
 213     break;
 214   case CallInfo::unknown_kind:
 215     assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set");
 216     break;
 217   default:
 218     fatal(err_msg_res("Unexpected call kind %d", call_kind()));
 219   }
 220 }
 221 #endif //ASSERT
 222 
 223 #ifndef PRODUCT
 224 void CallInfo::print() {
 225   ResourceMark rm;
 226   const char* kindstr = "unknown";
 227   switch (_call_kind) {
 228   case direct_call: kindstr = "direct"; break;
 229   case vtable_call: kindstr = "vtable"; break;
 230   case itable_call: kindstr = "itable"; break;
 231   }
 232   tty->print_cr("Call %s@%d %s", kindstr, _call_index,
 233                 _resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string());
 234 }
 235 #endif
 236 
 237 //------------------------------------------------------------------------------------------------------------------------
 238 // Implementation of LinkInfo


 482         if (appendix.is_null())  tty->print_cr("(none)");
 483         else                     appendix->print_on(tty);
 484       }
 485       if (result.not_null()) {
 486 #ifdef ASSERT
 487         ResourceMark rm(THREAD);
 488 
 489         TempNewSymbol basic_signature =
 490           MethodHandles::lookup_basic_type_signature(full_signature, CHECK_NULL);
 491         int actual_size_of_params = result->size_of_parameters();
 492         int expected_size_of_params = ArgumentSizeComputer(basic_signature).size();
 493         // +1 for MethodHandle.this, +1 for trailing MethodType
 494         if (!MethodHandles::is_signature_polymorphic_static(iid))  expected_size_of_params += 1;
 495         if (appendix.not_null())                                   expected_size_of_params += 1;
 496         if (actual_size_of_params != expected_size_of_params) {
 497           tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string());
 498           tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid));
 499           result->print();
 500         }
 501         assert(actual_size_of_params == expected_size_of_params,
 502                err_msg("%d != %d", actual_size_of_params, expected_size_of_params));
 503 #endif //ASSERT
 504 
 505         assert(appendix_result_or_null != NULL, "");
 506         (*appendix_result_or_null) = appendix;
 507         (*method_type_result)      = method_type;
 508       }
 509       return result;
 510     }
 511   }
 512   return NULL;
 513 }
 514 
 515 void LinkResolver::check_method_accessability(KlassHandle ref_klass,
 516                                               KlassHandle resolved_klass,
 517                                               KlassHandle sel_klass,
 518                                               const methodHandle& sel_method,
 519                                               TRAPS) {
 520 
 521   AccessFlags flags = sel_method->access_flags();
 522 




 162   } else if (!resolved_method_holder->is_interface()) {
 163     // Could be an Object method inherited into an interface, but still a vtable call.
 164     kind = CallInfo::vtable_call;
 165   } else if (!resolved_klass->is_interface()) {
 166     // A default or miranda method.  Compute the vtable index.
 167     ResourceMark rm;
 168     klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable();
 169     index = LinkResolver::vtable_index_of_interface_method(resolved_klass,
 170                            resolved_method);
 171     assert(index >= 0 , "we should have valid vtable index at this point");
 172 
 173     kind = CallInfo::vtable_call;
 174   } else if (resolved_method->has_vtable_index()) {
 175     // Can occur if an interface redeclares a method of Object.
 176 
 177 #ifdef ASSERT
 178     // Ensure that this is really the case.
 179     KlassHandle object_klass = SystemDictionary::Object_klass();
 180     Method * object_resolved_method = object_klass()->vtable()->method_at(index);
 181     assert(object_resolved_method->name() == resolved_method->name(),
 182       "Object and interface method names should match at vtable index %d, %s != %s",
 183       index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string());
 184     assert(object_resolved_method->signature() == resolved_method->signature(),
 185       "Object and interface method signatures should match at vtable index %d, %s != %s",
 186       index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string());
 187 #endif // ASSERT
 188 
 189     kind = CallInfo::vtable_call;
 190   } else {
 191     // A regular interface call.
 192     kind = CallInfo::itable_call;
 193     index = resolved_method->itable_index();
 194   }
 195   assert(index == Method::nonvirtual_vtable_index || index >= 0, "bad index %d", index);
 196   _call_kind  = kind;
 197   _call_index = index;
 198   _resolved_appendix = Handle();
 199   DEBUG_ONLY(verify());
 200 }
 201 
 202 #ifdef ASSERT
 203 void CallInfo::verify() {
 204   switch (call_kind()) {  // the meaning and allowed value of index depends on kind
 205   case CallInfo::direct_call:
 206     if (_call_index == Method::nonvirtual_vtable_index)  break;
 207     // else fall through to check vtable index:
 208   case CallInfo::vtable_call:
 209     assert(resolved_klass()->verify_vtable_index(_call_index), "");
 210     break;
 211   case CallInfo::itable_call:
 212     assert(resolved_method()->method_holder()->verify_itable_index(_call_index), "");
 213     break;
 214   case CallInfo::unknown_kind:
 215     assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set");
 216     break;
 217   default:
 218     fatal("Unexpected call kind %d", call_kind());
 219   }
 220 }
 221 #endif //ASSERT
 222 
 223 #ifndef PRODUCT
 224 void CallInfo::print() {
 225   ResourceMark rm;
 226   const char* kindstr = "unknown";
 227   switch (_call_kind) {
 228   case direct_call: kindstr = "direct"; break;
 229   case vtable_call: kindstr = "vtable"; break;
 230   case itable_call: kindstr = "itable"; break;
 231   }
 232   tty->print_cr("Call %s@%d %s", kindstr, _call_index,
 233                 _resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string());
 234 }
 235 #endif
 236 
 237 //------------------------------------------------------------------------------------------------------------------------
 238 // Implementation of LinkInfo


 482         if (appendix.is_null())  tty->print_cr("(none)");
 483         else                     appendix->print_on(tty);
 484       }
 485       if (result.not_null()) {
 486 #ifdef ASSERT
 487         ResourceMark rm(THREAD);
 488 
 489         TempNewSymbol basic_signature =
 490           MethodHandles::lookup_basic_type_signature(full_signature, CHECK_NULL);
 491         int actual_size_of_params = result->size_of_parameters();
 492         int expected_size_of_params = ArgumentSizeComputer(basic_signature).size();
 493         // +1 for MethodHandle.this, +1 for trailing MethodType
 494         if (!MethodHandles::is_signature_polymorphic_static(iid))  expected_size_of_params += 1;
 495         if (appendix.not_null())                                   expected_size_of_params += 1;
 496         if (actual_size_of_params != expected_size_of_params) {
 497           tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string());
 498           tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid));
 499           result->print();
 500         }
 501         assert(actual_size_of_params == expected_size_of_params,
 502                "%d != %d", actual_size_of_params, expected_size_of_params);
 503 #endif //ASSERT
 504 
 505         assert(appendix_result_or_null != NULL, "");
 506         (*appendix_result_or_null) = appendix;
 507         (*method_type_result)      = method_type;
 508       }
 509       return result;
 510     }
 511   }
 512   return NULL;
 513 }
 514 
 515 void LinkResolver::check_method_accessability(KlassHandle ref_klass,
 516                                               KlassHandle resolved_klass,
 517                                               KlassHandle sel_klass,
 518                                               const methodHandle& sel_method,
 519                                               TRAPS) {
 520 
 521   AccessFlags flags = sel_method->access_flags();
 522 


< prev index next >