< 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 // Constructors:
 39 
 40 inline frame::frame() {
 41   _pc = nullptr;
 42   _sp = nullptr;
 43   _unextended_sp = nullptr;
 44   _fp = nullptr;
 45   _cb = nullptr;
 46   _deopt_state = unknown;
 47   _sp_is_trusted = false;
 48   _on_heap = false;
 49   DEBUG_ONLY(_frame_index = -1;)
 50 }
 51 
 52 static int spin;
 53 
 54 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {

387   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
388   if (_cb != nullptr) return sender_for_compiled_frame(map);
389 
390   // Must be native-compiled frame, i.e. the marshaling code for native
391   // methods that exists in the core system.
392 
393   // Native code may or may not have signed the return address, we have no way to be sure or what
394   // signing methods they used. Instead, just ensure the stripped value is used.
395 
396   return frame(sender_sp(), link(), sender_pc());
397 }
398 
399 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
400   // we cannot rely upon the last fp having been saved to the thread
401   // in C2 code but it will have been pushed onto the stack. so we
402   // have to find it relative to the unextended sp
403 
404   assert(_cb->frame_size() > 0, "must have non-zero frame size");
405   intptr_t* l_sender_sp = (!PreserveFramePointer || _sp_is_trusted) ? unextended_sp() + _cb->frame_size()
406                                                                     : sender_sp();




407   assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
408 





409   // The return_address is always the word on the stack.
410   // For ROP protection, C1/C2 will have signed the sender_pc,
411   // but there is no requirement to authenticate it here.
412   address sender_pc = pauth_strip_verifiable((address) *(l_sender_sp - 1));
413 
414   intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);








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












422       if (oop_map() != nullptr) {
423         _oop_map->update_register_map(this, map);
424       }
425     } else {
426       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
427       assert(!map->include_argument_oops(), "");
428       assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
429     }
430 
431     // Since the prolog does the save and restore of FP there is no oopmap
432     // for it so we must fill in its location as if there was an oopmap entry
433     // since if our caller was compiled code there could be live jvm state in it.
434     update_map_with_saved_link(map, saved_fp_addr);
435   }
436 
437   if (Continuation::is_return_barrier_entry(sender_pc)) {
438     if (map->walk_cont()) { // about to walk into an h-stack
439       return Continuation::top_frame(*this, map);
440     } else {
441       return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp);

 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 // Constructors:
 42 
 43 inline frame::frame() {
 44   _pc = nullptr;
 45   _sp = nullptr;
 46   _unextended_sp = nullptr;
 47   _fp = nullptr;
 48   _cb = nullptr;
 49   _deopt_state = unknown;
 50   _sp_is_trusted = false;
 51   _on_heap = false;
 52   DEBUG_ONLY(_frame_index = -1;)
 53 }
 54 
 55 static int spin;
 56 
 57 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {

390   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
391   if (_cb != nullptr) return sender_for_compiled_frame(map);
392 
393   // Must be native-compiled frame, i.e. the marshaling code for native
394   // methods that exists in the core system.
395 
396   // Native code may or may not have signed the return address, we have no way to be sure or what
397   // signing methods they used. Instead, just ensure the stripped value is used.
398 
399   return frame(sender_sp(), link(), sender_pc());
400 }
401 
402 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
403   // we cannot rely upon the last fp having been saved to the thread
404   // in C2 code but it will have been pushed onto the stack. so we
405   // have to find it relative to the unextended sp
406 
407   assert(_cb->frame_size() > 0, "must have non-zero frame size");
408   intptr_t* l_sender_sp = (!PreserveFramePointer || _sp_is_trusted) ? unextended_sp() + _cb->frame_size()
409                                                                     : sender_sp();
410 #ifdef ASSERT
411    address sender_pc_copy = pauth_strip_verifiable((address) *(l_sender_sp-1));
412 #endif
413 
414   assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
415 
416   intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);
417 
418   // Repair the sender sp if the frame has been extended
419   l_sender_sp = repair_sender_sp(l_sender_sp, saved_fp_addr);
420 
421   // The return_address is always the word on the stack.
422   // For ROP protection, C1/C2 will have signed the sender_pc,
423   // but there is no requirement to authenticate it here.
424   address sender_pc = pauth_strip_verifiable((address) *(l_sender_sp - 1));
425 
426 #ifdef ASSERT
427   if (sender_pc != sender_pc_copy) {
428     // When extending the stack in the callee method entry to make room for unpacking of value
429     // type args, we keep a copy of the sender pc at the expected location in the callee frame.
430     // If the sender pc is patched due to deoptimization, the copy is not consistent anymore.
431     nmethod* nm = CodeCache::find_blob(sender_pc)->as_nmethod();
432     assert(sender_pc == nm->deopt_mh_handler_begin() || sender_pc == nm->deopt_handler_begin(), "unexpected sender pc");
433   }
434 #endif
435 
436   if (map->update_map()) {
437     // Tell GC to use argument oopmaps for some runtime stubs that need it.
438     // For C1, the runtime stub might not have oop maps, so set this flag
439     // outside of update_register_map.
440     bool c1_buffering = false;
441 #ifdef COMPILER1
442     nmethod* nm = _cb->as_nmethod_or_null();
443     if (nm != nullptr && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
444         pc() < nm->verified_inline_entry_point()) {
445       // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
446       // before doing any argument shuffling, so we need to scan the oops
447       // as the caller passes them.
448       c1_buffering = true;
449     }
450 #endif
451     if (!_cb->is_nmethod() || c1_buffering) { // compiled frames do not use callee-saved registers
452       bool caller_args = _cb->caller_must_gc_arguments(map->thread()) || c1_buffering;
453       map->set_include_argument_oops(caller_args);
454       if (oop_map() != nullptr) {
455         _oop_map->update_register_map(this, map);
456       }
457     } else {
458       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
459       assert(!map->include_argument_oops(), "");
460       assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
461     }
462 
463     // Since the prolog does the save and restore of FP there is no oopmap
464     // for it so we must fill in its location as if there was an oopmap entry
465     // since if our caller was compiled code there could be live jvm state in it.
466     update_map_with_saved_link(map, saved_fp_addr);
467   }
468 
469   if (Continuation::is_return_barrier_entry(sender_pc)) {
470     if (map->walk_cont()) { // about to walk into an h-stack
471       return Continuation::top_frame(*this, map);
472     } else {
473       return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp);
< prev index next >