42 #include "runtime/continuation.hpp"
43 #include "runtime/continuationEntry.inline.hpp"
44 #include "runtime/globals.hpp"
45 #include "runtime/jniHandles.hpp"
46 #include "runtime/safepointMechanism.hpp"
47 #include "runtime/sharedRuntime.hpp"
48 #include "runtime/signature.hpp"
49 #include "runtime/stubRoutines.hpp"
50 #include "runtime/timerTrace.hpp"
51 #include "runtime/vframeArray.hpp"
52 #include "utilities/align.hpp"
53 #include "utilities/formatBuffer.hpp"
54 #include "vmreg_riscv.inline.hpp"
55 #ifdef COMPILER1
56 #include "c1/c1_Runtime1.hpp"
57 #endif
58 #ifdef COMPILER2
59 #include "adfiles/ad_riscv.hpp"
60 #include "opto/runtime.hpp"
61 #endif
62 #if INCLUDE_JVMCI
63 #include "jvmci/jvmciJavaClasses.hpp"
64 #endif
65
66 #define __ masm->
67
68 #ifdef PRODUCT
69 #define BLOCK_COMMENT(str) /* nothing */
70 #else
71 #define BLOCK_COMMENT(str) __ block_comment(str)
72 #endif
73
74 const int StackAlignmentInSlots = StackAlignmentInBytes / VMRegImpl::stack_slot_size;
75
76 class RegisterSaver {
77 const bool _save_vectors;
78 public:
79 RegisterSaver(bool save_vectors) : _save_vectors(UseRVV && save_vectors) {}
80 ~RegisterSaver() {}
81 OopMap* save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words);
2765 int frame_complete = __ pc() - start;
2766 address the_pc = __ pc();
2767 jfr_prologue(the_pc, masm, xthread);
2768 __ call_VM_leaf(CAST_FROM_FN_PTR(address, JfrIntrinsicSupport::return_lease), 1);
2769
2770 jfr_epilogue(masm);
2771 __ leave();
2772 __ ret();
2773
2774 OopMap* map = new OopMap(framesize, 1);
2775 oop_maps->add_gc_map(the_pc - start, map);
2776
2777 RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
2778 RuntimeStub::new_runtime_stub(name, &code, frame_complete,
2779 (framesize >> (LogBytesPerWord - LogBytesPerInt)),
2780 oop_maps, false);
2781 return stub;
2782 }
2783
2784 #endif // INCLUDE_JFR
|
42 #include "runtime/continuation.hpp"
43 #include "runtime/continuationEntry.inline.hpp"
44 #include "runtime/globals.hpp"
45 #include "runtime/jniHandles.hpp"
46 #include "runtime/safepointMechanism.hpp"
47 #include "runtime/sharedRuntime.hpp"
48 #include "runtime/signature.hpp"
49 #include "runtime/stubRoutines.hpp"
50 #include "runtime/timerTrace.hpp"
51 #include "runtime/vframeArray.hpp"
52 #include "utilities/align.hpp"
53 #include "utilities/formatBuffer.hpp"
54 #include "vmreg_riscv.inline.hpp"
55 #ifdef COMPILER1
56 #include "c1/c1_Runtime1.hpp"
57 #endif
58 #ifdef COMPILER2
59 #include "adfiles/ad_riscv.hpp"
60 #include "opto/runtime.hpp"
61 #endif
62 #if INCLUDE_SHENANDOAHGC
63 #include "gc/shenandoah/shenandoahRuntime.hpp"
64 #endif
65 #if INCLUDE_JVMCI
66 #include "jvmci/jvmciJavaClasses.hpp"
67 #endif
68
69 #define __ masm->
70
71 #ifdef PRODUCT
72 #define BLOCK_COMMENT(str) /* nothing */
73 #else
74 #define BLOCK_COMMENT(str) __ block_comment(str)
75 #endif
76
77 const int StackAlignmentInSlots = StackAlignmentInBytes / VMRegImpl::stack_slot_size;
78
79 class RegisterSaver {
80 const bool _save_vectors;
81 public:
82 RegisterSaver(bool save_vectors) : _save_vectors(UseRVV && save_vectors) {}
83 ~RegisterSaver() {}
84 OopMap* save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words);
2768 int frame_complete = __ pc() - start;
2769 address the_pc = __ pc();
2770 jfr_prologue(the_pc, masm, xthread);
2771 __ call_VM_leaf(CAST_FROM_FN_PTR(address, JfrIntrinsicSupport::return_lease), 1);
2772
2773 jfr_epilogue(masm);
2774 __ leave();
2775 __ ret();
2776
2777 OopMap* map = new OopMap(framesize, 1);
2778 oop_maps->add_gc_map(the_pc - start, map);
2779
2780 RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size)
2781 RuntimeStub::new_runtime_stub(name, &code, frame_complete,
2782 (framesize >> (LogBytesPerWord - LogBytesPerInt)),
2783 oop_maps, false);
2784 return stub;
2785 }
2786
2787 #endif // INCLUDE_JFR
2788
2789 #if INCLUDE_SHENANDOAHGC
2790 RuntimeStub* SharedRuntime::generate_shenandoah_stub(StubId stub_id) {
2791 assert(UseShenandoahGC, "Only generate when Shenandoah is enabled");
2792
2793 const char* name = SharedRuntime::stub_name(stub_id);
2794 address stub_addr = nullptr;
2795 bool returns_obj = true;
2796
2797 switch (stub_id) {
2798 case StubId::shared_shenandoah_keepalive_id:
2799 case StubId::shared_shenandoah_keepalive_vectors_id: {
2800 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_pre);
2801 returns_obj = false;
2802 break;
2803 }
2804 case StubId::shared_shenandoah_lrb_strong_id:
2805 case StubId::shared_shenandoah_lrb_strong_vectors_id: {
2806 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_strong);
2807 break;
2808 }
2809 case StubId::shared_shenandoah_lrb_weak_id:
2810 case StubId::shared_shenandoah_lrb_weak_vectors_id: {
2811 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak);
2812 break;
2813 }
2814 case StubId::shared_shenandoah_lrb_phantom_id:
2815 case StubId::shared_shenandoah_lrb_phantom_vectors_id: {
2816 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom);
2817 break;
2818 }
2819 case StubId::shared_shenandoah_lrb_strong_narrow_id:
2820 case StubId::shared_shenandoah_lrb_strong_narrow_vectors_id: {
2821 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_strong_narrow);
2822 break;
2823 }
2824 case StubId::shared_shenandoah_lrb_weak_narrow_id:
2825 case StubId::shared_shenandoah_lrb_weak_narrow_vectors_id: {
2826 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak_narrow);
2827 break;
2828 }
2829 case StubId::shared_shenandoah_lrb_phantom_narrow_id:
2830 case StubId::shared_shenandoah_lrb_phantom_narrow_vectors_id: {
2831 stub_addr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom_narrow);
2832 break;
2833 }
2834 default:
2835 ShouldNotReachHere();
2836 }
2837
2838 bool save_vectors = true;
2839 switch (stub_id) {
2840 case StubId::shared_shenandoah_keepalive_vectors_id:
2841 case StubId::shared_shenandoah_lrb_strong_vectors_id:
2842 case StubId::shared_shenandoah_lrb_weak_vectors_id:
2843 case StubId::shared_shenandoah_lrb_phantom_vectors_id:
2844 case StubId::shared_shenandoah_lrb_strong_narrow_vectors_id:
2845 case StubId::shared_shenandoah_lrb_weak_narrow_vectors_id:
2846 case StubId::shared_shenandoah_lrb_phantom_narrow_vectors_id: {
2847 save_vectors = true;
2848 break;
2849 }
2850 case StubId::shared_shenandoah_keepalive_id:
2851 case StubId::shared_shenandoah_lrb_strong_id:
2852 case StubId::shared_shenandoah_lrb_weak_id:
2853 case StubId::shared_shenandoah_lrb_phantom_id:
2854 case StubId::shared_shenandoah_lrb_strong_narrow_id:
2855 case StubId::shared_shenandoah_lrb_weak_narrow_id:
2856 case StubId::shared_shenandoah_lrb_phantom_narrow_id: {
2857 save_vectors = false;
2858 break;
2859 }
2860 default:
2861 ShouldNotReachHere();
2862 }
2863
2864 CodeBuffer code(name, 2048, 64);
2865 MacroAssembler* masm = new MacroAssembler(&code);
2866 address start = __ pc();
2867
2868 int frame_size_in_words;
2869 RegisterSaver reg_save(save_vectors);
2870 OopMap* map = reg_save.save_live_registers(masm, 0, &frame_size_in_words);
2871 address frame_complete_pc = __ pc();
2872
2873 // Call the runtime, but keep exact post-call PC for the oop map.
2874 int32_t offset = 0;
2875 __ movptr(t1, stub_addr, offset, t0);
2876 __ jalr(t1, offset);
2877 address post_call_pc = __ pc();
2878
2879 if (returns_obj) {
2880 // RegisterSaver would clobber the call result when restoring.
2881 // Carry the result out of this stub by overwriting saved x10/a0.
2882 __ sd(x10, Address(sp, reg_save.reg_offset_in_bytes(x10)));
2883 }
2884
2885 OopMapSet* oop_maps = new OopMapSet();
2886 oop_maps->add_gc_map(post_call_pc - start, map);
2887
2888 reg_save.restore_live_registers(masm);
2889 __ ret();
2890
2891 return RuntimeStub::new_runtime_stub(name,
2892 &code,
2893 frame_complete_pc - start,
2894 frame_size_in_words,
2895 oop_maps,
2896 true);
2897 }
2898 #endif
|