23 */
24
25 #ifndef CPU_AARCH64_CONTINUATIONHELPER_AARCH64_INLINE_HPP
26 #define CPU_AARCH64_CONTINUATIONHELPER_AARCH64_INLINE_HPP
27
28 #include "runtime/continuationHelper.hpp"
29
30 #include "runtime/continuationEntry.inline.hpp"
31 #include "runtime/frame.inline.hpp"
32 #include "runtime/registerMap.hpp"
33 #include "utilities/macros.hpp"
34
35 template<typename FKind>
36 static inline intptr_t** link_address(const frame& f) {
37 assert(FKind::is_instance(f), "");
38 return FKind::interpreted
39 ? (intptr_t**)(f.fp() + frame::link_offset)
40 : (intptr_t**)(f.unextended_sp() + f.cb()->frame_size() - frame::sender_sp_offset);
41 }
42
43 inline int ContinuationHelper::frame_align_words(int size) {
44 #ifdef _LP64
45 return size & 1;
46 #else
47 return 0;
48 #endif
49 }
50
51 inline intptr_t* ContinuationHelper::frame_align_pointer(intptr_t* sp) {
52 #ifdef _LP64
53 sp = align_down(sp, frame::frame_alignment);
54 #endif
55 return sp;
56 }
57
58 template<typename FKind>
59 inline void ContinuationHelper::update_register_map(const frame& f, RegisterMap* map) {
60 frame::update_map_with_saved_link(map, link_address<FKind>(f));
61 }
62
66
67 inline void ContinuationHelper::push_pd(const frame& f) {
68 *(intptr_t**)(f.sp() - frame::sender_sp_offset) = f.fp();
69 }
70
71 #define CPU_OVERRIDES_RETURN_ADDRESS_ACCESSORS
72
73 inline address ContinuationHelper::return_address_at(intptr_t* sp) {
74 return pauth_strip_verifiable(*(address*)sp);
75 }
76
77 inline void ContinuationHelper::patch_return_address_at(intptr_t* sp,
78 address pc) {
79 *(address*)sp = pauth_sign_return_address(pc);
80 }
81
82 inline void ContinuationHelper::set_anchor_to_entry_pd(JavaFrameAnchor* anchor, ContinuationEntry* entry) {
83 anchor->set_last_Java_fp(entry->entry_fp());
84 }
85
86 #ifdef ASSERT
87 inline void ContinuationHelper::set_anchor_pd(JavaFrameAnchor* anchor, intptr_t* sp) {
88 intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
89 anchor->set_last_Java_fp(fp);
90 }
91
92 inline bool ContinuationHelper::Frame::assert_frame_laid_out(frame f) {
93 intptr_t* sp = f.sp();
94 address pc = ContinuationHelper::return_address_at(
95 sp - frame::sender_sp_ret_address_offset());
96 intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
97 assert(f.raw_pc() == pc, "f.ra_pc: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.raw_pc()), p2i(pc));
98 assert(f.fp() == fp, "f.fp: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.fp()), p2i(fp));
99 return f.raw_pc() == pc && f.fp() == fp;
100 }
101 #endif
102
103 inline intptr_t** ContinuationHelper::Frame::callee_link_address(const frame& f) {
104 return (intptr_t**)(f.sp() - frame::sender_sp_offset);
105 }
106
107 inline address* ContinuationHelper::Frame::return_pc_address(const frame& f) {
108 return (address*)(f.real_fp() - 1);
109 }
110
111 inline address* ContinuationHelper::InterpretedFrame::return_pc_address(const frame& f) {
|
23 */
24
25 #ifndef CPU_AARCH64_CONTINUATIONHELPER_AARCH64_INLINE_HPP
26 #define CPU_AARCH64_CONTINUATIONHELPER_AARCH64_INLINE_HPP
27
28 #include "runtime/continuationHelper.hpp"
29
30 #include "runtime/continuationEntry.inline.hpp"
31 #include "runtime/frame.inline.hpp"
32 #include "runtime/registerMap.hpp"
33 #include "utilities/macros.hpp"
34
35 template<typename FKind>
36 static inline intptr_t** link_address(const frame& f) {
37 assert(FKind::is_instance(f), "");
38 return FKind::interpreted
39 ? (intptr_t**)(f.fp() + frame::link_offset)
40 : (intptr_t**)(f.unextended_sp() + f.cb()->frame_size() - frame::sender_sp_offset);
41 }
42
43 static inline void patch_return_pc_with_preempt_stub(frame& f) {
44 // Unlike x86 we don't know where in the callee frame the return pc is
45 // saved so we can't patch the return from the VM call back to Java. If
46 // the target is coming from compiled code we will patch the return from
47 // the safepoint handler blob back to the compiled method instead. If
48 // it's coming from the interpreter, the target will check for preemption
49 // once it returns to the interpreter and will manually jump to the
50 // preempt stub.
51 if (!f.is_interpreted_frame()) {
52 assert(f.is_runtime_frame(), "invariant");
53 intptr_t* caller_sp = f.sp() + f.cb()->frame_size();
54 caller_sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
55 } else {
56 JavaThread *thread = JavaThread::current();
57 thread->set_preempt_alternate_return(StubRoutines::cont_preempt_stub());
58 thread->set_preempt_alternate_return_sp((address)f.sp());
59 }
60 }
61
62 inline int ContinuationHelper::frame_align_words(int size) {
63 #ifdef _LP64
64 return size & 1;
65 #else
66 return 0;
67 #endif
68 }
69
70 inline intptr_t* ContinuationHelper::frame_align_pointer(intptr_t* sp) {
71 #ifdef _LP64
72 sp = align_down(sp, frame::frame_alignment);
73 #endif
74 return sp;
75 }
76
77 template<typename FKind>
78 inline void ContinuationHelper::update_register_map(const frame& f, RegisterMap* map) {
79 frame::update_map_with_saved_link(map, link_address<FKind>(f));
80 }
81
85
86 inline void ContinuationHelper::push_pd(const frame& f) {
87 *(intptr_t**)(f.sp() - frame::sender_sp_offset) = f.fp();
88 }
89
90 #define CPU_OVERRIDES_RETURN_ADDRESS_ACCESSORS
91
92 inline address ContinuationHelper::return_address_at(intptr_t* sp) {
93 return pauth_strip_verifiable(*(address*)sp);
94 }
95
96 inline void ContinuationHelper::patch_return_address_at(intptr_t* sp,
97 address pc) {
98 *(address*)sp = pauth_sign_return_address(pc);
99 }
100
101 inline void ContinuationHelper::set_anchor_to_entry_pd(JavaFrameAnchor* anchor, ContinuationEntry* entry) {
102 anchor->set_last_Java_fp(entry->entry_fp());
103 }
104
105 inline void ContinuationHelper::set_anchor_pd(JavaFrameAnchor* anchor, intptr_t* sp) {
106 intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
107 anchor->set_last_Java_fp(fp);
108 }
109
110 #ifdef ASSERT
111 inline bool ContinuationHelper::Frame::assert_frame_laid_out(frame f) {
112 intptr_t* sp = f.sp();
113 address pc = ContinuationHelper::return_address_at(
114 sp - frame::sender_sp_ret_address_offset());
115 intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
116 assert(f.raw_pc() == pc, "f.ra_pc: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.raw_pc()), p2i(pc));
117 assert(f.fp() == fp, "f.fp: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.fp()), p2i(fp));
118 return f.raw_pc() == pc && f.fp() == fp;
119 }
120 #endif
121
122 inline intptr_t** ContinuationHelper::Frame::callee_link_address(const frame& f) {
123 return (intptr_t**)(f.sp() - frame::sender_sp_offset);
124 }
125
126 inline address* ContinuationHelper::Frame::return_pc_address(const frame& f) {
127 return (address*)(f.real_fp() - 1);
128 }
129
130 inline address* ContinuationHelper::InterpretedFrame::return_pc_address(const frame& f) {
|