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