src/cpu/x86/vm/frame_x86.hpp

Mon, 01 Feb 2010 19:29:46 +0100

author
twisti
date
Mon, 01 Feb 2010 19:29:46 +0100
changeset 1639
18a389214829
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6921352: JSR 292 needs its own deopt handler
Summary: We need to introduce a new MH deopt handler so we can easily determine if the deopt happened at a MH call site or not.
Reviewed-by: never, jrose

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

mercurial