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 ↓ 2363 lines elided ↑ open up ↑
2364 2364  
2365 2365    if (x->has_receiver()) {
2366 2366      args->at(0)->load_item_force(LIR_Assembler::receiverOpr());
2367 2367      receiver = args->at(0)->result();
2368 2368    }
2369 2369  
2370 2370    // emit invoke code
2371 2371    bool optimized = x->target_is_loaded() && x->target_is_final();
2372 2372    assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
2373 2373  
     2374 +  // JSR 292
     2375 +  // Preserve the SP over MethodHandle call sites.
     2376 +  ciMethod* target = x->target();
     2377 +  if (target->is_method_handle_invoke()) {
     2378 +    info->set_is_method_handle_invoke(true);
     2379 +    __ move(FrameMap::stack_pointer(), FrameMap::method_handle_invoke_SP_save_opr());
     2380 +  }
     2381 +
2374 2382    switch (x->code()) {
2375 2383      case Bytecodes::_invokestatic:
2376      -      __ call_static(x->target(), result_register,
     2384 +      __ call_static(target, result_register,
2377 2385                       SharedRuntime::get_resolve_static_call_stub(),
2378 2386                       arg_list, info);
2379 2387        break;
2380 2388      case Bytecodes::_invokespecial:
2381 2389      case Bytecodes::_invokevirtual:
2382 2390      case Bytecodes::_invokeinterface:
2383 2391        // for final target we still produce an inline cache, in order
2384 2392        // to be able to call mixed mode
2385 2393        if (x->code() == Bytecodes::_invokespecial || optimized) {
2386      -        __ call_opt_virtual(x->target(), receiver, result_register,
     2394 +        __ call_opt_virtual(target, receiver, result_register,
2387 2395                              SharedRuntime::get_resolve_opt_virtual_call_stub(),
2388 2396                              arg_list, info);
2389 2397        } else if (x->vtable_index() < 0) {
2390      -        __ call_icvirtual(x->target(), receiver, result_register,
     2398 +        __ call_icvirtual(target, receiver, result_register,
2391 2399                            SharedRuntime::get_resolve_virtual_call_stub(),
2392 2400                            arg_list, info);
2393 2401        } else {
2394 2402          int entry_offset = instanceKlass::vtable_start_offset() + x->vtable_index() * vtableEntry::size();
2395 2403          int vtable_offset = entry_offset * wordSize + vtableEntry::method_offset_in_bytes();
2396      -        __ call_virtual(x->target(), receiver, result_register, vtable_offset, arg_list, info);
     2404 +        __ call_virtual(target, receiver, result_register, vtable_offset, arg_list, info);
2397 2405        }
2398 2406        break;
2399 2407      case Bytecodes::_invokedynamic: {
2400 2408        ciBytecodeStream bcs(x->scope()->method());
2401 2409        bcs.force_bci(x->bci());
2402 2410        assert(bcs.cur_bc() == Bytecodes::_invokedynamic, "wrong stream");
2403 2411        ciCPCache* cpcache = bcs.get_cpcache();
2404 2412  
2405 2413        // Get CallSite offset from constant pool cache pointer.
2406 2414        int index = bcs.get_method_index();
↓ open down ↓ 18 lines elided ↑ open up ↑
2425 2433        receiver = LIR_Assembler::receiverOpr();
2426 2434        LIR_Opr tmp = new_register(objectType);
2427 2435  
2428 2436        // Load CallSite object from constant pool cache.
2429 2437        __ oop2reg(cpcache->constant_encoding(), tmp);
2430 2438        __ load(new LIR_Address(tmp, call_site_offset, T_OBJECT), tmp);
2431 2439  
2432 2440        // Load target MethodHandle from CallSite object.
2433 2441        __ load(new LIR_Address(tmp, java_dyn_CallSite::target_offset_in_bytes(), T_OBJECT), receiver);
2434 2442  
2435      -      __ call_dynamic(x->target(), receiver, result_register,
     2443 +      __ call_dynamic(target, receiver, result_register,
2436 2444                        SharedRuntime::get_resolve_opt_virtual_call_stub(),
2437 2445                        arg_list, info);
2438 2446        break;
2439 2447      }
2440 2448      default:
2441 2449        ShouldNotReachHere();
2442 2450        break;
2443 2451    }
2444 2452  
     2453 +  // JSR 292
     2454 +  // Restore the SP after MethodHandle call sites.
     2455 +  if (target->is_method_handle_invoke()) {
     2456 +    __ move(FrameMap::method_handle_invoke_SP_save_opr(), FrameMap::stack_pointer());
     2457 +  }
     2458 +
2445 2459    if (x->type()->is_float() || x->type()->is_double()) {
2446 2460      // Force rounding of results from non-strictfp when in strictfp
2447 2461      // scope (or when we don't know the strictness of the callee, to
2448 2462      // be safe.)
2449 2463      if (method()->is_strict()) {
2450 2464        if (!x->target_is_loaded() || !x->target_is_strictfp()) {
2451 2465          result_register = round_item(result_register);
2452 2466        }
2453 2467      }
2454 2468    }
↓ open down ↓ 276 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX