src/cpu/ppc/vm/templateTable_ppc_64.cpp

Print this page




 421   // Check out Conversions.java for an example.
 422   // Also ConstantPool::header_size() is 20, which makes it very difficult
 423   // to double-align double on the constant pool. SG, 11/7/97
 424   __ lfdx(F15_ftos, Rcpool, Rindex);
 425   __ push(dtos);
 426   __ b(Lexit);
 427 
 428   __ bind(Llong);
 429   __ ldx(R17_tos, Rcpool, Rindex);
 430   __ push(ltos);
 431 
 432   __ bind(Lexit);
 433 }
 434 
 435 // Get the locals index located in the bytecode stream at bcp + offset.
 436 void TemplateTable::locals_index(Register Rdst, int offset) {
 437   __ lbz(Rdst, offset, R14_bcp);
 438 }
 439 
 440 void TemplateTable::iload() {








 441   transition(vtos, itos);
 442 
 443   // Get the local value into tos
 444   const Register Rindex = R22_tmp2;
 445   locals_index(Rindex);
 446 
 447   // Rewrite iload,iload  pair into fast_iload2
 448   //         iload,caload pair into fast_icaload
 449   if (RewriteFrequentPairs) {
 450     Label Lrewrite, Ldone;
 451     Register Rnext_byte  = R3_ARG1,
 452              Rrewrite_to = R6_ARG4,
 453              Rscratch    = R11_scratch1;
 454 
 455     // get next byte
 456     __ lbz(Rnext_byte, Bytecodes::length_for(Bytecodes::_iload), R14_bcp);
 457 
 458     // if _iload, wait to rewrite to iload2. We only want to rewrite the
 459     // last two iloads in a pair. Comparing against fast_iload means that
 460     // the next bytecode is neither an iload or a caload, and therefore
 461     // an iload pair.
 462     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_iload);
 463     __ beq(CCR0, Ldone);
 464 
 465     __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_iload);
 466     __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iload2);
 467     __ beq(CCR1, Lrewrite);
 468 
 469     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_caload);


 693 
 694 void TemplateTable::fload(int n) {
 695   transition(vtos, ftos);
 696 
 697   __ lfs(F15_ftos, Interpreter::local_offset_in_bytes(n), R18_locals);
 698 }
 699 
 700 void TemplateTable::dload(int n) {
 701   transition(vtos, dtos);
 702 
 703   __ lfd(F15_ftos, Interpreter::local_offset_in_bytes(n + 1), R18_locals);
 704 }
 705 
 706 void TemplateTable::aload(int n) {
 707   transition(vtos, atos);
 708 
 709   __ ld(R17_tos, Interpreter::local_offset_in_bytes(n), R18_locals);
 710 }
 711 
 712 void TemplateTable::aload_0() {








 713   transition(vtos, atos);
 714   // According to bytecode histograms, the pairs:
 715   //
 716   // _aload_0, _fast_igetfield
 717   // _aload_0, _fast_agetfield
 718   // _aload_0, _fast_fgetfield
 719   //
 720   // occur frequently. If RewriteFrequentPairs is set, the (slow)
 721   // _aload_0 bytecode checks if the next bytecode is either
 722   // _fast_igetfield, _fast_agetfield or _fast_fgetfield and then
 723   // rewrites the current bytecode into a pair bytecode; otherwise it
 724   // rewrites the current bytecode into _0 that doesn't do
 725   // the pair check anymore.
 726   //
 727   // Note: If the next bytecode is _getfield, the rewrite must be
 728   //       delayed, otherwise we may miss an opportunity for a pair.
 729   //
 730   // Also rewrite frequent pairs
 731   //   aload_0, aload_1
 732   //   aload_0, iload_1
 733   // These bytecodes with a small amount of code are most profitable
 734   // to rewrite.
 735 
 736   if (RewriteFrequentPairs) {
 737 
 738     Label Lrewrite, Ldont_rewrite;
 739     Register Rnext_byte  = R3_ARG1,
 740              Rrewrite_to = R6_ARG4,
 741              Rscratch    = R11_scratch1;
 742 
 743     // Get next byte.
 744     __ lbz(Rnext_byte, Bytecodes::length_for(Bytecodes::_aload_0), R14_bcp);
 745 
 746     // If _getfield, wait to rewrite. We only want to rewrite the last two bytecodes in a pair.
 747     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_getfield);
 748     __ beq(CCR0, Ldont_rewrite);
 749 
 750     __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_igetfield);
 751     __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iaccess_0);
 752     __ beq(CCR1, Lrewrite);
 753 
 754     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_agetfield);
 755     __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_aaccess_0);
 756     __ beq(CCR0, Lrewrite);


2128 // want to float loads above this check.
2129 // See also comments in ConstantPoolCacheEntry::bytecode_1(),
2130 // ConstantPoolCacheEntry::bytecode_2() and ConstantPoolCacheEntry::f1();
2131 
2132 // Call into the VM if call site is not yet resolved
2133 //
2134 // Input regs:
2135 //   - None, all passed regs are outputs.
2136 //
2137 // Returns:
2138 //   - Rcache:  The const pool cache entry that contains the resolved result.
2139 //   - Rresult: Either noreg or output for f1/f2.
2140 //
2141 // Kills:
2142 //   - Rscratch
2143 void TemplateTable::resolve_cache_and_index(int byte_no, Register Rcache, Register Rscratch, size_t index_size) {
2144 
2145   __ get_cache_and_index_at_bcp(Rcache, 1, index_size);
2146   Label Lresolved, Ldone;
2147 







2148   assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
2149   // We are resolved if the indices offset contains the current bytecode.
2150 #if defined(VM_LITTLE_ENDIAN)
2151   __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + byte_no + 1, Rcache);
2152 #else
2153   __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 7 - (byte_no + 1), Rcache);
2154 #endif
2155   // Acquire by cmp-br-isync (see below).
2156   __ cmpdi(CCR0, Rscratch, (int)bytecode());
2157   __ beq(CCR0, Lresolved);
2158 
2159   address entry = NULL;
2160   switch (bytecode()) {
2161     case Bytecodes::_getstatic      : // fall through
2162     case Bytecodes::_putstatic      : // fall through
2163     case Bytecodes::_getfield       : // fall through
2164     case Bytecodes::_putfield       : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put); break;
2165     case Bytecodes::_invokevirtual  : // fall through
2166     case Bytecodes::_invokespecial  : // fall through
2167     case Bytecodes::_invokestatic   : // fall through
2168     case Bytecodes::_invokeinterface: entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke); break;
2169     case Bytecodes::_invokehandle   : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokehandle); break;
2170     case Bytecodes::_invokedynamic  : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic); break;
2171     default                         : ShouldNotReachHere(); break;
2172   }
2173   __ li(R4_ARG2, (int)bytecode());
2174   __ call_VM(noreg, entry, R4_ARG2, true);
2175 
2176   // Update registers with resolved info.
2177   __ get_cache_and_index_at_bcp(Rcache, 1, index_size);
2178   __ b(Ldone);
2179 
2180   __ bind(Lresolved);
2181   __ isync(); // Order load wrt. succeeding loads.
2182   __ bind(Ldone);
2183 }
2184 
2185 // Load the constant pool cache entry at field accesses into registers.
2186 // The Rcache and Rindex registers must be set before call.
2187 // Input:
2188 //   - Rcache, Rindex
2189 // Output:
2190 //   - Robj, Roffset, Rflags
2191 void TemplateTable::load_field_cp_cache_entry(Register Robj,
2192                                               Register Rcache,
2193                                               Register Rindex /* unused on PPC64 */,


2334       __ get_cache_and_index_at_bcp(Rcache, 1);
2335     }
2336 
2337     __ align(32, 12);
2338     __ bind(Lno_field_access_post);
2339   }
2340 }
2341 
2342 // kills R11_scratch1
2343 void TemplateTable::pop_and_check_object(Register Roop) {
2344   Register Rtmp = R11_scratch1;
2345 
2346   assert_different_registers(Rtmp, Roop);
2347   __ pop_ptr(Roop);
2348   // For field access must check obj.
2349   __ null_check_throw(Roop, -1, Rtmp);
2350   __ verify_oop(Roop);
2351 }
2352 
2353 // PPC64: implement volatile loads as fence-store-acquire.
2354 void TemplateTable::getfield_or_static(int byte_no, bool is_static) {
2355   transition(vtos, vtos);
2356 
2357   Label Lacquire, Lisync;
2358 
2359   const Register Rcache        = R3_ARG1,
2360                  Rclass_or_obj = R22_tmp2,
2361                  Roffset       = R23_tmp3,
2362                  Rflags        = R31,
2363                  Rbtable       = R5_ARG3,
2364                  Rbc           = R6_ARG4,
2365                  Rscratch      = R12_scratch2;
2366 
2367   static address field_branch_table[number_of_states],
2368                  static_branch_table[number_of_states];
2369 
2370   address* branch_table = is_static ? static_branch_table : field_branch_table;
2371 
2372   // Get field offset.
2373   resolve_cache_and_index(byte_no, Rcache, Rscratch, sizeof(u2));
2374 


2418 #ifdef ASSERT
2419   __ bind(LFlagInvalid);
2420   __ stop("got invalid flag", 0x654);
2421 
2422   // __ bind(Lvtos);
2423   address pc_before_fence = __ pc();
2424   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2425   assert(__ pc() - pc_before_fence == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
2426   assert(branch_table[vtos] == 0, "can't compute twice");
2427   branch_table[vtos] = __ pc(); // non-volatile_entry point
2428   __ stop("vtos unexpected", 0x655);
2429 #endif
2430 
2431   __ align(32, 28, 28); // Align load.
2432   // __ bind(Ldtos);
2433   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2434   assert(branch_table[dtos] == 0, "can't compute twice");
2435   branch_table[dtos] = __ pc(); // non-volatile_entry point
2436   __ lfdx(F15_ftos, Rclass_or_obj, Roffset);
2437   __ push(dtos);
2438   if (!is_static) patch_bytecode(Bytecodes::_fast_dgetfield, Rbc, Rscratch);
2439   {
2440     Label acquire_double;
2441     __ beq(CCR6, acquire_double); // Volatile?
2442     __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2443 
2444     __ bind(acquire_double);
2445     __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
2446     __ beq_predict_taken(CCR0, Lisync);
2447     __ b(Lisync); // In case of NAN.
2448   }
2449 
2450   __ align(32, 28, 28); // Align load.
2451   // __ bind(Lftos);
2452   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2453   assert(branch_table[ftos] == 0, "can't compute twice");
2454   branch_table[ftos] = __ pc(); // non-volatile_entry point
2455   __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
2456   __ push(ftos);
2457   if (!is_static) { patch_bytecode(Bytecodes::_fast_fgetfield, Rbc, Rscratch); }
2458   {
2459     Label acquire_float;
2460     __ beq(CCR6, acquire_float); // Volatile?
2461     __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2462 
2463     __ bind(acquire_float);
2464     __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
2465     __ beq_predict_taken(CCR0, Lisync);
2466     __ b(Lisync); // In case of NAN.
2467   }
2468 
2469   __ align(32, 28, 28); // Align load.
2470   // __ bind(Litos);
2471   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2472   assert(branch_table[itos] == 0, "can't compute twice");
2473   branch_table[itos] = __ pc(); // non-volatile_entry point
2474   __ lwax(R17_tos, Rclass_or_obj, Roffset);
2475   __ push(itos);
2476   if (!is_static) patch_bytecode(Bytecodes::_fast_igetfield, Rbc, Rscratch);
2477   __ beq(CCR6, Lacquire); // Volatile?
2478   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2479 
2480   __ align(32, 28, 28); // Align load.
2481   // __ bind(Lltos);
2482   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2483   assert(branch_table[ltos] == 0, "can't compute twice");
2484   branch_table[ltos] = __ pc(); // non-volatile_entry point
2485   __ ldx(R17_tos, Rclass_or_obj, Roffset);
2486   __ push(ltos);
2487   if (!is_static) patch_bytecode(Bytecodes::_fast_lgetfield, Rbc, Rscratch);
2488   __ beq(CCR6, Lacquire); // Volatile?
2489   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2490 
2491   __ align(32, 28, 28); // Align load.
2492   // __ bind(Lbtos);
2493   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2494   assert(branch_table[btos] == 0, "can't compute twice");
2495   branch_table[btos] = __ pc(); // non-volatile_entry point
2496   __ lbzx(R17_tos, Rclass_or_obj, Roffset);
2497   __ extsb(R17_tos, R17_tos);
2498   __ push(btos);
2499   if (!is_static) patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
2500   __ beq(CCR6, Lacquire); // Volatile?
2501   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2502 
2503   __ align(32, 28, 28); // Align load.
2504   // __ bind(Lctos);
2505   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2506   assert(branch_table[ctos] == 0, "can't compute twice");
2507   branch_table[ctos] = __ pc(); // non-volatile_entry point
2508   __ lhzx(R17_tos, Rclass_or_obj, Roffset);
2509   __ push(ctos);
2510   if (!is_static) patch_bytecode(Bytecodes::_fast_cgetfield, Rbc, Rscratch);
2511   __ beq(CCR6, Lacquire); // Volatile?
2512   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2513 
2514   __ align(32, 28, 28); // Align load.
2515   // __ bind(Lstos);
2516   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2517   assert(branch_table[stos] == 0, "can't compute twice");
2518   branch_table[stos] = __ pc(); // non-volatile_entry point
2519   __ lhax(R17_tos, Rclass_or_obj, Roffset);
2520   __ push(stos);
2521   if (!is_static) patch_bytecode(Bytecodes::_fast_sgetfield, Rbc, Rscratch);
2522   __ beq(CCR6, Lacquire); // Volatile?
2523   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2524 
2525   __ align(32, 28, 28); // Align load.
2526   // __ bind(Latos);
2527   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2528   assert(branch_table[atos] == 0, "can't compute twice");
2529   branch_table[atos] = __ pc(); // non-volatile_entry point
2530   __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
2531   __ verify_oop(R17_tos);
2532   __ push(atos);
2533   //__ dcbt(R17_tos); // prefetch
2534   if (!is_static) patch_bytecode(Bytecodes::_fast_agetfield, Rbc, Rscratch);
2535   __ beq(CCR6, Lacquire); // Volatile?
2536   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2537 
2538   __ align(32, 12);
2539   __ bind(Lacquire);
2540   __ twi_0(R17_tos);
2541   __ bind(Lisync);
2542   __ isync(); // acquire
2543 
2544 #ifdef ASSERT
2545   for (int i = 0; i<number_of_states; ++i) {
2546     assert(branch_table[i], "get initialization");
2547     //tty->print_cr("get: %s_branch_table[%d] = 0x%llx (opcode 0x%llx)",
2548     //              is_static ? "static" : "field", i, branch_table[i], *((unsigned int*)branch_table[i]));
2549   }
2550 #endif
2551 }
2552 
2553 void TemplateTable::getfield(int byte_no) {
2554   getfield_or_static(byte_no, false);
2555 }
2556 




2557 void TemplateTable::getstatic(int byte_no) {
2558   getfield_or_static(byte_no, true);
2559 }
2560 
2561 // The registers cache and index expected to be set before call.
2562 // The function may destroy various registers, just not the cache and index registers.
2563 void TemplateTable::jvmti_post_field_mod(Register Rcache, Register Rscratch, bool is_static) {
2564 
2565   assert_different_registers(Rcache, Rscratch, R6_ARG4);
2566 
2567   if (JvmtiExport::can_post_field_modification()) {
2568     Label Lno_field_mod_post;
2569 
2570     // Check if post field access in enabled.
2571     int offs = __ load_const_optimized(Rscratch, JvmtiExport::get_field_modification_count_addr(), R0, true);
2572     __ lwz(Rscratch, offs, Rscratch);
2573 
2574     __ cmpwi(CCR0, Rscratch, 0);
2575     __ beq(CCR0, Lno_field_mod_post);
2576 


2627 
2628     // In case of the fast versions, value lives in registers => put it back on tos.
2629     switch(bytecode()) {
2630       case Bytecodes::_fast_aputfield: __ pop_ptr(); break;
2631       case Bytecodes::_fast_iputfield: // Fall through
2632       case Bytecodes::_fast_bputfield: // Fall through
2633       case Bytecodes::_fast_cputfield: // Fall through
2634       case Bytecodes::_fast_sputfield: __ pop_i(); break;
2635       case Bytecodes::_fast_lputfield: __ pop_l(); break;
2636       case Bytecodes::_fast_fputfield: __ pop_f(); break;
2637       case Bytecodes::_fast_dputfield: __ pop_d(); break;
2638       default: break; // Nothin' to do.
2639     }
2640 
2641     __ align(32, 12);
2642     __ bind(Lno_field_mod_post);
2643   }
2644 }
2645 
2646 // PPC64: implement volatile stores as release-store (return bytecode contains an additional release).
2647 void TemplateTable::putfield_or_static(int byte_no, bool is_static) {
2648   Label Lvolatile;
2649 
2650   const Register Rcache        = R5_ARG3,  // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod).
2651                  Rclass_or_obj = R31,      // Needs to survive C call.
2652                  Roffset       = R22_tmp2, // Needs to survive C call.
2653                  Rflags        = R3_ARG1,
2654                  Rbtable       = R4_ARG2,
2655                  Rscratch      = R11_scratch1,
2656                  Rscratch2     = R12_scratch2,
2657                  Rscratch3     = R6_ARG4,
2658                  Rbc           = Rscratch3;
2659   const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).
2660 
2661   static address field_branch_table[number_of_states],
2662                  static_branch_table[number_of_states];
2663 
2664   address* branch_table = is_static ? static_branch_table : field_branch_table;
2665 
2666   // Stack (grows up):
2667   //  value


2701   __ bind(LFlagInvalid);
2702   __ stop("got invalid flag", 0x656);
2703 
2704   // __ bind(Lvtos);
2705   address pc_before_release = __ pc();
2706   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2707   assert(__ pc() - pc_before_release == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
2708   assert(branch_table[vtos] == 0, "can't compute twice");
2709   branch_table[vtos] = __ pc(); // non-volatile_entry point
2710   __ stop("vtos unexpected", 0x657);
2711 #endif
2712 
2713   __ align(32, 28, 28); // Align pop.
2714   // __ bind(Ldtos);
2715   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2716   assert(branch_table[dtos] == 0, "can't compute twice");
2717   branch_table[dtos] = __ pc(); // non-volatile_entry point
2718   __ pop(dtos);
2719   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2720   __ stfdx(F15_ftos, Rclass_or_obj, Roffset);
2721   if (!is_static) { patch_bytecode(Bytecodes::_fast_dputfield, Rbc, Rscratch, true, byte_no); }
2722   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2723     __ beq(CR_is_vol, Lvolatile); // Volatile?
2724   }
2725   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2726 
2727   __ align(32, 28, 28); // Align pop.
2728   // __ bind(Lftos);
2729   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2730   assert(branch_table[ftos] == 0, "can't compute twice");
2731   branch_table[ftos] = __ pc(); // non-volatile_entry point
2732   __ pop(ftos);
2733   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2734   __ stfsx(F15_ftos, Rclass_or_obj, Roffset);
2735   if (!is_static) { patch_bytecode(Bytecodes::_fast_fputfield, Rbc, Rscratch, true, byte_no); }
2736   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2737     __ beq(CR_is_vol, Lvolatile); // Volatile?
2738   }
2739   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2740 
2741   __ align(32, 28, 28); // Align pop.
2742   // __ bind(Litos);
2743   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2744   assert(branch_table[itos] == 0, "can't compute twice");
2745   branch_table[itos] = __ pc(); // non-volatile_entry point
2746   __ pop(itos);
2747   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2748   __ stwx(R17_tos, Rclass_or_obj, Roffset);
2749   if (!is_static) { patch_bytecode(Bytecodes::_fast_iputfield, Rbc, Rscratch, true, byte_no); }
2750   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2751     __ beq(CR_is_vol, Lvolatile); // Volatile?
2752   }
2753   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2754 
2755   __ align(32, 28, 28); // Align pop.
2756   // __ bind(Lltos);
2757   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2758   assert(branch_table[ltos] == 0, "can't compute twice");
2759   branch_table[ltos] = __ pc(); // non-volatile_entry point
2760   __ pop(ltos);
2761   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2762   __ stdx(R17_tos, Rclass_or_obj, Roffset);
2763   if (!is_static) { patch_bytecode(Bytecodes::_fast_lputfield, Rbc, Rscratch, true, byte_no); }
2764   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2765     __ beq(CR_is_vol, Lvolatile); // Volatile?
2766   }
2767   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2768 
2769   __ align(32, 28, 28); // Align pop.
2770   // __ bind(Lbtos);
2771   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2772   assert(branch_table[btos] == 0, "can't compute twice");
2773   branch_table[btos] = __ pc(); // non-volatile_entry point
2774   __ pop(btos);
2775   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2776   __ stbx(R17_tos, Rclass_or_obj, Roffset);
2777   if (!is_static) { patch_bytecode(Bytecodes::_fast_bputfield, Rbc, Rscratch, true, byte_no); }
2778   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2779     __ beq(CR_is_vol, Lvolatile); // Volatile?
2780   }
2781   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2782 
2783   __ align(32, 28, 28); // Align pop.
2784   // __ bind(Lctos);
2785   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2786   assert(branch_table[ctos] == 0, "can't compute twice");
2787   branch_table[ctos] = __ pc(); // non-volatile_entry point
2788   __ pop(ctos);
2789   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1..
2790   __ sthx(R17_tos, Rclass_or_obj, Roffset);
2791   if (!is_static) { patch_bytecode(Bytecodes::_fast_cputfield, Rbc, Rscratch, true, byte_no); }
2792   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2793     __ beq(CR_is_vol, Lvolatile); // Volatile?
2794   }
2795   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2796 
2797   __ align(32, 28, 28); // Align pop.
2798   // __ bind(Lstos);
2799   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2800   assert(branch_table[stos] == 0, "can't compute twice");
2801   branch_table[stos] = __ pc(); // non-volatile_entry point
2802   __ pop(stos);
2803   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2804   __ sthx(R17_tos, Rclass_or_obj, Roffset);
2805   if (!is_static) { patch_bytecode(Bytecodes::_fast_sputfield, Rbc, Rscratch, true, byte_no); }
2806   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2807     __ beq(CR_is_vol, Lvolatile); // Volatile?
2808   }
2809   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2810 
2811   __ align(32, 28, 28); // Align pop.
2812   // __ bind(Latos);
2813   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2814   assert(branch_table[atos] == 0, "can't compute twice");
2815   branch_table[atos] = __ pc(); // non-volatile_entry point
2816   __ pop(atos);
2817   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // kills R11_scratch1
2818   do_oop_store(_masm, Rclass_or_obj, Roffset, R17_tos, Rscratch, Rscratch2, Rscratch3, _bs->kind(), false /* precise */, true /* check null */);
2819   if (!is_static) { patch_bytecode(Bytecodes::_fast_aputfield, Rbc, Rscratch, true, byte_no); }
2820   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2821     __ beq(CR_is_vol, Lvolatile); // Volatile?
2822     __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2823 
2824     __ align(32, 12);
2825     __ bind(Lvolatile);
2826     __ fence();
2827   }
2828   // fallthru: __ b(Lexit);
2829 
2830 #ifdef ASSERT
2831   for (int i = 0; i<number_of_states; ++i) {
2832     assert(branch_table[i], "put initialization");
2833     //tty->print_cr("put: %s_branch_table[%d] = 0x%llx (opcode 0x%llx)",
2834     //              is_static ? "static" : "field", i, branch_table[i], *((unsigned int*)branch_table[i]));
2835   }
2836 #endif
2837 }
2838 
2839 void TemplateTable::putfield(int byte_no) {
2840   putfield_or_static(byte_no, false);
2841 }
2842 




2843 void TemplateTable::putstatic(int byte_no) {
2844   putfield_or_static(byte_no, true);
2845 }
2846 
2847 // See SPARC. On PPC64, we have a different jvmti_post_field_mod which does the job.
2848 void TemplateTable::jvmti_post_fast_field_mod() {
2849   __ should_not_reach_here();
2850 }
2851 
2852 void TemplateTable::fast_storefield(TosState state) {
2853   transition(state, vtos);
2854 
2855   const Register Rcache        = R5_ARG3,  // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod).
2856                  Rclass_or_obj = R31,      // Needs to survive C call.
2857                  Roffset       = R22_tmp2, // Needs to survive C call.
2858                  Rflags        = R3_ARG1,
2859                  Rscratch      = R11_scratch1,
2860                  Rscratch2     = R12_scratch2,
2861                  Rscratch3     = R4_ARG2;
2862   const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).


3149 //
3150 // Output:
3151 //   - Rmethod:        The method to invoke next.
3152 //   - Rret_addr:      The return address to return to.
3153 //   - Rindex:         MethodType (invokehandle) or CallSite obj (invokedynamic)
3154 //   - Rrecv:          Cache for "this" pointer, might be noreg if static call.
3155 //   - Rflags:         Method flags from const pool cache.
3156 //
3157 //  Kills:
3158 //   - Rscratch1
3159 //
3160 void TemplateTable::prepare_invoke(int byte_no,
3161                                    Register Rmethod,  // linked method (or i-klass)
3162                                    Register Rret_addr,// return address
3163                                    Register Rindex,   // itable index, MethodType, etc.
3164                                    Register Rrecv,    // If caller wants to see it.
3165                                    Register Rflags,   // If caller wants to test it.
3166                                    Register Rscratch
3167                                    ) {
3168   // Determine flags.
3169   const Bytecodes::Code code = bytecode();
3170   const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
3171   const bool is_invokedynamic    = code == Bytecodes::_invokedynamic;
3172   const bool is_invokehandle     = code == Bytecodes::_invokehandle;
3173   const bool is_invokevirtual    = code == Bytecodes::_invokevirtual;
3174   const bool is_invokespecial    = code == Bytecodes::_invokespecial;
3175   const bool load_receiver       = (Rrecv != noreg);
3176   assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), "");
3177 
3178   assert_different_registers(Rmethod, Rindex, Rflags, Rscratch);
3179   assert_different_registers(Rmethod, Rrecv, Rflags, Rscratch);
3180   assert_different_registers(Rret_addr, Rscratch);
3181 
3182   load_invoke_cp_cache_entry(byte_no, Rmethod, Rindex, Rflags, is_invokevirtual, false, is_invokedynamic);
3183 
3184   // Saving of SP done in call_from_interpreter.
3185 
3186   // Maybe push "appendix" to arguments.
3187   if (is_invokedynamic || is_invokehandle) {
3188     Label Ldone;
3189     __ rldicl_(R0, Rflags, 64-ConstantPoolCacheEntry::has_appendix_shift, 63);


3222 
3223 // Helper for virtual calls. Load target out of vtable and jump off!
3224 // Kills all passed registers.
3225 void TemplateTable::generate_vtable_call(Register Rrecv_klass, Register Rindex, Register Rret, Register Rtemp) {
3226 
3227   assert_different_registers(Rrecv_klass, Rtemp, Rret);
3228   const Register Rtarget_method = Rindex;
3229 
3230   // Get target method & entry point.
3231   const int base = InstanceKlass::vtable_start_offset() * wordSize;
3232   // Calc vtable addr scale the vtable index by 8.
3233   __ sldi(Rindex, Rindex, exact_log2(vtableEntry::size() * wordSize));
3234   // Load target.
3235   __ addi(Rrecv_klass, Rrecv_klass, base + vtableEntry::method_offset_in_bytes());
3236   __ ldx(Rtarget_method, Rindex, Rrecv_klass);
3237   // Argument and return type profiling.
3238   __ profile_arguments_type(Rtarget_method, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */, true);
3239   __ call_from_interpreter(Rtarget_method, Rret, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */);
3240 }
3241 
3242 // Virtual or final call. Final calls are rewritten on the fly to run through "fast_finalcall" next time.
3243 void TemplateTable::invokevirtual(int byte_no) {
3244   transition(vtos, vtos);








3245 
3246   Register Rtable_addr = R11_scratch1,
3247            Rret_type = R12_scratch2,
3248            Rret_addr = R5_ARG3,
3249            Rflags = R22_tmp2, // Should survive C call.
3250            Rrecv = R3_ARG1,
3251            Rrecv_klass = Rrecv,
3252            Rvtableindex_or_method = R31, // Should survive C call.
3253            Rnum_params = R4_ARG2,
3254            Rnew_bc = R6_ARG4;
3255 
3256   Label LnotFinal;
3257 
3258   load_invoke_cp_cache_entry(byte_no, Rvtableindex_or_method, noreg, Rflags, /*virtual*/ true, false, false);
3259 
3260   __ testbitdi(CCR0, R0, Rflags, ConstantPoolCacheEntry::is_vfinal_shift);
3261   __ bfalse(CCR0, LnotFinal);
3262 

3263   patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2);

3264   invokevfinal_helper(Rvtableindex_or_method, Rflags, R11_scratch1, R12_scratch2);
3265 
3266   __ align(32, 12);
3267   __ bind(LnotFinal);
3268   // Load "this" pointer (receiver).
3269   __ rldicl(Rnum_params, Rflags, 64, 48);
3270   __ load_receiver(Rnum_params, Rrecv);
3271   __ verify_oop(Rrecv);
3272 
3273   // Get return type. It's coded into the upper 4 bits of the lower half of the 64 bit value.
3274   __ rldicl(Rret_type, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
3275   __ load_dispatch_table(Rtable_addr, Interpreter::invoke_return_entry_table());
3276   __ sldi(Rret_type, Rret_type, LogBytesPerWord);
3277   __ ldx(Rret_addr, Rret_type, Rtable_addr);
3278   __ null_check_throw(Rrecv, oopDesc::klass_offset_in_bytes(), R11_scratch1);
3279   __ load_klass(Rrecv_klass, Rrecv);
3280   __ verify_klass_ptr(Rrecv_klass);
3281   __ profile_virtual_call(Rrecv_klass, R11_scratch1, R12_scratch2, false);
3282 
3283   generate_vtable_call(Rrecv_klass, Rvtableindex_or_method, Rret_addr, R11_scratch1);




 421   // Check out Conversions.java for an example.
 422   // Also ConstantPool::header_size() is 20, which makes it very difficult
 423   // to double-align double on the constant pool. SG, 11/7/97
 424   __ lfdx(F15_ftos, Rcpool, Rindex);
 425   __ push(dtos);
 426   __ b(Lexit);
 427 
 428   __ bind(Llong);
 429   __ ldx(R17_tos, Rcpool, Rindex);
 430   __ push(ltos);
 431 
 432   __ bind(Lexit);
 433 }
 434 
 435 // Get the locals index located in the bytecode stream at bcp + offset.
 436 void TemplateTable::locals_index(Register Rdst, int offset) {
 437   __ lbz(Rdst, offset, R14_bcp);
 438 }
 439 
 440 void TemplateTable::iload() {
 441   iload_internal();
 442 }
 443 
 444 void TemplateTable::nofast_iload() {
 445   iload_internal(MAY_NOT_REWRITE);
 446 }
 447 
 448 void TemplateTable::iload_internal(RewriteControl rc) {
 449   transition(vtos, itos);
 450 
 451   // Get the local value into tos
 452   const Register Rindex = R22_tmp2;
 453   locals_index(Rindex);
 454 
 455   // Rewrite iload,iload  pair into fast_iload2
 456   //         iload,caload pair into fast_icaload
 457   if (RewriteFrequentPairs && rc == MAY_REWRITE) {
 458     Label Lrewrite, Ldone;
 459     Register Rnext_byte  = R3_ARG1,
 460              Rrewrite_to = R6_ARG4,
 461              Rscratch    = R11_scratch1;
 462 
 463     // get next byte
 464     __ lbz(Rnext_byte, Bytecodes::length_for(Bytecodes::_iload), R14_bcp);
 465 
 466     // if _iload, wait to rewrite to iload2. We only want to rewrite the
 467     // last two iloads in a pair. Comparing against fast_iload means that
 468     // the next bytecode is neither an iload or a caload, and therefore
 469     // an iload pair.
 470     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_iload);
 471     __ beq(CCR0, Ldone);
 472 
 473     __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_iload);
 474     __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iload2);
 475     __ beq(CCR1, Lrewrite);
 476 
 477     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_caload);


 701 
 702 void TemplateTable::fload(int n) {
 703   transition(vtos, ftos);
 704 
 705   __ lfs(F15_ftos, Interpreter::local_offset_in_bytes(n), R18_locals);
 706 }
 707 
 708 void TemplateTable::dload(int n) {
 709   transition(vtos, dtos);
 710 
 711   __ lfd(F15_ftos, Interpreter::local_offset_in_bytes(n + 1), R18_locals);
 712 }
 713 
 714 void TemplateTable::aload(int n) {
 715   transition(vtos, atos);
 716 
 717   __ ld(R17_tos, Interpreter::local_offset_in_bytes(n), R18_locals);
 718 }
 719 
 720 void TemplateTable::aload_0() {
 721   aload_0_internal();
 722 }
 723 
 724 void TemplateTable::nofast_aload_0() {
 725   aload_0_internal(MAY_NOT_REWRITE);
 726 }
 727 
 728 void TemplateTable::aload_0_internal(RewriteControl rc) {
 729   transition(vtos, atos);
 730   // According to bytecode histograms, the pairs:
 731   //
 732   // _aload_0, _fast_igetfield
 733   // _aload_0, _fast_agetfield
 734   // _aload_0, _fast_fgetfield
 735   //
 736   // occur frequently. If RewriteFrequentPairs is set, the (slow)
 737   // _aload_0 bytecode checks if the next bytecode is either
 738   // _fast_igetfield, _fast_agetfield or _fast_fgetfield and then
 739   // rewrites the current bytecode into a pair bytecode; otherwise it
 740   // rewrites the current bytecode into _0 that doesn't do
 741   // the pair check anymore.
 742   //
 743   // Note: If the next bytecode is _getfield, the rewrite must be
 744   //       delayed, otherwise we may miss an opportunity for a pair.
 745   //
 746   // Also rewrite frequent pairs
 747   //   aload_0, aload_1
 748   //   aload_0, iload_1
 749   // These bytecodes with a small amount of code are most profitable
 750   // to rewrite.
 751 
 752   if (RewriteFrequentPairs && rc == MAY_REWRITE) {
 753 
 754     Label Lrewrite, Ldont_rewrite;
 755     Register Rnext_byte  = R3_ARG1,
 756              Rrewrite_to = R6_ARG4,
 757              Rscratch    = R11_scratch1;
 758 
 759     // Get next byte.
 760     __ lbz(Rnext_byte, Bytecodes::length_for(Bytecodes::_aload_0), R14_bcp);
 761 
 762     // If _getfield, wait to rewrite. We only want to rewrite the last two bytecodes in a pair.
 763     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_getfield);
 764     __ beq(CCR0, Ldont_rewrite);
 765 
 766     __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_igetfield);
 767     __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iaccess_0);
 768     __ beq(CCR1, Lrewrite);
 769 
 770     __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_agetfield);
 771     __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_aaccess_0);
 772     __ beq(CCR0, Lrewrite);


2144 // want to float loads above this check.
2145 // See also comments in ConstantPoolCacheEntry::bytecode_1(),
2146 // ConstantPoolCacheEntry::bytecode_2() and ConstantPoolCacheEntry::f1();
2147 
2148 // Call into the VM if call site is not yet resolved
2149 //
2150 // Input regs:
2151 //   - None, all passed regs are outputs.
2152 //
2153 // Returns:
2154 //   - Rcache:  The const pool cache entry that contains the resolved result.
2155 //   - Rresult: Either noreg or output for f1/f2.
2156 //
2157 // Kills:
2158 //   - Rscratch
2159 void TemplateTable::resolve_cache_and_index(int byte_no, Register Rcache, Register Rscratch, size_t index_size) {
2160 
2161   __ get_cache_and_index_at_bcp(Rcache, 1, index_size);
2162   Label Lresolved, Ldone;
2163 
2164   Bytecodes::Code code = bytecode();
2165   switch (code) {
2166   case Bytecodes::_nofast_getfield: code = Bytecodes::_getfield; break;
2167   case Bytecodes::_nofast_putfield: code = Bytecodes::_putfield; break;
2168   case Bytecodes::_nofast_invokevirtual: code = Bytecodes::_invokevirtual;
2169   }
2170 
2171   assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
2172   // We are resolved if the indices offset contains the current bytecode.
2173 #if defined(VM_LITTLE_ENDIAN)
2174   __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + byte_no + 1, Rcache);
2175 #else
2176   __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 7 - (byte_no + 1), Rcache);
2177 #endif
2178   // Acquire by cmp-br-isync (see below).
2179   __ cmpdi(CCR0, Rscratch, code);
2180   __ beq(CCR0, Lresolved);
2181 
2182   address entry = NULL;
2183   switch (code) {
2184     case Bytecodes::_getstatic      : // fall through
2185     case Bytecodes::_putstatic      : // fall through
2186     case Bytecodes::_getfield       : // fall through
2187     case Bytecodes::_putfield       : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put); break;
2188     case Bytecodes::_invokevirtual  : // fall through
2189     case Bytecodes::_invokespecial  : // fall through
2190     case Bytecodes::_invokestatic   : // fall through
2191     case Bytecodes::_invokeinterface: entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke); break;
2192     case Bytecodes::_invokehandle   : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokehandle); break;
2193     case Bytecodes::_invokedynamic  : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic); break;
2194     default                         : ShouldNotReachHere(); break;
2195   }
2196   __ li(R4_ARG2, code);
2197   __ call_VM(noreg, entry, R4_ARG2, true);
2198 
2199   // Update registers with resolved info.
2200   __ get_cache_and_index_at_bcp(Rcache, 1, index_size);
2201   __ b(Ldone);
2202 
2203   __ bind(Lresolved);
2204   __ isync(); // Order load wrt. succeeding loads.
2205   __ bind(Ldone);
2206 }
2207 
2208 // Load the constant pool cache entry at field accesses into registers.
2209 // The Rcache and Rindex registers must be set before call.
2210 // Input:
2211 //   - Rcache, Rindex
2212 // Output:
2213 //   - Robj, Roffset, Rflags
2214 void TemplateTable::load_field_cp_cache_entry(Register Robj,
2215                                               Register Rcache,
2216                                               Register Rindex /* unused on PPC64 */,


2357       __ get_cache_and_index_at_bcp(Rcache, 1);
2358     }
2359 
2360     __ align(32, 12);
2361     __ bind(Lno_field_access_post);
2362   }
2363 }
2364 
2365 // kills R11_scratch1
2366 void TemplateTable::pop_and_check_object(Register Roop) {
2367   Register Rtmp = R11_scratch1;
2368 
2369   assert_different_registers(Rtmp, Roop);
2370   __ pop_ptr(Roop);
2371   // For field access must check obj.
2372   __ null_check_throw(Roop, -1, Rtmp);
2373   __ verify_oop(Roop);
2374 }
2375 
2376 // PPC64: implement volatile loads as fence-store-acquire.
2377 void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteControl rc) {
2378   transition(vtos, vtos);
2379 
2380   Label Lacquire, Lisync;
2381 
2382   const Register Rcache        = R3_ARG1,
2383                  Rclass_or_obj = R22_tmp2,
2384                  Roffset       = R23_tmp3,
2385                  Rflags        = R31,
2386                  Rbtable       = R5_ARG3,
2387                  Rbc           = R6_ARG4,
2388                  Rscratch      = R12_scratch2;
2389 
2390   static address field_branch_table[number_of_states],
2391                  static_branch_table[number_of_states];
2392 
2393   address* branch_table = is_static ? static_branch_table : field_branch_table;
2394 
2395   // Get field offset.
2396   resolve_cache_and_index(byte_no, Rcache, Rscratch, sizeof(u2));
2397 


2441 #ifdef ASSERT
2442   __ bind(LFlagInvalid);
2443   __ stop("got invalid flag", 0x654);
2444 
2445   // __ bind(Lvtos);
2446   address pc_before_fence = __ pc();
2447   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2448   assert(__ pc() - pc_before_fence == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
2449   assert(branch_table[vtos] == 0, "can't compute twice");
2450   branch_table[vtos] = __ pc(); // non-volatile_entry point
2451   __ stop("vtos unexpected", 0x655);
2452 #endif
2453 
2454   __ align(32, 28, 28); // Align load.
2455   // __ bind(Ldtos);
2456   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2457   assert(branch_table[dtos] == 0, "can't compute twice");
2458   branch_table[dtos] = __ pc(); // non-volatile_entry point
2459   __ lfdx(F15_ftos, Rclass_or_obj, Roffset);
2460   __ push(dtos);
2461   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_dgetfield, Rbc, Rscratch);
2462   {
2463     Label acquire_double;
2464     __ beq(CCR6, acquire_double); // Volatile?
2465     __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2466 
2467     __ bind(acquire_double);
2468     __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
2469     __ beq_predict_taken(CCR0, Lisync);
2470     __ b(Lisync); // In case of NAN.
2471   }
2472 
2473   __ align(32, 28, 28); // Align load.
2474   // __ bind(Lftos);
2475   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2476   assert(branch_table[ftos] == 0, "can't compute twice");
2477   branch_table[ftos] = __ pc(); // non-volatile_entry point
2478   __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
2479   __ push(ftos);
2480   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_fgetfield, Rbc, Rscratch); }
2481   {
2482     Label acquire_float;
2483     __ beq(CCR6, acquire_float); // Volatile?
2484     __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2485 
2486     __ bind(acquire_float);
2487     __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
2488     __ beq_predict_taken(CCR0, Lisync);
2489     __ b(Lisync); // In case of NAN.
2490   }
2491 
2492   __ align(32, 28, 28); // Align load.
2493   // __ bind(Litos);
2494   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2495   assert(branch_table[itos] == 0, "can't compute twice");
2496   branch_table[itos] = __ pc(); // non-volatile_entry point
2497   __ lwax(R17_tos, Rclass_or_obj, Roffset);
2498   __ push(itos);
2499   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_igetfield, Rbc, Rscratch);
2500   __ beq(CCR6, Lacquire); // Volatile?
2501   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2502 
2503   __ align(32, 28, 28); // Align load.
2504   // __ bind(Lltos);
2505   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2506   assert(branch_table[ltos] == 0, "can't compute twice");
2507   branch_table[ltos] = __ pc(); // non-volatile_entry point
2508   __ ldx(R17_tos, Rclass_or_obj, Roffset);
2509   __ push(ltos);
2510   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_lgetfield, Rbc, Rscratch);
2511   __ beq(CCR6, Lacquire); // Volatile?
2512   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2513 
2514   __ align(32, 28, 28); // Align load.
2515   // __ bind(Lbtos);
2516   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2517   assert(branch_table[btos] == 0, "can't compute twice");
2518   branch_table[btos] = __ pc(); // non-volatile_entry point
2519   __ lbzx(R17_tos, Rclass_or_obj, Roffset);
2520   __ extsb(R17_tos, R17_tos);
2521   __ push(btos);
2522   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
2523   __ beq(CCR6, Lacquire); // Volatile?
2524   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2525 
2526   __ align(32, 28, 28); // Align load.
2527   // __ bind(Lctos);
2528   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2529   assert(branch_table[ctos] == 0, "can't compute twice");
2530   branch_table[ctos] = __ pc(); // non-volatile_entry point
2531   __ lhzx(R17_tos, Rclass_or_obj, Roffset);
2532   __ push(ctos);
2533   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_cgetfield, Rbc, Rscratch);
2534   __ beq(CCR6, Lacquire); // Volatile?
2535   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2536 
2537   __ align(32, 28, 28); // Align load.
2538   // __ bind(Lstos);
2539   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2540   assert(branch_table[stos] == 0, "can't compute twice");
2541   branch_table[stos] = __ pc(); // non-volatile_entry point
2542   __ lhax(R17_tos, Rclass_or_obj, Roffset);
2543   __ push(stos);
2544   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_sgetfield, Rbc, Rscratch);
2545   __ beq(CCR6, Lacquire); // Volatile?
2546   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2547 
2548   __ align(32, 28, 28); // Align load.
2549   // __ bind(Latos);
2550   __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2551   assert(branch_table[atos] == 0, "can't compute twice");
2552   branch_table[atos] = __ pc(); // non-volatile_entry point
2553   __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
2554   __ verify_oop(R17_tos);
2555   __ push(atos);
2556   //__ dcbt(R17_tos); // prefetch
2557   if (!is_static && rc == MAY_REWRITE) patch_bytecode(Bytecodes::_fast_agetfield, Rbc, Rscratch);
2558   __ beq(CCR6, Lacquire); // Volatile?
2559   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2560 
2561   __ align(32, 12);
2562   __ bind(Lacquire);
2563   __ twi_0(R17_tos);
2564   __ bind(Lisync);
2565   __ isync(); // acquire
2566 
2567 #ifdef ASSERT
2568   for (int i = 0; i<number_of_states; ++i) {
2569     assert(branch_table[i], "get initialization");
2570     //tty->print_cr("get: %s_branch_table[%d] = 0x%llx (opcode 0x%llx)",
2571     //              is_static ? "static" : "field", i, branch_table[i], *((unsigned int*)branch_table[i]));
2572   }
2573 #endif
2574 }
2575 
2576 void TemplateTable::getfield(int byte_no) {
2577   getfield_or_static(byte_no, false);
2578 }
2579 
2580 void TemplateTable::nofast_getfield(int byte_no) {
2581   getfield_or_static(byte_no, false, MAY_NOT_REWRITE);
2582 }
2583 
2584 void TemplateTable::getstatic(int byte_no) {
2585   getfield_or_static(byte_no, true);
2586 }
2587 
2588 // The registers cache and index expected to be set before call.
2589 // The function may destroy various registers, just not the cache and index registers.
2590 void TemplateTable::jvmti_post_field_mod(Register Rcache, Register Rscratch, bool is_static) {
2591 
2592   assert_different_registers(Rcache, Rscratch, R6_ARG4);
2593 
2594   if (JvmtiExport::can_post_field_modification()) {
2595     Label Lno_field_mod_post;
2596 
2597     // Check if post field access in enabled.
2598     int offs = __ load_const_optimized(Rscratch, JvmtiExport::get_field_modification_count_addr(), R0, true);
2599     __ lwz(Rscratch, offs, Rscratch);
2600 
2601     __ cmpwi(CCR0, Rscratch, 0);
2602     __ beq(CCR0, Lno_field_mod_post);
2603 


2654 
2655     // In case of the fast versions, value lives in registers => put it back on tos.
2656     switch(bytecode()) {
2657       case Bytecodes::_fast_aputfield: __ pop_ptr(); break;
2658       case Bytecodes::_fast_iputfield: // Fall through
2659       case Bytecodes::_fast_bputfield: // Fall through
2660       case Bytecodes::_fast_cputfield: // Fall through
2661       case Bytecodes::_fast_sputfield: __ pop_i(); break;
2662       case Bytecodes::_fast_lputfield: __ pop_l(); break;
2663       case Bytecodes::_fast_fputfield: __ pop_f(); break;
2664       case Bytecodes::_fast_dputfield: __ pop_d(); break;
2665       default: break; // Nothin' to do.
2666     }
2667 
2668     __ align(32, 12);
2669     __ bind(Lno_field_mod_post);
2670   }
2671 }
2672 
2673 // PPC64: implement volatile stores as release-store (return bytecode contains an additional release).
2674 void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteControl rc) {
2675   Label Lvolatile;
2676 
2677   const Register Rcache        = R5_ARG3,  // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod).
2678                  Rclass_or_obj = R31,      // Needs to survive C call.
2679                  Roffset       = R22_tmp2, // Needs to survive C call.
2680                  Rflags        = R3_ARG1,
2681                  Rbtable       = R4_ARG2,
2682                  Rscratch      = R11_scratch1,
2683                  Rscratch2     = R12_scratch2,
2684                  Rscratch3     = R6_ARG4,
2685                  Rbc           = Rscratch3;
2686   const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).
2687 
2688   static address field_branch_table[number_of_states],
2689                  static_branch_table[number_of_states];
2690 
2691   address* branch_table = is_static ? static_branch_table : field_branch_table;
2692 
2693   // Stack (grows up):
2694   //  value


2728   __ bind(LFlagInvalid);
2729   __ stop("got invalid flag", 0x656);
2730 
2731   // __ bind(Lvtos);
2732   address pc_before_release = __ pc();
2733   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2734   assert(__ pc() - pc_before_release == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
2735   assert(branch_table[vtos] == 0, "can't compute twice");
2736   branch_table[vtos] = __ pc(); // non-volatile_entry point
2737   __ stop("vtos unexpected", 0x657);
2738 #endif
2739 
2740   __ align(32, 28, 28); // Align pop.
2741   // __ bind(Ldtos);
2742   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2743   assert(branch_table[dtos] == 0, "can't compute twice");
2744   branch_table[dtos] = __ pc(); // non-volatile_entry point
2745   __ pop(dtos);
2746   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2747   __ stfdx(F15_ftos, Rclass_or_obj, Roffset);
2748   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_dputfield, Rbc, Rscratch, true, byte_no); }
2749   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2750     __ beq(CR_is_vol, Lvolatile); // Volatile?
2751   }
2752   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2753 
2754   __ align(32, 28, 28); // Align pop.
2755   // __ bind(Lftos);
2756   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2757   assert(branch_table[ftos] == 0, "can't compute twice");
2758   branch_table[ftos] = __ pc(); // non-volatile_entry point
2759   __ pop(ftos);
2760   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2761   __ stfsx(F15_ftos, Rclass_or_obj, Roffset);
2762   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_fputfield, Rbc, Rscratch, true, byte_no); }
2763   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2764     __ beq(CR_is_vol, Lvolatile); // Volatile?
2765   }
2766   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2767 
2768   __ align(32, 28, 28); // Align pop.
2769   // __ bind(Litos);
2770   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2771   assert(branch_table[itos] == 0, "can't compute twice");
2772   branch_table[itos] = __ pc(); // non-volatile_entry point
2773   __ pop(itos);
2774   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2775   __ stwx(R17_tos, Rclass_or_obj, Roffset);
2776   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_iputfield, Rbc, Rscratch, true, byte_no); }
2777   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2778     __ beq(CR_is_vol, Lvolatile); // Volatile?
2779   }
2780   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2781 
2782   __ align(32, 28, 28); // Align pop.
2783   // __ bind(Lltos);
2784   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2785   assert(branch_table[ltos] == 0, "can't compute twice");
2786   branch_table[ltos] = __ pc(); // non-volatile_entry point
2787   __ pop(ltos);
2788   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2789   __ stdx(R17_tos, Rclass_or_obj, Roffset);
2790   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_lputfield, Rbc, Rscratch, true, byte_no); }
2791   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2792     __ beq(CR_is_vol, Lvolatile); // Volatile?
2793   }
2794   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2795 
2796   __ align(32, 28, 28); // Align pop.
2797   // __ bind(Lbtos);
2798   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2799   assert(branch_table[btos] == 0, "can't compute twice");
2800   branch_table[btos] = __ pc(); // non-volatile_entry point
2801   __ pop(btos);
2802   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2803   __ stbx(R17_tos, Rclass_or_obj, Roffset);
2804   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_bputfield, Rbc, Rscratch, true, byte_no); }
2805   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2806     __ beq(CR_is_vol, Lvolatile); // Volatile?
2807   }
2808   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2809 
2810   __ align(32, 28, 28); // Align pop.
2811   // __ bind(Lctos);
2812   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2813   assert(branch_table[ctos] == 0, "can't compute twice");
2814   branch_table[ctos] = __ pc(); // non-volatile_entry point
2815   __ pop(ctos);
2816   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1..
2817   __ sthx(R17_tos, Rclass_or_obj, Roffset);
2818   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_cputfield, Rbc, Rscratch, true, byte_no); }
2819   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2820     __ beq(CR_is_vol, Lvolatile); // Volatile?
2821   }
2822   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2823 
2824   __ align(32, 28, 28); // Align pop.
2825   // __ bind(Lstos);
2826   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2827   assert(branch_table[stos] == 0, "can't compute twice");
2828   branch_table[stos] = __ pc(); // non-volatile_entry point
2829   __ pop(stos);
2830   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
2831   __ sthx(R17_tos, Rclass_or_obj, Roffset);
2832   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_sputfield, Rbc, Rscratch, true, byte_no); }
2833   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2834     __ beq(CR_is_vol, Lvolatile); // Volatile?
2835   }
2836   __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2837 
2838   __ align(32, 28, 28); // Align pop.
2839   // __ bind(Latos);
2840   __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2841   assert(branch_table[atos] == 0, "can't compute twice");
2842   branch_table[atos] = __ pc(); // non-volatile_entry point
2843   __ pop(atos);
2844   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // kills R11_scratch1
2845   do_oop_store(_masm, Rclass_or_obj, Roffset, R17_tos, Rscratch, Rscratch2, Rscratch3, _bs->kind(), false /* precise */, true /* check null */);
2846   if (!is_static && rc == MAY_REWRITE) { patch_bytecode(Bytecodes::_fast_aputfield, Rbc, Rscratch, true, byte_no); }
2847   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
2848     __ beq(CR_is_vol, Lvolatile); // Volatile?
2849     __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
2850 
2851     __ align(32, 12);
2852     __ bind(Lvolatile);
2853     __ fence();
2854   }
2855   // fallthru: __ b(Lexit);
2856 
2857 #ifdef ASSERT
2858   for (int i = 0; i<number_of_states; ++i) {
2859     assert(branch_table[i], "put initialization");
2860     //tty->print_cr("put: %s_branch_table[%d] = 0x%llx (opcode 0x%llx)",
2861     //              is_static ? "static" : "field", i, branch_table[i], *((unsigned int*)branch_table[i]));
2862   }
2863 #endif
2864 }
2865 
2866 void TemplateTable::putfield(int byte_no) {
2867   putfield_or_static(byte_no, false);
2868 }
2869 
2870 void TemplateTable::nofast_putfield(int byte_no) {
2871   putfield_or_static(byte_no, false, MAY_NOT_REWRITE);
2872 }
2873 
2874 void TemplateTable::putstatic(int byte_no) {
2875   putfield_or_static(byte_no, true);
2876 }
2877 
2878 // See SPARC. On PPC64, we have a different jvmti_post_field_mod which does the job.
2879 void TemplateTable::jvmti_post_fast_field_mod() {
2880   __ should_not_reach_here();
2881 }
2882 
2883 void TemplateTable::fast_storefield(TosState state) {
2884   transition(state, vtos);
2885 
2886   const Register Rcache        = R5_ARG3,  // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod).
2887                  Rclass_or_obj = R31,      // Needs to survive C call.
2888                  Roffset       = R22_tmp2, // Needs to survive C call.
2889                  Rflags        = R3_ARG1,
2890                  Rscratch      = R11_scratch1,
2891                  Rscratch2     = R12_scratch2,
2892                  Rscratch3     = R4_ARG2;
2893   const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).


3180 //
3181 // Output:
3182 //   - Rmethod:        The method to invoke next.
3183 //   - Rret_addr:      The return address to return to.
3184 //   - Rindex:         MethodType (invokehandle) or CallSite obj (invokedynamic)
3185 //   - Rrecv:          Cache for "this" pointer, might be noreg if static call.
3186 //   - Rflags:         Method flags from const pool cache.
3187 //
3188 //  Kills:
3189 //   - Rscratch1
3190 //
3191 void TemplateTable::prepare_invoke(int byte_no,
3192                                    Register Rmethod,  // linked method (or i-klass)
3193                                    Register Rret_addr,// return address
3194                                    Register Rindex,   // itable index, MethodType, etc.
3195                                    Register Rrecv,    // If caller wants to see it.
3196                                    Register Rflags,   // If caller wants to test it.
3197                                    Register Rscratch
3198                                    ) {
3199   // Determine flags.
3200   const Bytecodes::Code code = bytecode() == Bytecodes::_nofast_invokevirtual ? Bytecodes::_invokevirtual : bytecode();
3201   const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
3202   const bool is_invokedynamic    = code == Bytecodes::_invokedynamic;
3203   const bool is_invokehandle     = code == Bytecodes::_invokehandle;
3204   const bool is_invokevirtual    = code == Bytecodes::_invokevirtual;
3205   const bool is_invokespecial    = code == Bytecodes::_invokespecial;
3206   const bool load_receiver       = (Rrecv != noreg);
3207   assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), "");
3208 
3209   assert_different_registers(Rmethod, Rindex, Rflags, Rscratch);
3210   assert_different_registers(Rmethod, Rrecv, Rflags, Rscratch);
3211   assert_different_registers(Rret_addr, Rscratch);
3212 
3213   load_invoke_cp_cache_entry(byte_no, Rmethod, Rindex, Rflags, is_invokevirtual, false, is_invokedynamic);
3214 
3215   // Saving of SP done in call_from_interpreter.
3216 
3217   // Maybe push "appendix" to arguments.
3218   if (is_invokedynamic || is_invokehandle) {
3219     Label Ldone;
3220     __ rldicl_(R0, Rflags, 64-ConstantPoolCacheEntry::has_appendix_shift, 63);


3253 
3254 // Helper for virtual calls. Load target out of vtable and jump off!
3255 // Kills all passed registers.
3256 void TemplateTable::generate_vtable_call(Register Rrecv_klass, Register Rindex, Register Rret, Register Rtemp) {
3257 
3258   assert_different_registers(Rrecv_klass, Rtemp, Rret);
3259   const Register Rtarget_method = Rindex;
3260 
3261   // Get target method & entry point.
3262   const int base = InstanceKlass::vtable_start_offset() * wordSize;
3263   // Calc vtable addr scale the vtable index by 8.
3264   __ sldi(Rindex, Rindex, exact_log2(vtableEntry::size() * wordSize));
3265   // Load target.
3266   __ addi(Rrecv_klass, Rrecv_klass, base + vtableEntry::method_offset_in_bytes());
3267   __ ldx(Rtarget_method, Rindex, Rrecv_klass);
3268   // Argument and return type profiling.
3269   __ profile_arguments_type(Rtarget_method, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */, true);
3270   __ call_from_interpreter(Rtarget_method, Rret, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */);
3271 }
3272 

3273 void TemplateTable::invokevirtual(int byte_no) {
3274   invokevirtual_internal(byte_no);
3275 }
3276 
3277 void TemplateTable::nofast_invokevirtual(int byte_no) {
3278   invokevirtual_internal(byte_no, MAY_NOT_REWRITE);
3279 }
3280 
3281 // Virtual or final call. Final calls are rewritten on the fly to run through "fast_finalcall" next time.
3282 void TemplateTable::invokevirtual_internal(int byte_no, RewriteControl rc) {
3283 
3284   Register Rtable_addr = R11_scratch1,
3285            Rret_type = R12_scratch2,
3286            Rret_addr = R5_ARG3,
3287            Rflags = R22_tmp2, // Should survive C call.
3288            Rrecv = R3_ARG1,
3289            Rrecv_klass = Rrecv,
3290            Rvtableindex_or_method = R31, // Should survive C call.
3291            Rnum_params = R4_ARG2,
3292            Rnew_bc = R6_ARG4;
3293 
3294   Label LnotFinal;
3295 
3296   load_invoke_cp_cache_entry(byte_no, Rvtableindex_or_method, noreg, Rflags, /*virtual*/ true, false, false);
3297 
3298   __ testbitdi(CCR0, R0, Rflags, ConstantPoolCacheEntry::is_vfinal_shift);
3299   __ bfalse(CCR0, LnotFinal);
3300   
3301   if (rc == MAY_REWRITE) {
3302     patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2);
3303   }
3304   invokevfinal_helper(Rvtableindex_or_method, Rflags, R11_scratch1, R12_scratch2);
3305 
3306   __ align(32, 12);
3307   __ bind(LnotFinal);
3308   // Load "this" pointer (receiver).
3309   __ rldicl(Rnum_params, Rflags, 64, 48);
3310   __ load_receiver(Rnum_params, Rrecv);
3311   __ verify_oop(Rrecv);
3312 
3313   // Get return type. It's coded into the upper 4 bits of the lower half of the 64 bit value.
3314   __ rldicl(Rret_type, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
3315   __ load_dispatch_table(Rtable_addr, Interpreter::invoke_return_entry_table());
3316   __ sldi(Rret_type, Rret_type, LogBytesPerWord);
3317   __ ldx(Rret_addr, Rret_type, Rtable_addr);
3318   __ null_check_throw(Rrecv, oopDesc::klass_offset_in_bytes(), R11_scratch1);
3319   __ load_klass(Rrecv_klass, Rrecv);
3320   __ verify_klass_ptr(Rrecv_klass);
3321   __ profile_virtual_call(Rrecv_klass, R11_scratch1, R12_scratch2, false);
3322 
3323   generate_vtable_call(Rrecv_klass, Rvtableindex_or_method, Rret_addr, R11_scratch1);