Path: blob/master/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp
64441 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef CPU_AARCH64_FRAME_AARCH64_INLINE_HPP26#define CPU_AARCH64_FRAME_AARCH64_INLINE_HPP2728#include "code/codeCache.hpp"29#include "code/vmreg.inline.hpp"30#include "pauth_aarch64.hpp"3132// Inline functions for AArch64 frames:3334// Constructors:3536inline frame::frame() {37_pc = NULL;38_sp = NULL;39_unextended_sp = NULL;40_fp = NULL;41_cb = NULL;42_deopt_state = unknown;43}4445static int spin;4647inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {48assert(pauth_ptr_is_raw(pc), "cannot be signed");49intptr_t a = intptr_t(sp);50intptr_t b = intptr_t(fp);51_sp = sp;52_unextended_sp = sp;53_fp = fp;54_pc = pc;55assert(pc != NULL, "no pc?");56_cb = CodeCache::find_blob(pc);57adjust_unextended_sp();5859address original_pc = CompiledMethod::get_deopt_original_pc(this);60if (original_pc != NULL) {61_pc = original_pc;62_deopt_state = is_deoptimized;63} else {64_deopt_state = not_deoptimized;65}66}6768inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {69init(sp, fp, pc);70}7172inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {73assert(pauth_ptr_is_raw(pc), "cannot be signed");74intptr_t a = intptr_t(sp);75intptr_t b = intptr_t(fp);76_sp = sp;77_unextended_sp = unextended_sp;78_fp = fp;79_pc = pc;80assert(pc != NULL, "no pc?");81_cb = CodeCache::find_blob(pc);82adjust_unextended_sp();8384address original_pc = CompiledMethod::get_deopt_original_pc(this);85if (original_pc != NULL) {86_pc = original_pc;87assert(_cb->as_compiled_method()->insts_contains_inclusive(_pc),88"original PC must be in the main code section of the the compiled method (or must be immediately following it)");89_deopt_state = is_deoptimized;90} else {91_deopt_state = not_deoptimized;92}93}9495inline frame::frame(intptr_t* sp, intptr_t* fp) {96intptr_t a = intptr_t(sp);97intptr_t b = intptr_t(fp);98_sp = sp;99_unextended_sp = sp;100_fp = fp;101_pc = (address)(sp[-1]);102103// Here's a sticky one. This constructor can be called via AsyncGetCallTrace104// when last_Java_sp is non-null but the pc fetched is junk. If we are truly105// unlucky the junk value could be to a zombied method and we'll die on the106// find_blob call. This is also why we can have no asserts on the validity107// of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler108// -> pd_last_frame should use a specialized version of pd_last_frame which could109// call a specilaized frame constructor instead of this one.110// Then we could use the assert below. However this assert is of somewhat dubious111// value.112// assert(_pc != NULL, "no pc?");113114_cb = CodeCache::find_blob(_pc);115adjust_unextended_sp();116117address original_pc = CompiledMethod::get_deopt_original_pc(this);118if (original_pc != NULL) {119_pc = original_pc;120_deopt_state = is_deoptimized;121} else {122_deopt_state = not_deoptimized;123}124}125126// Accessors127128inline bool frame::equal(frame other) const {129bool ret = sp() == other.sp()130&& unextended_sp() == other.unextended_sp()131&& fp() == other.fp()132&& pc() == other.pc();133assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");134return ret;135}136137// Return unique id for this frame. The id must have a value where we can distinguish138// identity and younger/older relationship. NULL represents an invalid (incomparable)139// frame.140inline intptr_t* frame::id(void) const { return unextended_sp(); }141142// Return true if the frame is older (less recent activation) than the frame represented by id143inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");144return this->id() > id ; }145146inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }147148inline intptr_t* frame::link_or_null() const {149intptr_t** ptr = (intptr_t **)addr_at(link_offset);150return os::is_readable_pointer(ptr) ? *ptr : NULL;151}152153inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }154155// Return address:156157inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }158inline address frame::sender_pc_maybe_signed() const { return *sender_pc_addr(); }159inline address frame::sender_pc() const { return pauth_strip_pointer(sender_pc_maybe_signed()); }160161inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }162163inline intptr_t** frame::interpreter_frame_locals_addr() const {164return (intptr_t**)addr_at(interpreter_frame_locals_offset);165}166167inline intptr_t* frame::interpreter_frame_last_sp() const {168return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);169}170171inline intptr_t* frame::interpreter_frame_bcp_addr() const {172return (intptr_t*)addr_at(interpreter_frame_bcp_offset);173}174175inline intptr_t* frame::interpreter_frame_mdp_addr() const {176return (intptr_t*)addr_at(interpreter_frame_mdp_offset);177}178179180// Constant pool cache181182inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {183return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);184}185186// Method187188inline Method** frame::interpreter_frame_method_addr() const {189return (Method**)addr_at(interpreter_frame_method_offset);190}191192// Mirror193194inline oop* frame::interpreter_frame_mirror_addr() const {195return (oop*)addr_at(interpreter_frame_mirror_offset);196}197198// top of expression stack199inline intptr_t* frame::interpreter_frame_tos_address() const {200intptr_t* last_sp = interpreter_frame_last_sp();201if (last_sp == NULL) {202return sp();203} else {204// sp() may have been extended or shrunk by an adapter. At least205// check that we don't fall behind the legal region.206// For top deoptimized frame last_sp == interpreter_frame_monitor_end.207assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");208return last_sp;209}210}211212inline oop* frame::interpreter_frame_temp_oop_addr() const {213return (oop *)(fp() + interpreter_frame_oop_temp_offset);214}215216inline int frame::interpreter_frame_monitor_size() {217return BasicObjectLock::size();218}219220221// expression stack222// (the max_stack arguments are used by the GC; see class FrameClosure)223224inline intptr_t* frame::interpreter_frame_expression_stack() const {225intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();226return monitor_end-1;227}228229230// Entry frames231232inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {233return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);234}235236237// Compiled frames238239inline oop frame::saved_oop_result(RegisterMap* map) const {240oop* result_adr = (oop *)map->location(r0->as_VMReg());241guarantee(result_adr != NULL, "bad register save location");242243return (*result_adr);244}245246inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {247oop* result_adr = (oop *)map->location(r0->as_VMReg());248guarantee(result_adr != NULL, "bad register save location");249250*result_adr = obj;251}252253#endif // CPU_AARCH64_FRAME_AARCH64_INLINE_HPP254255256