Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/x86/vm/frame_x86.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_X86_VM_FRAME_X86_HPP25#define CPU_X86_VM_FRAME_X86_HPP2627#include "runtime/synchronizer.hpp"28#include "utilities/top.hpp"2930// A frame represents a physical stack frame (an activation). Frames can be31// C or Java frames, and the Java frames can be interpreted or compiled.32// In contrast, vframes represent source-level activations, so that one physical frame33// can correspond to multiple source level frames because of inlining.34// A frame is comprised of {pc, fp, sp}35// ------------------------------ Asm interpreter ----------------------------------------36// Layout of asm interpreter frame:37// [expression stack ] * <- sp38// [monitors ] \39// ... | monitor block size40// [monitors ] /41// [monitor block size ]42// [byte code index/pointr] = bcx() bcx_offset43// [pointer to locals ] = locals() locals_offset44// [constant pool cache ] = cache() cache_offset45// [methodData ] = mdp() mdx_offset46// [Method* ] = method() method_offset47// [last sp ] = last_sp() last_sp_offset48// [old stack pointer ] (sender_sp) sender_sp_offset49// [old frame pointer ] <- fp = link()50// [return pc ]51// [oop temp ] (only for native calls)52// [locals and parameters ]53// <- sender sp54// ------------------------------ Asm interpreter ----------------------------------------5556// ------------------------------ C++ interpreter ----------------------------------------57//58// Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)59//60// <- SP (current esp/rsp)61// [local variables ] BytecodeInterpreter::run local variables62// ... BytecodeInterpreter::run local variables63// [local variables ] BytecodeInterpreter::run local variables64// [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]65// [return pc ] (return to frame manager)66// [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------67// [expression stack ] <- last_Java_sp |68// [... ] * <- interpreter_state.stack |69// [expression stack ] * <- interpreter_state.stack_base |70// [monitors ] \ |71// ... | monitor block size |72// [monitors ] / <- interpreter_state.monitor_base |73// [struct interpretState ] <-----------------------------------------|74// [return pc ] (return to callee of frame manager [1]75// [locals and parameters ]76// <- sender sp7778// [1] When the C++ interpreter calls a new method it returns to the frame79// manager which allocates a new frame on the stack. In that case there80// is no real callee of this newly allocated frame. The frame manager is81// aware of the additional frame(s) and will pop them as nested calls82// complete. However, to make it look good in the debugger the frame83// manager actually installs a dummy pc pointing to RecursiveInterpreterActivation84// with a fake interpreter_state* parameter to make it easy to debug85// nested calls.8687// Note that contrary to the layout for the assembly interpreter the88// expression stack allocated for the C++ interpreter is full sized.89// However this is not as bad as it seems as the interpreter frame_manager90// will truncate the unused space on successive method calls.91//92// ------------------------------ C++ interpreter ----------------------------------------9394public:95enum {96pc_return_offset = 0,97// All frames98link_offset = 0,99return_addr_offset = 1,100// non-interpreter frames101sender_sp_offset = 2,102103#ifndef CC_INTERP104105// Interpreter frames106interpreter_frame_result_handler_offset = 3, // for native calls only107interpreter_frame_oop_temp_offset = 2, // for native calls only108109interpreter_frame_sender_sp_offset = -1,110// outgoing sp before a call to an invoked method111interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,112interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,113interpreter_frame_mdx_offset = interpreter_frame_method_offset - 1,114interpreter_frame_cache_offset = interpreter_frame_mdx_offset - 1,115interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,116interpreter_frame_bcx_offset = interpreter_frame_locals_offset - 1,117interpreter_frame_initial_sp_offset = interpreter_frame_bcx_offset - 1,118119interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,120interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,121122#endif // CC_INTERP123124// Entry frames125#ifdef AMD64126#ifdef _WIN64127entry_frame_after_call_words = 28,128entry_frame_call_wrapper_offset = 2,129130arg_reg_save_area_bytes = 32, // Register argument save area131#else132entry_frame_after_call_words = 13,133entry_frame_call_wrapper_offset = -6,134135arg_reg_save_area_bytes = 0,136#endif // _WIN64137#else138entry_frame_call_wrapper_offset = 2,139#endif // AMD64140141// Native frames142143native_frame_initial_param_offset = 2144145};146147intptr_t ptr_at(int offset) const {148return *ptr_at_addr(offset);149}150151void ptr_at_put(int offset, intptr_t value) {152*ptr_at_addr(offset) = value;153}154155private:156// an additional field beyond _sp and _pc:157intptr_t* _fp; // frame pointer158// The interpreter and adapters will extend the frame of the caller.159// Since oopMaps are based on the sp of the caller before extension160// we need to know that value. However in order to compute the address161// of the return address we need the real "raw" sp. Since sparc already162// uses sp() to mean "raw" sp and unextended_sp() to mean the caller's163// original sp we use that convention.164165intptr_t* _unextended_sp;166void adjust_unextended_sp();167168intptr_t* ptr_at_addr(int offset) const {169return (intptr_t*) addr_at(offset);170}171172#ifdef ASSERT173// Used in frame::sender_for_{interpreter,compiled}_frame174static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);175#endif176177public:178// Constructors179180frame(intptr_t* sp, intptr_t* fp, address pc);181182frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);183184frame(intptr_t* sp, intptr_t* fp);185186void init(intptr_t* sp, intptr_t* fp, address pc);187188// accessors for the instance variables189// Note: not necessarily the real 'frame pointer' (see real_fp)190intptr_t* fp() const { return _fp; }191192inline address* sender_pc_addr() const;193194// return address of param, zero origin index.195inline address* native_param_addr(int idx) const;196197// expression stack tos if we are nested in a java call198intptr_t* interpreter_frame_last_sp() const;199200// helper to update a map with callee-saved RBP201static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);202203#ifndef CC_INTERP204// deoptimization support205void interpreter_frame_set_last_sp(intptr_t* sp);206#endif // CC_INTERP207208#ifdef CC_INTERP209inline interpreterState get_interpreterState() const;210#endif // CC_INTERP211212#endif // CPU_X86_VM_FRAME_X86_HPP213214215