0
|
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 // Inline functions for Intel frames:
|
|
26
|
|
27 // Constructors:
|
|
28
|
|
29 inline frame::frame() {
|
|
30 _pc = NULL;
|
|
31 _sp = NULL;
|
|
32 _unextended_sp = NULL;
|
|
33 _fp = NULL;
|
|
34 _cb = NULL;
|
|
35 _deopt_state = unknown;
|
|
36 }
|
|
37
|
|
38 inline frame:: frame(intptr_t* sp, intptr_t* fp, address pc) {
|
|
39 _sp = sp;
|
|
40 _unextended_sp = sp;
|
|
41 _fp = fp;
|
|
42 _pc = pc;
|
|
43 assert(pc != NULL, "no pc?");
|
|
44 _cb = CodeCache::find_blob(pc);
|
|
45 _deopt_state = not_deoptimized;
|
|
46 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
|
|
47 _pc = (((nmethod*)_cb)->get_original_pc(this));
|
|
48 _deopt_state = is_deoptimized;
|
|
49 } else {
|
|
50 _deopt_state = not_deoptimized;
|
|
51 }
|
|
52 }
|
|
53
|
|
54 inline frame:: frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
|
|
55 _sp = sp;
|
|
56 _unextended_sp = unextended_sp;
|
|
57 _fp = fp;
|
|
58 _pc = pc;
|
|
59 assert(pc != NULL, "no pc?");
|
|
60 _cb = CodeCache::find_blob(pc);
|
|
61 _deopt_state = not_deoptimized;
|
|
62 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
|
|
63 _pc = (((nmethod*)_cb)->get_original_pc(this));
|
|
64 _deopt_state = is_deoptimized;
|
|
65 } else {
|
|
66 _deopt_state = not_deoptimized;
|
|
67 }
|
|
68 }
|
|
69
|
|
70 inline frame::frame(intptr_t* sp, intptr_t* fp) {
|
|
71 _sp = sp;
|
|
72 _unextended_sp = sp;
|
|
73 _fp = fp;
|
|
74 _pc = (address)(sp[-1]);
|
|
75 assert(_pc != NULL, "no pc?");
|
|
76 _cb = CodeCache::find_blob(_pc);
|
|
77 // In case of native stubs, the pc retreived here might be
|
|
78 // wrong. (the _last_native_pc will have the right value)
|
|
79 // So do not put add any asserts on the _pc here.
|
|
80
|
|
81 // QQQ The above comment is wrong and has been wrong for years. This constructor
|
|
82 // should (and MUST) not be called in that situation. In the native situation
|
|
83 // the pc should be supplied to the constructor.
|
|
84 _deopt_state = not_deoptimized;
|
|
85 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
|
|
86 _pc = (((nmethod*)_cb)->get_original_pc(this));
|
|
87 _deopt_state = is_deoptimized;
|
|
88 } else {
|
|
89 _deopt_state = not_deoptimized;
|
|
90 }
|
|
91 }
|
|
92
|
|
93 // Accessors
|
|
94
|
|
95 inline bool frame::equal(frame other) const {
|
|
96 bool ret = sp() == other.sp()
|
|
97 && unextended_sp() == other.unextended_sp()
|
|
98 && fp() == other.fp()
|
|
99 && pc() == other.pc();
|
|
100 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
|
|
101 return ret;
|
|
102 }
|
|
103
|
|
104 // Return unique id for this frame. The id must have a value where we can distinguish
|
|
105 // identity and younger/older relationship. NULL represents an invalid (incomparable)
|
|
106 // frame.
|
|
107 inline intptr_t* frame::id(void) const { return unextended_sp(); }
|
|
108
|
|
109 // Relationals on frames based
|
|
110 // Return true if the frame is younger (more recent activation) than the frame represented by id
|
|
111 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
|
|
112 return this->id() < id ; }
|
|
113
|
|
114 // Return true if the frame is older (less recent activation) than the frame represented by id
|
|
115 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
|
|
116 return this->id() > id ; }
|
|
117
|
|
118
|
|
119
|
|
120 inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
|
|
121 inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; }
|
|
122
|
|
123
|
|
124 inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }
|
|
125
|
|
126 // Return address:
|
|
127
|
|
128 inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }
|
|
129 inline address frame::sender_pc() const { return *sender_pc_addr(); }
|
|
130
|
|
131 // return address of param, zero origin index.
|
|
132 inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
|
|
133
|
|
134 #ifdef CC_INTERP
|
|
135
|
|
136 inline interpreterState frame::get_interpreterState() const {
|
|
137 return ((interpreterState)addr_at( -sizeof(BytecodeInterpreter)/wordSize ));
|
|
138 }
|
|
139
|
|
140 inline intptr_t* frame::sender_sp() const {
|
|
141 // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?
|
|
142 if (is_interpreted_frame()) {
|
|
143 assert(false, "should never happen");
|
|
144 return get_interpreterState()->sender_sp();
|
|
145 } else {
|
|
146 return addr_at(sender_sp_offset);
|
|
147 }
|
|
148 }
|
|
149
|
|
150 inline intptr_t** frame::interpreter_frame_locals_addr() const {
|
|
151 assert(is_interpreted_frame(), "must be interpreted");
|
|
152 return &(get_interpreterState()->_locals);
|
|
153 }
|
|
154
|
|
155 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
|
|
156 assert(is_interpreted_frame(), "must be interpreted");
|
|
157 return (jint*) &(get_interpreterState()->_bcp);
|
|
158 }
|
|
159
|
|
160
|
|
161 // Constant pool cache
|
|
162
|
|
163 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
|
|
164 assert(is_interpreted_frame(), "must be interpreted");
|
|
165 return &(get_interpreterState()->_constants);
|
|
166 }
|
|
167
|
|
168 // Method
|
|
169
|
|
170 inline methodOop* frame::interpreter_frame_method_addr() const {
|
|
171 assert(is_interpreted_frame(), "must be interpreted");
|
|
172 return &(get_interpreterState()->_method);
|
|
173 }
|
|
174
|
|
175 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
|
|
176 assert(is_interpreted_frame(), "must be interpreted");
|
|
177 return (jint*) &(get_interpreterState()->_mdx);
|
|
178 }
|
|
179
|
|
180 // top of expression stack
|
|
181 inline intptr_t* frame::interpreter_frame_tos_address() const {
|
|
182 assert(is_interpreted_frame(), "wrong frame type");
|
|
183 return get_interpreterState()->_stack + 1;
|
|
184 }
|
|
185
|
|
186 #else /* asm interpreter */
|
|
187 inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }
|
|
188
|
|
189 inline intptr_t** frame::interpreter_frame_locals_addr() const {
|
|
190 return (intptr_t**)addr_at(interpreter_frame_locals_offset);
|
|
191 }
|
|
192
|
|
193 inline intptr_t* frame::interpreter_frame_last_sp() const {
|
|
194 return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
|
|
195 }
|
|
196
|
|
197 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
|
|
198 return (intptr_t*)addr_at(interpreter_frame_bcx_offset);
|
|
199 }
|
|
200
|
|
201
|
|
202 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
|
|
203 return (intptr_t*)addr_at(interpreter_frame_mdx_offset);
|
|
204 }
|
|
205
|
|
206
|
|
207
|
|
208 // Constant pool cache
|
|
209
|
|
210 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
|
|
211 return (constantPoolCacheOop*)addr_at(interpreter_frame_cache_offset);
|
|
212 }
|
|
213
|
|
214 // Method
|
|
215
|
|
216 inline methodOop* frame::interpreter_frame_method_addr() const {
|
|
217 return (methodOop*)addr_at(interpreter_frame_method_offset);
|
|
218 }
|
|
219
|
|
220 // top of expression stack
|
|
221 inline intptr_t* frame::interpreter_frame_tos_address() const {
|
|
222 intptr_t* last_sp = interpreter_frame_last_sp();
|
|
223 if (last_sp == NULL ) {
|
|
224 return sp();
|
|
225 } else {
|
|
226 // sp() may have been extended by an adapter
|
|
227 assert(last_sp < fp() && last_sp >= sp(), "bad tos");
|
|
228 return last_sp;
|
|
229 }
|
|
230 }
|
|
231
|
|
232 #endif /* CC_INTERP */
|
|
233
|
|
234 inline int frame::pd_oop_map_offset_adjustment() const {
|
|
235 return 0;
|
|
236 }
|
|
237
|
|
238 inline int frame::interpreter_frame_monitor_size() {
|
|
239 return BasicObjectLock::size();
|
|
240 }
|
|
241
|
|
242
|
|
243 // expression stack
|
|
244 // (the max_stack arguments are used by the GC; see class FrameClosure)
|
|
245
|
|
246 inline intptr_t* frame::interpreter_frame_expression_stack() const {
|
|
247 intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
|
|
248 return monitor_end-1;
|
|
249 }
|
|
250
|
|
251
|
|
252 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
|
|
253
|
|
254
|
|
255 // Entry frames
|
|
256
|
|
257 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
|
|
258 return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset);
|
|
259 }
|
|
260
|
|
261
|
|
262 // Compiled frames
|
|
263
|
|
264 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
|
|
265 return (nof_args - local_index + (local_index < nof_args ? 1: -1));
|
|
266 }
|
|
267
|
|
268 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
|
|
269 return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
|
|
270 }
|
|
271
|
|
272 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
|
|
273 return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
|
|
274 }
|
|
275
|
|
276 inline bool frame::volatile_across_calls(Register reg) {
|
|
277 return true;
|
|
278 }
|
|
279
|
|
280
|
|
281
|
|
282 inline oop frame::saved_oop_result(RegisterMap* map) const {
|
|
283 return *((oop*) map->location(rax->as_VMReg()));
|
|
284 }
|
|
285
|
|
286 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
|
|
287 *((oop*) map->location(rax->as_VMReg())) = obj;
|
|
288 }
|