Path: blob/master/src/hotspot/cpu/s390/frame_s390.inline.hpp
40930 views
/*1* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016 SAP SE. 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_S390_FRAME_S390_INLINE_HPP26#define CPU_S390_FRAME_S390_INLINE_HPP2728#include "code/codeCache.hpp"29#include "code/vmreg.inline.hpp"30#include "utilities/align.hpp"3132// Inline functions for z/Architecture frames:3334inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) {35assert(pc != NULL, "precondition: must have PC");3637_cb = CodeCache::find_blob(pc);38_pc = pc; // Must be set for get_deopt_original_pc().3940_fp = (intptr_t *) own_abi()->callers_sp;4142address original_pc = CompiledMethod::get_deopt_original_pc(this);43if (original_pc != NULL) {44_pc = original_pc;45_deopt_state = is_deoptimized;46} else {47_deopt_state = not_deoptimized;48}4950assert(((uint64_t)_sp & 0x7) == 0, "SP must be 8-byte aligned");51}5253// Constructors5455// Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state.56inline frame::frame() : _sp(NULL), _pc(NULL), _cb(NULL), _deopt_state(unknown), _unextended_sp(NULL), _fp(NULL) {}5758inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) {59find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->return_pc);60}6162inline frame::frame(intptr_t* sp, address pc) : _sp(sp), _unextended_sp(sp) {63find_codeblob_and_set_pc_and_deopt_state(pc); // Also sets _fp and adjusts _unextended_sp.64}6566inline frame::frame(intptr_t* sp, address pc, intptr_t* unextended_sp) : _sp(sp), _unextended_sp(unextended_sp) {67find_codeblob_and_set_pc_and_deopt_state(pc); // Also sets _fp and adjusts _unextended_sp.68}6970// Generic constructor. Used by pns() in debug.cpp only71#ifndef PRODUCT72inline frame::frame(void* sp, void* pc, void* unextended_sp) :73_sp((intptr_t*)sp), _pc(NULL), _cb(NULL), _unextended_sp((intptr_t*)unextended_sp) {74find_codeblob_and_set_pc_and_deopt_state((address)pc); // Also sets _fp and adjusts _unextended_sp.75}76#endif7778// template interpreter state79inline frame::z_ijava_state* frame::ijava_state_unchecked() const {80z_ijava_state* state = (z_ijava_state*) ((uintptr_t)fp() - z_ijava_state_size);81return state;82}8384inline frame::z_ijava_state* frame::ijava_state() const {85z_ijava_state* state = ijava_state_unchecked();86assert(state->magic == (intptr_t) frame::z_istate_magic_number,87"wrong z_ijava_state in interpreter frame (no magic found)");88return state;89}9091inline BasicObjectLock** frame::interpreter_frame_monitors_addr() const {92return (BasicObjectLock**) &(ijava_state()->monitors);93}9495// The next two funcions read and write z_ijava_state.monitors.96inline BasicObjectLock* frame::interpreter_frame_monitors() const {97return *interpreter_frame_monitors_addr();98}99inline void frame::interpreter_frame_set_monitors(BasicObjectLock* monitors) {100*interpreter_frame_monitors_addr() = monitors;101}102103// Accessors104105// Return unique id for this frame. The id must have a value where we106// can distinguish identity and younger/older relationship. NULL107// represents an invalid (incomparable) frame.108inline intptr_t* frame::id(void) const {109// Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing.110return _fp;111}112113// Return true if this frame is older (less recent activation) than114// the frame represented by id.115inline bool frame::is_older(intptr_t* id) const {116assert(this->id() != NULL && id != NULL, "NULL frame id");117// Stack grows towards smaller addresses on z/Architecture.118return this->id() > id;119}120121inline int frame::frame_size(RegisterMap* map) const {122// Stack grows towards smaller addresses on z/Linux: sender is at a higher address.123return sender_sp() - sp();124}125126// Ignore c2i adapter frames.127inline intptr_t* frame::unextended_sp() const {128return _unextended_sp;129}130131inline address frame::sender_pc() const {132return (address) callers_abi()->return_pc;133}134135// Get caller pc, if caller is native from stack slot of gpr14.136inline address frame::native_sender_pc() const {137return (address) callers_abi()->gpr14;138}139140// Get caller pc from stack slot of gpr10.141inline address frame::callstub_sender_pc() const {142return (address) callers_abi()->gpr10;143}144145inline address* frame::sender_pc_addr() const {146return (address*) &(callers_abi()->return_pc);147}148149inline intptr_t* frame::sender_sp() const {150return (intptr_t*) callers_abi();151}152153inline intptr_t* frame::link() const {154return (intptr_t*) callers_abi()->callers_sp;155}156157inline intptr_t** frame::interpreter_frame_locals_addr() const {158return (intptr_t**) &(ijava_state()->locals);159}160161inline intptr_t* frame::interpreter_frame_bcp_addr() const {162return (intptr_t*) &(ijava_state()->bcp);163}164165inline intptr_t* frame::interpreter_frame_mdp_addr() const {166return (intptr_t*) &(ijava_state()->mdx);167}168169// Bottom(base) of the expression stack (highest address).170inline intptr_t* frame::interpreter_frame_expression_stack() const {171return (intptr_t*)interpreter_frame_monitor_end() - 1;172}173174inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {175return &interpreter_frame_tos_address()[offset];176}177178179// monitor elements180181// End is lower in memory than begin, and beginning element is oldest element.182// Also begin is one past last monitor.183184inline intptr_t* frame::interpreter_frame_top_frame_sp() {185return (intptr_t*)ijava_state()->top_frame_sp;186}187188inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) {189ijava_state()->top_frame_sp = (intptr_t) top_frame_sp;190}191192inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp) {193ijava_state()->sender_sp = (intptr_t) sender_sp;194}195196#ifdef ASSERT197inline void frame::interpreter_frame_set_magic() {198ijava_state()->magic = (intptr_t) frame::z_istate_magic_number;199}200#endif201202// Where z_ijava_state.esp is saved.203inline intptr_t** frame::interpreter_frame_esp_addr() const {204return (intptr_t**) &(ijava_state()->esp);205}206207// top of expression stack (lowest address)208inline intptr_t* frame::interpreter_frame_tos_address() const {209return *interpreter_frame_esp_addr() + 1;210}211212inline void frame::interpreter_frame_set_tos_address(intptr_t* x) {213*interpreter_frame_esp_addr() = x - 1;214}215216// Stack slot needed for native calls and GC.217inline oop * frame::interpreter_frame_temp_oop_addr() const {218return (oop *) ((address) _fp + _z_ijava_state_neg(oop_tmp));219}220221// In keeping with Intel side: end is lower in memory than begin.222// Beginning element is oldest element. Also begin is one past last monitor.223inline BasicObjectLock * frame::interpreter_frame_monitor_begin() const {224return (BasicObjectLock*)ijava_state();225}226227inline BasicObjectLock * frame::interpreter_frame_monitor_end() const {228return interpreter_frame_monitors();229}230231inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* monitors) {232interpreter_frame_set_monitors((BasicObjectLock *)monitors);233}234235inline int frame::interpreter_frame_monitor_size() {236// Number of stack slots for a monitor237return align_up(BasicObjectLock::size() /* number of stack slots */,238WordsPerLong /* Number of stack slots for a Java long. */);239}240241inline int frame::interpreter_frame_monitor_size_in_bytes() {242// Number of bytes for a monitor.243return frame::interpreter_frame_monitor_size() * wordSize;244}245246inline int frame::interpreter_frame_interpreterstate_size_in_bytes() {247return z_ijava_state_size;248}249250inline Method** frame::interpreter_frame_method_addr() const {251return (Method**)&(ijava_state()->method);252}253254inline oop* frame::interpreter_frame_mirror_addr() const {255return (oop*)&(ijava_state()->mirror);256}257258// Constant pool cache259260inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {261return (ConstantPoolCache**)&(ijava_state()->cpoolCache);262}263264// entry frames265266inline intptr_t* frame::entry_frame_argument_at(int offset) const {267// Since an entry frame always calls the interpreter first,268// the parameters are on the stack and relative to known register in the269// entry frame.270intptr_t* tos = (intptr_t*) entry_frame_locals()->arguments_tos_address;271return &tos[offset + 1]; // prepushed tos272}273274inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {275return (JavaCallWrapper**) &entry_frame_locals()->call_wrapper_address;276}277278inline oop frame::saved_oop_result(RegisterMap* map) const {279return *((oop*) map->location(Z_R2->as_VMReg())); // R2 is return register.280}281282inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {283*((oop*) map->location(Z_R2->as_VMReg())) = obj; // R2 is return register.284}285286inline intptr_t* frame::real_fp() const {287return fp();288}289290#endif // CPU_S390_FRAME_S390_INLINE_HPP291292293