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 if (f.is_runtime_frame()) {
45 // Patch the pc of the now old last Java frame (we already set the anchor to enterSpecial)
46 // so that when target goes back to Java it will actually return to the preempt cleanup stub.
47 intptr_t* sp = f.sp();
48 sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
49 } else {
50 // The target will check for preemption once it returns to the interpreter
51 // or the native wrapper code and will manually jump to the preempt stub.
52 JavaThread *thread = JavaThread::current();
53 thread->set_preempt_alternate_return(StubRoutines::cont_preempt_stub());
54 }
55 }
56
57 inline int ContinuationHelper::frame_align_words(int size) {
58 return size & 1;
59 }
60
61 inline intptr_t* ContinuationHelper::frame_align_pointer(intptr_t* sp) {
62 return align_down(sp, frame::frame_alignment);
63 }
64
65 template<typename FKind>
66 inline void ContinuationHelper::update_register_map(const frame& f, RegisterMap* map) {
67 frame::update_map_with_saved_link(map, link_address<FKind>(f));
68 }
69
70 inline void ContinuationHelper::update_register_map_with_callee(const frame& f, RegisterMap* map) {
71 frame::update_map_with_saved_link(map, ContinuationHelper::Frame::callee_link_address(f));
72 }
|
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 if (f.is_runtime_frame()) {
45 // Patch the pc of the now old last Java frame (we already set the anchor to enterSpecial)
46 // so that when target goes back to Java it will actually return to the preempt cleanup stub.
47 intptr_t* sp = f.sp();
48 sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
49 } else {
50 // The target will check for preemption once it returns to the interpreter
51 // or the native wrapper code and will manually jump to the preempt stub.
52 JavaThread *thread = JavaThread::current();
53 DEBUG_ONLY(Method* m = f.is_interpreted_frame() ? f.interpreter_frame_method() : f.cb()->as_nmethod()->method();)
54 assert(m->is_object_wait0() || thread->interp_at_preemptable_vmcall_cnt() > 0,
55 "preemptable VM call not using call_VM_preemptable");
56 thread->set_preempt_alternate_return(StubRoutines::cont_preempt_stub());
57 }
58 }
59
60 inline int ContinuationHelper::frame_align_words(int size) {
61 return size & 1;
62 }
63
64 inline intptr_t* ContinuationHelper::frame_align_pointer(intptr_t* sp) {
65 return align_down(sp, frame::frame_alignment);
66 }
67
68 template<typename FKind>
69 inline void ContinuationHelper::update_register_map(const frame& f, RegisterMap* map) {
70 frame::update_map_with_saved_link(map, link_address<FKind>(f));
71 }
72
73 inline void ContinuationHelper::update_register_map_with_callee(const frame& f, RegisterMap* map) {
74 frame::update_map_with_saved_link(map, ContinuationHelper::Frame::callee_link_address(f));
75 }
|