Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp
32285 views
/*1* Copyright (c) 2013, Red Hat Inc.2* Copyright (c) 1997, 2012, Oracle and/or its affiliates.3* 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 it7* under the terms of the GNU General Public License version 2 only, as8* published by the Free Software Foundation.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*24*/2526#ifndef CPU_AARCH64_VM_FRAME_AARCH64_HPP27#define CPU_AARCH64_VM_FRAME_AARCH64_HPP2829#include "runtime/synchronizer.hpp"30#include "utilities/top.hpp"3132// A frame represents a physical stack frame (an activation). Frames can be33// C or Java frames, and the Java frames can be interpreted or compiled.34// In contrast, vframes represent source-level activations, so that one physical frame35// can correspond to multiple source level frames because of inlining.36// A frame is comprised of {pc, fp, sp}37// ------------------------------ Asm interpreter ----------------------------------------38// Layout of asm interpreter frame:39// [expression stack ] * <- sp4041// [monitors[0] ] \42// ... | monitor block size = k43// [monitors[k-1] ] /44// [frame initial esp ] ( == &monitors[0], initially here) initial_sp_offset45// [byte code index/pointr] = bcx() bcx_offset4647// [pointer to locals ] = locals() locals_offset48// [constant pool cache ] = cache() cache_offset4950// [methodData ] = mdp() mdx_offset51// [methodOop ] = method() method_offset5253// [last esp ] = last_sp() last_sp_offset54// [old stack pointer ] (sender_sp) sender_sp_offset5556// [old frame pointer ] <- fp = link()57// [return pc ]5859// [last sp ]60// [oop temp ] (only for native calls)6162// [locals and parameters ]63// <- sender sp64// ------------------------------ Asm interpreter ----------------------------------------6566// ------------------------------ C++ interpreter ----------------------------------------67//68// Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)69//70// <- SP (current esp/rsp)71// [local variables ] BytecodeInterpreter::run local variables72// ... BytecodeInterpreter::run local variables73// [local variables ] BytecodeInterpreter::run local variables74// [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]75// [return pc ] (return to frame manager)76// [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------77// [expression stack ] <- last_Java_sp |78// [... ] * <- interpreter_state.stack |79// [expression stack ] * <- interpreter_state.stack_base |80// [monitors ] \ |81// ... | monitor block size |82// [monitors ] / <- interpreter_state.monitor_base |83// [struct interpretState ] <-----------------------------------------|84// [return pc ] (return to callee of frame manager [1]85// [locals and parameters ]86// <- sender sp8788// [1] When the c++ interpreter calls a new method it returns to the frame89// manager which allocates a new frame on the stack. In that case there90// is no real callee of this newly allocated frame. The frame manager is91// aware of the additional frame(s) and will pop them as nested calls92// complete. Howevers tTo make it look good in the debugger the frame93// manager actually installs a dummy pc pointing to RecursiveInterpreterActivation94// with a fake interpreter_state* parameter to make it easy to debug95// nested calls.9697// Note that contrary to the layout for the assembly interpreter the98// expression stack allocated for the C++ interpreter is full sized.99// However this is not as bad as it seems as the interpreter frame_manager100// will truncate the unused space on succesive method calls.101//102// ------------------------------ C++ interpreter ----------------------------------------103104public:105enum {106pc_return_offset = 0,107// All frames108link_offset = 0,109return_addr_offset = 1,110sender_sp_offset = 2,111112#ifndef CC_INTERP113114// Interpreter frames115interpreter_frame_oop_temp_offset = 3, // for native calls only116117interpreter_frame_sender_sp_offset = -1,118// outgoing sp before a call to an invoked method119interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,120interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,121interpreter_frame_mdx_offset = interpreter_frame_method_offset - 1,122interpreter_frame_cache_offset = interpreter_frame_mdx_offset - 1,123interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,124interpreter_frame_bcx_offset = interpreter_frame_locals_offset - 1,125interpreter_frame_initial_sp_offset = interpreter_frame_bcx_offset - 1,126127interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,128interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,129130#endif // CC_INTERP131132// Entry frames133// n.b. these values are determined by the layout defined in134// stubGenerator for the Java call stub135entry_frame_after_call_words = 27,136entry_frame_call_wrapper_offset = -8,137138// we don't need a save area139arg_reg_save_area_bytes = 0,140141// TODO - check that this is still correct142// Native frames143144native_frame_initial_param_offset = 2145146};147148intptr_t ptr_at(int offset) const {149return *ptr_at_addr(offset);150}151152void ptr_at_put(int offset, intptr_t value) {153*ptr_at_addr(offset) = value;154}155156private:157// an additional field beyond _sp and _pc:158intptr_t* _fp; // frame pointer159// The interpreter and adapters will extend the frame of the caller.160// Since oopMaps are based on the sp of the caller before extension161// we need to know that value. However in order to compute the address162// of the return address we need the real "raw" sp. Since sparc already163// uses sp() to mean "raw" sp and unextended_sp() to mean the caller's164// original sp we use that convention.165166intptr_t* _unextended_sp;167void adjust_unextended_sp();168169intptr_t* ptr_at_addr(int offset) const {170return (intptr_t*) addr_at(offset);171}172173#ifdef ASSERT174// Used in frame::sender_for_{interpreter,compiled}_frame175static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false);176static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) {177verify_deopt_original_pc(nm, unextended_sp, true);178}179#endif180181public:182// Constructors183184frame(intptr_t* sp, intptr_t* fp, address pc);185186frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);187188frame(intptr_t* sp, intptr_t* fp);189190void init(intptr_t* sp, intptr_t* fp, address pc);191192// accessors for the instance variables193// Note: not necessarily the real 'frame pointer' (see real_fp)194intptr_t* fp() const { return _fp; }195196inline address* sender_pc_addr() const;197198// return address of param, zero origin index.199inline address* native_param_addr(int idx) const;200201// expression stack tos if we are nested in a java call202intptr_t* interpreter_frame_last_sp() const;203204// helper to update a map with callee-saved RBP205static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);206207#ifndef CC_INTERP208// deoptimization support209void interpreter_frame_set_last_sp(intptr_t* sp);210#endif // CC_INTERP211212#ifdef CC_INTERP213inline interpreterState get_interpreterState() const;214#endif // CC_INTERP215216#endif // CPU_AARCH64_VM_FRAME_AARCH64_HPP217218219