< prev index next >

src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp

Print this page

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



 35 
 36 // Inline functions for AArch64 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]);

427     return map->stack_chunk()->sender(*this, map);
428   }
429 
430   if (is_entry_frame())       return sender_for_entry_frame(map);
431   if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
432   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
433 
434   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
435   if (_cb != nullptr) return sender_for_compiled_frame(map);
436 
437   // Must be native-compiled frame, i.e. the marshaling code for native
438   // methods that exists in the core system.
439 
440   // Native code may or may not have signed the return address, we have no way to be sure or what
441   // signing methods they used. Instead, just ensure the stripped value is used.
442 
443   return frame(sender_sp(), link(), sender_pc());
444 }
445 
446 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
447   // we cannot rely upon the last fp having been saved to the thread
448   // in C2 code but it will have been pushed onto the stack. so we
449   // have to find it relative to the unextended sp
450 
451   assert(_cb->frame_size() > 0, "must have non-zero frame size");
452   intptr_t* l_sender_sp = (!PreserveFramePointer || _sp_is_trusted) ? unextended_sp() + _cb->frame_size()
453                                                                     : sender_sp();
454   assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
455 
456   // The return_address is always the word on the stack.
457   // For ROP protection, C1/C2 will have signed the sender_pc,
458   // but there is no requirement to authenticate it here.
459   address sender_pc = pauth_strip_verifiable((address) *(l_sender_sp - 1));
460 
461   intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);
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     if (!_cb->is_nmethod()) { // compiled frames do not use callee-saved registers
468       map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));













469       if (oop_map() != nullptr) {
470         _oop_map->update_register_map(this, map);
471       }
472     } else {
473       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
474       assert(!map->include_argument_oops(), "");
475       assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
476     }
477 
478     // Since the prolog does the save and restore of FP there is no oopmap
479     // for it so we must fill in its location as if there was an oopmap entry
480     // since if our caller was compiled code there could be live jvm state in it.
481     update_map_with_saved_link(map, saved_fp_addr);
482   }
483 
484   if (Continuation::is_return_barrier_entry(sender_pc)) {
485     if (map->walk_cont()) { // about to walk into an h-stack
486       return Continuation::top_frame(*this, map);
487     } else {
488       return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp);
489     }
490   }
491 
492   intptr_t* unextended_sp = l_sender_sp;
493   return frame(l_sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
494 }
495 
496 template <typename RegisterMapT>
497 void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
498   // The interpreter and compiler(s) always save FP in a known
499   // location on entry. C2-compiled code uses FP as an allocatable
500   // callee-saved register. We must record where that location is so
501   // that if FP was live on callout from c2 we can find the saved copy.
502 
503   map->set_location(rfp->as_VMReg(), (address) link_addr);
504   // this is weird "H" ought to be at a higher address however the
505   // oopMaps seems to have the "H" regs at the same address and the
506   // vanilla register.
507   // XXXX make this go away
508   if (true) {
509     map->set_location(rfp->as_VMReg()->next(), (address) link_addr);
510   }
511 }
512 #endif // CPU_AARCH64_FRAME_AARCH64_INLINE_HPP

 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef CPU_AARCH64_FRAME_AARCH64_INLINE_HPP
 27 #define CPU_AARCH64_FRAME_AARCH64_INLINE_HPP
 28 
 29 #include "code/codeBlob.inline.hpp"
 30 #include "code/codeCache.inline.hpp"
 31 #include "code/vmreg.inline.hpp"
 32 #include "interpreter/interpreter.hpp"
 33 #include "runtime/sharedRuntime.hpp"
 34 #include "pauth_aarch64.hpp"
 35 #ifdef COMPILER1
 36 #include "c1/c1_Runtime1.hpp"
 37 #endif
 38 
 39 // Inline functions for AArch64 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]);

430     return map->stack_chunk()->sender(*this, map);
431   }
432 
433   if (is_entry_frame())       return sender_for_entry_frame(map);
434   if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
435   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
436 
437   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
438   if (_cb != nullptr) return sender_for_compiled_frame(map);
439 
440   // Must be native-compiled frame, i.e. the marshaling code for native
441   // methods that exists in the core system.
442 
443   // Native code may or may not have signed the return address, we have no way to be sure or what
444   // signing methods they used. Instead, just ensure the stripped value is used.
445 
446   return frame(sender_sp(), link(), sender_pc());
447 }
448 
449 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
450   CompiledFramePointers cfp = compiled_frame_details();







451 
452   // The return_address is always the word on the stack.
453   // For ROP protection, C1/C2 will have signed the sender_pc,
454   // but there is no requirement to authenticate it here.
455   address sender_pc = pauth_strip_verifiable(*cfp.sender_pc_addr);


456 
457   if (map->update_map()) {
458     // Tell GC to use argument oopmaps for some runtime stubs that need it.
459     // For C1, the runtime stub might not have oop maps, so set this flag
460     // outside of update_register_map.
461     bool c1_buffering = false;
462 #ifdef COMPILER1
463     nmethod* nm = _cb->as_nmethod_or_null();
464     if (nm != nullptr && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
465         pc() < nm->verified_inline_entry_point()) {
466       // TODO 8284443 Can't we do that by not passing 'dont_gc_arguments' in case 'StubId::c1_buffer_inline_args_id' in 'Runtime1::generate_code_for'?
467       // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
468       // before doing any argument shuffling, so we need to scan the oops
469       // as the caller passes them.
470       c1_buffering = true;
471     }
472 #endif
473     if (!_cb->is_nmethod() || c1_buffering) { // compiled frames do not use callee-saved registers
474       bool caller_args = _cb->caller_must_gc_arguments(map->thread()) || c1_buffering;
475       map->set_include_argument_oops(caller_args);
476       if (oop_map() != nullptr) {
477         _oop_map->update_register_map(this, map);
478       }
479     } else {
480       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
481       assert(!map->include_argument_oops(), "");
482       assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
483     }
484 
485     // Since the prolog does the save and restore of FP there is no oopmap
486     // for it so we must fill in its location as if there was an oopmap entry
487     // since if our caller was compiled code there could be live jvm state in it.
488     update_map_with_saved_link(map, cfp.saved_fp_addr);
489   }
490 
491   if (Continuation::is_return_barrier_entry(sender_pc)) {
492     if (map->walk_cont()) { // about to walk into an h-stack
493       return Continuation::top_frame(*this, map);
494     } else {
495       return Continuation::continuation_bottom_sender(map->thread(), *this, cfp.sender_sp);
496     }
497   }
498 
499   intptr_t* unextended_sp = cfp.sender_sp;
500   return frame(cfp.sender_sp, unextended_sp, *cfp.saved_fp_addr, sender_pc);
501 }
502 
503 template <typename RegisterMapT>
504 void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
505   // The interpreter and compiler(s) always save FP in a known
506   // location on entry. C2-compiled code uses FP as an allocatable
507   // callee-saved register. We must record where that location is so
508   // that if FP was live on callout from c2 we can find the saved copy.
509 
510   map->set_location(rfp->as_VMReg(), (address) link_addr);
511   // this is weird "H" ought to be at a higher address however the
512   // oopMaps seems to have the "H" regs at the same address and the
513   // vanilla register.
514   // XXXX make this go away
515   if (true) {
516     map->set_location(rfp->as_VMReg()->next(), (address) link_addr);
517   }
518 }
519 #endif // CPU_AARCH64_FRAME_AARCH64_INLINE_HPP
< prev index next >