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)) {
607 DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
608 DESCRIBE_FP_OFFSET(interpreter_frame_method);
609 DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
610 DESCRIBE_FP_OFFSET(interpreter_frame_extended_sp);
611 DESCRIBE_FP_OFFSET(interpreter_frame_mirror);
612 DESCRIBE_FP_OFFSET(interpreter_frame_cache);
613 DESCRIBE_FP_OFFSET(interpreter_frame_locals);
614 DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
615 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
616 }
617
618 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
619 intptr_t* ret_pc_loc;
620 intptr_t* fp_loc;
621 if (is_interpreted_frame()) {
622 ret_pc_loc = fp() + return_addr_offset;
623 fp_loc = fp();
624 } else {
625 ret_pc_loc = real_fp() - return_addr_offset;
626 fp_loc = real_fp() - sender_sp_offset;
627 }
628 address ret_pc = *(address*)ret_pc_loc;
629 values.describe(frame_no, ret_pc_loc,
630 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
631 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
632 }
633 }
634 #endif
635
636 intptr_t *frame::initial_deoptimization_info() {
637 // Not used on aarch64, but we must return something.
638 return nullptr;
639 }
640
641 #undef DESCRIBE_FP_OFFSET
642
643 #define DESCRIBE_FP_OFFSET(name) \
644 { \
645 uintptr_t *p = (uintptr_t *)fp; \
646 printf(INTPTR_FORMAT " " INTPTR_FORMAT " %s\n", \
762 }
763
764 // support for printing out where we are in a Java method
765 // needs to be passed current fp and bcp register values
766 // prints method name, bc index and bytecode name
767 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
768 DESCRIBE_FP_OFFSET(interpreter_frame_method);
769 uintptr_t *p = (uintptr_t *)fp;
770 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
771 printbc(m, bcx);
772 }
773
774 #ifndef PRODUCT
775 // This is a generic constructor which is only used by pns() in debug.cpp.
776 frame::frame(void* sp, void* fp, void* pc) {
777 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
778 }
779
780 #endif
781
782 void JavaFrameAnchor::make_walkable() {
783 // last frame set?
784 if (last_Java_sp() == nullptr) return;
785 // already walkable?
786 if (walkable()) return;
787 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
788 _last_Java_pc = (address)_last_Java_sp[-1];
789 vmassert(walkable(), "something went wrong");
790 }
|
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)) {
610 DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
611 DESCRIBE_FP_OFFSET(interpreter_frame_method);
612 DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
613 DESCRIBE_FP_OFFSET(interpreter_frame_extended_sp);
614 DESCRIBE_FP_OFFSET(interpreter_frame_mirror);
615 DESCRIBE_FP_OFFSET(interpreter_frame_cache);
616 DESCRIBE_FP_OFFSET(interpreter_frame_locals);
617 DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
618 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
619 }
620
621 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
622 intptr_t* ret_pc_loc;
623 intptr_t* fp_loc;
624 if (is_interpreted_frame()) {
625 ret_pc_loc = fp() + return_addr_offset;
626 fp_loc = fp();
627 } else {
628 ret_pc_loc = real_fp() - return_addr_offset;
629 fp_loc = real_fp() - sender_sp_offset;
630 if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
631 values.describe(frame_no, fp_loc - 1, err_msg("fsize for #%d", frame_no), 1);
632 }
633 }
634 address ret_pc = *(address*)ret_pc_loc;
635 values.describe(frame_no, ret_pc_loc,
636 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
637 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
638 }
639 }
640 #endif
641
642 intptr_t *frame::initial_deoptimization_info() {
643 // Not used on aarch64, but we must return something.
644 return nullptr;
645 }
646
647 #undef DESCRIBE_FP_OFFSET
648
649 #define DESCRIBE_FP_OFFSET(name) \
650 { \
651 uintptr_t *p = (uintptr_t *)fp; \
652 printf(INTPTR_FORMAT " " INTPTR_FORMAT " %s\n", \
768 }
769
770 // support for printing out where we are in a Java method
771 // needs to be passed current fp and bcp register values
772 // prints method name, bc index and bytecode name
773 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
774 DESCRIBE_FP_OFFSET(interpreter_frame_method);
775 uintptr_t *p = (uintptr_t *)fp;
776 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
777 printbc(m, bcx);
778 }
779
780 #ifndef PRODUCT
781 // This is a generic constructor which is only used by pns() in debug.cpp.
782 frame::frame(void* sp, void* fp, void* pc) {
783 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
784 }
785
786 #endif
787
788 // Check for a method with scalarized inline type arguments that needs
789 // a stack repair and return the repaired sender stack pointer.
790 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
791 nmethod* nm = _cb->as_nmethod_or_null();
792 if (nm != nullptr && nm->needs_stack_repair()) {
793 // The stack increment resides just below the saved FP on the stack and
794 // records the total frame size excluding the two words for saving FP and LR.
795 intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
796 assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
797 int real_frame_size = (*sp_inc_addr / wordSize) + 2;
798 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
799 sender_sp = unextended_sp() + real_frame_size;
800 }
801 return sender_sp;
802 }
803
804 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
805 assert(nm != nullptr && nm->needs_stack_repair(), "");
806 // The stack increment resides just below the saved FP on the stack and
807 // records the total frame size excluding the two words for saving FP and LR.
808 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
809 int real_frame_size = (*real_frame_size_addr / wordSize) + 2;
810 assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
811 return sp + real_frame_size;
812 }
813
814 bool frame::was_augmented_on_entry(int& real_size) const {
815 assert(is_compiled_frame(), "");
816 if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
817 intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
818 log_trace(continuations)("real_frame_size is addr is " INTPTR_FORMAT, p2i(real_frame_size_addr));
819 real_size = (*real_frame_size_addr / wordSize) + 2;
820 return real_size != _cb->frame_size();
821 }
822 real_size = _cb->frame_size();
823 return false;
824 }
825
826 void JavaFrameAnchor::make_walkable() {
827 // last frame set?
828 if (last_Java_sp() == nullptr) return;
829 // already walkable?
830 if (walkable()) return;
831 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
832 _last_Java_pc = (address)_last_Java_sp[-1];
833 vmassert(walkable(), "something went wrong");
834 }
|