src/share/vm/opto/doCall.cpp

changeset 4021
7f813940ac35
parent 3973
b72784e722ff
child 4037
da91efe96a93
     1.1 --- a/src/share/vm/opto/doCall.cpp	Mon Aug 27 15:17:17 2012 -0700
     1.2 +++ b/src/share/vm/opto/doCall.cpp	Tue Aug 28 15:24:39 2012 -0700
     1.3 @@ -341,25 +341,26 @@
     1.4    kill_dead_locals();
     1.5  
     1.6    // Set frequently used booleans
     1.7 -  bool is_virtual = bc() == Bytecodes::_invokevirtual;
     1.8 -  bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
     1.9 -  bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial;
    1.10 -  bool is_invokedynamic = bc() == Bytecodes::_invokedynamic;
    1.11 +  const bool is_virtual = bc() == Bytecodes::_invokevirtual;
    1.12 +  const bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
    1.13 +  const bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial;
    1.14  
    1.15    // Find target being called
    1.16    bool             will_link;
    1.17 -  ciMethod*        bc_callee    = iter().get_method(will_link);  // actual callee from bytecode
    1.18 -  ciInstanceKlass* holder_klass = bc_callee->holder();
    1.19 -  ciKlass* holder = iter().get_declared_method_holder();
    1.20 +  ciSignature*     declared_signature = NULL;
    1.21 +  ciMethod*        orig_callee  = iter().get_method(will_link, &declared_signature);  // callee in the bytecode
    1.22 +  ciInstanceKlass* holder_klass = orig_callee->holder();
    1.23 +  ciKlass*         holder       = iter().get_declared_method_holder();
    1.24    ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder);
    1.25 +  assert(declared_signature != NULL, "cannot be null");
    1.26  
    1.27    // uncommon-trap when callee is unloaded, uninitialized or will not link
    1.28    // bailout when too many arguments for register representation
    1.29 -  if (!will_link || can_not_compile_call_site(bc_callee, klass)) {
    1.30 +  if (!will_link || can_not_compile_call_site(orig_callee, klass)) {
    1.31  #ifndef PRODUCT
    1.32      if (PrintOpto && (Verbose || WizardMode)) {
    1.33        method()->print_name(); tty->print_cr(" can not compile call at bci %d to:", bci());
    1.34 -      bc_callee->print_name(); tty->cr();
    1.35 +      orig_callee->print_name(); tty->cr();
    1.36      }
    1.37  #endif
    1.38      return;
    1.39 @@ -372,7 +373,7 @@
    1.40    // Note:  In the absence of miranda methods, an abstract class K can perform
    1.41    // an invokevirtual directly on an interface method I.m if K implements I.
    1.42  
    1.43 -  const int nargs = bc_callee->arg_size();
    1.44 +  const int nargs = orig_callee->arg_size();
    1.45  
    1.46    // Push appendix argument (MethodType, CallSite, etc.), if one.
    1.47    if (iter().has_appendix()) {
    1.48 @@ -392,13 +393,13 @@
    1.49    // Choose call strategy.
    1.50    bool call_is_virtual = is_virtual_or_interface;
    1.51    int vtable_index = methodOopDesc::invalid_vtable_index;
    1.52 -  ciMethod* callee = bc_callee;
    1.53 +  ciMethod* callee = orig_callee;
    1.54  
    1.55    // Try to get the most accurate receiver type
    1.56    if (is_virtual_or_interface) {
    1.57      Node*             receiver_node = stack(sp() - nargs);
    1.58      const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
    1.59 -    ciMethod* optimized_virtual_method = optimize_inlining(method(), bci(), klass, bc_callee, receiver_type);
    1.60 +    ciMethod* optimized_virtual_method = optimize_inlining(method(), bci(), klass, orig_callee, receiver_type);
    1.61  
    1.62      // Have the call been sufficiently improved such that it is no longer a virtual?
    1.63      if (optimized_virtual_method != NULL) {
    1.64 @@ -425,7 +426,8 @@
    1.65    // It decides whether inlining is desirable or not.
    1.66    CallGenerator* cg = C->call_generator(callee, vtable_index, call_is_virtual, jvms, try_inline, prof_factor());
    1.67  
    1.68 -  bc_callee = callee = NULL;  // don't use bc_callee and callee after this point
    1.69 +  // NOTE:  Don't use orig_callee and callee after this point!  Use cg->method() instead.
    1.70 +  orig_callee = callee = NULL;
    1.71  
    1.72    // ---------------------
    1.73    // Round double arguments before call
    1.74 @@ -497,9 +499,9 @@
    1.75      round_double_result(cg->method());
    1.76  
    1.77      ciType* rtype = cg->method()->return_type();
    1.78 -    if (iter().cur_bc_raw() == Bytecodes::_invokehandle || is_invokedynamic) {
    1.79 +    if (Bytecodes::has_optional_appendix(iter().cur_bc_raw())) {
    1.80        // Be careful here with return types.
    1.81 -      ciType* ctype = iter().get_declared_method_signature()->return_type();
    1.82 +      ciType* ctype = declared_signature->return_type();
    1.83        if (ctype != rtype) {
    1.84          BasicType rt = rtype->basic_type();
    1.85          BasicType ct = ctype->basic_type();
    1.86 @@ -528,15 +530,13 @@
    1.87          } else if (rt == T_OBJECT || rt == T_ARRAY) {
    1.88            assert(ct == T_OBJECT || ct == T_ARRAY, err_msg_res("rt=%s, ct=%s", type2name(rt), type2name(ct)));
    1.89            if (ctype->is_loaded()) {
    1.90 -            Node* if_fail = top();
    1.91 -            retnode = gen_checkcast(retnode, makecon(TypeKlassPtr::make(ctype->as_klass())), &if_fail);
    1.92 -            if (if_fail != top()) {
    1.93 -              PreserveJVMState pjvms(this);
    1.94 -              set_control(if_fail);
    1.95 -              builtin_throw(Deoptimization::Reason_class_check);
    1.96 +            const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass());
    1.97 +            const Type*       sig_type = TypeOopPtr::make_from_klass(ctype->as_klass());
    1.98 +            if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
    1.99 +              Node* cast_obj = _gvn.transform(new (C, 2) CheckCastPPNode(control(), retnode, sig_type));
   1.100 +              pop();
   1.101 +              push(cast_obj);
   1.102              }
   1.103 -            pop();
   1.104 -            push(retnode);
   1.105            }
   1.106          } else {
   1.107            assert(ct == rt, err_msg_res("unexpected mismatch rt=%d, ct=%d", rt, ct));

mercurial