136 // which can be different from the sender unextended sp (the sp seen
137 // by the sender) because of current frame local variables
138 sender_sp = (intptr_t*) addr_at(sender_sp_offset);
139 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
140 saved_fp = (intptr_t*) this->fp()[link_offset];
141 sender_pc = pauth_strip_verifiable((address) this->fp()[return_addr_offset]);
142 } else {
143 // must be some sort of compiled/runtime frame
144 // fp does not have to be safe (although it could be check for c1?)
145
146 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
147 if (_cb->frame_size() <= 0) {
148 return false;
149 }
150
151 sender_sp = _unextended_sp + _cb->frame_size();
152 // Is sender_sp safe?
153 if (!thread->is_in_full_stack_checked((address)sender_sp)) {
154 return false;
155 }
156 sender_unextended_sp = sender_sp;
157 // Note: frame::sender_sp_offset is only valid for compiled frame
158 saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset);
159 // Note: PAC authentication may fail in case broken frame is passed in.
160 // Just strip it for now.
161 sender_pc = pauth_strip_pointer((address) *(sender_sp - 1));
162 }
163
164 if (Continuation::is_return_barrier_entry(sender_pc)) {
165 // sender_pc might be invalid so check that the frame
166 // actually belongs to a Continuation.
167 if (!Continuation::is_frame_in_continuation(thread, *this)) {
168 return false;
169 }
170 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
171 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
172 sender_sp = s.sp();
173 sender_pc = s.pc();
174 }
175
176 // If the potential sender is the interpreter then we can do some more checking
177 if (Interpreter::contains(sender_pc)) {
178
179 // fp is always saved in a recognizable place in any code we generate. However
180 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved fp
181 // is really a frame pointer.
182
183 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
805 }
806
807 // support for printing out where we are in a Java method
808 // needs to be passed current fp and bcp register values
809 // prints method name, bc index and bytecode name
810 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
811 DESCRIBE_FP_OFFSET(interpreter_frame_method);
812 uintptr_t *p = (uintptr_t *)fp;
813 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
814 printbc(m, bcx);
815 }
816
817 #ifndef PRODUCT
818 // This is a generic constructor which is only used by pns() in debug.cpp.
819 frame::frame(void* sp, void* fp, void* pc) {
820 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
821 }
822
823 #endif
824
825 void JavaFrameAnchor::make_walkable() {
826 // last frame set?
827 if (last_Java_sp() == nullptr) return;
828 // already walkable?
829 if (walkable()) return;
830 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
831 vmassert(last_Java_pc() == nullptr, "already walkable");
832 _last_Java_pc = (address)_last_Java_sp[-1];
833 vmassert(walkable(), "something went wrong");
834 }
|
136 // which can be different from the sender unextended sp (the sp seen
137 // by the sender) because of current frame local variables
138 sender_sp = (intptr_t*) addr_at(sender_sp_offset);
139 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
140 saved_fp = (intptr_t*) this->fp()[link_offset];
141 sender_pc = pauth_strip_verifiable((address) this->fp()[return_addr_offset]);
142 } else {
143 // must be some sort of compiled/runtime frame
144 // fp does not have to be safe (although it could be check for c1?)
145
146 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
147 if (_cb->frame_size() <= 0) {
148 return false;
149 }
150
151 sender_sp = _unextended_sp + _cb->frame_size();
152 // Is sender_sp safe?
153 if (!thread->is_in_full_stack_checked((address)sender_sp)) {
154 return false;
155 }
156 // Note: frame::sender_sp_offset is only valid for compiled frame
157 intptr_t **saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
158 saved_fp = *saved_fp_addr;
159 // Note: PAC authentication may fail in case broken frame is passed in.
160 // Just strip it for now.
161 sender_pc = pauth_strip_pointer((address) *(sender_sp - 1));
162
163 // Repair the sender sp if this is a method with scalarized inline type args
164 sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
165 sender_unextended_sp = sender_sp;
166 }
167 if (Continuation::is_return_barrier_entry(sender_pc)) {
168 // sender_pc might be invalid so check that the frame
169 // actually belongs to a Continuation.
170 if (!Continuation::is_frame_in_continuation(thread, *this)) {
171 return false;
172 }
173 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
174 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
175 sender_sp = s.sp();
176 sender_pc = s.pc();
177 }
178
179 // If the potential sender is the interpreter then we can do some more checking
180 if (Interpreter::contains(sender_pc)) {
181
182 // fp is always saved in a recognizable place in any code we generate. However
183 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved fp
184 // is really a frame pointer.
185
186 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
808 }
809
810 // support for printing out where we are in a Java method
811 // needs to be passed current fp and bcp register values
812 // prints method name, bc index and bytecode name
813 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
814 DESCRIBE_FP_OFFSET(interpreter_frame_method);
815 uintptr_t *p = (uintptr_t *)fp;
816 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
817 printbc(m, bcx);
818 }
819
820 #ifndef PRODUCT
821 // This is a generic constructor which is only used by pns() in debug.cpp.
822 frame::frame(void* sp, void* fp, void* pc) {
823 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
824 }
825
826 #endif
827
828 // Check for a method with scalarized inline type arguments that needs
829 // a stack repair and return the repaired sender stack pointer.
830 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
831 nmethod* nm = _cb->as_nmethod_or_null();
832 if (nm != nullptr && nm->needs_stack_repair()) {
833 // The stack increment resides just below the saved FP on the stack and
834 // records the total frame size excluding the two words for saving FP and LR.
835 intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
836 assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
837 int real_frame_size = (*sp_inc_addr / wordSize) + 2;
838 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
839 sender_sp = unextended_sp() + real_frame_size;
840 }
841 return sender_sp;
842 }
843
844 void JavaFrameAnchor::make_walkable() {
845 // last frame set?
846 if (last_Java_sp() == nullptr) return;
847 // already walkable?
848 if (walkable()) return;
849 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
850 vmassert(last_Java_pc() == nullptr, "already walkable");
851 _last_Java_pc = (address)_last_Java_sp[-1];
852 vmassert(walkable(), "something went wrong");
853 }
|