< prev index next >

src/hotspot/cpu/x86/frame_x86.cpp

Print this page

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

656 #ifdef AMD64
657   } else if (is_entry_frame()) {
658     // This could be more descriptive if we use the enum in
659     // stubGenerator to map to real names but it's most important to
660     // claim these frame slots so the error checking works.
661     for (int i = 0; i < entry_frame_after_call_words; i++) {
662       values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
663     }
664 #endif // AMD64
665   }
666 
667   if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
668     intptr_t* ret_pc_loc;
669     intptr_t* fp_loc;
670     if (is_interpreted_frame()) {
671       ret_pc_loc = fp() + return_addr_offset;
672       fp_loc = fp();
673     } else {
674       ret_pc_loc = real_fp() - return_addr_offset;
675       fp_loc = real_fp() - sender_sp_offset;



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 
684 #endif // !PRODUCT
685 
686 intptr_t *frame::initial_deoptimization_info() {
687   // used to reset the saved FP
688   return fp();
689 }
690 
691 #ifndef PRODUCT
692 // This is a generic constructor which is only used by pns() in debug.cpp.
693 frame::frame(void* sp, void* fp, void* pc) {
694   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
695 }
696 
697 #endif
698 





































699 void JavaFrameAnchor::make_walkable() {
700   // last frame set?
701   if (last_Java_sp() == nullptr) return;
702   // already walkable?
703   if (walkable()) return;
704   _last_Java_pc = (address)_last_Java_sp[-1];
705   vmassert(walkable(), "something went wrong");
706 }

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

659 #ifdef AMD64
660   } else if (is_entry_frame()) {
661     // This could be more descriptive if we use the enum in
662     // stubGenerator to map to real names but it's most important to
663     // claim these frame slots so the error checking works.
664     for (int i = 0; i < entry_frame_after_call_words; i++) {
665       values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
666     }
667 #endif // AMD64
668   }
669 
670   if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) {
671     intptr_t* ret_pc_loc;
672     intptr_t* fp_loc;
673     if (is_interpreted_frame()) {
674       ret_pc_loc = fp() + return_addr_offset;
675       fp_loc = fp();
676     } else {
677       ret_pc_loc = real_fp() - return_addr_offset;
678       fp_loc = real_fp() - sender_sp_offset;
679       if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
680         values.describe(frame_no, fp_loc - 1, err_msg("fsize for #%d", frame_no), 1);
681       }
682     }
683     address ret_pc = *(address*)ret_pc_loc;
684     values.describe(frame_no, ret_pc_loc,
685       Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
686     values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
687   }
688 }
689 
690 #endif // !PRODUCT
691 
692 intptr_t *frame::initial_deoptimization_info() {
693   // used to reset the saved FP
694   return fp();
695 }
696 
697 #ifndef PRODUCT
698 // This is a generic constructor which is only used by pns() in debug.cpp.
699 frame::frame(void* sp, void* fp, void* pc) {
700   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
701 }
702 
703 #endif
704 
705 // Check for a method with scalarized inline type arguments that needs
706 // a stack repair and return the repaired sender stack pointer.
707 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
708   nmethod* nm = _cb->as_nmethod_or_null();
709   if (nm != nullptr && nm->needs_stack_repair()) {
710     // The stack increment resides just below the saved rbp on the stack
711     // and does not account for the return address.
712     intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
713     int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
714     assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
715     sender_sp = unextended_sp() + real_frame_size;
716   }
717   return sender_sp;
718 }
719 
720 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
721   assert(nm != nullptr && nm->needs_stack_repair(), "");
722   // The stack increment resides just below the saved rbp on the stack
723   // and does not account for the return address.
724   intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
725   int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
726   assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
727   return sp + real_frame_size;
728 }
729 
730 bool frame::was_augmented_on_entry(int& real_size) const {
731   assert(is_compiled_frame(), "");
732   if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
733     intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
734     log_trace(continuations)("real_frame_size is addr is " INTPTR_FORMAT, p2i(real_frame_size_addr));
735     real_size = ((*real_frame_size_addr) + wordSize) / wordSize;
736     return real_size != _cb->frame_size();
737   }
738   real_size = _cb->frame_size();
739   return false;
740 }
741 
742 void JavaFrameAnchor::make_walkable() {
743   // last frame set?
744   if (last_Java_sp() == nullptr) return;
745   // already walkable?
746   if (walkable()) return;
747   _last_Java_pc = (address)_last_Java_sp[-1];
748   vmassert(walkable(), "something went wrong");
749 }
< prev index next >