< prev index next >

src/hotspot/cpu/aarch64/frame_aarch64.cpp

Print this page

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)) {

605   if (is_interpreted_frame()) {
606     DESCRIBE_FP_OFFSET(interpreter_frame_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",  \
647            (uintptr_t)(p + frame::name##_offset),    \
648            p[frame::name##_offset], #name);          \
649   }
650 
651 static THREAD_LOCAL uintptr_t nextfp;

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)) {

608   if (is_interpreted_frame()) {
609     DESCRIBE_FP_OFFSET(interpreter_frame_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       if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
629         values.describe(frame_no, real_fp() - sender_sp_offset - 1, err_msg("fsize for #%d", frame_no), 1);
630       }
631       frame::CompiledFramePointers cfp = compiled_frame_details();
632       ret_pc_loc = (intptr_t*)cfp.sender_pc_addr;
633       fp_loc = (intptr_t*)cfp.saved_fp_addr;
634     }
635     address ret_pc = *(address*)ret_pc_loc;
636     values.describe(frame_no, ret_pc_loc,
637       Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
638     values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
639 
640     intptr_t* ret_pc_loc2 = real_fp() - return_addr_offset;
641     if (ret_pc_loc2 != ret_pc_loc) {
642       intptr_t* fp_loc2 = real_fp() - sender_sp_offset;
643       values.describe(frame_no, ret_pc_loc2, "return address copy #2");
644       values.describe(-1, fp_loc2, "saved fp copy #2", 0);
645     }
646   }
647 }
648 #endif
649 
650 intptr_t *frame::initial_deoptimization_info() {
651   // Not used on aarch64, but we must return something.
652   return nullptr;
653 }
654 
655 #undef DESCRIBE_FP_OFFSET
656 
657 #define DESCRIBE_FP_OFFSET(name)                     \
658   {                                                  \
659     uintptr_t *p = (uintptr_t *)fp;                  \
660     printf(INTPTR_FORMAT " " INTPTR_FORMAT " %s\n",  \
661            (uintptr_t)(p + frame::name##_offset),    \
662            p[frame::name##_offset], #name);          \
663   }
664 
665 static THREAD_LOCAL uintptr_t nextfp;

776 }
777 
778 // support for printing out where we are in a Java method
779 // needs to be passed current fp and bcp register values
780 // prints method name, bc index and bytecode name
781 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
782   DESCRIBE_FP_OFFSET(interpreter_frame_method);
783   uintptr_t *p = (uintptr_t *)fp;
784   Method* m = (Method*)p[frame::interpreter_frame_method_offset];
785   printbc(m, bcx);
786 }
787 
788 #ifndef PRODUCT
789 // This is a generic constructor which is only used by pns() in debug.cpp.
790 frame::frame(void* sp, void* fp, void* pc) {
791   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
792 }
793 
794 #endif
795 
796 // Check for a method with scalarized inline type arguments that needs
797 // a stack repair and return the repaired sender stack pointer.
798 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
799   nmethod* nm = _cb->as_nmethod_or_null();
800   if (nm != nullptr && nm->needs_stack_repair()) {
801     // The stack increment resides just below the saved FP on the stack and
802     // records the total frame size excluding the two words for saving FP and LR
803     // (see MacroAssembler::remove_frame).
804     intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
805     assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
806     int real_frame_size = (*sp_inc_addr / wordSize) + metadata_words_at_bottom;
807     assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
808     sender_sp = unextended_sp() + real_frame_size;
809   }
810   return sender_sp;
811 }
812 
813 // See comment in MacroAssembler::remove_frame
814 frame::CompiledFramePointers frame::compiled_frame_details() const {
815   // we cannot rely upon the last fp having been saved to the thread
816   // in C2 code but it will have been pushed onto the stack. so we
817   // have to find it relative to the unextended sp
818 
819   assert(_cb->frame_size() > 0, "must have non-zero frame size");
820 
821   // if need stack repair: the bottom of the fake frame, under LR #2
822   // else the bottom of the frame
823   intptr_t* l_sender_sp = (!PreserveFramePointer || _sp_is_trusted)
824       ? unextended_sp() + _cb->frame_size()
825       : sender_sp();
826 
827   assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
828 
829   // the actual bottom of the frame. This actually changes something if the frame needs stack repair
830   l_sender_sp = repair_sender_sp(l_sender_sp, (intptr_t**)(l_sender_sp - frame::sender_sp_offset));
831 
832   // From the sender's sp, we can locate the real saved lr (x30) and rfp (x29): they are
833   // immediately above, no matter if the stack was extended or not
834   CompiledFramePointers cfp;
835   cfp.sender_sp = l_sender_sp;
836   cfp.saved_fp_addr = (intptr_t**)(l_sender_sp - frame::sender_sp_offset);
837   cfp.sender_pc_addr = (address*)(l_sender_sp - frame::return_addr_offset);
838 
839   return cfp;
840 }
841 
842 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
843   assert(nm != nullptr && nm->needs_stack_repair(), "");
844   // The stack increment resides just below the saved FP on the stack and
845   // records the total frame size excluding the two words for saving FP and LR
846   // (see MacroAssembler::remove_frame).
847   intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
848   int real_frame_size = (*real_frame_size_addr / wordSize) + metadata_words_at_bottom;
849   assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
850   return sp + real_frame_size;
851 }
852 
853 bool frame::was_augmented_on_entry(int& real_size) const {
854   assert(is_compiled_frame(), "");
855   if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
856     // The stack increment resides just below the saved FP on the stack and
857     // records the total frame size excluding the two words for saving FP and LR
858     // (see MacroAssembler::remove_frame).
859     intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
860     log_trace(continuations)("real_frame_size is addr is " INTPTR_FORMAT, p2i(real_frame_size_addr));
861     real_size = (*real_frame_size_addr / wordSize) + metadata_words_at_bottom;
862     return real_size != _cb->frame_size();
863   }
864   real_size = _cb->frame_size();
865   return false;
866 }
867 
868 void JavaFrameAnchor::make_walkable() {
869   // last frame set?
870   if (last_Java_sp() == nullptr) return;
871   // already walkable?
872   if (walkable()) return;
873   vmassert(last_Java_sp() != nullptr, "not called from Java code?");
874   _last_Java_pc = (address)_last_Java_sp[-1];
875   vmassert(walkable(), "something went wrong");
876 }
< prev index next >