128 // which can be different from the sender unextended sp (the sp seen
129 // by the sender) because of current frame local variables
130 sender_sp = (intptr_t*) addr_at(sender_sp_offset);
131 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
132 saved_fp = (intptr_t*) this->fp()[link_offset];
133
134 } else {
135 // must be some sort of compiled/runtime frame
136 // fp does not have to be safe (although it could be check for c1?)
137
138 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
139 if (_cb->frame_size() <= 0) {
140 return false;
141 }
142
143 sender_sp = _unextended_sp + _cb->frame_size();
144 // Is sender_sp safe?
145 if (!thread->is_in_full_stack_checked((address)sender_sp)) {
146 return false;
147 }
148 sender_unextended_sp = sender_sp;
149 // On Intel the return_address is always the word on the stack
150 sender_pc = (address) *(sender_sp-1);
151 // Note: frame::sender_sp_offset is only valid for compiled frame
152 saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset);
153 }
154
155 if (Continuation::is_return_barrier_entry(sender_pc)) {
156 // sender_pc might be invalid so check that the frame
157 // actually belongs to a Continuation.
158 if (!Continuation::is_frame_in_continuation(thread, *this)) {
159 return false;
160 }
161 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
162 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
163 sender_sp = s.sp();
164 sender_pc = s.pc();
165 }
166
167 // If the potential sender is the interpreter then we can do some more checking
168 if (Interpreter::contains(sender_pc)) {
169
170 // ebp is always saved in a recognizable place in any code we generate. However
171 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved ebp
172 // is really a frame pointer.
173
174 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
614 #ifdef AMD64
615 } else if (is_entry_frame()) {
616 // This could be more descriptive if we use the enum in
617 // stubGenerator to map to real names but it's most important to
618 // claim these frame slots so the error checking works.
619 for (int i = 0; i < entry_frame_after_call_words; i++) {
620 values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
621 }
622 #endif // AMD64
623 }
624
625 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
626 intptr_t* ret_pc_loc;
627 intptr_t* fp_loc;
628 if (is_interpreted_frame()) {
629 ret_pc_loc = fp() + return_addr_offset;
630 fp_loc = fp();
631 } else {
632 ret_pc_loc = real_fp() - return_addr_offset;
633 fp_loc = real_fp() - sender_sp_offset;
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 }
641
642 #endif // !PRODUCT
643
644 intptr_t *frame::initial_deoptimization_info() {
645 // used to reset the saved FP
646 return fp();
647 }
648
649 #ifndef PRODUCT
650 // This is a generic constructor which is only used by pns() in debug.cpp.
651 frame::frame(void* sp, void* fp, void* pc) {
652 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
653 }
654
655 #endif
656
657 void JavaFrameAnchor::make_walkable() {
658 // last frame set?
659 if (last_Java_sp() == nullptr) return;
660 // already walkable?
661 if (walkable()) return;
662 _last_Java_pc = (address)_last_Java_sp[-1];
663 vmassert(walkable(), "something went wrong");
664 }
|
128 // which can be different from the sender unextended sp (the sp seen
129 // by the sender) because of current frame local variables
130 sender_sp = (intptr_t*) addr_at(sender_sp_offset);
131 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
132 saved_fp = (intptr_t*) this->fp()[link_offset];
133
134 } else {
135 // must be some sort of compiled/runtime frame
136 // fp does not have to be safe (although it could be check for c1?)
137
138 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
139 if (_cb->frame_size() <= 0) {
140 return false;
141 }
142
143 sender_sp = _unextended_sp + _cb->frame_size();
144 // Is sender_sp safe?
145 if (!thread->is_in_full_stack_checked((address)sender_sp)) {
146 return false;
147 }
148 // On Intel the return_address is always the word on the stack
149 sender_pc = (address) *(sender_sp-1);
150 // Note: frame::sender_sp_offset is only valid for compiled frame
151 intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
152 saved_fp = *saved_fp_addr;
153
154 // Repair the sender sp if this is a method with scalarized inline type args
155 sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
156 sender_unextended_sp = sender_sp;
157 }
158 if (Continuation::is_return_barrier_entry(sender_pc)) {
159 // sender_pc might be invalid so check that the frame
160 // actually belongs to a Continuation.
161 if (!Continuation::is_frame_in_continuation(thread, *this)) {
162 return false;
163 }
164 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
165 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
166 sender_sp = s.sp();
167 sender_pc = s.pc();
168 }
169
170 // If the potential sender is the interpreter then we can do some more checking
171 if (Interpreter::contains(sender_pc)) {
172
173 // ebp is always saved in a recognizable place in any code we generate. However
174 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved ebp
175 // is really a frame pointer.
176
177 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
617 #ifdef AMD64
618 } else if (is_entry_frame()) {
619 // This could be more descriptive if we use the enum in
620 // stubGenerator to map to real names but it's most important to
621 // claim these frame slots so the error checking works.
622 for (int i = 0; i < entry_frame_after_call_words; i++) {
623 values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
624 }
625 #endif // AMD64
626 }
627
628 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
629 intptr_t* ret_pc_loc;
630 intptr_t* fp_loc;
631 if (is_interpreted_frame()) {
632 ret_pc_loc = fp() + return_addr_offset;
633 fp_loc = fp();
634 } else {
635 ret_pc_loc = real_fp() - return_addr_offset;
636 fp_loc = real_fp() - sender_sp_offset;
637 if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
638 values.describe(frame_no, fp_loc - 1, err_msg("fsize for #%d", frame_no), 1);
639 }
640 }
641 address ret_pc = *(address*)ret_pc_loc;
642 values.describe(frame_no, ret_pc_loc,
643 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
644 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
645 }
646 }
647
648 #endif // !PRODUCT
649
650 intptr_t *frame::initial_deoptimization_info() {
651 // used to reset the saved FP
652 return fp();
653 }
654
655 #ifndef PRODUCT
656 // This is a generic constructor which is only used by pns() in debug.cpp.
657 frame::frame(void* sp, void* fp, void* pc) {
658 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
659 }
660
661 #endif
662
663 // Check for a method with scalarized inline type arguments that needs
664 // a stack repair and return the repaired sender stack pointer.
665 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
666 nmethod* nm = _cb->as_nmethod_or_null();
667 if (nm != nullptr && nm->needs_stack_repair()) {
668 // The stack increment resides just below the saved rbp on the stack
669 // and does not account for the return address.
670 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
671 int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
672 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
673 sender_sp = unextended_sp() + real_frame_size;
674 }
675 return sender_sp;
676 }
677
678 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
679 assert(nm != nullptr && nm->needs_stack_repair(), "");
680 // The stack increment resides just below the saved rbp on the stack
681 // and does not account for the return address.
682 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
683 int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
684 assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
685 return sp + real_frame_size;
686 }
687
688 bool frame::was_augmented_on_entry(int& real_size) const {
689 assert(is_compiled_frame(), "");
690 if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
691 intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
692 log_trace(continuations)("real_frame_size is addr is " INTPTR_FORMAT, p2i(real_frame_size_addr));
693 real_size = ((*real_frame_size_addr) + wordSize) / wordSize;
694 return real_size != _cb->frame_size();
695 }
696 real_size = _cb->frame_size();
697 return false;
698 }
699
700 void JavaFrameAnchor::make_walkable() {
701 // last frame set?
702 if (last_Java_sp() == nullptr) return;
703 // already walkable?
704 if (walkable()) return;
705 _last_Java_pc = (address)_last_Java_sp[-1];
706 vmassert(walkable(), "something went wrong");
707 }
|