< prev index next >

src/hotspot/cpu/s390/sharedRuntime_s390.cpp

Print this page

2537   __ flush();
2538   //////////////////////////////////////////////////////////////////////
2539   // end of code generation
2540   //////////////////////////////////////////////////////////////////////
2541 
2542 
2543   nmethod *nm = nmethod::new_native_nmethod(method,
2544                                             compile_id,
2545                                             masm->code(),
2546                                             (int)(wrapper_VEPStart-wrapper_CodeStart),
2547                                             (int)(wrapper_FrameDone-wrapper_CodeStart),
2548                                             stack_slots / VMRegImpl::slots_per_word,
2549                                             (method_is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
2550                                             in_ByteSize(lock_offset),
2551                                             oop_maps);
2552 
2553   return nm;
2554 }
2555 
2556 static address gen_c2i_adapter(MacroAssembler  *masm,
2557                                int total_args_passed,
2558                                int comp_args_on_stack,
2559                                const BasicType *sig_bt,
2560                                const VMRegPair *regs,
2561                                Label &skip_fixup) {
2562   // Before we get into the guts of the C2I adapter, see if we should be here
2563   // at all. We've come from compiled code and are attempting to jump to the
2564   // interpreter, which means the caller made a static call to get here
2565   // (vcalls always get a compiled target if there is one). Check for a
2566   // compiled target. If there is one, we need to patch the caller's call.
2567 
2568   // These two defs MUST MATCH code in gen_i2c2i_adapter!
2569   const Register ientry = Z_R11;
2570   const Register code   = Z_R11;
2571 
2572   address c2i_entrypoint;
2573   Label   patch_callsite;
2574 
2575   // Regular (verified) c2i entry point.
2576   c2i_entrypoint = __ pc();
2577 
2578   // Call patching needed?
2579   __ load_and_test_long(Z_R0_scratch, method_(code));
2580   __ z_lg(ientry, method_(interpreter_entry));  // Preload interpreter entry (also if patching).
2581   __ z_brne(patch_callsite);                    // Patch required if code isn't null (compiled target exists).
2582 
2583   __ bind(skip_fixup);  // Return point from patch_callsite.
2584 
2585   // Since all args are passed on the stack, total_args_passed*wordSize is the
2586   // space we need. We need ABI scratch area but we use the caller's since
2587   // it has already been allocated.
2588 
2589   const int abi_scratch = frame::z_top_ijava_frame_abi_size;
2590   int       extraspace  = align_up(total_args_passed, 2)*wordSize + abi_scratch;
2591   Register  sender_SP   = Z_R10;
2592   Register  value       = Z_R12;
2593 
2594   // Remember the senderSP so we can pop the interpreter arguments off of the stack.
2595   // In addition, template interpreter expects initial_caller_sp in Z_R10.
2596   __ z_lgr(sender_SP, Z_SP);
2597 
2598   // This should always fit in 14 bit immediate.
2599   __ resize_frame(-extraspace, Z_R0_scratch);
2600 
2601   // We use the caller's ABI scratch area (out_preserved_stack_slots) for the initial
2602   // args. This essentially moves the callers ABI scratch area from the top to the
2603   // bottom of the arg area.
2604 
2605   int st_off =  extraspace - wordSize;
2606 
2607   // Now write the args into the outgoing interpreter space.
2608   for (int i = 0; i < total_args_passed; i++) {


2609     VMReg r_1 = regs[i].first();
2610     VMReg r_2 = regs[i].second();
2611     if (!r_1->is_valid()) {
2612       assert(!r_2->is_valid(), "");
2613       continue;
2614     }
2615     if (r_1->is_stack()) {
2616       // The calling convention produces OptoRegs that ignore the preserve area (abi scratch).
2617       // We must account for it here.
2618       int ld_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
2619 
2620       if (!r_2->is_valid()) {
2621         __ z_mvc(Address(Z_SP, st_off), Address(sender_SP, ld_off), sizeof(void*));
2622       } else {
2623         // longs are given 2 64-bit slots in the interpreter,
2624         // but the data is passed in only 1 slot.
2625         if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2626 #ifdef ASSERT
2627           __ clear_mem(Address(Z_SP, st_off), sizeof(void *));
2628 #endif
2629           st_off -= wordSize;
2630         }
2631         __ z_mvc(Address(Z_SP, st_off), Address(sender_SP, ld_off), sizeof(void*));
2632       }
2633     } else {
2634       if (r_1->is_Register()) {
2635         if (!r_2->is_valid()) {
2636           __ z_st(r_1->as_Register(), st_off, Z_SP);
2637         } else {
2638           // longs are given 2 64-bit slots in the interpreter, but the
2639           // data is passed in only 1 slot.
2640           if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2641 #ifdef ASSERT
2642             __ clear_mem(Address(Z_SP, st_off), sizeof(void *));
2643 #endif
2644             st_off -= wordSize;
2645           }
2646           __ z_stg(r_1->as_Register(), st_off, Z_SP);
2647         }
2648       } else {
2649         assert(r_1->is_FloatRegister(), "");
2650         if (!r_2->is_valid()) {
2651           __ z_ste(r_1->as_FloatRegister(), st_off, Z_SP);
2652         } else {
2653           // In 64bit, doubles are given 2 64-bit slots in the interpreter, but the
2654           // data is passed in only 1 slot.
2655           // One of these should get known junk...
2656 #ifdef ASSERT
2657           __ z_lzdr(Z_F1);
2658           __ z_std(Z_F1, st_off, Z_SP);
2659 #endif
2660           st_off-=wordSize;

2685   __ bind(patch_callsite);
2686 
2687   RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers);
2688   __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite), Z_method, Z_R14);
2689   RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers);
2690   __ z_bru(skip_fixup);
2691 
2692   // end of out-of-line code
2693 
2694   return c2i_entrypoint;
2695 }
2696 
2697 // On entry, the following registers are set
2698 //
2699 //    Z_thread  r8  - JavaThread*
2700 //    Z_method  r9  - callee's method (method to be invoked)
2701 //    Z_esp     r7  - operand (or expression) stack pointer of caller. one slot above last arg.
2702 //    Z_SP      r15 - SP prepared by call stub such that caller's outgoing args are near top
2703 //
2704 void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
2705                                     int total_args_passed,
2706                                     int comp_args_on_stack,
2707                                     const BasicType *sig_bt,
2708                                     const VMRegPair *regs) {
2709   const Register value = Z_R12;
2710   const Register ld_ptr= Z_esp;

2711 
2712   int ld_offset = total_args_passed * wordSize;
2713 
2714   // Cut-out for having no stack args.
2715   if (comp_args_on_stack) {
2716     // Sig words on the stack are greater than VMRegImpl::stack0. Those in
2717     // registers are below. By subtracting stack0, we either get a negative
2718     // number (all values in registers) or the maximum stack slot accessed.
2719     // Convert VMRegImpl (4 byte) stack slots to words.
2720     int comp_words_on_stack = align_up(comp_args_on_stack*VMRegImpl::stack_slot_size, wordSize)>>LogBytesPerWord;
2721     // Round up to miminum stack alignment, in wordSize
2722     comp_words_on_stack = align_up(comp_words_on_stack, 2);
2723 
2724     __ resize_frame(-comp_words_on_stack*wordSize, Z_R0_scratch);
2725   }
2726 
2727   // Now generate the shuffle code. Pick up all register args and move the
2728   // rest through register value=Z_R12.
2729   for (int i = 0; i < total_args_passed; i++) {
2730     if (sig_bt[i] == T_VOID) {
2731       assert(i > 0 && (sig_bt[i-1] == T_LONG || sig_bt[i-1] == T_DOUBLE), "missing half");

2732       continue;
2733     }
2734 
2735     // Pick up 0, 1 or 2 words from ld_ptr.
2736     assert(!regs[i].second()->is_valid() || regs[i].first()->next() == regs[i].second(),
2737            "scrambled load targets?");
2738     VMReg r_1 = regs[i].first();
2739     VMReg r_2 = regs[i].second();
2740     if (!r_1->is_valid()) {
2741       assert(!r_2->is_valid(), "");
2742       continue;
2743     }
2744     if (r_1->is_FloatRegister()) {
2745       if (!r_2->is_valid()) {
2746         __ z_le(r_1->as_FloatRegister(), ld_offset, ld_ptr);
2747         ld_offset-=wordSize;
2748       } else {
2749         // Skip the unused interpreter slot.
2750         __ z_ld(r_1->as_FloatRegister(), ld_offset - wordSize, ld_ptr);
2751         ld_offset -= 2 * wordSize;
2752       }
2753     } else {
2754       if (r_1->is_stack()) {
2755         // Must do a memory to memory move.
2756         int st_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
2757 
2758         if (!r_2->is_valid()) {
2759           __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2760         } else {
2761           // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2762           // data is passed in only 1 slot.
2763           if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2764             ld_offset -= wordSize;
2765           }
2766           __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2767         }
2768       } else {
2769         if (!r_2->is_valid()) {
2770           // Not sure we need to do this but it shouldn't hurt.
2771           if (is_reference_type(sig_bt[i]) || sig_bt[i] == T_ADDRESS) {
2772             __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2773           } else {
2774             __ z_l(r_1->as_Register(), ld_offset, ld_ptr);
2775           }
2776         } else {
2777           // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2778           // data is passed in only 1 slot.
2779           if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2780             ld_offset -= wordSize;
2781           }
2782           __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2783         }
2784       }
2785       ld_offset -= wordSize;
2786     }
2787   }
2788 
2789   __ push_cont_fastpath(); // Set JavaThread::_cont_fastpath to the sp of the oldest interpreted frame we know about
2790 
2791   // Jump to the compiled code just as if compiled code was doing it.
2792   // load target address from method:
2793   __ z_lg(Z_R1_scratch, Address(Z_method, Method::from_compiled_offset()));
2794 
2795   // Store method into thread->callee_target.
2796   // 6243940: We might end up in handle_wrong_method if
2797   // the callee is deoptimized as we race thru here. If that
2798   // happens we don't want to take a safepoint because the
2799   // caller frame will look interpreted and arguments are now
2800   // "compiled" so it is much better to make this transition
2801   // invisible to the stack walking code. Unfortunately, if
2802   // we try and find the callee by normal means a safepoint
2803   // is possible. So we stash the desired callee in the thread
2804   // and the vm will find it there should this case occur.
2805   __ z_stg(Z_method, thread_(callee_target));
2806 
2807   __ z_br(Z_R1_scratch);
2808 }
2809 
2810 void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
2811                                             int total_args_passed,
2812                                             int comp_args_on_stack,
2813                                             const BasicType *sig_bt,
2814                                             const VMRegPair *regs,
2815                                             address entry_address[AdapterBlob::ENTRY_COUNT]) {






2816   __ align(CodeEntryAlignment);
2817   entry_address[AdapterBlob::I2C] = __ pc();
2818   gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
2819 
2820   Label skip_fixup;
2821   {
2822     Label ic_miss;
2823 
2824     // Out-of-line call to ic_miss handler.
2825     __ call_ic_miss_handler(ic_miss, 0x11, 0, Z_R1_scratch);
2826 
2827     // Unverified Entry Point UEP
2828     __ align(CodeEntryAlignment);
2829     entry_address[AdapterBlob::C2I_Unverified] = __ pc();
2830 
2831     __ ic_check(2);
2832     __ z_lg(Z_method, Address(Z_inline_cache, CompiledICData::speculated_method_offset()));
2833     // This def MUST MATCH code in gen_c2i_adapter!
2834     const Register code = Z_R11;
2835 
2836     __ load_and_test_long(Z_R0, method_(code));
2837     __ z_brne(ic_miss);  // Cache miss: call runtime to handle this.
2838 

2843 
2844   // Class initialization barrier for static methods
2845   entry_address[AdapterBlob::C2I_No_Clinit_Check] = nullptr;
2846   assert(VM_Version::supports_fast_class_init_checks(), "sanity");
2847   Label L_skip_barrier;
2848 
2849   // Bypass the barrier for non-static methods
2850   __ testbit_ushort(Address(Z_method, Method::access_flags_offset()), JVM_ACC_STATIC_BIT);
2851   __ z_bfalse(L_skip_barrier); // non-static
2852 
2853   Register klass = Z_R11;
2854   __ load_method_holder(klass, Z_method);
2855   __ clinit_barrier(klass, Z_thread, &L_skip_barrier /*L_fast_path*/);
2856 
2857   __ load_const_optimized(klass, SharedRuntime::get_handle_wrong_method_stub());
2858   __ z_br(klass);
2859 
2860   __ bind(L_skip_barrier);
2861   entry_address[AdapterBlob::C2I_No_Clinit_Check] = __ pc();
2862 
2863   gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
2864   return;
2865 }
2866 
2867 // This function returns the adjust size (in number of words) to a c2i adapter
2868 // activation for use during deoptimization.
2869 //
2870 // Actually only compiled frames need to be adjusted, but it
2871 // doesn't harm to adjust entry and interpreter frames, too.
2872 //
2873 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals) {
2874   assert(callee_locals >= callee_parameters,
2875           "test and remove; got more parms than locals");
2876   // Handle the abi adjustment here instead of doing it in push_skeleton_frames.
2877   return (callee_locals - callee_parameters) * Interpreter::stackElementWords +
2878          frame::z_parent_ijava_frame_abi_size / BytesPerWord;
2879 }
2880 
2881 uint SharedRuntime::in_preserve_stack_slots() {
2882   return frame::jit_in_preserve_size_in_4_byte_units;
2883 }

3927 
3928   __ reset_last_Java_frame();
3929 
3930   __ pop_frame();
3931   __ restore_return_pc();
3932   __ z_br(Z_R14);
3933 
3934   OopMapSet* oop_maps = new OopMapSet();
3935   OopMap* map = new OopMap(framesize, 0);
3936   oop_maps->add_gc_map(calls_return_pc - start, map);
3937 
3938   RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
3939     RuntimeStub::new_runtime_stub(name, &code, frame_complete,
3940                                   (framesize >> (LogBytesPerWord - LogBytesPerInt)),
3941                                   oop_maps, false);
3942 
3943   return stub;
3944 }
3945 
3946 #endif // INCLUDE_JFR





















2537   __ flush();
2538   //////////////////////////////////////////////////////////////////////
2539   // end of code generation
2540   //////////////////////////////////////////////////////////////////////
2541 
2542 
2543   nmethod *nm = nmethod::new_native_nmethod(method,
2544                                             compile_id,
2545                                             masm->code(),
2546                                             (int)(wrapper_VEPStart-wrapper_CodeStart),
2547                                             (int)(wrapper_FrameDone-wrapper_CodeStart),
2548                                             stack_slots / VMRegImpl::slots_per_word,
2549                                             (method_is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
2550                                             in_ByteSize(lock_offset),
2551                                             oop_maps);
2552 
2553   return nm;
2554 }
2555 
2556 static address gen_c2i_adapter(MacroAssembler  *masm,

2557                                int comp_args_on_stack,
2558                                const GrowableArray<SigEntry>* sig,
2559                                const VMRegPair *regs,
2560                                Label &skip_fixup) {
2561   // Before we get into the guts of the C2I adapter, see if we should be here
2562   // at all. We've come from compiled code and are attempting to jump to the
2563   // interpreter, which means the caller made a static call to get here
2564   // (vcalls always get a compiled target if there is one). Check for a
2565   // compiled target. If there is one, we need to patch the caller's call.
2566 
2567   // These two defs MUST MATCH code in gen_i2c2i_adapter!
2568   const Register ientry = Z_R11;
2569   const Register code   = Z_R11;
2570 
2571   address c2i_entrypoint;
2572   Label   patch_callsite;
2573 
2574   // Regular (verified) c2i entry point.
2575   c2i_entrypoint = __ pc();
2576 
2577   // Call patching needed?
2578   __ load_and_test_long(Z_R0_scratch, method_(code));
2579   __ z_lg(ientry, method_(interpreter_entry));  // Preload interpreter entry (also if patching).
2580   __ z_brne(patch_callsite);                    // Patch required if code isn't null (compiled target exists).
2581 
2582   __ bind(skip_fixup);  // Return point from patch_callsite.
2583 
2584   // Since all args are passed on the stack, total_args_passed*wordSize is the
2585   // space we need. We need ABI scratch area but we use the caller's since
2586   // it has already been allocated.
2587   int       total_args_passed = sig->length();
2588   const int abi_scratch = frame::z_top_ijava_frame_abi_size;
2589   int       extraspace  = align_up(total_args_passed, 2)*wordSize + abi_scratch;
2590   Register  sender_SP   = Z_R10;
2591   Register  value       = Z_R12;
2592 
2593   // Remember the senderSP so we can pop the interpreter arguments off of the stack.
2594   // In addition, template interpreter expects initial_caller_sp in Z_R10.
2595   __ z_lgr(sender_SP, Z_SP);
2596 
2597   // This should always fit in 14 bit immediate.
2598   __ resize_frame(-extraspace, Z_R0_scratch);
2599 
2600   // We use the caller's ABI scratch area (out_preserved_stack_slots) for the initial
2601   // args. This essentially moves the callers ABI scratch area from the top to the
2602   // bottom of the arg area.
2603 
2604   int st_off =  extraspace - wordSize;
2605 
2606   // Now write the args into the outgoing interpreter space.
2607   for (int i = 0; i < total_args_passed; i++) {
2608     BasicType bt = sig->at(i)._bt;
2609 
2610     VMReg r_1 = regs[i].first();
2611     VMReg r_2 = regs[i].second();
2612     if (!r_1->is_valid()) {
2613       assert(!r_2->is_valid(), "");
2614       continue;
2615     }
2616     if (r_1->is_stack()) {
2617       // The calling convention produces OptoRegs that ignore the preserve area (abi scratch).
2618       // We must account for it here.
2619       int ld_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
2620 
2621       if (!r_2->is_valid()) {
2622         __ z_mvc(Address(Z_SP, st_off), Address(sender_SP, ld_off), sizeof(void*));
2623       } else {
2624         // longs are given 2 64-bit slots in the interpreter,
2625         // but the data is passed in only 1 slot.
2626         if (bt == T_LONG || bt == T_DOUBLE) {
2627 #ifdef ASSERT
2628           __ clear_mem(Address(Z_SP, st_off), sizeof(void *));
2629 #endif
2630           st_off -= wordSize;
2631         }
2632         __ z_mvc(Address(Z_SP, st_off), Address(sender_SP, ld_off), sizeof(void*));
2633       }
2634     } else {
2635       if (r_1->is_Register()) {
2636         if (!r_2->is_valid()) {
2637           __ z_st(r_1->as_Register(), st_off, Z_SP);
2638         } else {
2639           // longs are given 2 64-bit slots in the interpreter, but the
2640           // data is passed in only 1 slot.
2641           if (bt == T_LONG || bt == T_DOUBLE) {
2642 #ifdef ASSERT
2643             __ clear_mem(Address(Z_SP, st_off), sizeof(void *));
2644 #endif
2645             st_off -= wordSize;
2646           }
2647           __ z_stg(r_1->as_Register(), st_off, Z_SP);
2648         }
2649       } else {
2650         assert(r_1->is_FloatRegister(), "");
2651         if (!r_2->is_valid()) {
2652           __ z_ste(r_1->as_FloatRegister(), st_off, Z_SP);
2653         } else {
2654           // In 64bit, doubles are given 2 64-bit slots in the interpreter, but the
2655           // data is passed in only 1 slot.
2656           // One of these should get known junk...
2657 #ifdef ASSERT
2658           __ z_lzdr(Z_F1);
2659           __ z_std(Z_F1, st_off, Z_SP);
2660 #endif
2661           st_off-=wordSize;

2686   __ bind(patch_callsite);
2687 
2688   RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers);
2689   __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite), Z_method, Z_R14);
2690   RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers);
2691   __ z_bru(skip_fixup);
2692 
2693   // end of out-of-line code
2694 
2695   return c2i_entrypoint;
2696 }
2697 
2698 // On entry, the following registers are set
2699 //
2700 //    Z_thread  r8  - JavaThread*
2701 //    Z_method  r9  - callee's method (method to be invoked)
2702 //    Z_esp     r7  - operand (or expression) stack pointer of caller. one slot above last arg.
2703 //    Z_SP      r15 - SP prepared by call stub such that caller's outgoing args are near top
2704 //
2705 void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,

2706                                     int comp_args_on_stack,
2707                                     const GrowableArray<SigEntry>* sig,
2708                                     const VMRegPair *regs) {
2709   const Register value = Z_R12;
2710   const Register ld_ptr= Z_esp;
2711   int total_args_passed = sig->length();
2712 
2713   int ld_offset = total_args_passed * wordSize;
2714 
2715   // Cut-out for having no stack args.
2716   if (comp_args_on_stack) {
2717     // Sig words on the stack are greater than VMRegImpl::stack0. Those in
2718     // registers are below. By subtracting stack0, we either get a negative
2719     // number (all values in registers) or the maximum stack slot accessed.
2720     // Convert VMRegImpl (4 byte) stack slots to words.
2721     int comp_words_on_stack = align_up(comp_args_on_stack*VMRegImpl::stack_slot_size, wordSize)>>LogBytesPerWord;
2722     // Round up to miminum stack alignment, in wordSize
2723     comp_words_on_stack = align_up(comp_words_on_stack, 2);
2724 
2725     __ resize_frame(-comp_words_on_stack*wordSize, Z_R0_scratch);
2726   }
2727 
2728   // Now generate the shuffle code. Pick up all register args and move the
2729   // rest through register value=Z_R12.
2730   for (int i = 0; i < total_args_passed; i++) {
2731     BasicType bt = sig->at(i)._bt;
2732     if (bt == T_VOID) {
2733       assert(i > 0 && (sig->at(i - 1)._bt == T_LONG || sig->at(i - 1)._bt == T_DOUBLE), "missing half");
2734       continue;
2735     }
2736 
2737     // Pick up 0, 1 or 2 words from ld_ptr.
2738     assert(!regs[i].second()->is_valid() || regs[i].first()->next() == regs[i].second(),
2739            "scrambled load targets?");
2740     VMReg r_1 = regs[i].first();
2741     VMReg r_2 = regs[i].second();
2742     if (!r_1->is_valid()) {
2743       assert(!r_2->is_valid(), "");
2744       continue;
2745     }
2746     if (r_1->is_FloatRegister()) {
2747       if (!r_2->is_valid()) {
2748         __ z_le(r_1->as_FloatRegister(), ld_offset, ld_ptr);
2749         ld_offset-=wordSize;
2750       } else {
2751         // Skip the unused interpreter slot.
2752         __ z_ld(r_1->as_FloatRegister(), ld_offset - wordSize, ld_ptr);
2753         ld_offset -= 2 * wordSize;
2754       }
2755     } else {
2756       if (r_1->is_stack()) {
2757         // Must do a memory to memory move.
2758         int st_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
2759 
2760         if (!r_2->is_valid()) {
2761           __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2762         } else {
2763           // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2764           // data is passed in only 1 slot.
2765           if (bt == T_LONG || bt == T_DOUBLE) {
2766             ld_offset -= wordSize;
2767           }
2768           __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2769         }
2770       } else {
2771         if (!r_2->is_valid()) {
2772           // Not sure we need to do this but it shouldn't hurt.
2773           if (is_reference_type(bt) || bt == T_ADDRESS) {
2774             __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2775           } else {
2776             __ z_l(r_1->as_Register(), ld_offset, ld_ptr);
2777           }
2778         } else {
2779           // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2780           // data is passed in only 1 slot.
2781           if (bt == T_LONG || bt == T_DOUBLE) {
2782             ld_offset -= wordSize;
2783           }
2784           __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2785         }
2786       }
2787       ld_offset -= wordSize;
2788     }
2789   }
2790 
2791   __ push_cont_fastpath(); // Set JavaThread::_cont_fastpath to the sp of the oldest interpreted frame we know about
2792 
2793   // Jump to the compiled code just as if compiled code was doing it.
2794   // load target address from method:
2795   __ z_lg(Z_R1_scratch, Address(Z_method, Method::from_compiled_offset()));
2796 
2797   // Store method into thread->callee_target.
2798   // 6243940: We might end up in handle_wrong_method if
2799   // the callee is deoptimized as we race thru here. If that
2800   // happens we don't want to take a safepoint because the
2801   // caller frame will look interpreted and arguments are now
2802   // "compiled" so it is much better to make this transition
2803   // invisible to the stack walking code. Unfortunately, if
2804   // we try and find the callee by normal means a safepoint
2805   // is possible. So we stash the desired callee in the thread
2806   // and the vm will find it there should this case occur.
2807   __ z_stg(Z_method, thread_(callee_target));
2808 
2809   __ z_br(Z_R1_scratch);
2810 }
2811 
2812 void SharedRuntime::generate_i2c2i_adapters(MacroAssembler* masm,

2813                                             int comp_args_on_stack,
2814                                             const GrowableArray<SigEntry>* sig,
2815                                             const VMRegPair* regs,
2816                                             const GrowableArray<SigEntry>* sig_cc,
2817                                             const VMRegPair* regs_cc,
2818                                             const GrowableArray<SigEntry>* sig_cc_ro,
2819                                             const VMRegPair* regs_cc_ro,
2820                                             address entry_address[AdapterBlob::ENTRY_COUNT],
2821                                             AdapterBlob*& new_adapter,
2822                                             bool allocate_code_blob) {
2823   __ align(CodeEntryAlignment);
2824   entry_address[AdapterBlob::I2C] = __ pc();
2825   gen_i2c_adapter(masm, comp_args_on_stack, sig, regs);
2826 
2827   Label skip_fixup;
2828   {
2829     Label ic_miss;
2830 
2831     // Out-of-line call to ic_miss handler.
2832     __ call_ic_miss_handler(ic_miss, 0x11, 0, Z_R1_scratch);
2833 
2834     // Unverified Entry Point UEP
2835     __ align(CodeEntryAlignment);
2836     entry_address[AdapterBlob::C2I_Unverified] = __ pc();
2837 
2838     __ ic_check(2);
2839     __ z_lg(Z_method, Address(Z_inline_cache, CompiledICData::speculated_method_offset()));
2840     // This def MUST MATCH code in gen_c2i_adapter!
2841     const Register code = Z_R11;
2842 
2843     __ load_and_test_long(Z_R0, method_(code));
2844     __ z_brne(ic_miss);  // Cache miss: call runtime to handle this.
2845 

2850 
2851   // Class initialization barrier for static methods
2852   entry_address[AdapterBlob::C2I_No_Clinit_Check] = nullptr;
2853   assert(VM_Version::supports_fast_class_init_checks(), "sanity");
2854   Label L_skip_barrier;
2855 
2856   // Bypass the barrier for non-static methods
2857   __ testbit_ushort(Address(Z_method, Method::access_flags_offset()), JVM_ACC_STATIC_BIT);
2858   __ z_bfalse(L_skip_barrier); // non-static
2859 
2860   Register klass = Z_R11;
2861   __ load_method_holder(klass, Z_method);
2862   __ clinit_barrier(klass, Z_thread, &L_skip_barrier /*L_fast_path*/);
2863 
2864   __ load_const_optimized(klass, SharedRuntime::get_handle_wrong_method_stub());
2865   __ z_br(klass);
2866 
2867   __ bind(L_skip_barrier);
2868   entry_address[AdapterBlob::C2I_No_Clinit_Check] = __ pc();
2869 
2870   gen_c2i_adapter(masm, comp_args_on_stack, sig, regs, skip_fixup);
2871   return;
2872 }
2873 
2874 // This function returns the adjust size (in number of words) to a c2i adapter
2875 // activation for use during deoptimization.
2876 //
2877 // Actually only compiled frames need to be adjusted, but it
2878 // doesn't harm to adjust entry and interpreter frames, too.
2879 //
2880 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals) {
2881   assert(callee_locals >= callee_parameters,
2882           "test and remove; got more parms than locals");
2883   // Handle the abi adjustment here instead of doing it in push_skeleton_frames.
2884   return (callee_locals - callee_parameters) * Interpreter::stackElementWords +
2885          frame::z_parent_ijava_frame_abi_size / BytesPerWord;
2886 }
2887 
2888 uint SharedRuntime::in_preserve_stack_slots() {
2889   return frame::jit_in_preserve_size_in_4_byte_units;
2890 }

3934 
3935   __ reset_last_Java_frame();
3936 
3937   __ pop_frame();
3938   __ restore_return_pc();
3939   __ z_br(Z_R14);
3940 
3941   OopMapSet* oop_maps = new OopMapSet();
3942   OopMap* map = new OopMap(framesize, 0);
3943   oop_maps->add_gc_map(calls_return_pc - start, map);
3944 
3945   RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
3946     RuntimeStub::new_runtime_stub(name, &code, frame_complete,
3947                                   (framesize >> (LogBytesPerWord - LogBytesPerInt)),
3948                                   oop_maps, false);
3949 
3950   return stub;
3951 }
3952 
3953 #endif // INCLUDE_JFR
3954 
3955 const uint SharedRuntime::java_return_convention_max_int = Argument::n_int_register_parameters_j;
3956 const uint SharedRuntime::java_return_convention_max_float = Argument::n_float_register_parameters_j;
3957 
3958 int SharedRuntime::java_return_convention(const BasicType *sig_bt, VMRegPair *regs, int total_args_passed) {
3959   Unimplemented();
3960   return 0;
3961 }
3962 
3963 BufferedInlineTypeBlob* SharedRuntime::generate_buffered_inline_type_adapter(const InlineKlass* vk) {
3964   Unimplemented();
3965   return nullptr;
3966 }
3967 
3968 // Call here from the interpreter or compiled code to store returned
3969 // values to a newly allocated inline type instance.
3970 RuntimeStub* SharedRuntime::generate_return_value_stub(address destination) {
3971   Unimplemented();
3972   return nullptr;
3973 }
< prev index next >