< prev index next >

src/hotspot/cpu/x86/frame_x86.inline.hpp

Print this page

 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef CPU_X86_FRAME_X86_INLINE_HPP
 26 #define CPU_X86_FRAME_X86_INLINE_HPP
 27 
 28 #include "code/codeBlob.inline.hpp"
 29 #include "code/codeCache.inline.hpp"
 30 #include "code/vmreg.inline.hpp"
 31 #include "compiler/oopMap.inline.hpp"
 32 #include "interpreter/interpreter.hpp"
 33 #include "runtime/sharedRuntime.hpp"
 34 #include "runtime/registerMap.hpp"



 35 
 36 // Inline functions for Intel frames:
 37 
 38 #if INCLUDE_JFR
 39 
 40 // Static helper routines
 41 
 42 inline address frame::interpreter_bcp(const intptr_t* fp) {
 43   assert(fp != nullptr, "invariant");
 44   return reinterpret_cast<address>(fp[frame::interpreter_frame_bcp_offset]);
 45 }
 46 
 47 inline address frame::interpreter_return_address(const intptr_t* fp) {
 48   assert(fp != nullptr, "invariant");
 49   return reinterpret_cast<address>(fp[frame::return_addr_offset]);
 50 }
 51 
 52 inline intptr_t* frame::interpreter_sender_sp(const intptr_t* fp) {
 53   assert(fp != nullptr, "invariant");
 54   return reinterpret_cast<intptr_t*>(fp[frame::interpreter_frame_sender_sp_offset]);

415   if (is_entry_frame())       return sender_for_entry_frame(map);
416   if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
417   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
418 
419   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
420   if (_cb != nullptr) return sender_for_compiled_frame(map);
421 
422   // Must be native-compiled frame, i.e. the marshaling code for native
423   // methods that exists in the core system.
424   return frame(sender_sp(), link(), sender_pc());
425 }
426 
427 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
428   assert(map != nullptr, "map must be set");
429 
430   // frame owned by optimizing compiler
431   assert(_cb->frame_size() > 0, "must have non-zero frame size");
432   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
433   assert(sender_sp == real_fp(), "");
434 
435   // On Intel the return_address is always the word on the stack
436   address sender_pc = (address) *(sender_sp-1);

437 
438   // This is the saved value of EBP which may or may not really be an FP.
439   // It is only an FP if the sender is an interpreter frame (or C1?).
440   // saved_fp_addr should be correct even for a bottom thawed frame (with a return barrier)
441   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
442 
















443   if (map->update_map()) {
444     // Tell GC to use argument oopmaps for some runtime stubs that need it.
445     // For C1, the runtime stub might not have oop maps, so set this flag
446     // outside of update_register_map.
447     if (!_cb->is_nmethod()) { // compiled frames do not use callee-saved registers
448       map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));


















449       if (oop_map() != nullptr) {
450         _oop_map->update_register_map(this, map);
451       }
452     } else {
453       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
454       assert(!map->include_argument_oops(), "");
455       assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
456     }
457 
458     // Since the prolog does the save and restore of EBP there is no oopmap
459     // for it so we must fill in its location as if there was an oopmap entry
460     // since if our caller was compiled code there could be live jvm state in it.
461     update_map_with_saved_link(map, saved_fp_addr);
462   }
463 
464   assert(sender_sp != sp(), "must have changed");
465 
466   if (Continuation::is_return_barrier_entry(sender_pc)) {
467     if (map->walk_cont()) { // about to walk into an h-stack
468       return Continuation::top_frame(*this, map);

 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef CPU_X86_FRAME_X86_INLINE_HPP
 26 #define CPU_X86_FRAME_X86_INLINE_HPP
 27 
 28 #include "code/codeBlob.inline.hpp"
 29 #include "code/codeCache.inline.hpp"
 30 #include "code/vmreg.inline.hpp"
 31 #include "compiler/oopMap.inline.hpp"
 32 #include "interpreter/interpreter.hpp"
 33 #include "runtime/sharedRuntime.hpp"
 34 #include "runtime/registerMap.hpp"
 35 #ifdef COMPILER1
 36 #include "c1/c1_Runtime1.hpp"
 37 #endif
 38 
 39 // Inline functions for Intel frames:
 40 
 41 #if INCLUDE_JFR
 42 
 43 // Static helper routines
 44 
 45 inline address frame::interpreter_bcp(const intptr_t* fp) {
 46   assert(fp != nullptr, "invariant");
 47   return reinterpret_cast<address>(fp[frame::interpreter_frame_bcp_offset]);
 48 }
 49 
 50 inline address frame::interpreter_return_address(const intptr_t* fp) {
 51   assert(fp != nullptr, "invariant");
 52   return reinterpret_cast<address>(fp[frame::return_addr_offset]);
 53 }
 54 
 55 inline intptr_t* frame::interpreter_sender_sp(const intptr_t* fp) {
 56   assert(fp != nullptr, "invariant");
 57   return reinterpret_cast<intptr_t*>(fp[frame::interpreter_frame_sender_sp_offset]);

418   if (is_entry_frame())       return sender_for_entry_frame(map);
419   if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
420   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
421 
422   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
423   if (_cb != nullptr) return sender_for_compiled_frame(map);
424 
425   // Must be native-compiled frame, i.e. the marshaling code for native
426   // methods that exists in the core system.
427   return frame(sender_sp(), link(), sender_pc());
428 }
429 
430 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
431   assert(map != nullptr, "map must be set");
432 
433   // frame owned by optimizing compiler
434   assert(_cb->frame_size() > 0, "must have non-zero frame size");
435   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
436   assert(sender_sp == real_fp(), "");
437 
438 #ifdef ASSERT
439   address sender_pc_copy = (address) *(sender_sp-1);
440 #endif
441 
442   // This is the saved value of EBP which may or may not really be an FP.
443   // It is only an FP if the sender is an interpreter frame (or C1?).
444   // saved_fp_addr should be correct even for a bottom thawed frame (with a return barrier)
445   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
446 
447   // Repair the sender sp if the frame has been extended
448   sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
449 
450   // On Intel the return_address is always the word on the stack
451   address sender_pc = (address) *(sender_sp-1);
452 
453 #ifdef ASSERT
454   if (sender_pc != sender_pc_copy) {
455     // When extending the stack in the callee method entry to make room for unpacking of value
456     // type args, we keep a copy of the sender pc at the expected location in the callee frame.
457     // If the sender pc is patched due to deoptimization, the copy is not consistent anymore.
458     nmethod* nm = CodeCache::find_blob(sender_pc)->as_nmethod();
459     assert(sender_pc == nm->deopt_mh_handler_begin() || sender_pc == nm->deopt_handler_begin(), "unexpected sender pc");
460   }
461 #endif
462 
463   if (map->update_map()) {
464     // Tell GC to use argument oopmaps for some runtime stubs that need it.
465     // For C1, the runtime stub might not have oop maps, so set this flag
466     // outside of update_register_map.
467     bool c1_buffering = false;
468 #ifdef COMPILER1
469     nmethod* nm = _cb->as_nmethod_or_null();
470     if (nm != nullptr && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
471         pc() < nm->verified_inline_entry_point()) {
472       // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
473       // before doing any argument shuffling, so we need to scan the oops
474       // as the caller passes them.
475       c1_buffering = true;
476 #ifdef ASSERT
477       NativeCall* call = nativeCall_before(pc());
478       address dest = call->destination();
479       assert(dest == Runtime1::entry_for(C1StubId::buffer_inline_args_no_receiver_id) ||
480              dest == Runtime1::entry_for(C1StubId::buffer_inline_args_id), "unexpected safepoint in entry point");
481 #endif
482     }
483 #endif
484     if (!_cb->is_nmethod() || c1_buffering) { // compiled frames do not use callee-saved registers
485       bool caller_args = _cb->caller_must_gc_arguments(map->thread()) || c1_buffering;
486       map->set_include_argument_oops(caller_args);
487       if (oop_map() != nullptr) {
488         _oop_map->update_register_map(this, map);
489       }
490     } else {
491       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
492       assert(!map->include_argument_oops(), "");
493       assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
494     }
495 
496     // Since the prolog does the save and restore of EBP there is no oopmap
497     // for it so we must fill in its location as if there was an oopmap entry
498     // since if our caller was compiled code there could be live jvm state in it.
499     update_map_with_saved_link(map, saved_fp_addr);
500   }
501 
502   assert(sender_sp != sp(), "must have changed");
503 
504   if (Continuation::is_return_barrier_entry(sender_pc)) {
505     if (map->walk_cont()) { // about to walk into an h-stack
506       return Continuation::top_frame(*this, map);
< prev index next >