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]);
431 assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
432 if (_cb != nullptr) return sender_for_compiled_frame(map);
433
434 // Must be native-compiled frame, i.e. the marshaling code for native
435 // methods that exists in the core system.
436
437 // Native code may or may not have signed the return address, we have no way to be sure or what
438 // signing methods they used. Instead, just ensure the stripped value is used.
439
440 return frame(sender_sp(), link(), sender_pc());
441 }
442
443 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
444 // we cannot rely upon the last fp having been saved to the thread
445 // in C2 code but it will have been pushed onto the stack. so we
446 // have to find it relative to the unextended sp
447
448 assert(_cb->frame_size() > 0, "must have non-zero frame size");
449 intptr_t* l_sender_sp = (!PreserveFramePointer || _sp_is_trusted) ? unextended_sp() + _cb->frame_size()
450 : sender_sp();
451 assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
452
453 // The return_address is always the word on the stack.
454 // For ROP protection, C1/C2 will have signed the sender_pc,
455 // but there is no requirement to authenticate it here.
456 address sender_pc = pauth_strip_verifiable((address) *(l_sender_sp - 1));
457
458 intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);
459
460 if (map->update_map()) {
461 // Tell GC to use argument oopmaps for some runtime stubs that need it.
462 // For C1, the runtime stub might not have oop maps, so set this flag
463 // outside of update_register_map.
464 if (!_cb->is_nmethod()) { // compiled frames do not use callee-saved registers
465 map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
466 if (oop_map() != nullptr) {
467 _oop_map->update_register_map(this, map);
468 }
469 } else {
470 assert(!_cb->caller_must_gc_arguments(map->thread()), "");
471 assert(!map->include_argument_oops(), "");
472 assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
473 }
474
475 // Since the prolog does the save and restore of FP there is no oopmap
476 // for it so we must fill in its location as if there was an oopmap entry
477 // since if our caller was compiled code there could be live jvm state in it.
478 update_map_with_saved_link(map, saved_fp_addr);
479 }
480
481 if (Continuation::is_return_barrier_entry(sender_pc)) {
482 if (map->walk_cont()) { // about to walk into an h-stack
483 return Continuation::top_frame(*this, map);
484 } else {
485 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 #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]);
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 #ifdef ASSERT
455 address sender_pc_copy = pauth_strip_verifiable((address) *(l_sender_sp-1));
456 #endif
457
458 assert(!_sp_is_trusted || l_sender_sp == real_fp(), "");
459
460 intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);
461
462 // Repair the sender sp if the frame has been extended
463 l_sender_sp = repair_sender_sp(l_sender_sp, saved_fp_addr);
464
465 // The return_address is always the word on the stack.
466 // For ROP protection, C1/C2 will have signed the sender_pc,
467 // but there is no requirement to authenticate it here.
468 address sender_pc = pauth_strip_verifiable((address) *(l_sender_sp - 1));
469
470 #ifdef ASSERT
471 if (sender_pc != sender_pc_copy) {
472 // When extending the stack in the callee method entry to make room for unpacking of value
473 // type args, we keep a copy of the sender pc at the expected location in the callee frame.
474 // If the sender pc is patched due to deoptimization, the copy is not consistent anymore.
475 nmethod* nm = CodeCache::find_blob(sender_pc)->as_nmethod();
476 assert(sender_pc == nm->deopt_handler_begin(), "unexpected sender pc");
477 }
478 #endif
479
480 if (map->update_map()) {
481 // Tell GC to use argument oopmaps for some runtime stubs that need it.
482 // For C1, the runtime stub might not have oop maps, so set this flag
483 // outside of update_register_map.
484 bool c1_buffering = false;
485 #ifdef COMPILER1
486 nmethod* nm = _cb->as_nmethod_or_null();
487 if (nm != nullptr && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
488 pc() < nm->verified_inline_entry_point()) {
489 // 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'?
490 // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
491 // before doing any argument shuffling, so we need to scan the oops
492 // as the caller passes them.
493 c1_buffering = true;
494 }
495 #endif
496 if (!_cb->is_nmethod() || c1_buffering) { // compiled frames do not use callee-saved registers
497 bool caller_args = _cb->caller_must_gc_arguments(map->thread()) || c1_buffering;
498 map->set_include_argument_oops(caller_args);
499 if (oop_map() != nullptr) {
500 _oop_map->update_register_map(this, map);
501 }
502 } else {
503 assert(!_cb->caller_must_gc_arguments(map->thread()), "");
504 assert(!map->include_argument_oops(), "");
505 assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
506 }
507
508 // Since the prolog does the save and restore of FP there is no oopmap
509 // for it so we must fill in its location as if there was an oopmap entry
510 // since if our caller was compiled code there could be live jvm state in it.
511 update_map_with_saved_link(map, saved_fp_addr);
512 }
513
514 if (Continuation::is_return_barrier_entry(sender_pc)) {
515 if (map->walk_cont()) { // about to walk into an h-stack
516 return Continuation::top_frame(*this, map);
517 } else {
518 return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp);
|