Mercurial > hg > truffle
annotate src/cpu/zero/vm/frame_zero.cpp @ 1932:e6500c6c5e24
Removed launch configuration.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 21 Dec 2010 17:09:37 +0100 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
1010 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1512
diff
changeset
|
2 * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. |
1505 | 3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. |
1010 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1512
diff
changeset
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1512
diff
changeset
|
21 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1512
diff
changeset
|
22 * questions. |
1010 | 23 * |
24 */ | |
25 | |
26 #include "incls/_precompiled.incl" | |
27 #include "incls/_frame_zero.cpp.incl" | |
28 | |
29 #ifdef ASSERT | |
30 void RegisterMap::check_location_valid() { | |
31 ShouldNotCallThis(); | |
32 } | |
33 #endif | |
34 | |
35 bool frame::is_interpreted_frame() const { | |
36 return zeroframe()->is_interpreter_frame(); | |
37 } | |
38 | |
1512 | 39 bool frame::is_fake_stub_frame() const { |
40 return zeroframe()->is_fake_stub_frame(); | |
41 } | |
42 | |
1010 | 43 frame frame::sender_for_entry_frame(RegisterMap *map) const { |
1078 | 44 assert(zeroframe()->is_entry_frame(), "wrong type of frame"); |
1010 | 45 assert(map != NULL, "map must be set"); |
46 assert(!entry_frame_is_first(), "next Java fp must be non zero"); | |
47 assert(entry_frame_call_wrapper()->anchor()->last_Java_sp() == sender_sp(), | |
48 "sender should be next Java frame"); | |
49 map->clear(); | |
50 assert(map->include_argument_oops(), "should be set by clear"); | |
1505 | 51 return frame(zeroframe()->next(), sender_sp()); |
1010 | 52 } |
53 | |
1078 | 54 frame frame::sender_for_nonentry_frame(RegisterMap *map) const { |
55 assert(zeroframe()->is_interpreter_frame() || | |
56 zeroframe()->is_shark_frame() || | |
57 zeroframe()->is_fake_stub_frame(), "wrong type of frame"); | |
1505 | 58 return frame(zeroframe()->next(), sender_sp()); |
1010 | 59 } |
60 | |
61 frame frame::sender(RegisterMap* map) const { | |
62 // Default is not to follow arguments; the various | |
63 // sender_for_xxx methods update this accordingly. | |
64 map->set_include_argument_oops(false); | |
65 | |
66 if (is_entry_frame()) | |
67 return sender_for_entry_frame(map); | |
1078 | 68 else |
69 return sender_for_nonentry_frame(map); | |
1010 | 70 } |
71 | |
72 #ifdef CC_INTERP | |
73 BasicObjectLock* frame::interpreter_frame_monitor_begin() const { | |
74 return get_interpreterState()->monitor_base(); | |
75 } | |
76 | |
77 BasicObjectLock* frame::interpreter_frame_monitor_end() const { | |
78 return (BasicObjectLock*) get_interpreterState()->stack_base(); | |
79 } | |
80 #endif // CC_INTERP | |
81 | |
82 void frame::patch_pc(Thread* thread, address pc) { | |
83 // We borrow this call to set the thread pointer in the interpreter | |
84 // state; the hook to set up deoptimized frames isn't supplied it. | |
85 assert(pc == NULL, "should be"); | |
86 get_interpreterState()->set_thread((JavaThread *) thread); | |
87 } | |
88 | |
89 bool frame::safe_for_sender(JavaThread *thread) { | |
90 ShouldNotCallThis(); | |
91 } | |
92 | |
93 void frame::pd_gc_epilog() { | |
94 } | |
95 | |
96 bool frame::is_interpreted_frame_valid(JavaThread *thread) const { | |
97 ShouldNotCallThis(); | |
98 } | |
99 | |
100 BasicType frame::interpreter_frame_result(oop* oop_result, | |
101 jvalue* value_result) { | |
102 assert(is_interpreted_frame(), "interpreted frame expected"); | |
103 methodOop method = interpreter_frame_method(); | |
104 BasicType type = method->result_type(); | |
105 intptr_t* tos_addr = (intptr_t *) interpreter_frame_tos_address(); | |
106 oop obj; | |
107 | |
108 switch (type) { | |
109 case T_VOID: | |
110 break; | |
111 case T_BOOLEAN: | |
112 value_result->z = *(jboolean *) tos_addr; | |
113 break; | |
114 case T_BYTE: | |
115 value_result->b = *(jbyte *) tos_addr; | |
116 break; | |
117 case T_CHAR: | |
118 value_result->c = *(jchar *) tos_addr; | |
119 break; | |
120 case T_SHORT: | |
121 value_result->s = *(jshort *) tos_addr; | |
122 break; | |
123 case T_INT: | |
124 value_result->i = *(jint *) tos_addr; | |
125 break; | |
126 case T_LONG: | |
127 value_result->j = *(jlong *) tos_addr; | |
128 break; | |
129 case T_FLOAT: | |
130 value_result->f = *(jfloat *) tos_addr; | |
131 break; | |
132 case T_DOUBLE: | |
133 value_result->d = *(jdouble *) tos_addr; | |
134 break; | |
135 | |
136 case T_OBJECT: | |
137 case T_ARRAY: | |
138 if (method->is_native()) { | |
139 obj = get_interpreterState()->oop_temp(); | |
140 } | |
141 else { | |
142 oop* obj_p = (oop *) tos_addr; | |
143 obj = (obj_p == NULL) ? (oop) NULL : *obj_p; | |
144 } | |
145 assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); | |
146 *oop_result = obj; | |
147 break; | |
148 | |
149 default: | |
150 ShouldNotReachHere(); | |
151 } | |
152 | |
153 return type; | |
154 } | |
155 | |
156 int frame::frame_size(RegisterMap* map) const { | |
157 #ifdef PRODUCT | |
158 ShouldNotCallThis(); | |
159 #else | |
160 return 0; // make javaVFrame::print_value work | |
161 #endif // PRODUCT | |
162 } | |
163 | |
164 intptr_t* frame::interpreter_frame_tos_at(jint offset) const { | |
165 int index = (Interpreter::expr_offset_in_bytes(offset) / wordSize); | |
166 return &interpreter_frame_tos_address()[index]; | |
167 } | |
168 | |
169 void frame::zero_print_on_error(int frame_index, | |
170 outputStream* st, | |
171 char* buf, | |
172 int buflen) const { | |
173 // Divide the buffer between the field and the value | |
174 buflen >>= 1; | |
175 char *fieldbuf = buf; | |
176 char *valuebuf = buf + buflen; | |
177 | |
178 // Print each word of the frame | |
1505 | 179 for (intptr_t *addr = sp(); addr <= fp(); addr++) { |
180 int offset = fp() - addr; | |
1010 | 181 |
182 // Fill in default values, then try and improve them | |
183 snprintf(fieldbuf, buflen, "word[%d]", offset); | |
184 snprintf(valuebuf, buflen, PTR_FORMAT, *addr); | |
185 zeroframe()->identify_word(frame_index, offset, fieldbuf, valuebuf, buflen); | |
186 fieldbuf[buflen - 1] = '\0'; | |
187 valuebuf[buflen - 1] = '\0'; | |
188 | |
189 // Print the result | |
190 st->print_cr(" " PTR_FORMAT ": %-21s = %s", addr, fieldbuf, valuebuf); | |
191 } | |
192 } | |
193 | |
194 void ZeroFrame::identify_word(int frame_index, | |
195 int offset, | |
196 char* fieldbuf, | |
197 char* valuebuf, | |
198 int buflen) const { | |
199 switch (offset) { | |
200 case next_frame_off: | |
201 strncpy(fieldbuf, "next_frame", buflen); | |
202 break; | |
203 | |
204 case frame_type_off: | |
205 strncpy(fieldbuf, "frame_type", buflen); | |
206 if (is_entry_frame()) | |
207 strncpy(valuebuf, "ENTRY_FRAME", buflen); | |
208 else if (is_interpreter_frame()) | |
209 strncpy(valuebuf, "INTERPRETER_FRAME", buflen); | |
210 else if (is_shark_frame()) | |
211 strncpy(valuebuf, "SHARK_FRAME", buflen); | |
212 else if (is_fake_stub_frame()) | |
213 strncpy(valuebuf, "FAKE_STUB_FRAME", buflen); | |
214 break; | |
215 | |
216 default: | |
217 if (is_entry_frame()) { | |
218 as_entry_frame()->identify_word( | |
219 frame_index, offset, fieldbuf, valuebuf, buflen); | |
220 } | |
221 else if (is_interpreter_frame()) { | |
222 as_interpreter_frame()->identify_word( | |
223 frame_index, offset, fieldbuf, valuebuf, buflen); | |
224 } | |
225 else if (is_shark_frame()) { | |
226 as_shark_frame()->identify_word( | |
227 frame_index, offset, fieldbuf, valuebuf, buflen); | |
228 } | |
229 else if (is_fake_stub_frame()) { | |
230 as_fake_stub_frame()->identify_word( | |
231 frame_index, offset, fieldbuf, valuebuf, buflen); | |
232 } | |
233 } | |
234 } | |
235 | |
236 void EntryFrame::identify_word(int frame_index, | |
237 int offset, | |
238 char* fieldbuf, | |
239 char* valuebuf, | |
240 int buflen) const { | |
241 switch (offset) { | |
242 case call_wrapper_off: | |
243 strncpy(fieldbuf, "call_wrapper", buflen); | |
244 break; | |
245 | |
246 default: | |
247 snprintf(fieldbuf, buflen, "local[%d]", offset - 3); | |
248 } | |
249 } | |
250 | |
251 void InterpreterFrame::identify_word(int frame_index, | |
252 int offset, | |
253 char* fieldbuf, | |
254 char* valuebuf, | |
255 int buflen) const { | |
256 interpreterState istate = interpreter_state(); | |
257 bool is_valid = istate->self_link() == istate; | |
258 intptr_t *addr = addr_of_word(offset); | |
259 | |
260 // Fixed part | |
261 if (addr >= (intptr_t *) istate) { | |
262 const char *field = istate->name_of_field_at_address((address) addr); | |
263 if (field) { | |
264 if (is_valid && !strcmp(field, "_method")) { | |
265 istate->method()->name_and_sig_as_C_string(valuebuf, buflen); | |
266 } | |
267 else if (is_valid && !strcmp(field, "_bcp") && istate->bcp()) { | |
268 snprintf(valuebuf, buflen, PTR_FORMAT " (bci %d)", | |
269 (intptr_t) istate->bcp(), | |
270 istate->method()->bci_from(istate->bcp())); | |
271 } | |
272 snprintf(fieldbuf, buflen, "%sistate->%s", | |
273 field[strlen(field) - 1] == ')' ? "(": "", field); | |
274 } | |
275 else if (addr == (intptr_t *) istate) { | |
276 strncpy(fieldbuf, "(vtable for istate)", buflen); | |
277 } | |
278 return; | |
279 } | |
280 | |
281 // Variable part | |
282 if (!is_valid) | |
283 return; | |
284 | |
285 // JNI stuff | |
286 if (istate->method()->is_native() && addr < istate->stack_base()) { | |
287 address hA = istate->method()->signature_handler(); | |
288 if (hA != NULL) { | |
289 if (hA != (address) InterpreterRuntime::slow_signature_handler) { | |
290 InterpreterRuntime::SignatureHandler *handler = | |
291 InterpreterRuntime::SignatureHandler::from_handlerAddr(hA); | |
292 | |
293 intptr_t *params = istate->stack_base() - handler->argument_count(); | |
294 if (addr >= params) { | |
295 int param = addr - params; | |
296 const char *desc = ""; | |
297 if (param == 0) | |
298 desc = " (JNIEnv)"; | |
299 else if (param == 1) { | |
300 if (istate->method()->is_static()) | |
301 desc = " (mirror)"; | |
302 else | |
303 desc = " (this)"; | |
304 } | |
305 snprintf(fieldbuf, buflen, "parameter[%d]%s", param, desc); | |
306 return; | |
307 } | |
308 | |
309 for (int i = 0; i < handler->argument_count(); i++) { | |
310 if (params[i] == (intptr_t) addr) { | |
311 snprintf(fieldbuf, buflen, "unboxed parameter[%d]", i); | |
312 return; | |
313 } | |
314 } | |
315 } | |
316 } | |
317 return; | |
318 } | |
319 | |
320 // Monitors and stack | |
321 identify_vp_word(frame_index, addr, | |
322 (intptr_t *) istate->monitor_base(), | |
323 istate->stack_base(), | |
324 fieldbuf, buflen); | |
325 } | |
326 | |
327 void SharkFrame::identify_word(int frame_index, | |
328 int offset, | |
329 char* fieldbuf, | |
330 char* valuebuf, | |
331 int buflen) const { | |
332 // Fixed part | |
333 switch (offset) { | |
334 case pc_off: | |
335 strncpy(fieldbuf, "pc", buflen); | |
336 if (method()->is_oop()) { | |
337 nmethod *code = method()->code(); | |
338 if (code && code->pc_desc_at(pc())) { | |
339 SimpleScopeDesc ssd(code, pc()); | |
340 snprintf(valuebuf, buflen, PTR_FORMAT " (bci %d)", | |
341 (intptr_t) pc(), ssd.bci()); | |
342 } | |
343 } | |
344 return; | |
345 | |
346 case unextended_sp_off: | |
347 strncpy(fieldbuf, "unextended_sp", buflen); | |
348 return; | |
349 | |
350 case method_off: | |
351 strncpy(fieldbuf, "method", buflen); | |
352 if (method()->is_oop()) { | |
353 method()->name_and_sig_as_C_string(valuebuf, buflen); | |
354 } | |
355 return; | |
356 | |
357 case oop_tmp_off: | |
358 strncpy(fieldbuf, "oop_tmp", buflen); | |
359 return; | |
360 } | |
361 | |
362 // Variable part | |
363 if (method()->is_oop()) { | |
364 identify_vp_word(frame_index, addr_of_word(offset), | |
365 addr_of_word(header_words + 1), | |
366 unextended_sp() + method()->max_stack(), | |
367 fieldbuf, buflen); | |
368 } | |
369 } | |
370 | |
371 void ZeroFrame::identify_vp_word(int frame_index, | |
372 intptr_t* addr, | |
373 intptr_t* monitor_base, | |
374 intptr_t* stack_base, | |
375 char* fieldbuf, | |
376 int buflen) const { | |
377 // Monitors | |
378 if (addr >= stack_base && addr < monitor_base) { | |
379 int monitor_size = frame::interpreter_frame_monitor_size(); | |
380 int last_index = (monitor_base - stack_base) / monitor_size - 1; | |
381 int index = last_index - (addr - stack_base) / monitor_size; | |
382 intptr_t monitor = (intptr_t) ( | |
383 (BasicObjectLock *) monitor_base - 1 - index); | |
384 intptr_t offset = (intptr_t) addr - monitor; | |
385 | |
386 if (offset == BasicObjectLock::obj_offset_in_bytes()) | |
387 snprintf(fieldbuf, buflen, "monitor[%d]->_obj", index); | |
388 else if (offset == BasicObjectLock::lock_offset_in_bytes()) | |
389 snprintf(fieldbuf, buflen, "monitor[%d]->_lock", index); | |
390 | |
391 return; | |
392 } | |
393 | |
394 // Expression stack | |
395 if (addr < stack_base) { | |
396 snprintf(fieldbuf, buflen, "%s[%d]", | |
397 frame_index == 0 ? "stack_word" : "local", | |
398 (int) (stack_base - addr - 1)); | |
399 return; | |
400 } | |
401 } |