579 }
580
581 __ push_cont_fastpath(xthread); // Set JavaThread::_cont_fastpath to the sp of the oldest interpreted frame we know about
582
583 // 6243940 We might end up in handle_wrong_method if
584 // the callee is deoptimized as we race thru here. If that
585 // happens we don't want to take a safepoint because the
586 // caller frame will look interpreted and arguments are now
587 // "compiled" so it is much better to make this transition
588 // invisible to the stack walking code. Unfortunately if
589 // we try and find the callee by normal means a safepoint
590 // is possible. So we stash the desired callee in the thread
591 // and the vm will find there should this case occur.
592
593 __ sd(xmethod, Address(xthread, JavaThread::callee_target_offset()));
594
595 __ jr(t1);
596 }
597
598 // ---------------------------------------------------------------
599 AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
600 int total_args_passed,
601 int comp_args_on_stack,
602 const BasicType *sig_bt,
603 const VMRegPair *regs,
604 AdapterFingerPrint* fingerprint) {
605 address i2c_entry = __ pc();
606 gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
607
608 address c2i_unverified_entry = __ pc();
609 Label skip_fixup;
610
611 const Register receiver = j_rarg0;
612 const Register data = t0;
613
614 // -------------------------------------------------------------------------
615 // Generate a C2I adapter. On entry we know xmethod holds the Method* during calls
616 // to the interpreter. The args start out packed in the compiled layout. They
617 // need to be unpacked into the interpreter layout. This will almost always
618 // require some stack space. We grow the current (compiled) stack, then repack
619 // the args. We finally end in a jump to the generic interpreter entry point.
620 // On exit from the interpreter, the interpreter will restore our SP (lest the
621 // compiled code, which relies solely on SP and not FP, get sick).
622
623 {
624 __ block_comment("c2i_unverified_entry {");
641
642 { // Bypass the barrier for non-static methods
643 __ load_unsigned_short(t0, Address(xmethod, Method::access_flags_offset()));
644 __ test_bit(t1, t0, exact_log2(JVM_ACC_STATIC));
645 __ beqz(t1, L_skip_barrier); // non-static
646 }
647
648 __ load_method_holder(t1, xmethod);
649 __ clinit_barrier(t1, t0, &L_skip_barrier);
650 __ far_jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
651
652 __ bind(L_skip_barrier);
653 c2i_no_clinit_check_entry = __ pc();
654 }
655
656 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
657 bs->c2i_entry_barrier(masm);
658
659 gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
660
661 return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
662 }
663
664 int SharedRuntime::vector_calling_convention(VMRegPair *regs,
665 uint num_bits,
666 uint total_args_passed) {
667 assert(total_args_passed <= Argument::n_vector_register_parameters_c, "unsupported");
668 assert(num_bits >= 64 && num_bits <= 2048 && is_power_of_2(num_bits), "unsupported");
669
670 // check more info at https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc
671 static const VectorRegister VEC_ArgReg[Argument::n_vector_register_parameters_c] = {
672 v8, v9, v10, v11, v12, v13, v14, v15,
673 v16, v17, v18, v19, v20, v21, v22, v23
674 };
675
676 const int next_reg_val = 3;
677 for (uint i = 0; i < total_args_passed; i++) {
678 VMReg vmreg = VEC_ArgReg[i]->as_VMReg();
679 regs[i].set_pair(vmreg->next(next_reg_val), vmreg);
680 }
681 return 0;
|
579 }
580
581 __ push_cont_fastpath(xthread); // Set JavaThread::_cont_fastpath to the sp of the oldest interpreted frame we know about
582
583 // 6243940 We might end up in handle_wrong_method if
584 // the callee is deoptimized as we race thru here. If that
585 // happens we don't want to take a safepoint because the
586 // caller frame will look interpreted and arguments are now
587 // "compiled" so it is much better to make this transition
588 // invisible to the stack walking code. Unfortunately if
589 // we try and find the callee by normal means a safepoint
590 // is possible. So we stash the desired callee in the thread
591 // and the vm will find there should this case occur.
592
593 __ sd(xmethod, Address(xthread, JavaThread::callee_target_offset()));
594
595 __ jr(t1);
596 }
597
598 // ---------------------------------------------------------------
599
600 void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
601 int total_args_passed,
602 int comp_args_on_stack,
603 const BasicType *sig_bt,
604 const VMRegPair *regs,
605 AdapterHandlerEntry* handler) {
606 address i2c_entry = __ pc();
607 gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
608
609 address c2i_unverified_entry = __ pc();
610 Label skip_fixup;
611
612 const Register receiver = j_rarg0;
613 const Register data = t0;
614
615 // -------------------------------------------------------------------------
616 // Generate a C2I adapter. On entry we know xmethod holds the Method* during calls
617 // to the interpreter. The args start out packed in the compiled layout. They
618 // need to be unpacked into the interpreter layout. This will almost always
619 // require some stack space. We grow the current (compiled) stack, then repack
620 // the args. We finally end in a jump to the generic interpreter entry point.
621 // On exit from the interpreter, the interpreter will restore our SP (lest the
622 // compiled code, which relies solely on SP and not FP, get sick).
623
624 {
625 __ block_comment("c2i_unverified_entry {");
642
643 { // Bypass the barrier for non-static methods
644 __ load_unsigned_short(t0, Address(xmethod, Method::access_flags_offset()));
645 __ test_bit(t1, t0, exact_log2(JVM_ACC_STATIC));
646 __ beqz(t1, L_skip_barrier); // non-static
647 }
648
649 __ load_method_holder(t1, xmethod);
650 __ clinit_barrier(t1, t0, &L_skip_barrier);
651 __ far_jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
652
653 __ bind(L_skip_barrier);
654 c2i_no_clinit_check_entry = __ pc();
655 }
656
657 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
658 bs->c2i_entry_barrier(masm);
659
660 gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
661
662 handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
663 return;
664 }
665
666 int SharedRuntime::vector_calling_convention(VMRegPair *regs,
667 uint num_bits,
668 uint total_args_passed) {
669 assert(total_args_passed <= Argument::n_vector_register_parameters_c, "unsupported");
670 assert(num_bits >= 64 && num_bits <= 2048 && is_power_of_2(num_bits), "unsupported");
671
672 // check more info at https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc
673 static const VectorRegister VEC_ArgReg[Argument::n_vector_register_parameters_c] = {
674 v8, v9, v10, v11, v12, v13, v14, v15,
675 v16, v17, v18, v19, v20, v21, v22, v23
676 };
677
678 const int next_reg_val = 3;
679 for (uint i = 0; i < total_args_passed; i++) {
680 VMReg vmreg = VEC_ArgReg[i]->as_VMReg();
681 regs[i].set_pair(vmreg->next(next_reg_val), vmreg);
682 }
683 return 0;
|