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)) {
650 DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
651 DESCRIBE_FP_OFFSET(interpreter_frame_method);
652 DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
653 DESCRIBE_FP_OFFSET(interpreter_frame_extended_sp);
654 DESCRIBE_FP_OFFSET(interpreter_frame_mirror);
655 DESCRIBE_FP_OFFSET(interpreter_frame_cache);
656 DESCRIBE_FP_OFFSET(interpreter_frame_locals);
657 DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
658 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
659 }
660
661 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
662 intptr_t* ret_pc_loc;
663 intptr_t* fp_loc;
664 if (is_interpreted_frame()) {
665 ret_pc_loc = fp() + return_addr_offset;
666 fp_loc = fp();
667 } else {
668 ret_pc_loc = real_fp() - return_addr_offset;
669 fp_loc = real_fp() - sender_sp_offset;
670 }
671 address ret_pc = *(address*)ret_pc_loc;
672 values.describe(frame_no, ret_pc_loc,
673 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
674 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
675 }
676 }
677 #endif
678
679 intptr_t *frame::initial_deoptimization_info() {
680 // Not used on aarch64, but we must return something.
681 return nullptr;
682 }
683
684 #undef DESCRIBE_FP_OFFSET
685
686 #define DESCRIBE_FP_OFFSET(name) \
687 { \
688 uintptr_t *p = (uintptr_t *)fp; \
689 printf(INTPTR_FORMAT " " INTPTR_FORMAT " %s\n", \
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 _last_Java_pc = (address)_last_Java_sp[-1];
832 vmassert(walkable(), "something went wrong");
833 }
|
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)) {
653 DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
654 DESCRIBE_FP_OFFSET(interpreter_frame_method);
655 DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
656 DESCRIBE_FP_OFFSET(interpreter_frame_extended_sp);
657 DESCRIBE_FP_OFFSET(interpreter_frame_mirror);
658 DESCRIBE_FP_OFFSET(interpreter_frame_cache);
659 DESCRIBE_FP_OFFSET(interpreter_frame_locals);
660 DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
661 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
662 }
663
664 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
665 intptr_t* ret_pc_loc;
666 intptr_t* fp_loc;
667 if (is_interpreted_frame()) {
668 ret_pc_loc = fp() + return_addr_offset;
669 fp_loc = fp();
670 } else {
671 ret_pc_loc = real_fp() - return_addr_offset;
672 fp_loc = real_fp() - sender_sp_offset;
673 if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
674 values.describe(frame_no, fp_loc - 1, err_msg("fsize for #%d", frame_no), 1);
675 }
676 }
677 address ret_pc = *(address*)ret_pc_loc;
678 values.describe(frame_no, ret_pc_loc,
679 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
680 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
681 }
682 }
683 #endif
684
685 intptr_t *frame::initial_deoptimization_info() {
686 // Not used on aarch64, but we must return something.
687 return nullptr;
688 }
689
690 #undef DESCRIBE_FP_OFFSET
691
692 #define DESCRIBE_FP_OFFSET(name) \
693 { \
694 uintptr_t *p = (uintptr_t *)fp; \
695 printf(INTPTR_FORMAT " " INTPTR_FORMAT " %s\n", \
811 }
812
813 // support for printing out where we are in a Java method
814 // needs to be passed current fp and bcp register values
815 // prints method name, bc index and bytecode name
816 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
817 DESCRIBE_FP_OFFSET(interpreter_frame_method);
818 uintptr_t *p = (uintptr_t *)fp;
819 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
820 printbc(m, bcx);
821 }
822
823 #ifndef PRODUCT
824 // This is a generic constructor which is only used by pns() in debug.cpp.
825 frame::frame(void* sp, void* fp, void* pc) {
826 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
827 }
828
829 #endif
830
831 // Check for a method with scalarized inline type arguments that needs
832 // a stack repair and return the repaired sender stack pointer.
833 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
834 nmethod* nm = _cb->as_nmethod_or_null();
835 if (nm != nullptr && nm->needs_stack_repair()) {
836 // The stack increment resides just below the saved FP on the stack and
837 // records the total frame size excluding the two words for saving FP and LR.
838 intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
839 assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
840 int real_frame_size = (*sp_inc_addr / wordSize) + 2;
841 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
842 sender_sp = unextended_sp() + real_frame_size;
843 }
844 return sender_sp;
845 }
846
847 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
848 assert(nm != nullptr && nm->needs_stack_repair(), "");
849 // The stack increment resides just below the saved FP on the stack and
850 // records the total frame size excluding the two words for saving FP and LR.
851 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
852 int real_frame_size = (*real_frame_size_addr / wordSize) + 2;
853 assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
854 return sp + real_frame_size;
855 }
856
857 bool frame::was_augmented_on_entry(int& real_size) const {
858 assert(is_compiled_frame(), "");
859 if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
860 intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
861 log_trace(continuations)("real_frame_size is addr is " INTPTR_FORMAT, p2i(real_frame_size_addr));
862 real_size = (*real_frame_size_addr / wordSize) + 2;
863 return real_size != _cb->frame_size();
864 }
865 real_size = _cb->frame_size();
866 return false;
867 }
868
869 void JavaFrameAnchor::make_walkable() {
870 // last frame set?
871 if (last_Java_sp() == nullptr) return;
872 // already walkable?
873 if (walkable()) return;
874 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
875 _last_Java_pc = (address)_last_Java_sp[-1];
876 vmassert(walkable(), "something went wrong");
877 }
|