comparison src/cpu/x86/vm/frame_x86.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 18a389214829
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 1997-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 // A frame represents a physical stack frame (an activation). Frames can be
26 // C or Java frames, and the Java frames can be interpreted or compiled.
27 // In contrast, vframes represent source-level activations, so that one physical frame
28 // can correspond to multiple source level frames because of inlining.
29 // A frame is comprised of {pc, fp, sp}
30 // ------------------------------ Asm interpreter ----------------------------------------
31 // Layout of asm interpreter frame:
32 // [expression stack ] * <- sp
33 // [monitors ] \
34 // ... | monitor block size
35 // [monitors ] /
36 // [monitor block size ]
37 // [byte code index/pointr] = bcx() bcx_offset
38 // [pointer to locals ] = locals() locals_offset
39 // [constant pool cache ] = cache() cache_offset
40 // [methodData ] = mdp() mdx_offset
41 // [methodOop ] = method() method_offset
42 // [last sp ] = last_sp() last_sp_offset
43 // [old stack pointer ] (sender_sp) sender_sp_offset
44 // [old frame pointer ] <- fp = link()
45 // [return pc ]
46 // [oop temp ] (only for native calls)
47 // [locals and parameters ]
48 // <- sender sp
49 // ------------------------------ Asm interpreter ----------------------------------------
50
51 // ------------------------------ C++ interpreter ----------------------------------------
52 //
53 // Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)
54 //
55 // <- SP (current esp/rsp)
56 // [local variables ] BytecodeInterpreter::run local variables
57 // ... BytecodeInterpreter::run local variables
58 // [local variables ] BytecodeInterpreter::run local variables
59 // [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]
60 // [return pc ] (return to frame manager)
61 // [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------
62 // [expression stack ] <- last_Java_sp |
63 // [... ] * <- interpreter_state.stack |
64 // [expression stack ] * <- interpreter_state.stack_base |
65 // [monitors ] \ |
66 // ... | monitor block size |
67 // [monitors ] / <- interpreter_state.monitor_base |
68 // [struct interpretState ] <-----------------------------------------|
69 // [return pc ] (return to callee of frame manager [1]
70 // [locals and parameters ]
71 // <- sender sp
72
73 // [1] When the c++ interpreter calls a new method it returns to the frame
74 // manager which allocates a new frame on the stack. In that case there
75 // is no real callee of this newly allocated frame. The frame manager is
76 // aware of the additional frame(s) and will pop them as nested calls
77 // complete. Howevers tTo make it look good in the debugger the frame
78 // manager actually installs a dummy pc pointing to RecursiveInterpreterActivation
79 // with a fake interpreter_state* parameter to make it easy to debug
80 // nested calls.
81
82 // Note that contrary to the layout for the assembly interpreter the
83 // expression stack allocated for the C++ interpreter is full sized.
84 // However this is not as bad as it seems as the interpreter frame_manager
85 // will truncate the unused space on succesive method calls.
86 //
87 // ------------------------------ C++ interpreter ----------------------------------------
88
89 public:
90 enum {
91 pc_return_offset = 0,
92 // All frames
93 link_offset = 0,
94 return_addr_offset = 1,
95 // non-interpreter frames
96 sender_sp_offset = 2,
97
98 #ifndef CC_INTERP
99
100 // Interpreter frames
101 interpreter_frame_result_handler_offset = 3, // for native calls only
102 interpreter_frame_oop_temp_offset = 2, // for native calls only
103
104 interpreter_frame_sender_sp_offset = -1,
105 // outgoing sp before a call to an invoked method
106 interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,
107 interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,
108 interpreter_frame_mdx_offset = interpreter_frame_method_offset - 1,
109 interpreter_frame_cache_offset = interpreter_frame_mdx_offset - 1,
110 interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,
111 interpreter_frame_bcx_offset = interpreter_frame_locals_offset - 1,
112 interpreter_frame_initial_sp_offset = interpreter_frame_bcx_offset - 1,
113
114 interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,
115 interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,
116
117 #endif // CC_INTERP
118
119 // Entry frames
120 #ifdef AMD64
121 #ifdef _WIN64
122 entry_frame_after_call_words = 8,
123 entry_frame_call_wrapper_offset = 2,
124
125 arg_reg_save_area_bytes = 32, // Register argument save area
126 #else
127 entry_frame_after_call_words = 13,
128 entry_frame_call_wrapper_offset = -6,
129
130 arg_reg_save_area_bytes = 0,
131 #endif // _WIN64
132 #else
133 entry_frame_call_wrapper_offset = 2,
134 #endif // AMD64
135
136 // Native frames
137
138 native_frame_initial_param_offset = 2
139
140 };
141
142 intptr_t ptr_at(int offset) const {
143 return *ptr_at_addr(offset);
144 }
145
146 void ptr_at_put(int offset, intptr_t value) {
147 *ptr_at_addr(offset) = value;
148 }
149
150 private:
151 // an additional field beyond _sp and _pc:
152 intptr_t* _fp; // frame pointer
153 // The interpreter and adapters will extend the frame of the caller.
154 // Since oopMaps are based on the sp of the caller before extension
155 // we need to know that value. However in order to compute the address
156 // of the return address we need the real "raw" sp. Since sparc already
157 // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
158 // original sp we use that convention.
159
160 intptr_t* _unextended_sp;
161
162 intptr_t* ptr_at_addr(int offset) const {
163 return (intptr_t*) addr_at(offset);
164 }
165
166 public:
167 // Constructors
168
169 frame(intptr_t* sp, intptr_t* fp, address pc);
170
171 frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
172
173 frame(intptr_t* sp, intptr_t* fp);
174
175 // accessors for the instance variables
176 intptr_t* fp() const { return _fp; }
177
178 inline address* sender_pc_addr() const;
179
180 // return address of param, zero origin index.
181 inline address* native_param_addr(int idx) const;
182
183 // expression stack tos if we are nested in a java call
184 intptr_t* interpreter_frame_last_sp() const;
185
186 #ifndef CC_INTERP
187 // deoptimization support
188 void interpreter_frame_set_last_sp(intptr_t* sp);
189 #endif // CC_INTERP
190
191 #ifdef CC_INTERP
192 inline interpreterState get_interpreterState() const;
193 #endif // CC_INTERP