frame_x86.hpp revision 11079:69d081845165
1/* 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25#ifndef CPU_X86_VM_FRAME_X86_HPP 26#define CPU_X86_VM_FRAME_X86_HPP 27 28#include "runtime/synchronizer.hpp" 29 30// A frame represents a physical stack frame (an activation). Frames can be 31// 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 frame 33// 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 ] * <- sp 38// [monitors ] \ 39// ... | monitor block size 40// [monitors ] / 41// [monitor block size ] 42// [byte code pointer ] = bcp() bcp_offset 43// [pointer to locals ] = locals() locals_offset 44// [constant pool cache ] = cache() cache_offset 45// [methodData ] = mdp() mdx_offset 46// [Method* ] = method() method_offset 47// [last sp ] = last_sp() last_sp_offset 48// [old stack pointer ] (sender_sp) sender_sp_offset 49// [old frame pointer ] <- fp = link() 50// [return pc ] 51// [oop temp ] (only for native calls) 52// [locals and parameters ] 53// <- sender sp 54// ------------------------------ Asm interpreter ---------------------------------------- 55 56 public: 57 enum { 58 pc_return_offset = 0, 59 // All frames 60 link_offset = 0, 61 return_addr_offset = 1, 62 // non-interpreter frames 63 sender_sp_offset = 2, 64 65 // Interpreter frames 66 interpreter_frame_result_handler_offset = 3, // for native calls only 67 interpreter_frame_oop_temp_offset = 2, // for native calls only 68 69 interpreter_frame_sender_sp_offset = -1, 70 // outgoing sp before a call to an invoked method 71 interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1, 72 interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1, 73 interpreter_frame_mdp_offset = interpreter_frame_method_offset - 1, 74 interpreter_frame_cache_offset = interpreter_frame_mdp_offset - 1, 75 interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1, 76 interpreter_frame_bcp_offset = interpreter_frame_locals_offset - 1, 77 interpreter_frame_initial_sp_offset = interpreter_frame_bcp_offset - 1, 78 79 interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset, 80 interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset, 81 82 // Entry frames 83#ifdef AMD64 84#ifdef _WIN64 85 entry_frame_after_call_words = 60, 86 entry_frame_call_wrapper_offset = 2, 87 88 arg_reg_save_area_bytes = 32 // Register argument save area 89#else 90 entry_frame_after_call_words = 13, 91 entry_frame_call_wrapper_offset = -6, 92 93 arg_reg_save_area_bytes = 0 94#endif // _WIN64 95#else 96 entry_frame_call_wrapper_offset = 2 97#endif // AMD64 98 }; 99 100 intptr_t ptr_at(int offset) const { 101 return *ptr_at_addr(offset); 102 } 103 104 void ptr_at_put(int offset, intptr_t value) { 105 *ptr_at_addr(offset) = value; 106 } 107 108 private: 109 // an additional field beyond _sp and _pc: 110 intptr_t* _fp; // frame pointer 111 // The interpreter and adapters will extend the frame of the caller. 112 // Since oopMaps are based on the sp of the caller before extension 113 // we need to know that value. However in order to compute the address 114 // of the return address we need the real "raw" sp. Since sparc already 115 // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's 116 // original sp we use that convention. 117 118 intptr_t* _unextended_sp; 119 void adjust_unextended_sp(); 120 121 intptr_t* ptr_at_addr(int offset) const { 122 return (intptr_t*) addr_at(offset); 123 } 124 125#ifdef ASSERT 126 // Used in frame::sender_for_{interpreter,compiled}_frame 127 static void verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp); 128#endif 129 130 public: 131 // Constructors 132 133 frame(intptr_t* sp, intptr_t* fp, address pc); 134 135 frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc); 136 137 frame(intptr_t* sp, intptr_t* fp); 138 139 void init(intptr_t* sp, intptr_t* fp, address pc); 140 141 // accessors for the instance variables 142 // Note: not necessarily the real 'frame pointer' (see real_fp) 143 intptr_t* fp() const { return _fp; } 144 145 inline address* sender_pc_addr() const; 146 147 // expression stack tos if we are nested in a java call 148 intptr_t* interpreter_frame_last_sp() const; 149 150 // helper to update a map with callee-saved RBP 151 static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr); 152 153 // deoptimization support 154 void interpreter_frame_set_last_sp(intptr_t* sp); 155 156#endif // CPU_X86_VM_FRAME_X86_HPP 157