Mercurial > hg > truffle
annotate src/cpu/x86/vm/frame_x86.inline.hpp @ 6327:be0788825ffa
Move VirtualMachineComponent to interpreter project.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 07 Sep 2012 11:10:48 +0200 |
parents | 3dbcd1013cc8 |
children | e522a00b91aa |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1255
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef CPU_X86_VM_FRAME_X86_INLINE_HPP |
26 #define CPU_X86_VM_FRAME_X86_INLINE_HPP | |
27 | |
0 | 28 // Inline functions for Intel frames: |
29 | |
30 // Constructors: | |
31 | |
32 inline frame::frame() { | |
33 _pc = NULL; | |
34 _sp = NULL; | |
35 _unextended_sp = NULL; | |
36 _fp = NULL; | |
37 _cb = NULL; | |
38 _deopt_state = unknown; | |
39 } | |
40 | |
1204 | 41 inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) { |
0 | 42 _sp = sp; |
43 _unextended_sp = sp; | |
44 _fp = fp; | |
45 _pc = pc; | |
46 assert(pc != NULL, "no pc?"); | |
47 _cb = CodeCache::find_blob(pc); | |
3446
07c2e7ffd1fc
7047697: MethodHandle.invokeExact call for wrong method causes VM failure if run with -Xcomp
jrose
parents:
3363
diff
changeset
|
48 adjust_unextended_sp(); |
1204 | 49 |
50 address original_pc = nmethod::get_deopt_original_pc(this); | |
51 if (original_pc != NULL) { | |
52 _pc = original_pc; | |
0 | 53 _deopt_state = is_deoptimized; |
54 } else { | |
55 _deopt_state = not_deoptimized; | |
56 } | |
57 } | |
58 | |
1204 | 59 inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) { |
0 | 60 _sp = sp; |
61 _unextended_sp = unextended_sp; | |
62 _fp = fp; | |
63 _pc = pc; | |
64 assert(pc != NULL, "no pc?"); | |
65 _cb = CodeCache::find_blob(pc); | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
1972
diff
changeset
|
66 adjust_unextended_sp(); |
1204 | 67 |
68 address original_pc = nmethod::get_deopt_original_pc(this); | |
69 if (original_pc != NULL) { | |
70 _pc = original_pc; | |
1748 | 71 assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod"); |
0 | 72 _deopt_state = is_deoptimized; |
73 } else { | |
74 _deopt_state = not_deoptimized; | |
75 } | |
76 } | |
77 | |
78 inline frame::frame(intptr_t* sp, intptr_t* fp) { | |
79 _sp = sp; | |
80 _unextended_sp = sp; | |
81 _fp = fp; | |
82 _pc = (address)(sp[-1]); | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
83 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
84 // Here's a sticky one. This constructor can be called via AsyncGetCallTrace |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
85 // when last_Java_sp is non-null but the pc fetched is junk. If we are truly |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
86 // unlucky the junk value could be to a zombied method and we'll die on the |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
87 // find_blob call. This is also why we can have no asserts on the validity |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
88 // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
89 // -> pd_last_frame should use a specialized version of pd_last_frame which could |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
90 // call a specilaized frame constructor instead of this one. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
91 // Then we could use the assert below. However this assert is of somewhat dubious |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
92 // value. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
93 // assert(_pc != NULL, "no pc?"); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
94 |
0 | 95 _cb = CodeCache::find_blob(_pc); |
3446
07c2e7ffd1fc
7047697: MethodHandle.invokeExact call for wrong method causes VM failure if run with -Xcomp
jrose
parents:
3363
diff
changeset
|
96 adjust_unextended_sp(); |
0 | 97 |
1204 | 98 address original_pc = nmethod::get_deopt_original_pc(this); |
99 if (original_pc != NULL) { | |
100 _pc = original_pc; | |
0 | 101 _deopt_state = is_deoptimized; |
102 } else { | |
103 _deopt_state = not_deoptimized; | |
104 } | |
105 } | |
106 | |
107 // Accessors | |
108 | |
109 inline bool frame::equal(frame other) const { | |
110 bool ret = sp() == other.sp() | |
111 && unextended_sp() == other.unextended_sp() | |
112 && fp() == other.fp() | |
113 && pc() == other.pc(); | |
114 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); | |
115 return ret; | |
116 } | |
117 | |
118 // Return unique id for this frame. The id must have a value where we can distinguish | |
119 // identity and younger/older relationship. NULL represents an invalid (incomparable) | |
120 // frame. | |
121 inline intptr_t* frame::id(void) const { return unextended_sp(); } | |
122 | |
123 // Relationals on frames based | |
124 // Return true if the frame is younger (more recent activation) than the frame represented by id | |
125 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); | |
126 return this->id() < id ; } | |
127 | |
128 // Return true if the frame is older (less recent activation) than the frame represented by id | |
129 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); | |
130 return this->id() > id ; } | |
131 | |
132 | |
133 | |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
134 inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); } |
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
135 inline intptr_t** frame::link_addr() const { return (intptr_t **)addr_at(link_offset); } |
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
136 inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; } |
0 | 137 |
138 | |
139 inline intptr_t* frame::unextended_sp() const { return _unextended_sp; } | |
140 | |
141 // Return address: | |
142 | |
143 inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); } | |
144 inline address frame::sender_pc() const { return *sender_pc_addr(); } | |
145 | |
146 // return address of param, zero origin index. | |
147 inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); } | |
148 | |
149 #ifdef CC_INTERP | |
150 | |
151 inline interpreterState frame::get_interpreterState() const { | |
520
52a431267315
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
304
diff
changeset
|
152 return ((interpreterState)addr_at( -((int)sizeof(BytecodeInterpreter))/wordSize )); |
0 | 153 } |
154 | |
155 inline intptr_t* frame::sender_sp() const { | |
156 // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames? | |
157 if (is_interpreted_frame()) { | |
158 assert(false, "should never happen"); | |
159 return get_interpreterState()->sender_sp(); | |
160 } else { | |
161 return addr_at(sender_sp_offset); | |
162 } | |
163 } | |
164 | |
165 inline intptr_t** frame::interpreter_frame_locals_addr() const { | |
166 assert(is_interpreted_frame(), "must be interpreted"); | |
167 return &(get_interpreterState()->_locals); | |
168 } | |
169 | |
170 inline intptr_t* frame::interpreter_frame_bcx_addr() const { | |
171 assert(is_interpreted_frame(), "must be interpreted"); | |
304 | 172 return (intptr_t*) &(get_interpreterState()->_bcp); |
0 | 173 } |
174 | |
175 | |
176 // Constant pool cache | |
177 | |
178 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const { | |
179 assert(is_interpreted_frame(), "must be interpreted"); | |
180 return &(get_interpreterState()->_constants); | |
181 } | |
182 | |
183 // Method | |
184 | |
185 inline methodOop* frame::interpreter_frame_method_addr() const { | |
186 assert(is_interpreted_frame(), "must be interpreted"); | |
187 return &(get_interpreterState()->_method); | |
188 } | |
189 | |
190 inline intptr_t* frame::interpreter_frame_mdx_addr() const { | |
191 assert(is_interpreted_frame(), "must be interpreted"); | |
304 | 192 return (intptr_t*) &(get_interpreterState()->_mdx); |
0 | 193 } |
194 | |
195 // top of expression stack | |
196 inline intptr_t* frame::interpreter_frame_tos_address() const { | |
197 assert(is_interpreted_frame(), "wrong frame type"); | |
198 return get_interpreterState()->_stack + 1; | |
199 } | |
200 | |
201 #else /* asm interpreter */ | |
202 inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); } | |
203 | |
204 inline intptr_t** frame::interpreter_frame_locals_addr() const { | |
205 return (intptr_t**)addr_at(interpreter_frame_locals_offset); | |
206 } | |
207 | |
208 inline intptr_t* frame::interpreter_frame_last_sp() const { | |
209 return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset); | |
210 } | |
211 | |
4668
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
212 inline intptr_t** frame::interpreter_frame_last_sp_addr() const { |
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
213 return (intptr_t**)addr_at(interpreter_frame_last_sp_offset); |
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
214 } |
3dbcd1013cc8
added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents:
3446
diff
changeset
|
215 |
0 | 216 inline intptr_t* frame::interpreter_frame_bcx_addr() const { |
217 return (intptr_t*)addr_at(interpreter_frame_bcx_offset); | |
218 } | |
219 | |
220 | |
221 inline intptr_t* frame::interpreter_frame_mdx_addr() const { | |
222 return (intptr_t*)addr_at(interpreter_frame_mdx_offset); | |
223 } | |
224 | |
225 | |
226 | |
227 // Constant pool cache | |
228 | |
229 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const { | |
230 return (constantPoolCacheOop*)addr_at(interpreter_frame_cache_offset); | |
231 } | |
232 | |
233 // Method | |
234 | |
235 inline methodOop* frame::interpreter_frame_method_addr() const { | |
236 return (methodOop*)addr_at(interpreter_frame_method_offset); | |
237 } | |
238 | |
239 // top of expression stack | |
240 inline intptr_t* frame::interpreter_frame_tos_address() const { | |
241 intptr_t* last_sp = interpreter_frame_last_sp(); | |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
579
diff
changeset
|
242 if (last_sp == NULL) { |
0 | 243 return sp(); |
244 } else { | |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
579
diff
changeset
|
245 // sp() may have been extended or shrunk by an adapter. At least |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
579
diff
changeset
|
246 // check that we don't fall behind the legal region. |
1255
e3a4305c6bc3
6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents:
1204
diff
changeset
|
247 // For top deoptimized frame last_sp == interpreter_frame_monitor_end. |
e3a4305c6bc3
6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents:
1204
diff
changeset
|
248 assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos"); |
0 | 249 return last_sp; |
250 } | |
251 } | |
252 | |
253 #endif /* CC_INTERP */ | |
254 | |
255 inline int frame::pd_oop_map_offset_adjustment() const { | |
256 return 0; | |
257 } | |
258 | |
259 inline int frame::interpreter_frame_monitor_size() { | |
260 return BasicObjectLock::size(); | |
261 } | |
262 | |
263 | |
264 // expression stack | |
265 // (the max_stack arguments are used by the GC; see class FrameClosure) | |
266 | |
267 inline intptr_t* frame::interpreter_frame_expression_stack() const { | |
268 intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end(); | |
269 return monitor_end-1; | |
270 } | |
271 | |
272 | |
273 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; } | |
274 | |
275 | |
276 // Entry frames | |
277 | |
278 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const { | |
279 return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset); | |
280 } | |
281 | |
282 | |
283 // Compiled frames | |
284 | |
285 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { | |
286 return (nof_args - local_index + (local_index < nof_args ? 1: -1)); | |
287 } | |
288 | |
289 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { | |
290 return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors); | |
291 } | |
292 | |
293 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) { | |
294 return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1); | |
295 } | |
296 | |
297 inline bool frame::volatile_across_calls(Register reg) { | |
298 return true; | |
299 } | |
300 | |
301 | |
302 | |
303 inline oop frame::saved_oop_result(RegisterMap* map) const { | |
304 return *((oop*) map->location(rax->as_VMReg())); | |
305 } | |
306 | |
307 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { | |
308 *((oop*) map->location(rax->as_VMReg())) = obj; | |
309 } | |
1972 | 310 |
311 #endif // CPU_X86_VM_FRAME_X86_INLINE_HPP |