Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/opto/doCall.cpp
          +++ new/src/share/vm/opto/doCall.cpp
↓ open down ↓ 54 lines elided ↑ open up ↑
  55   55      tty->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count);
  56   56      prof_klass->name()->print_symbol();
  57   57      tty->cr();
  58   58    }
  59   59  }
  60   60  #endif
  61   61  
  62   62  CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index, bool call_is_virtual,
  63   63                                         JVMState* jvms, bool allow_inline,
  64   64                                         float prof_factor) {
  65      -  CallGenerator* cg;
       65 +  CallGenerator*  cg;
       66 +  ciMethod*       caller   = jvms->method();
       67 +  int             bci      = jvms->bci();
       68 +  Bytecodes::Code bytecode = caller->java_code_at_bci(bci);
  66   69    guarantee(call_method != NULL, "failed method resolution");
  67   70  
  68   71    // Dtrace currently doesn't work unless all calls are vanilla
  69   72    if (env()->dtrace_method_probes()) {
  70   73      allow_inline = false;
  71   74    }
  72   75  
  73   76    // Note: When we get profiling during stage-1 compiles, we want to pull
  74   77    // from more specific profile data which pertains to this inlining.
  75   78    // Right now, ignore the information in jvms->caller(), and do method[bci].
  76      -  ciCallProfile profile    = jvms->method()->call_profile_at_bci(jvms->bci());
  77      -  Bytecodes::Code bytecode = jvms->method()->java_code_at_bci(jvms->bci());
       79 +  ciCallProfile profile = caller->call_profile_at_bci(bci);
  78   80  
  79   81    // See how many times this site has been invoked.
  80   82    int site_count = profile.count();
  81   83    int receiver_count = -1;
  82   84    if (call_is_virtual && UseTypeProfile && profile.has_receiver(0)) {
  83   85      // Receivers in the profile structure are ordered by call counts
  84   86      // so that the most called (major) receiver is profile.receiver(0).
  85   87      receiver_count = profile.receiver_count(0);
  86   88    }
  87   89  
↓ open down ↓ 31 lines elided ↑ open up ↑
 119  121    if (call_method->is_method_handle_invoke()) {
 120  122      if (bytecode != Bytecodes::_invokedynamic) {
 121  123        GraphKit kit(jvms);
 122  124        Node* n = kit.argument(0);
 123  125  
 124  126        if (n->Opcode() == Op_ConP) {
 125  127          const TypeOopPtr* oop_ptr = n->bottom_type()->is_oopptr();
 126  128          ciObject* const_oop = oop_ptr->const_oop();
 127  129          ciMethodHandle* method_handle = const_oop->as_method_handle();
 128  130  
 129      -        // Set the actually called method to have access to the class
 130      -        // and signature in the MethodHandleCompiler.
      131 +        // Set the callee to have access to the class and signature in
      132 +        // the MethodHandleCompiler.
 131  133          method_handle->set_callee(call_method);
      134 +        method_handle->set_caller(caller);
 132  135          method_handle->set_call_profile(&profile);
 133  136  
 134  137          // Get an adapter for the MethodHandle.
 135  138          ciMethod* target_method = method_handle->get_method_handle_adapter();
 136  139          if (target_method != NULL) {
 137  140            CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
 138  141            if (hit_cg != NULL && hit_cg->is_inline())
 139  142              return hit_cg;
 140  143          }
 141  144        }
↓ open down ↓ 1 lines elided ↑ open up ↑
 143  146        return CallGenerator::for_direct_call(call_method);
 144  147      }
 145  148      else {
 146  149        // Get the MethodHandle from the CallSite.
 147  150        ciMethod* caller_method = jvms->method();
 148  151        ciBytecodeStream str(caller_method);
 149  152        str.force_bci(jvms->bci());  // Set the stream to the invokedynamic bci.
 150  153        ciCallSite*     call_site     = str.get_call_site();
 151  154        ciMethodHandle* method_handle = call_site->get_target();
 152  155  
 153      -      // Set the actually called method to have access to the class
 154      -      // and signature in the MethodHandleCompiler.
      156 +      // Set the callee to have access to the class and signature in
      157 +      // the MethodHandleCompiler.
 155  158        method_handle->set_callee(call_method);
      159 +      method_handle->set_caller(caller);
 156  160        method_handle->set_call_profile(&profile);
 157  161  
 158  162        // Get an adapter for the MethodHandle.
 159  163        ciMethod* target_method = method_handle->get_invokedynamic_adapter();
 160  164        if (target_method != NULL) {
 161  165          CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
 162  166          if (hit_cg != NULL && hit_cg->is_inline()) {
 163  167            CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method);
 164  168            return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor);
 165  169          }
↓ open down ↓ 795 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX