Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp
32285 views
/*1* Copyright (c) 1997, 2013, 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_SPARC_VM_FRAME_SPARC_INLINE_HPP25#define CPU_SPARC_VM_FRAME_SPARC_INLINE_HPP2627#include "asm/macroAssembler.hpp"2829// Inline functions for SPARC frames:3031// Constructors3233inline frame::frame() {34_pc = NULL;35_sp = NULL;36_younger_sp = NULL;37_cb = NULL;38_deopt_state = unknown;39_sp_adjustment_by_callee = 0;40}4142// Accessors:4344inline bool frame::equal(frame other) const {45bool ret = sp() == other.sp()46&& fp() == other.fp()47&& pc() == other.pc();48assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");49return ret;50}5152// Return unique id for this frame. The id must have a value where we can distinguish53// identity and younger/older relationship. NULL represents an invalid (incomparable)54// frame.55inline intptr_t* frame::id(void) const { return unextended_sp(); }5657// Relationals on frames based58// Return true if the frame is younger (more recent activation) than the frame represented by id59inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");60return this->id() < id ; }6162// Return true if the frame is older (less recent activation) than the frame represented by id63inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");64return this->id() > id ; }6566inline int frame::frame_size(RegisterMap* map) const { return sender_sp() - sp(); }6768inline intptr_t* frame::link() const { return (intptr_t *)(fp()[FP->sp_offset_in_saved_window()] + STACK_BIAS); }6970inline void frame::set_link(intptr_t* addr) { assert(link()==addr, "frame nesting is controlled by hardware"); }7172inline intptr_t* frame::unextended_sp() const { return sp() + _sp_adjustment_by_callee; }7374// return address:7576inline address frame::sender_pc() const { return *I7_addr() + pc_return_offset; }7778inline address* frame::I7_addr() const { return (address*) &sp()[ I7->sp_offset_in_saved_window()]; }79inline address* frame::I0_addr() const { return (address*) &sp()[ I0->sp_offset_in_saved_window()]; }8081inline address* frame::O7_addr() const { return (address*) &younger_sp()[ I7->sp_offset_in_saved_window()]; }82inline address* frame::O0_addr() const { return (address*) &younger_sp()[ I0->sp_offset_in_saved_window()]; }8384inline intptr_t* frame::sender_sp() const { return fp(); }8586inline intptr_t* frame::real_fp() const { return fp(); }8788// Used only in frame::oopmapreg_to_location89// This return a value in VMRegImpl::slot_size90inline int frame::pd_oop_map_offset_adjustment() const {91return _sp_adjustment_by_callee * VMRegImpl::slots_per_word;92}9394#ifdef CC_INTERP95inline intptr_t** frame::interpreter_frame_locals_addr() const {96interpreterState istate = get_interpreterState();97return (intptr_t**) &istate->_locals;98}99100inline intptr_t* frame::interpreter_frame_bcx_addr() const {101interpreterState istate = get_interpreterState();102return (intptr_t*) &istate->_bcp;103}104105inline intptr_t* frame::interpreter_frame_mdx_addr() const {106interpreterState istate = get_interpreterState();107return (intptr_t*) &istate->_mdx;108}109110inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }111112// bottom(base) of the expression stack (highest address)113inline intptr_t* frame::interpreter_frame_expression_stack() const {114return (intptr_t*)interpreter_frame_monitor_end() - 1;115}116117// top of expression stack (lowest address)118inline intptr_t* frame::interpreter_frame_tos_address() const {119interpreterState istate = get_interpreterState();120return istate->_stack + 1; // Is this off by one? QQQ121}122123// monitor elements124125// in keeping with Intel side: end is lower in memory than begin;126// and beginning element is oldest element127// Also begin is one past last monitor.128129inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {130return get_interpreterState()->monitor_base();131}132133inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {134return (BasicObjectLock*) get_interpreterState()->stack_base();135}136137138inline int frame::interpreter_frame_monitor_size() {139return round_to(BasicObjectLock::size(), WordsPerLong);140}141142inline Method** frame::interpreter_frame_method_addr() const {143interpreterState istate = get_interpreterState();144return &istate->_method;145}146147148// Constant pool cache149150// where LcpoolCache is saved:151inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {152interpreterState istate = get_interpreterState();153return &istate->_constants; // should really use accessor154}155156inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {157interpreterState istate = get_interpreterState();158return &istate->_constants;159}160161#else // !CC_INTERP162163inline intptr_t** frame::interpreter_frame_locals_addr() const {164return (intptr_t**) sp_addr_at( Llocals->sp_offset_in_saved_window());165}166167inline intptr_t* frame::interpreter_frame_bcx_addr() const {168// %%%%% reinterpreting Lbcp as a bcx169return (intptr_t*) sp_addr_at( Lbcp->sp_offset_in_saved_window());170}171172inline intptr_t* frame::interpreter_frame_mdx_addr() const {173// %%%%% reinterpreting ImethodDataPtr as a mdx174return (intptr_t*) sp_addr_at( ImethodDataPtr->sp_offset_in_saved_window());175}176177inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }178179// bottom(base) of the expression stack (highest address)180inline intptr_t* frame::interpreter_frame_expression_stack() const {181return (intptr_t*)interpreter_frame_monitors() - 1;182}183184// top of expression stack (lowest address)185inline intptr_t* frame::interpreter_frame_tos_address() const {186return *interpreter_frame_esp_addr() + 1;187}188189inline BasicObjectLock** frame::interpreter_frame_monitors_addr() const {190return (BasicObjectLock**) sp_addr_at(Lmonitors->sp_offset_in_saved_window());191}192inline intptr_t** frame::interpreter_frame_esp_addr() const {193return (intptr_t**)sp_addr_at(Lesp->sp_offset_in_saved_window());194}195196inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) {197*interpreter_frame_esp_addr() = x - 1;198}199200// monitor elements201202// in keeping with Intel side: end is lower in memory than begin;203// and beginning element is oldest element204// Also begin is one past last monitor.205206inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {207int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words, WordsPerLong);208return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words);209}210211inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {212return interpreter_frame_monitors();213}214215216inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {217interpreter_frame_set_monitors(value);218}219220inline int frame::interpreter_frame_monitor_size() {221return round_to(BasicObjectLock::size(), WordsPerLong);222}223224inline Method** frame::interpreter_frame_method_addr() const {225return (Method**)sp_addr_at( Lmethod->sp_offset_in_saved_window());226}227228inline BasicObjectLock* frame::interpreter_frame_monitors() const {229return *interpreter_frame_monitors_addr();230}231232inline void frame::interpreter_frame_set_monitors(BasicObjectLock* monitors) {233*interpreter_frame_monitors_addr() = monitors;234}235236// Constant pool cache237238// where LcpoolCache is saved:239inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {240return (ConstantPoolCache**)sp_addr_at(LcpoolCache->sp_offset_in_saved_window());241}242243inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {244return (ConstantPoolCache**)sp_addr_at( LcpoolCache->sp_offset_in_saved_window());245}246247inline oop* frame::interpreter_frame_temp_oop_addr() const {248return (oop *)(fp() + interpreter_frame_oop_temp_offset);249}250#endif // CC_INTERP251252253inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {254// note: adjust this code if the link argument in StubGenerator::call_stub() changes!255const Argument link = Argument(0, false);256return (JavaCallWrapper**)&sp()[link.as_in().as_register()->sp_offset_in_saved_window()];257}258259260inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {261// always allocate non-argument locals 0..5 as if they were arguments:262int allocated_above_frame = nof_args;263if (allocated_above_frame < callee_register_argument_save_area_words)264allocated_above_frame = callee_register_argument_save_area_words;265if (allocated_above_frame > max_nof_locals)266allocated_above_frame = max_nof_locals;267268// Note: monitors (BasicLock blocks) are never allocated in argument slots269//assert(local_index >= 0 && local_index < max_nof_locals, "bad local index");270if (local_index < allocated_above_frame)271return local_index + callee_register_argument_save_area_sp_offset;272else273return local_index - (max_nof_locals + max_nof_monitors*2) + compiler_frame_vm_locals_fp_offset;274}275276inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {277assert(local_index >= max_nof_locals && ((local_index - max_nof_locals) & 1) && (local_index - max_nof_locals) < max_nof_monitors*2, "bad monitor index");278279// The compiler uses the __higher__ of two indexes allocated to the monitor.280// Increasing local indexes are mapped to increasing memory locations,281// so the start of the BasicLock is associated with the __lower__ index.282283int offset = (local_index-1) - (max_nof_locals + max_nof_monitors*2) + compiler_frame_vm_locals_fp_offset;284285// We allocate monitors aligned zero mod 8:286assert((offset & 1) == 0, "monitor must be an an even address.");287// This works because all monitors are allocated after288// all locals, and because the highest address corresponding to any289// monitor index is always even.290assert((compiler_frame_vm_locals_fp_offset & 1) == 0, "end of monitors must be even address");291292return offset;293}294295inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {296// always allocate non-argument locals 0..5 as if they were arguments:297int allocated_above_frame = nof_args;298if (allocated_above_frame < callee_register_argument_save_area_words)299allocated_above_frame = callee_register_argument_save_area_words;300if (allocated_above_frame > max_nof_locals)301allocated_above_frame = max_nof_locals;302303int allocated_in_frame = (max_nof_locals + max_nof_monitors*2) - allocated_above_frame;304305return compiler_frame_vm_locals_fp_offset - allocated_in_frame;306}307308// On SPARC, the %lN and %iN registers are non-volatile.309inline bool frame::volatile_across_calls(Register reg) {310// This predicate is (presently) applied only to temporary registers,311// and so it need not recognize non-volatile globals.312return reg->is_out() || reg->is_global();313}314315inline oop frame::saved_oop_result(RegisterMap* map) const {316return *((oop*) map->location(O0->as_VMReg()));317}318319inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {320*((oop*) map->location(O0->as_VMReg())) = obj;321}322323#endif // CPU_SPARC_VM_FRAME_SPARC_INLINE_HPP324325326