author | coleenp |
Sat, 27 May 2017 09:21:01 -0400 | |
changeset 46505 | fd4bc78630b1 |
parent 42556 | c03d98321ad1 |
child 46620 | 750c6edff33b |
permissions | -rw-r--r-- |
42065 | 1 |
/* |
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* Copyright (c) 2016 SAP SE. All rights reserved. |
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
26 |
#ifndef CPU_S390_VM_FRAME_S390_INLINE_HPP |
|
27 |
#define CPU_S390_VM_FRAME_S390_INLINE_HPP |
|
28 |
||
29 |
#include "code/codeCache.hpp" |
|
30 |
#include "code/vmreg.inline.hpp" |
|
31 |
||
32 |
// Inline functions for z/Architecture frames: |
|
33 |
||
34 |
inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) { |
|
35 |
assert(pc != NULL, "precondition: must have PC"); |
|
36 |
||
37 |
_cb = CodeCache::find_blob(pc); |
|
38 |
_pc = pc; // Must be set for get_deopt_original_pc(). |
|
39 |
||
40 |
_fp = (intptr_t *) own_abi()->callers_sp; |
|
41 |
||
42556
c03d98321ad1
8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents:
42065
diff
changeset
|
42 |
address original_pc = CompiledMethod::get_deopt_original_pc(this); |
42065 | 43 |
if (original_pc != NULL) { |
44 |
_pc = original_pc; |
|
45 |
_deopt_state = is_deoptimized; |
|
46 |
} else { |
|
47 |
_deopt_state = not_deoptimized; |
|
48 |
} |
|
49 |
||
50 |
assert(((uint64_t)_sp & 0x7) == 0, "SP must be 8-byte aligned"); |
|
51 |
} |
|
52 |
||
53 |
// Constructors |
|
54 |
||
55 |
// Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state. |
|
56 |
inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {} |
|
57 |
||
58 |
inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) { |
|
59 |
find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->return_pc); |
|
60 |
} |
|
61 |
||
62 |
inline frame::frame(intptr_t* sp, address pc) : _sp(sp), _unextended_sp(sp) { |
|
63 |
find_codeblob_and_set_pc_and_deopt_state(pc); // Also sets _fp and adjusts _unextended_sp. |
|
64 |
} |
|
65 |
||
66 |
inline frame::frame(intptr_t* sp, address pc, intptr_t* unextended_sp) : _sp(sp), _unextended_sp(unextended_sp) { |
|
67 |
find_codeblob_and_set_pc_and_deopt_state(pc); // Also sets _fp and adjusts _unextended_sp. |
|
68 |
} |
|
69 |
||
70 |
// Generic constructor. Used by pns() in debug.cpp only |
|
71 |
#ifndef PRODUCT |
|
72 |
inline frame::frame(void* sp, void* pc, void* unextended_sp) : |
|
73 |
_sp((intptr_t*)sp), _unextended_sp((intptr_t*)unextended_sp), _cb(NULL), _pc(NULL) { |
|
74 |
find_codeblob_and_set_pc_and_deopt_state((address)pc); // Also sets _fp and adjusts _unextended_sp. |
|
75 |
} |
|
76 |
#endif |
|
77 |
||
78 |
// template interpreter state |
|
79 |
inline frame::z_ijava_state* frame::ijava_state() const { |
|
80 |
z_ijava_state* state = (z_ijava_state*) ((uintptr_t)fp() - z_ijava_state_size); |
|
81 |
assert(state->magic == (intptr_t) frame::z_istate_magic_number, |
|
82 |
"wrong z_ijava_state in interpreter frame (no magic found)"); |
|
83 |
return state; |
|
84 |
} |
|
85 |
||
86 |
inline BasicObjectLock** frame::interpreter_frame_monitors_addr() const { |
|
87 |
return (BasicObjectLock**) &(ijava_state()->monitors); |
|
88 |
} |
|
89 |
||
90 |
// The next two funcions read and write z_ijava_state.monitors. |
|
91 |
inline BasicObjectLock* frame::interpreter_frame_monitors() const { |
|
92 |
return *interpreter_frame_monitors_addr(); |
|
93 |
} |
|
94 |
inline void frame::interpreter_frame_set_monitors(BasicObjectLock* monitors) { |
|
95 |
*interpreter_frame_monitors_addr() = monitors; |
|
96 |
} |
|
97 |
||
98 |
// Accessors |
|
99 |
||
100 |
// Return unique id for this frame. The id must have a value where we |
|
101 |
// can distinguish identity and younger/older relationship. NULL |
|
102 |
// represents an invalid (incomparable) frame. |
|
103 |
inline intptr_t* frame::id(void) const { |
|
104 |
// Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing. |
|
105 |
return _fp; |
|
106 |
} |
|
107 |
||
108 |
// Return true if this frame is younger (more recent activation) than |
|
109 |
// the frame represented by id. |
|
110 |
inline bool frame::is_younger(intptr_t* id) const { |
|
111 |
assert(this->id() != NULL && id != NULL, "NULL frame id"); |
|
112 |
// Stack grows towards smaller addresses on z/Architecture. |
|
113 |
return this->id() < id; |
|
114 |
} |
|
115 |
||
116 |
// Return true if this frame is older (less recent activation) than |
|
117 |
// the frame represented by id. |
|
118 |
inline bool frame::is_older(intptr_t* id) const { |
|
119 |
assert(this->id() != NULL && id != NULL, "NULL frame id"); |
|
120 |
// Stack grows towards smaller addresses on z/Architecture. |
|
121 |
return this->id() > id; |
|
122 |
} |
|
123 |
||
124 |
inline int frame::frame_size(RegisterMap* map) const { |
|
125 |
// Stack grows towards smaller addresses on z/Linux: sender is at a higher address. |
|
126 |
return sender_sp() - sp(); |
|
127 |
} |
|
128 |
||
129 |
// Ignore c2i adapter frames. |
|
130 |
inline intptr_t* frame::unextended_sp() const { |
|
131 |
return _unextended_sp; |
|
132 |
} |
|
133 |
||
134 |
inline address frame::sender_pc() const { |
|
135 |
return (address) callers_abi()->return_pc; |
|
136 |
} |
|
137 |
||
138 |
// Get caller pc, if caller is native from stack slot of gpr14. |
|
139 |
inline address frame::native_sender_pc() const { |
|
140 |
return (address) callers_abi()->gpr14; |
|
141 |
} |
|
142 |
||
143 |
// Get caller pc from stack slot of gpr10. |
|
144 |
inline address frame::callstub_sender_pc() const { |
|
145 |
return (address) callers_abi()->gpr10; |
|
146 |
} |
|
147 |
||
148 |
inline address* frame::sender_pc_addr() const { |
|
149 |
return (address*) &(callers_abi()->return_pc); |
|
150 |
} |
|
151 |
||
152 |
inline intptr_t* frame::sender_sp() const { |
|
153 |
return (intptr_t*) callers_abi(); |
|
154 |
} |
|
155 |
||
156 |
inline intptr_t* frame::link() const { |
|
157 |
return (intptr_t*) callers_abi()->callers_sp; |
|
158 |
} |
|
159 |
||
160 |
inline intptr_t** frame::interpreter_frame_locals_addr() const { |
|
161 |
return (intptr_t**) &(ijava_state()->locals); |
|
162 |
} |
|
163 |
||
164 |
inline intptr_t* frame::interpreter_frame_bcp_addr() const { |
|
165 |
return (intptr_t*) &(ijava_state()->bcp); |
|
166 |
} |
|
167 |
||
168 |
inline intptr_t* frame::interpreter_frame_mdp_addr() const { |
|
169 |
return (intptr_t*) &(ijava_state()->mdx); |
|
170 |
} |
|
171 |
||
172 |
// Bottom(base) of the expression stack (highest address). |
|
173 |
inline intptr_t* frame::interpreter_frame_expression_stack() const { |
|
174 |
return (intptr_t*)interpreter_frame_monitor_end() - 1; |
|
175 |
} |
|
176 |
||
177 |
inline jint frame::interpreter_frame_expression_stack_direction() { |
|
178 |
return -1; |
|
179 |
} |
|
180 |
||
181 |
inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const { |
|
182 |
return &interpreter_frame_tos_address()[offset]; |
|
183 |
} |
|
184 |
||
185 |
||
186 |
// monitor elements |
|
187 |
||
188 |
// End is lower in memory than begin, and beginning element is oldest element. |
|
189 |
// Also begin is one past last monitor. |
|
190 |
||
191 |
inline intptr_t* frame::interpreter_frame_top_frame_sp() { |
|
192 |
return (intptr_t*)ijava_state()->top_frame_sp; |
|
193 |
} |
|
194 |
||
195 |
inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) { |
|
196 |
ijava_state()->top_frame_sp = (intptr_t) top_frame_sp; |
|
197 |
} |
|
198 |
||
199 |
inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp) { |
|
200 |
ijava_state()->sender_sp = (intptr_t) sender_sp; |
|
201 |
} |
|
202 |
||
203 |
#ifdef ASSERT |
|
204 |
inline void frame::interpreter_frame_set_magic() { |
|
205 |
ijava_state()->magic = (intptr_t) frame::z_istate_magic_number; |
|
206 |
} |
|
207 |
#endif |
|
208 |
||
209 |
// Where z_ijava_state.esp is saved. |
|
210 |
inline intptr_t** frame::interpreter_frame_esp_addr() const { |
|
211 |
return (intptr_t**) &(ijava_state()->esp); |
|
212 |
} |
|
213 |
||
214 |
// top of expression stack (lowest address) |
|
215 |
inline intptr_t* frame::interpreter_frame_tos_address() const { |
|
216 |
return *interpreter_frame_esp_addr() + 1; |
|
217 |
} |
|
218 |
||
219 |
inline void frame::interpreter_frame_set_tos_address(intptr_t* x) { |
|
220 |
*interpreter_frame_esp_addr() = x - 1; |
|
221 |
} |
|
222 |
||
223 |
// Stack slot needed for native calls and GC. |
|
224 |
inline oop * frame::interpreter_frame_temp_oop_addr() const { |
|
225 |
return (oop *) ((address) _fp + _z_ijava_state_neg(oop_tmp)); |
|
226 |
} |
|
227 |
||
228 |
// In keeping with Intel side: end is lower in memory than begin. |
|
229 |
// Beginning element is oldest element. Also begin is one past last monitor. |
|
230 |
inline BasicObjectLock * frame::interpreter_frame_monitor_begin() const { |
|
231 |
return (BasicObjectLock*)ijava_state(); |
|
232 |
} |
|
233 |
||
234 |
inline BasicObjectLock * frame::interpreter_frame_monitor_end() const { |
|
235 |
return interpreter_frame_monitors(); |
|
236 |
} |
|
237 |
||
238 |
inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* monitors) { |
|
239 |
interpreter_frame_set_monitors((BasicObjectLock *)monitors); |
|
240 |
} |
|
241 |
||
242 |
inline int frame::interpreter_frame_monitor_size() { |
|
243 |
// Number of stack slots for a monitor |
|
244 |
return round_to(BasicObjectLock::size() /* number of stack slots */, |
|
245 |
WordsPerLong /* Number of stack slots for a Java long. */); |
|
246 |
} |
|
247 |
||
248 |
inline int frame::interpreter_frame_monitor_size_in_bytes() { |
|
249 |
// Number of bytes for a monitor. |
|
250 |
return frame::interpreter_frame_monitor_size() * wordSize; |
|
251 |
} |
|
252 |
||
253 |
inline int frame::interpreter_frame_interpreterstate_size_in_bytes() { |
|
254 |
return z_ijava_state_size; |
|
255 |
} |
|
256 |
||
257 |
inline Method** frame::interpreter_frame_method_addr() const { |
|
258 |
return (Method**)&(ijava_state()->method); |
|
259 |
} |
|
260 |
||
261 |
inline oop* frame::interpreter_frame_mirror_addr() const { |
|
262 |
return (oop*)&(ijava_state()->mirror); |
|
263 |
} |
|
264 |
||
265 |
// Constant pool cache |
|
266 |
||
267 |
inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { |
|
268 |
return (ConstantPoolCache**)&(ijava_state()->cpoolCache); |
|
269 |
} |
|
270 |
||
271 |
// entry frames |
|
272 |
||
273 |
inline intptr_t* frame::entry_frame_argument_at(int offset) const { |
|
274 |
// Since an entry frame always calls the interpreter first, |
|
275 |
// the parameters are on the stack and relative to known register in the |
|
276 |
// entry frame. |
|
277 |
intptr_t* tos = (intptr_t*) entry_frame_locals()->arguments_tos_address; |
|
278 |
return &tos[offset + 1]; // prepushed tos |
|
279 |
} |
|
280 |
||
281 |
inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const { |
|
282 |
return (JavaCallWrapper**) &entry_frame_locals()->call_wrapper_address; |
|
283 |
} |
|
284 |
||
285 |
inline oop frame::saved_oop_result(RegisterMap* map) const { |
|
286 |
return *((oop*) map->location(Z_R2->as_VMReg())); // R2 is return register. |
|
287 |
} |
|
288 |
||
289 |
inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { |
|
290 |
*((oop*) map->location(Z_R2->as_VMReg())) = obj; // R2 is return register. |
|
291 |
} |
|
292 |
||
293 |
inline intptr_t* frame::real_fp() const { |
|
294 |
return fp(); |
|
295 |
} |
|
296 |
||
297 |
#endif // CPU_S390_VM_FRAME_S390_INLINE_HPP |