frame_ppc.inline.hpp revision 6760:22b98ab2a69f
1/* 2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2012, 2014 SAP AG. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26#ifndef CPU_PPC_VM_FRAME_PPC_INLINE_HPP 27#define CPU_PPC_VM_FRAME_PPC_INLINE_HPP 28 29#include "code/codeCache.hpp" 30#include "code/vmreg.inline.hpp" 31 32// Inline functions for ppc64 frames: 33 34// Find codeblob and set deopt_state. 35inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) { 36 assert(pc != NULL, "precondition: must have PC"); 37 38 _cb = CodeCache::find_blob(pc); 39 _pc = pc; // Must be set for get_deopt_original_pc() 40 41 _fp = (intptr_t*)own_abi()->callers_sp; 42 // Use _fp - frame_size, needs to be done between _cb and _pc initialization 43 // and get_deopt_original_pc. 44 adjust_unextended_sp(); 45 46 address original_pc = nmethod::get_deopt_original_pc(this); 47 if (original_pc != NULL) { 48 _pc = original_pc; 49 _deopt_state = is_deoptimized; 50 } else { 51 _deopt_state = not_deoptimized; 52 } 53 54 assert(((uint64_t)_sp & 0xf) == 0, "SP must be 16-byte aligned"); 55} 56 57// Constructors 58 59// Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state. 60inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {} 61 62inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) { 63 find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->lr); // also sets _fp and adjusts _unextended_sp 64} 65 66inline frame::frame(intptr_t* sp, address pc) : _sp(sp), _unextended_sp(sp) { 67 find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp 68} 69 70inline frame::frame(intptr_t* sp, address pc, intptr_t* unextended_sp) : _sp(sp), _unextended_sp(unextended_sp) { 71 find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp 72} 73 74// Accessors 75 76// Return unique id for this frame. The id must have a value where we 77// can distinguish identity and younger/older relationship. NULL 78// represents an invalid (incomparable) frame. 79inline intptr_t* frame::id(void) const { 80 // Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing. 81 return _fp; 82} 83 84// Return true if this frame is older (less recent activation) than 85// the frame represented by id. 86inline bool frame::is_older(intptr_t* id) const { 87 assert(this->id() != NULL && id != NULL, "NULL frame id"); 88 // Stack grows towards smaller addresses on ppc64. 89 return this->id() > id; 90} 91 92inline int frame::frame_size(RegisterMap* map) const { 93 // Stack grows towards smaller addresses on PPC64: sender is at a higher address. 94 return sender_sp() - sp(); 95} 96 97// Return the frame's stack pointer before it has been extended by a 98// c2i adapter. This is needed by deoptimization for ignoring c2i adapter 99// frames. 100inline intptr_t* frame::unextended_sp() const { 101 return _unextended_sp; 102} 103 104// All frames have this field. 105inline address frame::sender_pc() const { 106 return (address)callers_abi()->lr; 107} 108inline address* frame::sender_pc_addr() const { 109 return (address*)&(callers_abi()->lr); 110} 111 112// All frames have this field. 113inline intptr_t* frame::sender_sp() const { 114 return (intptr_t*)callers_abi(); 115} 116 117// All frames have this field. 118inline intptr_t* frame::link() const { 119 return (intptr_t*)callers_abi()->callers_sp; 120} 121 122inline intptr_t* frame::real_fp() const { 123 return fp(); 124} 125 126#ifdef CC_INTERP 127 128inline interpreterState frame::get_interpreterState() const { 129 return (interpreterState)(((address)callers_abi()) 130 - frame::interpreter_frame_cinterpreterstate_size_in_bytes()); 131} 132 133inline intptr_t** frame::interpreter_frame_locals_addr() const { 134 interpreterState istate = get_interpreterState(); 135 return (intptr_t**)&istate->_locals; 136} 137 138inline intptr_t* frame::interpreter_frame_bcx_addr() const { 139 interpreterState istate = get_interpreterState(); 140 return (intptr_t*)&istate->_bcp; 141} 142 143inline intptr_t* frame::interpreter_frame_mdx_addr() const { 144 interpreterState istate = get_interpreterState(); 145 return (intptr_t*)&istate->_mdx; 146} 147 148inline intptr_t* frame::interpreter_frame_expression_stack() const { 149 return (intptr_t*)interpreter_frame_monitor_end() - 1; 150} 151 152inline jint frame::interpreter_frame_expression_stack_direction() { 153 return -1; 154} 155 156// top of expression stack 157inline intptr_t* frame::interpreter_frame_tos_address() const { 158 interpreterState istate = get_interpreterState(); 159 return istate->_stack + 1; 160} 161 162inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const { 163 return &interpreter_frame_tos_address()[offset]; 164} 165 166// monitor elements 167 168// in keeping with Intel side: end is lower in memory than begin; 169// and beginning element is oldest element 170// Also begin is one past last monitor. 171 172inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { 173 return get_interpreterState()->monitor_base(); 174} 175 176inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { 177 return (BasicObjectLock*)get_interpreterState()->stack_base(); 178} 179 180inline int frame::interpreter_frame_cinterpreterstate_size_in_bytes() { 181 // Size of an interpreter object. Not aligned with frame size. 182 return round_to(sizeof(BytecodeInterpreter), 8); 183} 184 185inline Method** frame::interpreter_frame_method_addr() const { 186 interpreterState istate = get_interpreterState(); 187 return &istate->_method; 188} 189 190// Constant pool cache 191 192inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const { 193 interpreterState istate = get_interpreterState(); 194 return &istate->_constants; // should really use accessor 195} 196 197inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { 198 interpreterState istate = get_interpreterState(); 199 return &istate->_constants; 200} 201 202#else // !CC_INTERP 203 204// Template Interpreter frame value accessors. 205 206inline frame::ijava_state* frame::get_ijava_state() const { 207 return (ijava_state*) ((uintptr_t)fp() - ijava_state_size); 208} 209 210inline intptr_t** frame::interpreter_frame_locals_addr() const { 211 return (intptr_t**) &(get_ijava_state()->locals); 212} 213inline intptr_t* frame::interpreter_frame_bcx_addr() const { 214 return (intptr_t*) &(get_ijava_state()->bcp); 215} 216inline intptr_t* frame::interpreter_frame_mdx_addr() const { 217 return (intptr_t*) &(get_ijava_state()->mdx); 218} 219// Pointer beyond the "oldest/deepest" BasicObjectLock on stack. 220inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { 221 return (BasicObjectLock *) get_ijava_state()->monitors; 222} 223 224inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { 225 return (BasicObjectLock *) get_ijava_state(); 226} 227 228// SAPJVM ASc 2012-11-21. Return register stack slot addr at which currently interpreted method is found 229inline Method** frame::interpreter_frame_method_addr() const { 230 return (Method**) &(get_ijava_state()->method); 231} 232inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const { 233 return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache); 234} 235inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { 236 return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache); 237} 238 239inline oop* frame::interpreter_frame_temp_oop_addr() const { 240 return (oop *) &(get_ijava_state()->oop_tmp); 241} 242inline intptr_t* frame::interpreter_frame_esp() const { 243 return (intptr_t*) get_ijava_state()->esp; 244} 245 246// Convenient setters 247inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* end) { get_ijava_state()->monitors = (intptr_t) end;} 248inline void frame::interpreter_frame_set_cpcache(ConstantPoolCache* cp) { *frame::interpreter_frame_cpoolcache_addr() = cp; } 249inline void frame::interpreter_frame_set_esp(intptr_t* esp) { get_ijava_state()->esp = (intptr_t) esp; } 250inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) { get_ijava_state()->top_frame_sp = (intptr_t) top_frame_sp; } 251inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp) { get_ijava_state()->sender_sp = (intptr_t) sender_sp; } 252 253inline intptr_t* frame::interpreter_frame_expression_stack() const { 254 return (intptr_t*)interpreter_frame_monitor_end() - 1; 255} 256 257inline jint frame::interpreter_frame_expression_stack_direction() { 258 return -1; 259} 260 261// top of expression stack 262inline intptr_t* frame::interpreter_frame_tos_address() const { 263 return ((intptr_t*) get_ijava_state()->esp) + Interpreter::stackElementWords; 264} 265 266inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const { 267 return &interpreter_frame_tos_address()[offset]; 268} 269 270#endif // CC_INTERP 271 272inline int frame::interpreter_frame_monitor_size() { 273 // Number of stack slots for a monitor. 274 return round_to(BasicObjectLock::size(), // number of stack slots 275 WordsPerLong); // number of stack slots for a Java long 276} 277 278inline int frame::interpreter_frame_monitor_size_in_bytes() { 279 return frame::interpreter_frame_monitor_size() * wordSize; 280} 281 282// entry frames 283 284inline intptr_t* frame::entry_frame_argument_at(int offset) const { 285 // Since an entry frame always calls the interpreter first, the 286 // parameters are on the stack and relative to known register in the 287 // entry frame. 288 intptr_t* tos = (intptr_t*)get_entry_frame_locals()->arguments_tos_address; 289 return &tos[offset + 1]; // prepushed tos 290} 291 292inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const { 293 return (JavaCallWrapper**)&get_entry_frame_locals()->call_wrapper_address; 294} 295 296inline oop frame::saved_oop_result(RegisterMap* map) const { 297 return *((oop*)map->location(R3->as_VMReg())); 298} 299 300inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { 301 *((oop*)map->location(R3->as_VMReg())) = obj; 302} 303 304#endif // CPU_PPC_VM_FRAME_PPC_INLINE_HPP 305