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)) {
593 DESCRIBE_FP_OFFSET(interpreter_frame_cache);
594 DESCRIBE_FP_OFFSET(interpreter_frame_locals);
595 DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
596 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
597 } else if (is_entry_frame()) {
598 // This could be more descriptive if we use the enum in
599 // stubGenerator to map to real names but it's most important to
600 // claim these frame slots so the error checking works.
601 for (int i = 0; i < entry_frame_after_call_words; i++) {
602 values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
603 }
604 }
605
606 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
607 intptr_t* ret_pc_loc;
608 intptr_t* fp_loc;
609 if (is_interpreted_frame()) {
610 ret_pc_loc = fp() + return_addr_offset;
611 fp_loc = fp();
612 } else {
613 ret_pc_loc = real_fp() - return_addr_offset;
614 fp_loc = real_fp() - sender_sp_offset;
615 }
616 address ret_pc = *(address*)ret_pc_loc;
617 values.describe(frame_no, ret_pc_loc,
618 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
619 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
620 }
621 }
622
623 #endif // !PRODUCT
624
625 intptr_t *frame::initial_deoptimization_info() {
626 // used to reset the saved FP
627 return fp();
628 }
629
630 #ifndef PRODUCT
631 // This is a generic constructor which is only used by pns() in debug.cpp.
632 frame::frame(void* sp, void* fp, void* pc) {
633 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
634 }
635
636 #endif
637
638 void JavaFrameAnchor::make_walkable() {
639 // last frame set?
640 if (last_Java_sp() == nullptr) return;
641 // already walkable?
642 if (walkable()) return;
643 _last_Java_pc = (address)_last_Java_sp[-1];
644 vmassert(walkable(), "something went wrong");
645 }
|
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)) {
596 DESCRIBE_FP_OFFSET(interpreter_frame_cache);
597 DESCRIBE_FP_OFFSET(interpreter_frame_locals);
598 DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
599 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
600 } else if (is_entry_frame()) {
601 // This could be more descriptive if we use the enum in
602 // stubGenerator to map to real names but it's most important to
603 // claim these frame slots so the error checking works.
604 for (int i = 0; i < entry_frame_after_call_words; i++) {
605 values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
606 }
607 }
608
609 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
610 intptr_t* ret_pc_loc;
611 intptr_t* fp_loc;
612 if (is_interpreted_frame()) {
613 ret_pc_loc = fp() + return_addr_offset;
614 fp_loc = fp();
615 } else {
616 if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
617 values.describe(frame_no, real_fp() - sender_sp_offset - 1, err_msg("fsize for #%d", frame_no), 1);
618 }
619 frame::CompiledFramePointers cfp = compiled_frame_details();
620 ret_pc_loc = (intptr_t*)cfp.sender_pc_addr;
621 fp_loc = (intptr_t*)cfp.saved_fp_addr;
622 }
623 address ret_pc = *(address*)ret_pc_loc;
624 values.describe(frame_no, ret_pc_loc,
625 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
626 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
627
628 intptr_t* ret_pc_loc2 = real_fp() - return_addr_offset;
629 if (ret_pc_loc2 != ret_pc_loc) {
630 intptr_t* fp_loc2 = real_fp() - sender_sp_offset;
631 values.describe(frame_no, ret_pc_loc2, "return address copy #2");
632 values.describe(-1, fp_loc2, "saved fp copy #2", 0);
633 }
634 }
635 }
636
637 #endif // !PRODUCT
638
639 intptr_t *frame::initial_deoptimization_info() {
640 // used to reset the saved FP
641 return fp();
642 }
643
644 #ifndef PRODUCT
645 // This is a generic constructor which is only used by pns() in debug.cpp.
646 frame::frame(void* sp, void* fp, void* pc) {
647 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
648 }
649
650 #endif
651
652 // Check for a method with scalarized inline type arguments that needs
653 // a stack repair and return the repaired sender stack pointer.
654 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
655 nmethod* nm = _cb->as_nmethod_or_null();
656 if (nm != nullptr && nm->needs_stack_repair()) {
657 // The stack increment resides just below the saved rbp on the stack
658 // and does not account for the return address and rbp (see MacroAssembler::remove_frame).
659 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
660 int real_frame_size = (*real_frame_size_addr / wordSize) + metadata_words_at_bottom;
661 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
662 sender_sp = unextended_sp() + real_frame_size;
663 }
664 return sender_sp;
665 }
666
667
668 // See comment in MacroAssembler::remove_frame
669 frame::CompiledFramePointers frame::compiled_frame_details() const {
670 // frame owned by optimizing compiler
671 assert(_cb->frame_size() > 0, "must have non-zero frame size");
672 intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
673 assert(sender_sp == real_fp(), "");
674
675 // Repair the sender sp if the frame has been extended
676 sender_sp = repair_sender_sp(sender_sp, (intptr_t**)(sender_sp - frame::sender_sp_offset));
677
678 CompiledFramePointers cfp;
679 cfp.sender_sp = sender_sp;
680 cfp.saved_fp_addr = (intptr_t**)(sender_sp - frame::sender_sp_offset);
681 // On Intel the return_address is always the word on the stack
682 cfp.sender_pc_addr = (address*)(sender_sp - frame::return_addr_offset);
683
684 return cfp;
685 }
686
687 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
688 assert(nm != nullptr && nm->needs_stack_repair(), "");
689 // The stack increment resides just below the saved rbp on the stack
690 // and does not account for the return address and rbp (see MacroAssembler::remove_frame).
691 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
692 int real_frame_size = (*real_frame_size_addr / wordSize) + metadata_words_at_bottom;
693 assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
694 return sp + real_frame_size;
695 }
696
697 bool frame::was_augmented_on_entry(int& real_size) const {
698 assert(is_compiled_frame(), "");
699 if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
700 // The stack increment resides just below the saved rbp on the stack
701 // and does not account for the return address and rbp (see MacroAssembler::remove_frame).
702 intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
703 real_size = (*real_frame_size_addr / wordSize) + metadata_words_at_bottom;
704 return real_size != _cb->frame_size();
705 }
706 real_size = _cb->frame_size();
707 return false;
708 }
709
710 void JavaFrameAnchor::make_walkable() {
711 // last frame set?
712 if (last_Java_sp() == nullptr) return;
713 // already walkable?
714 if (walkable()) return;
715 _last_Java_pc = (address)_last_Java_sp[-1];
716 vmassert(walkable(), "something went wrong");
717 }
|