Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp
32285 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef CPU_X86_VM_FRAME_X86_INLINE_HPP25#define CPU_X86_VM_FRAME_X86_INLINE_HPP2627#include "code/codeCache.hpp"2829// Inline functions for Intel frames:3031// Constructors:3233inline frame::frame() {34_pc = NULL;35_sp = NULL;36_unextended_sp = NULL;37_fp = NULL;38_cb = NULL;39_deopt_state = unknown;40}4142inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {43_sp = sp;44_unextended_sp = sp;45_fp = fp;46_pc = pc;47assert(pc != NULL, "no pc?");48_cb = CodeCache::find_blob(pc);49adjust_unextended_sp();5051address original_pc = nmethod::get_deopt_original_pc(this);52if (original_pc != NULL) {53_pc = original_pc;54_deopt_state = is_deoptimized;55} else {56_deopt_state = not_deoptimized;57}58}5960inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {61init(sp, fp, pc);62}6364inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {65_sp = sp;66_unextended_sp = unextended_sp;67_fp = fp;68_pc = pc;69assert(pc != NULL, "no pc?");70_cb = CodeCache::find_blob(pc);71adjust_unextended_sp();7273address original_pc = nmethod::get_deopt_original_pc(this);74if (original_pc != NULL) {75_pc = original_pc;76assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod");77_deopt_state = is_deoptimized;78} else {79_deopt_state = not_deoptimized;80}81}8283inline frame::frame(intptr_t* sp, intptr_t* fp) {84_sp = sp;85_unextended_sp = sp;86_fp = fp;87_pc = (address)(sp[-1]);8889// Here's a sticky one. This constructor can be called via AsyncGetCallTrace90// when last_Java_sp is non-null but the pc fetched is junk. If we are truly91// unlucky the junk value could be to a zombied method and we'll die on the92// find_blob call. This is also why we can have no asserts on the validity93// of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler94// -> pd_last_frame should use a specialized version of pd_last_frame which could95// call a specialized frame constructor instead of this one.96// Then we could use the assert below. However this assert is of somewhat dubious97// value.98// UPDATE: this constructor is only used by trace_method_handle_stub() now.99// assert(_pc != NULL, "no pc?");100101_cb = CodeCache::find_blob(_pc);102adjust_unextended_sp();103104address original_pc = nmethod::get_deopt_original_pc(this);105if (original_pc != NULL) {106_pc = original_pc;107_deopt_state = is_deoptimized;108} else {109_deopt_state = not_deoptimized;110}111}112113// Accessors114115inline bool frame::equal(frame other) const {116bool ret = sp() == other.sp()117&& unextended_sp() == other.unextended_sp()118&& fp() == other.fp()119&& pc() == other.pc();120assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");121return ret;122}123124// Return unique id for this frame. The id must have a value where we can distinguish125// identity and younger/older relationship. NULL represents an invalid (incomparable)126// frame.127inline intptr_t* frame::id(void) const { return unextended_sp(); }128129// Relationals on frames based130// Return true if the frame is younger (more recent activation) than the frame represented by id131inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");132return this->id() < id ; }133134// Return true if the frame is older (less recent activation) than the frame represented by id135inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");136return this->id() > id ; }137138139140inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }141inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; }142143144inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }145146// Return address:147148inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }149inline address frame::sender_pc() const { return *sender_pc_addr(); }150151// return address of param, zero origin index.152inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }153154#ifdef CC_INTERP155156inline interpreterState frame::get_interpreterState() const {157return ((interpreterState)addr_at( -((int)sizeof(BytecodeInterpreter))/wordSize ));158}159160inline intptr_t* frame::sender_sp() const {161// Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?162if (is_interpreted_frame()) {163assert(false, "should never happen");164return get_interpreterState()->sender_sp();165} else {166return addr_at(sender_sp_offset);167}168}169170inline intptr_t** frame::interpreter_frame_locals_addr() const {171assert(is_interpreted_frame(), "must be interpreted");172return &(get_interpreterState()->_locals);173}174175inline intptr_t* frame::interpreter_frame_bcx_addr() const {176assert(is_interpreted_frame(), "must be interpreted");177return (intptr_t*) &(get_interpreterState()->_bcp);178}179180181// Constant pool cache182183inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {184assert(is_interpreted_frame(), "must be interpreted");185return &(get_interpreterState()->_constants);186}187188// Method189190inline Method** frame::interpreter_frame_method_addr() const {191assert(is_interpreted_frame(), "must be interpreted");192return &(get_interpreterState()->_method);193}194195inline intptr_t* frame::interpreter_frame_mdx_addr() const {196assert(is_interpreted_frame(), "must be interpreted");197return (intptr_t*) &(get_interpreterState()->_mdx);198}199200// top of expression stack201inline intptr_t* frame::interpreter_frame_tos_address() const {202assert(is_interpreted_frame(), "wrong frame type");203return get_interpreterState()->_stack + 1;204}205206#else /* asm interpreter */207inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }208209inline intptr_t** frame::interpreter_frame_locals_addr() const {210return (intptr_t**)addr_at(interpreter_frame_locals_offset);211}212213inline intptr_t* frame::interpreter_frame_last_sp() const {214return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);215}216217inline intptr_t* frame::interpreter_frame_bcx_addr() const {218return (intptr_t*)addr_at(interpreter_frame_bcx_offset);219}220221222inline intptr_t* frame::interpreter_frame_mdx_addr() const {223return (intptr_t*)addr_at(interpreter_frame_mdx_offset);224}225226227228// Constant pool cache229230inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {231return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);232}233234// Method235236inline Method** frame::interpreter_frame_method_addr() const {237return (Method**)addr_at(interpreter_frame_method_offset);238}239240// top of expression stack241inline intptr_t* frame::interpreter_frame_tos_address() const {242intptr_t* last_sp = interpreter_frame_last_sp();243if (last_sp == NULL) {244return sp();245} else {246// sp() may have been extended or shrunk by an adapter. At least247// check that we don't fall behind the legal region.248// For top deoptimized frame last_sp == interpreter_frame_monitor_end.249assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");250return last_sp;251}252}253254inline oop* frame::interpreter_frame_temp_oop_addr() const {255return (oop *)(fp() + interpreter_frame_oop_temp_offset);256}257258#endif /* CC_INTERP */259260inline int frame::pd_oop_map_offset_adjustment() const {261return 0;262}263264inline int frame::interpreter_frame_monitor_size() {265return BasicObjectLock::size();266}267268269// expression stack270// (the max_stack arguments are used by the GC; see class FrameClosure)271272inline intptr_t* frame::interpreter_frame_expression_stack() const {273intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();274return monitor_end-1;275}276277278inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }279280281// Entry frames282283inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {284return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);285}286287// Compiled frames288289inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {290return (nof_args - local_index + (local_index < nof_args ? 1: -1));291}292293inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {294return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);295}296297inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {298return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);299}300301inline bool frame::volatile_across_calls(Register reg) {302return true;303}304305inline oop frame::saved_oop_result(RegisterMap* map) const {306oop* result_adr = (oop *)map->location(rax->as_VMReg());307guarantee(result_adr != NULL, "bad register save location");308309return (*result_adr);310}311312inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {313oop* result_adr = (oop *)map->location(rax->as_VMReg());314guarantee(result_adr != NULL, "bad register save location");315316*result_adr = obj;317}318319#endif // CPU_X86_VM_FRAME_X86_INLINE_HPP320321322