annotate src/cpu/aarch64/vm/frame_aarch64.hpp @ 8306:b7e5b185e33a

8079564: Use FP register as proper frame pointer in JIT compiled code on aarch64 Summary: Add support for PreserveFramePointer for debug/profile Reviewed-by: kvn
author enevill
date Fri, 15 May 2015 09:21:48 +0000
parents 36143dafcf1c
children d321ba06d890
rev   line source
aph@7879 1 /*
mikael@7993 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
aph@7879 3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
aph@7879 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aph@7879 5 *
aph@7879 6 * This code is free software; you can redistribute it and/or modify it
aph@7879 7 * under the terms of the GNU General Public License version 2 only, as
aph@7879 8 * published by the Free Software Foundation.
aph@7879 9 *
aph@7879 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aph@7879 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aph@7879 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aph@7879 13 * version 2 for more details (a copy is included in the LICENSE file that
aph@7879 14 * accompanied this code).
aph@7879 15 *
aph@7879 16 * You should have received a copy of the GNU General Public License version
aph@7879 17 * 2 along with this work; if not, write to the Free Software Foundation,
aph@7879 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aph@7879 19 *
aph@7879 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aph@7879 21 * or visit www.oracle.com if you need additional information or have any
aph@7879 22 * questions.
aph@7879 23 *
aph@7879 24 */
aph@7879 25
aph@7879 26 #ifndef CPU_AARCH64_VM_FRAME_AARCH64_HPP
aph@7879 27 #define CPU_AARCH64_VM_FRAME_AARCH64_HPP
aph@7879 28
aph@7879 29 #include "runtime/synchronizer.hpp"
aph@7879 30 #include "utilities/top.hpp"
aph@7879 31
aph@7879 32 // A frame represents a physical stack frame (an activation). Frames can be
aph@7879 33 // C or Java frames, and the Java frames can be interpreted or compiled.
aph@7879 34 // In contrast, vframes represent source-level activations, so that one physical frame
aph@7879 35 // can correspond to multiple source level frames because of inlining.
aph@7879 36 // A frame is comprised of {pc, fp, sp}
aph@7879 37 // ------------------------------ Asm interpreter ----------------------------------------
aph@7879 38 // Layout of asm interpreter frame:
aph@7879 39 // [expression stack ] * <- sp
aph@7879 40
aph@7879 41 // [monitors[0] ] \
aph@7879 42 // ... | monitor block size = k
aph@7879 43 // [monitors[k-1] ] /
aph@7879 44 // [frame initial esp ] ( == &monitors[0], initially here) initial_sp_offset
aph@7879 45 // [byte code index/pointr] = bcx() bcx_offset
aph@7879 46
aph@7879 47 // [pointer to locals ] = locals() locals_offset
aph@7879 48 // [constant pool cache ] = cache() cache_offset
aph@7879 49
aph@7879 50 // [methodData ] = mdp() mdx_offset
aph@7879 51 // [methodOop ] = method() method_offset
aph@7879 52
aph@7879 53 // [last esp ] = last_sp() last_sp_offset
aph@7879 54 // [old stack pointer ] (sender_sp) sender_sp_offset
aph@7879 55
aph@7879 56 // [old frame pointer ] <- fp = link()
aph@7879 57 // [return pc ]
aph@7879 58
aph@7879 59 // [last sp ]
aph@7879 60 // [oop temp ] (only for native calls)
aph@7879 61
aph@7879 62 // [locals and parameters ]
aph@7879 63 // <- sender sp
aph@7879 64 // ------------------------------ Asm interpreter ----------------------------------------
aph@7879 65
aph@7879 66 // ------------------------------ C++ interpreter ----------------------------------------
aph@7879 67 //
aph@7879 68 // Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)
aph@7879 69 //
aph@7879 70 // <- SP (current esp/rsp)
aph@7879 71 // [local variables ] BytecodeInterpreter::run local variables
aph@7879 72 // ... BytecodeInterpreter::run local variables
aph@7879 73 // [local variables ] BytecodeInterpreter::run local variables
aph@7879 74 // [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]
aph@7879 75 // [return pc ] (return to frame manager)
aph@7879 76 // [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------
aph@7879 77 // [expression stack ] <- last_Java_sp |
aph@7879 78 // [... ] * <- interpreter_state.stack |
aph@7879 79 // [expression stack ] * <- interpreter_state.stack_base |
aph@7879 80 // [monitors ] \ |
aph@7879 81 // ... | monitor block size |
aph@7879 82 // [monitors ] / <- interpreter_state.monitor_base |
aph@7879 83 // [struct interpretState ] <-----------------------------------------|
aph@7879 84 // [return pc ] (return to callee of frame manager [1]
aph@7879 85 // [locals and parameters ]
aph@7879 86 // <- sender sp
aph@7879 87
aph@7879 88 // [1] When the c++ interpreter calls a new method it returns to the frame
aph@7879 89 // manager which allocates a new frame on the stack. In that case there
aph@7879 90 // is no real callee of this newly allocated frame. The frame manager is
aph@7879 91 // aware of the additional frame(s) and will pop them as nested calls
aph@7879 92 // complete. Howevers tTo make it look good in the debugger the frame
aph@7879 93 // manager actually installs a dummy pc pointing to RecursiveInterpreterActivation
aph@7879 94 // with a fake interpreter_state* parameter to make it easy to debug
aph@7879 95 // nested calls.
aph@7879 96
aph@7879 97 // Note that contrary to the layout for the assembly interpreter the
aph@7879 98 // expression stack allocated for the C++ interpreter is full sized.
aph@7879 99 // However this is not as bad as it seems as the interpreter frame_manager
aph@7879 100 // will truncate the unused space on succesive method calls.
aph@7879 101 //
aph@7879 102 // ------------------------------ C++ interpreter ----------------------------------------
aph@7879 103
aph@7879 104 public:
aph@7879 105 enum {
aph@7879 106 pc_return_offset = 0,
aph@7879 107 // All frames
aph@7879 108 link_offset = 0,
aph@7879 109 return_addr_offset = 1,
aph@7879 110 sender_sp_offset = 2,
aph@7879 111
aph@7879 112 #ifndef CC_INTERP
aph@7879 113
aph@7879 114 // Interpreter frames
aph@7879 115 interpreter_frame_oop_temp_offset = 3, // for native calls only
aph@7879 116
aph@7879 117 interpreter_frame_sender_sp_offset = -1,
aph@7879 118 // outgoing sp before a call to an invoked method
aph@7879 119 interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,
aph@7879 120 interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,
aph@7879 121 interpreter_frame_mdp_offset = interpreter_frame_method_offset - 1,
aph@7879 122 interpreter_frame_cache_offset = interpreter_frame_mdp_offset - 1,
aph@7879 123 interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,
aph@7879 124 interpreter_frame_bcp_offset = interpreter_frame_locals_offset - 1,
aph@7879 125 interpreter_frame_initial_sp_offset = interpreter_frame_bcp_offset - 1,
aph@7879 126
aph@7879 127 interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,
aph@7879 128 interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,
aph@7879 129
aph@7879 130 #endif // CC_INTERP
aph@7879 131
aph@7879 132 // Entry frames
aph@7879 133 // n.b. these values are determined by the layout defined in
aph@7879 134 // stubGenerator for the Java call stub
aph@7879 135 entry_frame_after_call_words = 27,
aph@7879 136 entry_frame_call_wrapper_offset = -8,
aph@7879 137
aph@7879 138 // we don't need a save area
mikael@7993 139 arg_reg_save_area_bytes = 0
aph@7879 140
aph@7879 141 };
aph@7879 142
aph@7879 143 intptr_t ptr_at(int offset) const {
aph@7879 144 return *ptr_at_addr(offset);
aph@7879 145 }
aph@7879 146
aph@7879 147 void ptr_at_put(int offset, intptr_t value) {
aph@7879 148 *ptr_at_addr(offset) = value;
aph@7879 149 }
aph@7879 150
aph@7879 151 private:
aph@7879 152 // an additional field beyond _sp and _pc:
aph@7879 153 intptr_t* _fp; // frame pointer
aph@7879 154 // The interpreter and adapters will extend the frame of the caller.
aph@7879 155 // Since oopMaps are based on the sp of the caller before extension
aph@7879 156 // we need to know that value. However in order to compute the address
aph@7879 157 // of the return address we need the real "raw" sp. Since sparc already
aph@7879 158 // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
aph@7879 159 // original sp we use that convention.
aph@7879 160
aph@7879 161 intptr_t* _unextended_sp;
aph@7879 162 void adjust_unextended_sp();
aph@7879 163
aph@7879 164 intptr_t* ptr_at_addr(int offset) const {
aph@7879 165 return (intptr_t*) addr_at(offset);
aph@7879 166 }
aph@7879 167
aph@7879 168 #ifdef ASSERT
aph@7879 169 // Used in frame::sender_for_{interpreter,compiled}_frame
enevill@8306 170 static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp);
aph@7879 171 #endif
aph@7879 172
aph@7879 173 public:
aph@7879 174 // Constructors
aph@7879 175
aph@7879 176 frame(intptr_t* sp, intptr_t* fp, address pc);
aph@7879 177
aph@7879 178 frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
aph@7879 179
aph@7879 180 frame(intptr_t* sp, intptr_t* fp);
aph@7879 181
aph@7879 182 void init(intptr_t* sp, intptr_t* fp, address pc);
aph@7879 183
aph@7879 184 // accessors for the instance variables
aph@7879 185 // Note: not necessarily the real 'frame pointer' (see real_fp)
aph@7879 186 intptr_t* fp() const { return _fp; }
aph@7879 187
aph@7879 188 inline address* sender_pc_addr() const;
aph@7879 189
aph@7879 190 // expression stack tos if we are nested in a java call
aph@7879 191 intptr_t* interpreter_frame_last_sp() const;
aph@7879 192
aph@7879 193 // helper to update a map with callee-saved RBP
aph@7879 194 static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);
aph@7879 195
aph@7879 196 #ifndef CC_INTERP
aph@7879 197 // deoptimization support
aph@7879 198 void interpreter_frame_set_last_sp(intptr_t* sp);
aph@7879 199 #endif // CC_INTERP
aph@7879 200
aph@7879 201 #ifdef CC_INTERP
aph@7879 202 inline interpreterState get_interpreterState() const;
aph@7879 203 #endif // CC_INTERP
aph@7879 204
aph@7879 205 #endif // CPU_AARCH64_VM_FRAME_AARCH64_HPP