Path: blob/master/src/hotspot/cpu/x86/frame_x86.hpp
41144 views
/*1* Copyright (c) 1997, 2020, 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_FRAME_X86_HPP25#define CPU_X86_FRAME_X86_HPP2627#include "runtime/synchronizer.hpp"2829// A frame represents a physical stack frame (an activation). Frames can be30// C or Java frames, and the Java frames can be interpreted or compiled.31// In contrast, vframes represent source-level activations, so that one physical frame32// can correspond to multiple source level frames because of inlining.33// A frame is comprised of {pc, fp, sp}34// ------------------------------ Asm interpreter ----------------------------------------35// Layout of asm interpreter frame:36// [expression stack ] * <- sp37// [monitors ] \38// ... | monitor block size39// [monitors ] /40// [monitor block size ]41// [byte code pointer ] = bcp() bcp_offset42// [pointer to locals ] = locals() locals_offset43// [constant pool cache ] = cache() cache_offset44// [methodData ] = mdp() mdx_offset45// [Method* ] = method() method_offset46// [last sp ] = last_sp() last_sp_offset47// [old stack pointer ] (sender_sp) sender_sp_offset48// [old frame pointer ] <- fp = link()49// [return pc ]50// [oop temp ] (only for native calls)51// [locals and parameters ]52// <- sender sp53// ------------------------------ Asm interpreter ----------------------------------------5455public:56enum {57pc_return_offset = 0,58// All frames59link_offset = 0,60return_addr_offset = 1,61// non-interpreter frames62sender_sp_offset = 2,6364// Interpreter frames65interpreter_frame_result_handler_offset = 3, // for native calls only66interpreter_frame_oop_temp_offset = 2, // for native calls only6768interpreter_frame_sender_sp_offset = -1,69// outgoing sp before a call to an invoked method70interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,71interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,72interpreter_frame_mirror_offset = interpreter_frame_method_offset - 1,73interpreter_frame_mdp_offset = interpreter_frame_mirror_offset - 1,74interpreter_frame_cache_offset = interpreter_frame_mdp_offset - 1,75interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,76interpreter_frame_bcp_offset = interpreter_frame_locals_offset - 1,77interpreter_frame_initial_sp_offset = interpreter_frame_bcp_offset - 1,7879interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,80interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,8182// Entry frames83#ifdef AMD6484#ifdef _WIN6485entry_frame_after_call_words = 60,86entry_frame_call_wrapper_offset = 2,8788arg_reg_save_area_bytes = 32 // Register argument save area89#else90entry_frame_after_call_words = 13,91entry_frame_call_wrapper_offset = -6,9293arg_reg_save_area_bytes = 094#endif // _WIN6495#else96entry_frame_call_wrapper_offset = 297#endif // AMD6498};99100intptr_t ptr_at(int offset) const {101return *ptr_at_addr(offset);102}103104void ptr_at_put(int offset, intptr_t value) {105*ptr_at_addr(offset) = value;106}107108private:109// an additional field beyond _sp and _pc:110intptr_t* _fp; // frame pointer111// The interpreter and adapters will extend the frame of the caller.112// Since oopMaps are based on the sp of the caller before extension113// we need to know that value. However in order to compute the address114// of the return address we need the real "raw" sp. By convention we115// use sp() to mean "raw" sp and unextended_sp() to mean the caller's116// original sp.117118intptr_t* _unextended_sp;119void adjust_unextended_sp() NOT_DEBUG_RETURN;120121intptr_t* ptr_at_addr(int offset) const {122return (intptr_t*) addr_at(offset);123}124125#ifdef ASSERT126// Used in frame::sender_for_{interpreter,compiled}_frame127static void verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp);128#endif129130public:131// Constructors132133frame(intptr_t* sp, intptr_t* fp, address pc);134135frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);136137frame(intptr_t* sp, intptr_t* fp);138139void init(intptr_t* sp, intptr_t* fp, address pc);140141// accessors for the instance variables142// Note: not necessarily the real 'frame pointer' (see real_fp)143intptr_t* fp() const { return _fp; }144145inline address* sender_pc_addr() const;146147// expression stack tos if we are nested in a java call148intptr_t* interpreter_frame_last_sp() const;149150// helper to update a map with callee-saved RBP151static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);152153// deoptimization support154void interpreter_frame_set_last_sp(intptr_t* sp);155156static jint interpreter_frame_expression_stack_direction() { return -1; }157158// returns the sending frame, without applying any barriers159frame sender_raw(RegisterMap* map) const;160161#endif // CPU_X86_FRAME_X86_HPP162163164