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

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

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       ret_pc_loc = real_fp() - return_addr_offset;
617       fp_loc = real_fp() - sender_sp_offset;
618       if (cb()->is_nmethod() && cb()->as_nmethod_or_null()->needs_stack_repair()) {
619         values.describe(frame_no, fp_loc - 1, err_msg("fsize for #%d", frame_no), 1);
620       }
621     }
622     address ret_pc = *(address*)ret_pc_loc;
623     values.describe(frame_no, ret_pc_loc,
624       Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
625     values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
626   }
627 }
628 
629 #endif // !PRODUCT
630 
631 intptr_t *frame::initial_deoptimization_info() {
632   // used to reset the saved FP
633   return fp();
634 }
635 
636 #ifndef PRODUCT
637 // This is a generic constructor which is only used by pns() in debug.cpp.
638 frame::frame(void* sp, void* fp, void* pc) {
639   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
640 }
641 
642 #endif
643 
644 // Check for a method with scalarized inline type arguments that needs
645 // a stack repair and return the repaired sender stack pointer.
646 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
647   nmethod* nm = _cb->as_nmethod_or_null();
648   if (nm != nullptr && nm->needs_stack_repair()) {
649     // The stack increment resides just below the saved rbp on the stack
650     // and does not account for the return address.
651     intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
652     int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
653     assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
654     sender_sp = unextended_sp() + real_frame_size;
655   }
656   return sender_sp;
657 }
658 
659 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
660   assert(nm != nullptr && nm->needs_stack_repair(), "");
661   // The stack increment resides just below the saved rbp on the stack
662   // and does not account for the return address.
663   intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
664   int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
665   assert(real_frame_size >= nm->frame_size() && real_frame_size <= 1000000, "invalid frame size");
666   return sp + real_frame_size;
667 }
668 
669 bool frame::was_augmented_on_entry(int& real_size) const {
670   assert(is_compiled_frame(), "");
671   if (_cb->as_nmethod_or_null()->needs_stack_repair()) {
672     intptr_t* real_frame_size_addr = unextended_sp() + _cb->frame_size() - sender_sp_offset - 1;
673     log_trace(continuations)("real_frame_size is addr is " INTPTR_FORMAT, p2i(real_frame_size_addr));
674     real_size = ((*real_frame_size_addr) + wordSize) / wordSize;
675     return real_size != _cb->frame_size();
676   }
677   real_size = _cb->frame_size();
678   return false;
679 }
680 
681 void JavaFrameAnchor::make_walkable() {
682   // last frame set?
683   if (last_Java_sp() == nullptr) return;
684   // already walkable?
685   if (walkable()) return;
686   _last_Java_pc = (address)_last_Java_sp[-1];
687   vmassert(walkable(), "something went wrong");
688 }
< prev index next >