Path: blob/master/src/hotspot/cpu/x86/frame_x86.inline.hpp
41144 views
/*1* Copyright (c) 1997, 2021, 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_FRAME_X86_INLINE_HPP25#define CPU_X86_FRAME_X86_INLINE_HPP2627#include "code/codeCache.hpp"28#include "code/vmreg.inline.hpp"29#include "runtime/registerMap.hpp"3031// Inline functions for Intel 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}4344inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {45_sp = sp;46_unextended_sp = sp;47_fp = fp;48_pc = pc;49assert(pc != NULL, "no pc?");50_cb = CodeCache::find_blob(pc);51adjust_unextended_sp();5253address original_pc = CompiledMethod::get_deopt_original_pc(this);54if (original_pc != NULL) {55_pc = original_pc;56_deopt_state = is_deoptimized;57} else {58_deopt_state = not_deoptimized;59}60}6162inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {63init(sp, fp, pc);64}6566inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {67_sp = sp;68_unextended_sp = unextended_sp;69_fp = fp;70_pc = pc;71assert(pc != NULL, "no pc?");72_cb = CodeCache::find_blob(pc);73adjust_unextended_sp();7475address original_pc = CompiledMethod::get_deopt_original_pc(this);76if (original_pc != NULL) {77_pc = original_pc;78assert(_cb->as_compiled_method()->insts_contains_inclusive(_pc),79"original PC must be in the main code section of the the compiled method (or must be immediately following it)");80_deopt_state = is_deoptimized;81} else {82if (_cb->is_deoptimization_stub()) {83_deopt_state = is_deoptimized;84} else {85_deopt_state = not_deoptimized;86}87}88}8990inline frame::frame(intptr_t* sp, intptr_t* fp) {91_sp = sp;92_unextended_sp = sp;93_fp = fp;94_pc = (address)(sp[-1]);9596// Here's a sticky one. This constructor can be called via AsyncGetCallTrace97// when last_Java_sp is non-null but the pc fetched is junk. If we are truly98// unlucky the junk value could be to a zombied method and we'll die on the99// find_blob call. This is also why we can have no asserts on the validity100// of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler101// -> pd_last_frame should use a specialized version of pd_last_frame which could102// call a specialized frame constructor instead of this one.103// Then we could use the assert below. However this assert is of somewhat dubious104// value.105// UPDATE: this constructor is only used by trace_method_handle_stub() now.106// assert(_pc != NULL, "no pc?");107108_cb = CodeCache::find_blob(_pc);109adjust_unextended_sp();110111address original_pc = CompiledMethod::get_deopt_original_pc(this);112if (original_pc != NULL) {113_pc = original_pc;114_deopt_state = is_deoptimized;115} else {116_deopt_state = not_deoptimized;117}118}119120// Accessors121122inline bool frame::equal(frame other) const {123bool ret = sp() == other.sp()124&& unextended_sp() == other.unextended_sp()125&& fp() == other.fp()126&& pc() == other.pc();127assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");128return ret;129}130131// Return unique id for this frame. The id must have a value where we can distinguish132// identity and younger/older relationship. NULL represents an invalid (incomparable)133// frame.134inline intptr_t* frame::id(void) const { return unextended_sp(); }135136// Return true if the frame is older (less recent activation) than the frame represented by id137inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");138return this->id() > id ; }139140141142inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }143144inline 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(); }150151inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }152153inline intptr_t** frame::interpreter_frame_locals_addr() const {154return (intptr_t**)addr_at(interpreter_frame_locals_offset);155}156157inline intptr_t* frame::interpreter_frame_last_sp() const {158return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);159}160161inline intptr_t* frame::interpreter_frame_bcp_addr() const {162return (intptr_t*)addr_at(interpreter_frame_bcp_offset);163}164165166inline intptr_t* frame::interpreter_frame_mdp_addr() const {167return (intptr_t*)addr_at(interpreter_frame_mdp_offset);168}169170171172// Constant pool cache173174inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {175return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);176}177178// Method179180inline Method** frame::interpreter_frame_method_addr() const {181return (Method**)addr_at(interpreter_frame_method_offset);182}183184// Mirror185186inline oop* frame::interpreter_frame_mirror_addr() const {187return (oop*)addr_at(interpreter_frame_mirror_offset);188}189190// top of expression stack191inline intptr_t* frame::interpreter_frame_tos_address() const {192intptr_t* last_sp = interpreter_frame_last_sp();193if (last_sp == NULL) {194return sp();195} else {196// sp() may have been extended or shrunk by an adapter. At least197// check that we don't fall behind the legal region.198// For top deoptimized frame last_sp == interpreter_frame_monitor_end.199assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");200return last_sp;201}202}203204inline oop* frame::interpreter_frame_temp_oop_addr() const {205return (oop *)(fp() + interpreter_frame_oop_temp_offset);206}207208inline int frame::interpreter_frame_monitor_size() {209return BasicObjectLock::size();210}211212213// expression stack214// (the max_stack arguments are used by the GC; see class FrameClosure)215216inline intptr_t* frame::interpreter_frame_expression_stack() const {217intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();218return monitor_end-1;219}220221// Entry frames222223inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {224return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);225}226227// Compiled frames228229inline oop frame::saved_oop_result(RegisterMap* map) const {230oop* result_adr = (oop *)map->location(rax->as_VMReg());231guarantee(result_adr != NULL, "bad register save location");232233return (*result_adr);234}235236inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {237oop* result_adr = (oop *)map->location(rax->as_VMReg());238guarantee(result_adr != NULL, "bad register save location");239240*result_adr = obj;241}242243#endif // CPU_X86_FRAME_X86_INLINE_HPP244245246