Print this page
rev 1024 : imported patch indy-cleanup-6893081.patch
rev 1025 : imported patch indy.compiler.patch

Split Close
Expand all
Collapse all
          --- old/src/share/vm/opto/doCall.cpp
          +++ new/src/share/vm/opto/doCall.cpp
↓ open down ↓ 214 lines elided ↑ open up ↑
 215  215            }
 216  216          }
 217  217        }
 218  218      }
 219  219    }
 220  220  
 221  221    // There was no special inlining tactic, or it bailed out.
 222  222    // Use a more generic tactic, like a simple call.
 223  223    if (call_is_virtual) {
 224  224      return CallGenerator::for_virtual_call(call_method, vtable_index);
      225 +  } else if (call_method->is_method_handle_invoke()) {
      226 +    if (jvms->method()->java_code_at_bci(jvms->bci()) == Bytecodes::_invokedynamic)
      227 +      return CallGenerator::for_dynamic_call(call_method);
      228 +    else
      229 +      // %%% if the target MH is a compile-time constant, we should try to inline it
      230 +      return CallGenerator::for_direct_call(call_method);
 225  231    } else {
 226  232      // Class Hierarchy Analysis or Type Profile reveals a unique target,
 227  233      // or it is a static or special call.
 228  234      return CallGenerator::for_direct_call(call_method);
 229  235    }
 230  236  }
 231  237  
 232  238  
 233  239  // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
 234  240  bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
 235  241    // Additional inputs to consider...
 236  242    // bc      = bc()
 237  243    // caller  = method()
 238  244    // iter().get_method_holder_index()
 239  245    assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 240  246    // Interface classes can be loaded & linked and never get around to
 241  247    // being initialized.  Uncommon-trap for not-initialized static or
 242  248    // v-calls.  Let interface calls happen.
 243      -  ciInstanceKlass* holder_klass  = dest_method->holder();
      249 +  ciInstanceKlass* holder_klass = dest_method->holder();
 244  250    if (!holder_klass->is_initialized() &&
 245  251        !holder_klass->is_interface()) {
 246  252      uncommon_trap(Deoptimization::Reason_uninitialized,
 247  253                    Deoptimization::Action_reinterpret,
 248  254                    holder_klass);
 249  255      return true;
 250  256    }
 251      -  if (dest_method->is_method_handle_invoke()
 252      -      && holder_klass->name() == ciSymbol::java_dyn_InvokeDynamic()) {
 253      -    // FIXME: NYI
 254      -    uncommon_trap(Deoptimization::Reason_unhandled,
 255      -                  Deoptimization::Action_none,
 256      -                  holder_klass);
 257      -    return true;
 258      -  }
 259  257  
 260  258    assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility");
 261  259    return false;
 262  260  }
 263  261  
 264  262  
 265  263  //------------------------------do_call----------------------------------------
 266  264  // Handle your basic call.  Inline if we can & want to, else just setup call.
 267  265  void Parse::do_call() {
 268  266    // It's likely we are going to add debug info soon.
 269  267    // Also, if we inline a guy who eventually needs debug info for this JVMS,
 270  268    // our contribution to it is cleaned up right here.
 271  269    kill_dead_locals();
 272  270  
 273  271    // Set frequently used booleans
 274  272    bool is_virtual = bc() == Bytecodes::_invokevirtual;
 275  273    bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
 276  274    bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial;
      275 +  bool is_invokedynamic = bc() == Bytecodes::_invokedynamic;
 277  276  
 278  277    // Find target being called
 279  278    bool             will_link;
 280  279    ciMethod*        dest_method   = iter().get_method(will_link);
 281  280    ciInstanceKlass* holder_klass  = dest_method->holder();
 282  281    ciKlass* holder = iter().get_declared_method_holder();
 283  282    ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder);
 284  283  
 285      -  int   nargs    = dest_method->arg_size();
      284 +  int nargs = dest_method->arg_size();
      285 +  if (is_invokedynamic)  nargs -= 1;
 286  286  
 287  287    // uncommon-trap when callee is unloaded, uninitialized or will not link
 288  288    // bailout when too many arguments for register representation
 289  289    if (!will_link || can_not_compile_call_site(dest_method, klass)) {
 290  290  #ifndef PRODUCT
 291  291      if (PrintOpto && (Verbose || WizardMode)) {
 292  292        method()->print_name(); tty->print_cr(" can not compile call at bci %d to:", bci());
 293  293        dest_method->print_name(); tty->cr();
 294  294      }
 295  295  #endif
 296  296      return;
 297  297    }
 298  298    assert(holder_klass->is_loaded(), "");
 299      -  assert(dest_method->is_static() == !has_receiver, "must match bc");
      299 +  assert((dest_method->is_static() || is_invokedynamic) == !has_receiver , "must match bc");
 300  300    // Note: this takes into account invokeinterface of methods declared in java/lang/Object,
 301  301    // which should be invokevirtuals but according to the VM spec may be invokeinterfaces
 302  302    assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc");
 303  303    // Note:  In the absence of miranda methods, an abstract class K can perform
 304  304    // an invokevirtual directly on an interface method I.m if K implements I.
 305  305  
 306  306    // ---------------------
 307  307    // Does Class Hierarchy Analysis reveal only a single target of a v-call?
 308  308    // Then we may inline or make a static call, but become dependent on there being only 1 target.
 309  309    // Does the call-site type profile reveal only one receiver?
↓ open down ↓ 565 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX