18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef CPU_AARCH64_STACKCHUNKFRAMESTREAM_AARCH64_INLINE_HPP
26 #define CPU_AARCH64_STACKCHUNKFRAMESTREAM_AARCH64_INLINE_HPP
27
28 #include "interpreter/oopMapCache.hpp"
29 #include "pauth_aarch64.hpp"
30 #include "runtime/frame.inline.hpp"
31 #include "runtime/registerMap.hpp"
32
33 #ifdef ASSERT
34 template <ChunkFrames frame_kind>
35 inline bool StackChunkFrameStream<frame_kind>::is_in_frame(void* p0) const {
36 assert(!is_done(), "");
37 intptr_t* p = (intptr_t*)p0;
38 int argsize = is_compiled() ? (_cb->as_nmethod()->num_stack_arg_slots() * VMRegImpl::stack_slot_size) >> LogBytesPerWord : 0;
39 int frame_size = _cb->frame_size() + argsize;
40 return p == sp() - frame::sender_sp_offset || ((p - unextended_sp()) >= 0 && (p - unextended_sp()) < frame_size);
41 }
42 #endif
43
44 template <ChunkFrames frame_kind>
45 inline frame StackChunkFrameStream<frame_kind>::to_frame() const {
46 if (is_done()) {
47 return frame(_sp, _sp, nullptr, nullptr, nullptr, nullptr, true);
48 } else {
49 return frame(sp(), unextended_sp(), fp(), pc(), cb(), _oopmap, true);
50 }
51 }
52
53 template <ChunkFrames frame_kind>
54 inline address StackChunkFrameStream<frame_kind>::get_pc() const {
55 assert(!is_done(), "");
56 // Just strip it for frames on the heap.
57 return pauth_strip_pointer(*(address*)(_sp - 1));
58 }
59
60 template <ChunkFrames frame_kind>
61 inline intptr_t* StackChunkFrameStream<frame_kind>::fp() const {
62 intptr_t* fp_addr = _sp - frame::sender_sp_offset;
63 return (frame_kind == ChunkFrames::Mixed && is_interpreted())
64 ? fp_addr + *fp_addr // derelativize
65 : *(intptr_t**)fp_addr;
66 }
67
68 template <ChunkFrames frame_kind>
69 inline intptr_t* StackChunkFrameStream<frame_kind>::derelativize(int offset) const {
70 intptr_t* fp = this->fp();
71 assert(fp != nullptr, "");
72 return fp + fp[offset];
73 }
74
75 template <ChunkFrames frame_kind>
76 inline intptr_t* StackChunkFrameStream<frame_kind>::unextended_sp_for_interpreter_frame() const {
77 assert_is_interpreted_and_frame_type_mixed();
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef CPU_AARCH64_STACKCHUNKFRAMESTREAM_AARCH64_INLINE_HPP
26 #define CPU_AARCH64_STACKCHUNKFRAMESTREAM_AARCH64_INLINE_HPP
27
28 #include "interpreter/oopMapCache.hpp"
29 #include "pauth_aarch64.hpp"
30 #include "runtime/frame.inline.hpp"
31 #include "runtime/registerMap.hpp"
32
33 #ifdef ASSERT
34 template <ChunkFrames frame_kind>
35 inline bool StackChunkFrameStream<frame_kind>::is_in_frame(void* p0) const {
36 assert(!is_done(), "");
37 intptr_t* p = (intptr_t*)p0;
38 int frame_size = _cb->frame_size();
39 if (is_compiled()) {
40 nmethod* nm = _cb->as_nmethod_or_null();
41 if (nm->needs_stack_repair() && nm->is_compiled_by_c2()) {
42 frame f = to_frame();
43 bool augmented = f.was_augmented_on_entry(frame_size);
44 if (!augmented) {
45 // Fix: C2 caller, so frame was not extended and thus the
46 // size read from the frame does not include the arguments.
47 // Ideally we have to count the arg size for the scalarized
48 // convention. For now we include the size of the caller frame
49 // which would at least be equal to that.
50 RegisterMap map(nullptr,
51 RegisterMap::UpdateMap::skip,
52 RegisterMap::ProcessFrames::skip,
53 RegisterMap::WalkContinuation::skip);
54 frame caller = to_frame().sender(&map);
55 assert(caller.is_compiled_frame() && caller.cb()->as_nmethod()->is_compiled_by_c2(), "needs stack repair but was not extended with c1/interpreter caller");
56 frame_size += (caller.real_fp() - caller.sp());
57 }
58 } else {
59 frame_size += _cb->as_nmethod()->num_stack_arg_slots() * VMRegImpl::stack_slot_size >> LogBytesPerWord;
60 }
61 }
62 return p == sp() - frame::sender_sp_offset || ((p - unextended_sp()) >= 0 && (p - unextended_sp()) < frame_size);
63 }
64 #endif
65
66 template <ChunkFrames frame_kind>
67 inline frame StackChunkFrameStream<frame_kind>::to_frame() const {
68 if (is_done()) {
69 return frame(_sp, _sp, nullptr, nullptr, nullptr, nullptr, true);
70 } else {
71 frame f = frame(sp(), unextended_sp(), fp(), pc(), cb(), _oopmap, true);
72 // If caller tries to get the sender of this frame and PreserveFramePointer
73 // is set, fp() will be used which contains the old value at the time of
74 // freeze (fp is reconstructed again during thaw). Setting sp as trusted
75 // causes the sender code to use _unextended_sp instead (see sender_for_compiled_frame()).
76 f.set_sp_is_trusted();
77 return f;
78 }
79 }
80
81 template <ChunkFrames frame_kind>
82 inline address StackChunkFrameStream<frame_kind>::get_pc() const {
83 assert(!is_done(), "");
84 // Just strip it for frames on the heap.
85 return pauth_strip_pointer(*(address*)((_callee_augmented ? _unextended_sp : _sp) - 1));
86 }
87
88 template <ChunkFrames frame_kind>
89 inline intptr_t* StackChunkFrameStream<frame_kind>::fp() const {
90 intptr_t* fp_addr = _sp - frame::sender_sp_offset;
91 return (frame_kind == ChunkFrames::Mixed && is_interpreted())
92 ? fp_addr + *fp_addr // derelativize
93 : *(intptr_t**)fp_addr;
94 }
95
96 template <ChunkFrames frame_kind>
97 inline intptr_t* StackChunkFrameStream<frame_kind>::derelativize(int offset) const {
98 intptr_t* fp = this->fp();
99 assert(fp != nullptr, "");
100 return fp + fp[offset];
101 }
102
103 template <ChunkFrames frame_kind>
104 inline intptr_t* StackChunkFrameStream<frame_kind>::unextended_sp_for_interpreter_frame() const {
105 assert_is_interpreted_and_frame_type_mixed();
|