0N/A/*
3087N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef CPU_X86_VM_FRAME_X86_HPP
1879N/A#define CPU_X86_VM_FRAME_X86_HPP
1879N/A
1879N/A#include "runtime/synchronizer.hpp"
1879N/A#include "utilities/top.hpp"
1879N/A
0N/A// A frame represents a physical stack frame (an activation). Frames can be
0N/A// C or Java frames, and the Java frames can be interpreted or compiled.
0N/A// In contrast, vframes represent source-level activations, so that one physical frame
0N/A// can correspond to multiple source level frames because of inlining.
0N/A// A frame is comprised of {pc, fp, sp}
0N/A// ------------------------------ Asm interpreter ----------------------------------------
0N/A// Layout of asm interpreter frame:
0N/A// [expression stack ] * <- sp
0N/A// [monitors ] \
0N/A// ... | monitor block size
0N/A// [monitors ] /
0N/A// [monitor block size ]
0N/A// [byte code index/pointr] = bcx() bcx_offset
0N/A// [pointer to locals ] = locals() locals_offset
0N/A// [constant pool cache ] = cache() cache_offset
0N/A// [methodData ] = mdp() mdx_offset
0N/A// [methodOop ] = method() method_offset
0N/A// [last sp ] = last_sp() last_sp_offset
0N/A// [old stack pointer ] (sender_sp) sender_sp_offset
0N/A// [old frame pointer ] <- fp = link()
0N/A// [return pc ]
0N/A// [oop temp ] (only for native calls)
0N/A// [locals and parameters ]
0N/A// <- sender sp
0N/A// ------------------------------ Asm interpreter ----------------------------------------
0N/A
0N/A// ------------------------------ C++ interpreter ----------------------------------------
0N/A//
0N/A// Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)
0N/A//
0N/A// <- SP (current esp/rsp)
0N/A// [local variables ] BytecodeInterpreter::run local variables
0N/A// ... BytecodeInterpreter::run local variables
0N/A// [local variables ] BytecodeInterpreter::run local variables
0N/A// [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]
0N/A// [return pc ] (return to frame manager)
0N/A// [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------
0N/A// [expression stack ] <- last_Java_sp |
0N/A// [... ] * <- interpreter_state.stack |
0N/A// [expression stack ] * <- interpreter_state.stack_base |
0N/A// [monitors ] \ |
0N/A// ... | monitor block size |
0N/A// [monitors ] / <- interpreter_state.monitor_base |
0N/A// [struct interpretState ] <-----------------------------------------|
0N/A// [return pc ] (return to callee of frame manager [1]
0N/A// [locals and parameters ]
0N/A// <- sender sp
0N/A
0N/A// [1] When the c++ interpreter calls a new method it returns to the frame
0N/A// manager which allocates a new frame on the stack. In that case there
0N/A// is no real callee of this newly allocated frame. The frame manager is
0N/A// aware of the additional frame(s) and will pop them as nested calls
0N/A// complete. Howevers tTo make it look good in the debugger the frame
0N/A// manager actually installs a dummy pc pointing to RecursiveInterpreterActivation
0N/A// with a fake interpreter_state* parameter to make it easy to debug
0N/A// nested calls.
0N/A
0N/A// Note that contrary to the layout for the assembly interpreter the
0N/A// expression stack allocated for the C++ interpreter is full sized.
0N/A// However this is not as bad as it seems as the interpreter frame_manager
0N/A// will truncate the unused space on succesive method calls.
0N/A//
0N/A// ------------------------------ C++ interpreter ----------------------------------------
0N/A
0N/A public:
0N/A enum {
0N/A pc_return_offset = 0,
0N/A // All frames
0N/A link_offset = 0,
0N/A return_addr_offset = 1,
0N/A // non-interpreter frames
0N/A sender_sp_offset = 2,
0N/A
0N/A#ifndef CC_INTERP
0N/A
0N/A // Interpreter frames
0N/A interpreter_frame_result_handler_offset = 3, // for native calls only
0N/A interpreter_frame_oop_temp_offset = 2, // for native calls only
0N/A
0N/A interpreter_frame_sender_sp_offset = -1,
0N/A // outgoing sp before a call to an invoked method
0N/A interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,
0N/A interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,
0N/A interpreter_frame_mdx_offset = interpreter_frame_method_offset - 1,
0N/A interpreter_frame_cache_offset = interpreter_frame_mdx_offset - 1,
0N/A interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,
0N/A interpreter_frame_bcx_offset = interpreter_frame_locals_offset - 1,
0N/A interpreter_frame_initial_sp_offset = interpreter_frame_bcx_offset - 1,
0N/A
0N/A interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,
0N/A interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,
0N/A
0N/A#endif // CC_INTERP
0N/A
0N/A // Entry frames
0N/A#ifdef AMD64
0N/A#ifdef _WIN64
2254N/A entry_frame_after_call_words = 28,
0N/A entry_frame_call_wrapper_offset = 2,
0N/A
0N/A arg_reg_save_area_bytes = 32, // Register argument save area
0N/A#else
0N/A entry_frame_after_call_words = 13,
0N/A entry_frame_call_wrapper_offset = -6,
0N/A
0N/A arg_reg_save_area_bytes = 0,
0N/A#endif // _WIN64
0N/A#else
0N/A entry_frame_call_wrapper_offset = 2,
0N/A#endif // AMD64
0N/A
0N/A // Native frames
0N/A
0N/A native_frame_initial_param_offset = 2
0N/A
0N/A };
0N/A
0N/A intptr_t ptr_at(int offset) const {
0N/A return *ptr_at_addr(offset);
0N/A }
0N/A
0N/A void ptr_at_put(int offset, intptr_t value) {
0N/A *ptr_at_addr(offset) = value;
0N/A }
0N/A
0N/A private:
0N/A // an additional field beyond _sp and _pc:
0N/A intptr_t* _fp; // frame pointer
0N/A // The interpreter and adapters will extend the frame of the caller.
0N/A // Since oopMaps are based on the sp of the caller before extension
0N/A // we need to know that value. However in order to compute the address
0N/A // of the return address we need the real "raw" sp. Since sparc already
0N/A // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
0N/A // original sp we use that convention.
0N/A
0N/A intptr_t* _unextended_sp;
2460N/A void adjust_unextended_sp();
0N/A
0N/A intptr_t* ptr_at_addr(int offset) const {
0N/A return (intptr_t*) addr_at(offset);
0N/A }
0N/A
1204N/A#if ASSERT
1204N/A // Used in frame::sender_for_{interpreter,compiled}_frame
1204N/A static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false);
1204N/A static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) {
1204N/A verify_deopt_original_pc(nm, unextended_sp, true);
1204N/A }
1204N/A#endif
1204N/A
0N/A public:
0N/A // Constructors
0N/A
0N/A frame(intptr_t* sp, intptr_t* fp, address pc);
0N/A
0N/A frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
0N/A
0N/A frame(intptr_t* sp, intptr_t* fp);
0N/A
0N/A // accessors for the instance variables
3087N/A // Note: not necessarily the real 'frame pointer' (see real_fp)
0N/A intptr_t* fp() const { return _fp; }
0N/A
0N/A inline address* sender_pc_addr() const;
0N/A
0N/A // return address of param, zero origin index.
0N/A inline address* native_param_addr(int idx) const;
0N/A
0N/A // expression stack tos if we are nested in a java call
0N/A intptr_t* interpreter_frame_last_sp() const;
0N/A
2460N/A // helper to update a map with callee-saved RBP
2460N/A static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);
2460N/A
0N/A#ifndef CC_INTERP
0N/A // deoptimization support
0N/A void interpreter_frame_set_last_sp(intptr_t* sp);
0N/A#endif // CC_INTERP
0N/A
0N/A#ifdef CC_INTERP
0N/A inline interpreterState get_interpreterState() const;
0N/A#endif // CC_INTERP
1879N/A
1879N/A#endif // CPU_X86_VM_FRAME_X86_HPP