< prev index next >

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

Print this page

 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 "interpreter/oopMapCache.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "pauth_aarch64.hpp"



 36 
 37 // Inline functions for AArch64 frames:
 38 
 39 // Constructors:
 40 
 41 inline frame::frame() {
 42   _pc = NULL;
 43   _sp = NULL;
 44   _unextended_sp = NULL;
 45   _fp = NULL;
 46   _cb = NULL;
 47   _deopt_state = unknown;
 48   _sp_is_trusted = false;
 49   _on_heap = false;
 50   DEBUG_ONLY(_frame_index = -1;)
 51 }
 52 
 53 static int spin;
 54 
 55 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {

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




416   assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
417 





418   // the return_address is always the word on the stack
419   // For ROP protection, C1/C2 will have signed the sender_pc, but there is no requirement to authenticate it here.
420   address sender_pc = pauth_strip_verifiable((address) *(l_sender_sp-1), (address) *(l_sender_sp-2));
421 
422   intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);








423 
424   if (map->update_map()) {
425     // Tell GC to use argument oopmaps for some runtime stubs that need it.
426     // For C1, the runtime stub might not have oop maps, so set this flag
427     // outside of update_register_map.
428     if (!_cb->is_compiled()) { // compiled frames do not use callee-saved registers
429       map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));












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

 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 "interpreter/oopMapCache.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "pauth_aarch64.hpp"
 36 #ifdef COMPILER1
 37 #include "c1/c1_Runtime1.hpp"
 38 #endif
 39 
 40 // Inline functions for AArch64 frames:
 41 
 42 // Constructors:
 43 
 44 inline frame::frame() {
 45   _pc = NULL;
 46   _sp = NULL;
 47   _unextended_sp = NULL;
 48   _fp = NULL;
 49   _cb = NULL;
 50   _deopt_state = unknown;
 51   _sp_is_trusted = false;
 52   _on_heap = false;
 53   DEBUG_ONLY(_frame_index = -1;)
 54 }
 55 
 56 static int spin;
 57 
 58 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {

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