Print this page
rev 1081 : imported patch indy-cleanup-6893081.patch
rev 1082 : [mq]: 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 ↓ 220 lines elided ↑ open up ↑
 221  221            }
 222  222          }
 223  223        }
 224  224      }
 225  225    }
 226  226  
 227  227    // There was no special inlining tactic, or it bailed out.
 228  228    // Use a more generic tactic, like a simple call.
 229  229    if (call_is_virtual) {
 230  230      return CallGenerator::for_virtual_call(call_method, vtable_index);
      231 +  } else if (call_method->is_method_handle_invoke()) {
      232 +    if (jvms->method()->java_code_at_bci(jvms->bci()) == Bytecodes::_invokedynamic)
      233 +      return CallGenerator::for_dynamic_call(call_method);
      234 +    else
      235 +      // %%% if the target MH is a compile-time constant, we should try to inline it
      236 +      return CallGenerator::for_direct_call(call_method);
 231  237    } else {
 232  238      // Class Hierarchy Analysis or Type Profile reveals a unique target,
 233  239      // or it is a static or special call.
 234  240      return CallGenerator::for_direct_call(call_method, should_delay_inlining(call_method, jvms));
 235  241    }
 236  242  }
 237  243  
 238  244  // Return true for methods that shouldn't be inlined early so that
 239  245  // they are easier to analyze and optimize as intrinsics.
 240  246  bool Compile::should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
↓ open down ↓ 51 lines elided ↑ open up ↑
 292  298  // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
 293  299  bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
 294  300    // Additional inputs to consider...
 295  301    // bc      = bc()
 296  302    // caller  = method()
 297  303    // iter().get_method_holder_index()
 298  304    assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 299  305    // Interface classes can be loaded & linked and never get around to
 300  306    // being initialized.  Uncommon-trap for not-initialized static or
 301  307    // v-calls.  Let interface calls happen.
 302      -  ciInstanceKlass* holder_klass  = dest_method->holder();
      308 +  ciInstanceKlass* holder_klass = dest_method->holder();
 303  309    if (!holder_klass->is_initialized() &&
 304  310        !holder_klass->is_interface()) {
 305  311      uncommon_trap(Deoptimization::Reason_uninitialized,
 306  312                    Deoptimization::Action_reinterpret,
 307  313                    holder_klass);
 308  314      return true;
 309  315    }
 310      -  if (dest_method->is_method_handle_invoke()
 311      -      && holder_klass->name() == ciSymbol::java_dyn_InvokeDynamic()) {
 312      -    // FIXME: NYI
 313      -    uncommon_trap(Deoptimization::Reason_unhandled,
 314      -                  Deoptimization::Action_none,
 315      -                  holder_klass);
 316      -    return true;
 317      -  }
 318  316  
 319  317    assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility");
 320  318    return false;
 321  319  }
 322  320  
 323  321  
 324  322  //------------------------------do_call----------------------------------------
 325  323  // Handle your basic call.  Inline if we can & want to, else just setup call.
 326  324  void Parse::do_call() {
 327  325    // It's likely we are going to add debug info soon.
 328  326    // Also, if we inline a guy who eventually needs debug info for this JVMS,
 329  327    // our contribution to it is cleaned up right here.
 330  328    kill_dead_locals();
 331  329  
 332  330    // Set frequently used booleans
 333  331    bool is_virtual = bc() == Bytecodes::_invokevirtual;
 334  332    bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
 335  333    bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial;
      334 +  bool is_invokedynamic = bc() == Bytecodes::_invokedynamic;
 336  335  
 337  336    // Find target being called
 338  337    bool             will_link;
 339  338    ciMethod*        dest_method   = iter().get_method(will_link);
 340  339    ciInstanceKlass* holder_klass  = dest_method->holder();
 341  340    ciKlass* holder = iter().get_declared_method_holder();
 342  341    ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder);
 343  342  
 344      -  int   nargs    = dest_method->arg_size();
      343 +  int nargs = dest_method->arg_size();
      344 +  if (is_invokedynamic)  nargs -= 1;
 345  345  
 346  346    // uncommon-trap when callee is unloaded, uninitialized or will not link
 347  347    // bailout when too many arguments for register representation
 348  348    if (!will_link || can_not_compile_call_site(dest_method, klass)) {
 349  349  #ifndef PRODUCT
 350  350      if (PrintOpto && (Verbose || WizardMode)) {
 351  351        method()->print_name(); tty->print_cr(" can not compile call at bci %d to:", bci());
 352  352        dest_method->print_name(); tty->cr();
 353  353      }
 354  354  #endif
 355  355      return;
 356  356    }
 357  357    assert(holder_klass->is_loaded(), "");
 358      -  assert(dest_method->is_static() == !has_receiver, "must match bc");
      358 +  assert((dest_method->is_static() || is_invokedynamic) == !has_receiver , "must match bc");
 359  359    // Note: this takes into account invokeinterface of methods declared in java/lang/Object,
 360  360    // which should be invokevirtuals but according to the VM spec may be invokeinterfaces
 361  361    assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc");
 362  362    // Note:  In the absence of miranda methods, an abstract class K can perform
 363  363    // an invokevirtual directly on an interface method I.m if K implements I.
 364  364  
 365  365    // ---------------------
 366  366    // Does Class Hierarchy Analysis reveal only a single target of a v-call?
 367  367    // Then we may inline or make a static call, but become dependent on there being only 1 target.
 368  368    // Does the call-site type profile reveal only one receiver?
↓ open down ↓ 565 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX