682
683
684 static void move_i2c_double(MacroAssembler *masm, XMMRegister r, Register saved_sp, int ld_off) {
685 int next_val_off = ld_off - Interpreter::stackElementSize;
686 __ movdbl(r, Address(saved_sp, next_val_off));
687 }
688
689 static void range_check(MacroAssembler* masm, Register pc_reg, Register temp_reg,
690 address code_start, address code_end,
691 Label& L_ok) {
692 Label L_fail;
693 __ lea(temp_reg, ExternalAddress(code_start));
694 __ cmpptr(pc_reg, temp_reg);
695 __ jcc(Assembler::belowEqual, L_fail);
696 __ lea(temp_reg, ExternalAddress(code_end));
697 __ cmpptr(pc_reg, temp_reg);
698 __ jcc(Assembler::below, L_ok);
699 __ bind(L_fail);
700 }
701
702 static void gen_i2c_adapter(MacroAssembler *masm,
703 int total_args_passed,
704 int comp_args_on_stack,
705 const BasicType *sig_bt,
706 const VMRegPair *regs) {
707
708 // Note: rsi contains the senderSP on entry. We must preserve it since
709 // we may do a i2c -> c2i transition if we lose a race where compiled
710 // code goes non-entrant while we get args ready.
711
712 // Adapters can be frameless because they do not require the caller
713 // to perform additional cleanup work, such as correcting the stack pointer.
714 // An i2c adapter is frameless because the *caller* frame, which is interpreted,
715 // routinely repairs its own stack pointer (from interpreter_frame_last_sp),
716 // even if a callee has modified the stack pointer.
717 // A c2i adapter is frameless because the *callee* frame, which is interpreted,
718 // routinely repairs its caller's stack pointer (from sender_sp, which is set
719 // up via the senderSP register).
720 // In other words, if *either* the caller or callee is interpreted, we can
721 // get the stack pointer repaired after a call.
722 // This is why c2i and i2c adapters cannot be indefinitely composed.
723 // In particular, if a c2i adapter were to somehow call an i2c adapter,
724 // both caller and callee would be compiled methods, and neither would
725 // clean up the stack pointer changes performed by the two adapters.
726 // If this happens, control eventually transfers back to the compiled
727 // caller, but with an uncorrected stack, causing delayed havoc.
|
682
683
684 static void move_i2c_double(MacroAssembler *masm, XMMRegister r, Register saved_sp, int ld_off) {
685 int next_val_off = ld_off - Interpreter::stackElementSize;
686 __ movdbl(r, Address(saved_sp, next_val_off));
687 }
688
689 static void range_check(MacroAssembler* masm, Register pc_reg, Register temp_reg,
690 address code_start, address code_end,
691 Label& L_ok) {
692 Label L_fail;
693 __ lea(temp_reg, ExternalAddress(code_start));
694 __ cmpptr(pc_reg, temp_reg);
695 __ jcc(Assembler::belowEqual, L_fail);
696 __ lea(temp_reg, ExternalAddress(code_end));
697 __ cmpptr(pc_reg, temp_reg);
698 __ jcc(Assembler::below, L_ok);
699 __ bind(L_fail);
700 }
701
702 void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
703 int total_args_passed,
704 int comp_args_on_stack,
705 const BasicType *sig_bt,
706 const VMRegPair *regs) {
707 // Note: rsi contains the senderSP on entry. We must preserve it since
708 // we may do a i2c -> c2i transition if we lose a race where compiled
709 // code goes non-entrant while we get args ready.
710
711 // Adapters can be frameless because they do not require the caller
712 // to perform additional cleanup work, such as correcting the stack pointer.
713 // An i2c adapter is frameless because the *caller* frame, which is interpreted,
714 // routinely repairs its own stack pointer (from interpreter_frame_last_sp),
715 // even if a callee has modified the stack pointer.
716 // A c2i adapter is frameless because the *callee* frame, which is interpreted,
717 // routinely repairs its caller's stack pointer (from sender_sp, which is set
718 // up via the senderSP register).
719 // In other words, if *either* the caller or callee is interpreted, we can
720 // get the stack pointer repaired after a call.
721 // This is why c2i and i2c adapters cannot be indefinitely composed.
722 // In particular, if a c2i adapter were to somehow call an i2c adapter,
723 // both caller and callee would be compiled methods, and neither would
724 // clean up the stack pointer changes performed by the two adapters.
725 // If this happens, control eventually transfers back to the compiled
726 // caller, but with an uncorrected stack, causing delayed havoc.
|