Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp
32285 views
/*1* Copyright (c) 2013, Red Hat Inc.2* Copyright (c) 1997, 2010, Oracle and/or its affiliates.3* All rights reserved.4* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5*6* This code is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License version 2 only, as8* published by the Free Software Foundation.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*24*/2526#ifndef CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP27#define CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP2829#include "code/codeCache.hpp"3031// Inline functions for AArch64 frames:3233// Constructors:3435inline frame::frame() {36_pc = NULL;37_sp = NULL;38_unextended_sp = NULL;39_fp = NULL;40_cb = NULL;41_deopt_state = unknown;42}4344//static int spin;4546inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {47intptr_t a = intptr_t(sp);48intptr_t b = intptr_t(fp);49_sp = sp;50_unextended_sp = sp;51_fp = fp;52_pc = pc;53assert(pc != NULL, "no pc?");54_cb = CodeCache::find_blob(pc);55adjust_unextended_sp();5657address original_pc = nmethod::get_deopt_original_pc(this);58if (original_pc != NULL) {59_pc = original_pc;60_deopt_state = is_deoptimized;61} else {62_deopt_state = not_deoptimized;63}64}6566inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {67init(sp, fp, pc);68}6970inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {71intptr_t a = intptr_t(sp);72intptr_t b = intptr_t(fp);73_sp = sp;74_unextended_sp = unextended_sp;75_fp = fp;76_pc = pc;77assert(pc != NULL, "no pc?");78_cb = CodeCache::find_blob(pc);79adjust_unextended_sp();8081address original_pc = nmethod::get_deopt_original_pc(this);82if (original_pc != NULL) {83_pc = original_pc;84assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod");85_deopt_state = is_deoptimized;86} else {87_deopt_state = not_deoptimized;88}89}9091inline frame::frame(intptr_t* sp, intptr_t* fp) {92intptr_t a = intptr_t(sp);93intptr_t b = intptr_t(fp);94_sp = sp;95_unextended_sp = sp;96_fp = fp;97_pc = (address)(sp[-1]);9899// Here's a sticky one. This constructor can be called via AsyncGetCallTrace100// when last_Java_sp is non-null but the pc fetched is junk. If we are truly101// unlucky the junk value could be to a zombied method and we'll die on the102// find_blob call. This is also why we can have no asserts on the validity103// of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler104// -> pd_last_frame should use a specialized version of pd_last_frame which could105// call a specilaized frame constructor instead of this one.106// Then we could use the assert below. However this assert is of somewhat dubious107// value.108// assert(_pc != NULL, "no pc?");109110_cb = CodeCache::find_blob(_pc);111adjust_unextended_sp();112113address original_pc = nmethod::get_deopt_original_pc(this);114if (original_pc != NULL) {115_pc = original_pc;116_deopt_state = is_deoptimized;117} else {118_deopt_state = not_deoptimized;119}120}121122// Accessors123124inline bool frame::equal(frame other) const {125bool ret = sp() == other.sp()126&& unextended_sp() == other.unextended_sp()127&& fp() == other.fp()128&& pc() == other.pc();129assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");130return ret;131}132133// Return unique id for this frame. The id must have a value where we can distinguish134// identity and younger/older relationship. NULL represents an invalid (incomparable)135// frame.136inline intptr_t* frame::id(void) const { return unextended_sp(); }137138// Relationals on frames based139// Return true if the frame is younger (more recent activation) than the frame represented by id140inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");141return this->id() < id ; }142143// Return true if the frame is older (less recent activation) than the frame represented by id144inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");145return this->id() > id ; }146147148149inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }150inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; }151152153inline 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() const { return *sender_pc_addr(); }159160// return address of param, zero origin index.161inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }162163#ifdef CC_INTERP164165inline interpreterState frame::get_interpreterState() const {166return ((interpreterState)addr_at( -((int)sizeof(BytecodeInterpreter))/wordSize ));167}168169inline intptr_t* frame::sender_sp() const {170// Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?171if (is_interpreted_frame()) {172assert(false, "should never happen");173return get_interpreterState()->sender_sp();174} else {175return addr_at(sender_sp_offset);176}177}178179inline intptr_t** frame::interpreter_frame_locals_addr() const {180assert(is_interpreted_frame(), "must be interpreted");181return &(get_interpreterState()->_locals);182}183184inline intptr_t* frame::interpreter_frame_bcx_addr() const {185assert(is_interpreted_frame(), "must be interpreted");186return (intptr_t*) &(get_interpreterState()->_bcp);187}188189190// Constant pool cache191192inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {193assert(is_interpreted_frame(), "must be interpreted");194return &(get_interpreterState()->_constants);195}196197// Method198199inline methodOop* frame::interpreter_frame_method_addr() const {200assert(is_interpreted_frame(), "must be interpreted");201return &(get_interpreterState()->_method);202}203204inline intptr_t* frame::interpreter_frame_mdx_addr() const {205assert(is_interpreted_frame(), "must be interpreted");206return (intptr_t*) &(get_interpreterState()->_mdx);207}208209// top of expression stack210inline intptr_t* frame::interpreter_frame_tos_address() const {211assert(is_interpreted_frame(), "wrong frame type");212return get_interpreterState()->_stack + 1;213}214215#else /* asm interpreter */216inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }217218inline intptr_t** frame::interpreter_frame_locals_addr() const {219return (intptr_t**)addr_at(interpreter_frame_locals_offset);220}221222inline intptr_t* frame::interpreter_frame_last_sp() const {223return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);224}225226inline intptr_t* frame::interpreter_frame_bcx_addr() const {227return (intptr_t*)addr_at(interpreter_frame_bcx_offset);228}229230231inline intptr_t* frame::interpreter_frame_mdx_addr() const {232return (intptr_t*)addr_at(interpreter_frame_mdx_offset);233}234235236237// Constant pool cache238239inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {240return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);241}242243// Method244245inline Method** frame::interpreter_frame_method_addr() const {246return (Method**)addr_at(interpreter_frame_method_offset);247}248249// top of expression stack250inline intptr_t* frame::interpreter_frame_tos_address() const {251intptr_t* last_sp = interpreter_frame_last_sp();252if (last_sp == NULL) {253return sp();254} else {255// sp() may have been extended or shrunk by an adapter. At least256// check that we don't fall behind the legal region.257// For top deoptimized frame last_sp == interpreter_frame_monitor_end.258assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");259return last_sp;260}261}262263inline oop* frame::interpreter_frame_temp_oop_addr() const {264return (oop *)(fp() + interpreter_frame_oop_temp_offset);265}266267#endif /* CC_INTERP */268269inline int frame::pd_oop_map_offset_adjustment() const {270return 0;271}272273inline int frame::interpreter_frame_monitor_size() {274return BasicObjectLock::size();275}276277278// expression stack279// (the max_stack arguments are used by the GC; see class FrameClosure)280281inline intptr_t* frame::interpreter_frame_expression_stack() const {282intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();283return monitor_end-1;284}285286287inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }288289290// Entry frames291292inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {293return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);294}295296297// Compiled frames298299inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {300return (nof_args - local_index + (local_index < nof_args ? 1: -1));301}302303inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {304return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);305}306307inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {308return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);309}310311inline bool frame::volatile_across_calls(Register reg) {312return true;313}314315316317inline oop frame::saved_oop_result(RegisterMap* map) const {318oop* result_adr = (oop *)map->location(r0->as_VMReg());319guarantee(result_adr != NULL, "bad register save location");320321return (*result_adr);322}323324inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {325oop* result_adr = (oop *)map->location(r0->as_VMReg());326guarantee(result_adr != NULL, "bad register save location");327328*result_adr = obj;329}330331#endif // CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP332333334