Path: blob/master/src/hotspot/cpu/s390/frame_s390.inline.hpp
64440 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::link_or_null() const {158return link();159}160161inline intptr_t** frame::interpreter_frame_locals_addr() const {162return (intptr_t**) &(ijava_state()->locals);163}164165inline intptr_t* frame::interpreter_frame_bcp_addr() const {166return (intptr_t*) &(ijava_state()->bcp);167}168169inline intptr_t* frame::interpreter_frame_mdp_addr() const {170return (intptr_t*) &(ijava_state()->mdx);171}172173// Bottom(base) of the expression stack (highest address).174inline intptr_t* frame::interpreter_frame_expression_stack() const {175return (intptr_t*)interpreter_frame_monitor_end() - 1;176}177178inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {179return &interpreter_frame_tos_address()[offset];180}181182183// monitor elements184185// End is lower in memory than begin, and beginning element is oldest element.186// Also begin is one past last monitor.187188inline intptr_t* frame::interpreter_frame_top_frame_sp() {189return (intptr_t*)ijava_state()->top_frame_sp;190}191192inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) {193ijava_state()->top_frame_sp = (intptr_t) top_frame_sp;194}195196inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp) {197ijava_state()->sender_sp = (intptr_t) sender_sp;198}199200#ifdef ASSERT201inline void frame::interpreter_frame_set_magic() {202ijava_state()->magic = (intptr_t) frame::z_istate_magic_number;203}204#endif205206// Where z_ijava_state.esp is saved.207inline intptr_t** frame::interpreter_frame_esp_addr() const {208return (intptr_t**) &(ijava_state()->esp);209}210211// top of expression stack (lowest address)212inline intptr_t* frame::interpreter_frame_tos_address() const {213return *interpreter_frame_esp_addr() + 1;214}215216inline void frame::interpreter_frame_set_tos_address(intptr_t* x) {217*interpreter_frame_esp_addr() = x - 1;218}219220// Stack slot needed for native calls and GC.221inline oop * frame::interpreter_frame_temp_oop_addr() const {222return (oop *) ((address) _fp + _z_ijava_state_neg(oop_tmp));223}224225// In keeping with Intel side: end is lower in memory than begin.226// Beginning element is oldest element. Also begin is one past last monitor.227inline BasicObjectLock * frame::interpreter_frame_monitor_begin() const {228return (BasicObjectLock*)ijava_state();229}230231inline BasicObjectLock * frame::interpreter_frame_monitor_end() const {232return interpreter_frame_monitors();233}234235inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* monitors) {236interpreter_frame_set_monitors((BasicObjectLock *)monitors);237}238239inline int frame::interpreter_frame_monitor_size() {240// Number of stack slots for a monitor241return align_up(BasicObjectLock::size() /* number of stack slots */,242WordsPerLong /* Number of stack slots for a Java long. */);243}244245inline int frame::interpreter_frame_monitor_size_in_bytes() {246// Number of bytes for a monitor.247return frame::interpreter_frame_monitor_size() * wordSize;248}249250inline int frame::interpreter_frame_interpreterstate_size_in_bytes() {251return z_ijava_state_size;252}253254inline Method** frame::interpreter_frame_method_addr() const {255return (Method**)&(ijava_state()->method);256}257258inline oop* frame::interpreter_frame_mirror_addr() const {259return (oop*)&(ijava_state()->mirror);260}261262// Constant pool cache263264inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {265return (ConstantPoolCache**)&(ijava_state()->cpoolCache);266}267268// entry frames269270inline intptr_t* frame::entry_frame_argument_at(int offset) const {271// Since an entry frame always calls the interpreter first,272// the parameters are on the stack and relative to known register in the273// entry frame.274intptr_t* tos = (intptr_t*) entry_frame_locals()->arguments_tos_address;275return &tos[offset + 1]; // prepushed tos276}277278inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {279return (JavaCallWrapper**) &entry_frame_locals()->call_wrapper_address;280}281282inline oop frame::saved_oop_result(RegisterMap* map) const {283return *((oop*) map->location(Z_R2->as_VMReg())); // R2 is return register.284}285286inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {287*((oop*) map->location(Z_R2->as_VMReg())) = obj; // R2 is return register.288}289290inline intptr_t* frame::real_fp() const {291return fp();292}293294#endif // CPU_S390_FRAME_S390_INLINE_HPP295296297