Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/c1/c1_LIRGenerator.cpp
          +++ new/src/share/vm/c1/c1_LIRGenerator.cpp
↓ open down ↓ 2381 lines elided ↑ open up ↑
2382 2382  
2383 2383    if (x->has_receiver()) {
2384 2384      args->at(0)->load_item_force(LIR_Assembler::receiverOpr());
2385 2385      receiver = args->at(0)->result();
2386 2386    }
2387 2387  
2388 2388    // emit invoke code
2389 2389    bool optimized = x->target_is_loaded() && x->target_is_final();
2390 2390    assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
2391 2391  
     2392 +  // JSR 292
     2393 +  // Preserve the SP over MethodHandle call sites.
     2394 +  ciMethod* target = x->target();
     2395 +  if (target->is_method_handle_invoke()) {
     2396 +    info->set_is_method_handle_invoke(true);
     2397 +    __ move(FrameMap::stack_pointer(), FrameMap::method_handle_invoke_SP_save_opr());
     2398 +  }
     2399 +
2392 2400    switch (x->code()) {
2393 2401      case Bytecodes::_invokestatic:
2394      -      __ call_static(x->target(), result_register,
     2402 +      __ call_static(target, result_register,
2395 2403                       SharedRuntime::get_resolve_static_call_stub(),
2396 2404                       arg_list, info);
2397 2405        break;
2398 2406      case Bytecodes::_invokespecial:
2399 2407      case Bytecodes::_invokevirtual:
2400 2408      case Bytecodes::_invokeinterface:
2401 2409        // for final target we still produce an inline cache, in order
2402 2410        // to be able to call mixed mode
2403 2411        if (x->code() == Bytecodes::_invokespecial || optimized) {
2404      -        __ call_opt_virtual(x->target(), receiver, result_register,
     2412 +        __ call_opt_virtual(target, receiver, result_register,
2405 2413                              SharedRuntime::get_resolve_opt_virtual_call_stub(),
2406 2414                              arg_list, info);
2407 2415        } else if (x->vtable_index() < 0) {
2408      -        __ call_icvirtual(x->target(), receiver, result_register,
     2416 +        __ call_icvirtual(target, receiver, result_register,
2409 2417                            SharedRuntime::get_resolve_virtual_call_stub(),
2410 2418                            arg_list, info);
2411 2419        } else {
2412 2420          int entry_offset = instanceKlass::vtable_start_offset() + x->vtable_index() * vtableEntry::size();
2413 2421          int vtable_offset = entry_offset * wordSize + vtableEntry::method_offset_in_bytes();
2414      -        __ call_virtual(x->target(), receiver, result_register, vtable_offset, arg_list, info);
     2422 +        __ call_virtual(target, receiver, result_register, vtable_offset, arg_list, info);
2415 2423        }
2416 2424        break;
2417 2425      case Bytecodes::_invokedynamic: {
2418 2426        ciBytecodeStream bcs(x->scope()->method());
2419 2427        bcs.force_bci(x->bci());
2420 2428        assert(bcs.cur_bc() == Bytecodes::_invokedynamic, "wrong stream");
2421 2429        ciCPCache* cpcache = bcs.get_cpcache();
2422 2430  
2423 2431        // Get CallSite offset from constant pool cache pointer.
2424 2432        int index = bcs.get_method_index();
↓ open down ↓ 18 lines elided ↑ open up ↑
2443 2451        receiver = LIR_Assembler::receiverOpr();
2444 2452        LIR_Opr tmp = new_register(objectType);
2445 2453  
2446 2454        // Load CallSite object from constant pool cache.
2447 2455        __ oop2reg(cpcache->constant_encoding(), tmp);
2448 2456        __ load(new LIR_Address(tmp, call_site_offset, T_OBJECT), tmp);
2449 2457  
2450 2458        // Load target MethodHandle from CallSite object.
2451 2459        __ load(new LIR_Address(tmp, java_dyn_CallSite::target_offset_in_bytes(), T_OBJECT), receiver);
2452 2460  
2453      -      __ call_dynamic(x->target(), receiver, result_register,
     2461 +      __ call_dynamic(target, receiver, result_register,
2454 2462                        SharedRuntime::get_resolve_opt_virtual_call_stub(),
2455 2463                        arg_list, info);
2456 2464        break;
2457 2465      }
2458 2466      default:
2459 2467        ShouldNotReachHere();
2460 2468        break;
2461 2469    }
2462 2470  
     2471 +  // JSR 292
     2472 +  // Restore the SP after MethodHandle call sites.
     2473 +  if (target->is_method_handle_invoke()) {
     2474 +    __ move(FrameMap::method_handle_invoke_SP_save_opr(), FrameMap::stack_pointer());
     2475 +  }
     2476 +
2463 2477    if (x->type()->is_float() || x->type()->is_double()) {
2464 2478      // Force rounding of results from non-strictfp when in strictfp
2465 2479      // scope (or when we don't know the strictness of the callee, to
2466 2480      // be safe.)
2467 2481      if (method()->is_strict()) {
2468 2482        if (!x->target_is_loaded() || !x->target_is_strictfp()) {
2469 2483          result_register = round_item(result_register);
2470 2484        }
2471 2485      }
2472 2486    }
↓ open down ↓ 276 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX