Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp
32285 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* Copyright 2012, 2014 SAP AG. 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_PPC_VM_FRAME_PPC_INLINE_HPP26#define CPU_PPC_VM_FRAME_PPC_INLINE_HPP2728#include "code/codeCache.hpp"2930// Inline functions for ppc64 frames:3132// Find codeblob and set deopt_state.33inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) {34assert(pc != NULL, "precondition: must have PC");3536_cb = CodeCache::find_blob(pc);37_pc = pc; // Must be set for get_deopt_original_pc()3839_fp = (intptr_t*)own_abi()->callers_sp;40// Use _fp - frame_size, needs to be done between _cb and _pc initialization41// and get_deopt_original_pc.42adjust_unextended_sp();4344address original_pc = nmethod::get_deopt_original_pc(this);45if (original_pc != NULL) {46_pc = original_pc;47_deopt_state = is_deoptimized;48} else {49_deopt_state = not_deoptimized;50}5152assert(((uint64_t)_sp & 0xf) == 0, "SP must be 16-byte aligned");53}5455// Constructors5657// Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state.58inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {}5960inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) {61find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->lr); // also sets _fp and adjusts _unextended_sp62}6364inline frame::frame(intptr_t* sp, address pc) : _sp(sp), _unextended_sp(sp) {65find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp66}6768inline frame::frame(intptr_t* sp, address pc, intptr_t* unextended_sp) : _sp(sp), _unextended_sp(unextended_sp) {69find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp70}7172// Accessors7374// Return unique id for this frame. The id must have a value where we75// can distinguish identity and younger/older relationship. NULL76// represents an invalid (incomparable) frame.77inline intptr_t* frame::id(void) const {78// Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing.79return _fp;80}8182// Return true if this frame is older (less recent activation) than83// the frame represented by id.84inline bool frame::is_older(intptr_t* id) const {85assert(this->id() != NULL && id != NULL, "NULL frame id");86// Stack grows towards smaller addresses on ppc64.87return this->id() > id;88}8990inline int frame::frame_size(RegisterMap* map) const {91// Stack grows towards smaller addresses on PPC64: sender is at a higher address.92return sender_sp() - sp();93}9495// Return the frame's stack pointer before it has been extended by a96// c2i adapter. This is needed by deoptimization for ignoring c2i adapter97// frames.98inline intptr_t* frame::unextended_sp() const {99return _unextended_sp;100}101102// All frames have this field.103inline address frame::sender_pc() const {104return (address)callers_abi()->lr;105}106inline address* frame::sender_pc_addr() const {107return (address*)&(callers_abi()->lr);108}109110// All frames have this field.111inline intptr_t* frame::sender_sp() const {112return (intptr_t*)callers_abi();113}114115// All frames have this field.116inline intptr_t* frame::link() const {117return (intptr_t*)callers_abi()->callers_sp;118}119120inline intptr_t* frame::real_fp() const {121return fp();122}123124#ifdef CC_INTERP125126inline interpreterState frame::get_interpreterState() const {127return (interpreterState)(((address)callers_abi())128- frame::interpreter_frame_cinterpreterstate_size_in_bytes());129}130131inline intptr_t** frame::interpreter_frame_locals_addr() const {132interpreterState istate = get_interpreterState();133return (intptr_t**)&istate->_locals;134}135136inline intptr_t* frame::interpreter_frame_bcx_addr() const {137interpreterState istate = get_interpreterState();138return (intptr_t*)&istate->_bcp;139}140141inline intptr_t* frame::interpreter_frame_mdx_addr() const {142interpreterState istate = get_interpreterState();143return (intptr_t*)&istate->_mdx;144}145146inline intptr_t* frame::interpreter_frame_expression_stack() const {147return (intptr_t*)interpreter_frame_monitor_end() - 1;148}149150inline jint frame::interpreter_frame_expression_stack_direction() {151return -1;152}153154// top of expression stack155inline intptr_t* frame::interpreter_frame_tos_address() const {156interpreterState istate = get_interpreterState();157return istate->_stack + 1;158}159160inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {161return &interpreter_frame_tos_address()[offset];162}163164// monitor elements165166// in keeping with Intel side: end is lower in memory than begin;167// and beginning element is oldest element168// Also begin is one past last monitor.169170inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {171return get_interpreterState()->monitor_base();172}173174inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {175return (BasicObjectLock*)get_interpreterState()->stack_base();176}177178inline int frame::interpreter_frame_cinterpreterstate_size_in_bytes() {179// Size of an interpreter object. Not aligned with frame size.180return round_to(sizeof(BytecodeInterpreter), 8);181}182183inline Method** frame::interpreter_frame_method_addr() const {184interpreterState istate = get_interpreterState();185return &istate->_method;186}187188// Constant pool cache189190inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {191interpreterState istate = get_interpreterState();192return &istate->_constants; // should really use accessor193}194195inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {196interpreterState istate = get_interpreterState();197return &istate->_constants;198}199200#else // !CC_INTERP201202// Template Interpreter frame value accessors.203204inline frame::ijava_state* frame::get_ijava_state() const {205return (ijava_state*) ((uintptr_t)fp() - ijava_state_size);206}207208inline intptr_t** frame::interpreter_frame_locals_addr() const {209return (intptr_t**) &(get_ijava_state()->locals);210}211inline intptr_t* frame::interpreter_frame_bcx_addr() const {212return (intptr_t*) &(get_ijava_state()->bcp);213}214inline intptr_t* frame::interpreter_frame_mdx_addr() const {215return (intptr_t*) &(get_ijava_state()->mdx);216}217// Pointer beyond the "oldest/deepest" BasicObjectLock on stack.218inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {219return (BasicObjectLock *) get_ijava_state()->monitors;220}221222inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {223return (BasicObjectLock *) get_ijava_state();224}225226// SAPJVM ASc 2012-11-21. Return register stack slot addr at which currently interpreted method is found227inline Method** frame::interpreter_frame_method_addr() const {228return (Method**) &(get_ijava_state()->method);229}230inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {231return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache);232}233inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {234return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache);235}236237inline oop* frame::interpreter_frame_temp_oop_addr() const {238return (oop *) &(get_ijava_state()->oop_tmp);239}240inline intptr_t* frame::interpreter_frame_esp() const {241return (intptr_t*) get_ijava_state()->esp;242}243244// Convenient setters245inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* end) { get_ijava_state()->monitors = (intptr_t) end;}246inline void frame::interpreter_frame_set_cpcache(ConstantPoolCache* cp) { *frame::interpreter_frame_cpoolcache_addr() = cp; }247inline void frame::interpreter_frame_set_esp(intptr_t* esp) { get_ijava_state()->esp = (intptr_t) esp; }248inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) { get_ijava_state()->top_frame_sp = (intptr_t) top_frame_sp; }249inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp) { get_ijava_state()->sender_sp = (intptr_t) sender_sp; }250251inline intptr_t* frame::interpreter_frame_expression_stack() const {252return (intptr_t*)interpreter_frame_monitor_end() - 1;253}254255inline jint frame::interpreter_frame_expression_stack_direction() {256return -1;257}258259// top of expression stack260inline intptr_t* frame::interpreter_frame_tos_address() const {261return ((intptr_t*) get_ijava_state()->esp) + Interpreter::stackElementWords;262}263264inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {265return &interpreter_frame_tos_address()[offset];266}267268#endif // CC_INTERP269270inline int frame::interpreter_frame_monitor_size() {271// Number of stack slots for a monitor.272return round_to(BasicObjectLock::size(), // number of stack slots273WordsPerLong); // number of stack slots for a Java long274}275276inline int frame::interpreter_frame_monitor_size_in_bytes() {277return frame::interpreter_frame_monitor_size() * wordSize;278}279280// entry frames281282inline intptr_t* frame::entry_frame_argument_at(int offset) const {283// Since an entry frame always calls the interpreter first, the284// parameters are on the stack and relative to known register in the285// entry frame.286intptr_t* tos = (intptr_t*)get_entry_frame_locals()->arguments_tos_address;287return &tos[offset + 1]; // prepushed tos288}289290inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {291return (JavaCallWrapper**)&get_entry_frame_locals()->call_wrapper_address;292}293294inline oop frame::saved_oop_result(RegisterMap* map) const {295return *((oop*)map->location(R3->as_VMReg()));296}297298inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {299*((oop*)map->location(R3->as_VMReg())) = obj;300}301302#endif // CPU_PPC_VM_FRAME_PPC_INLINE_HPP303304305