Mercurial > hg > truffle
annotate src/share/vm/runtime/vframeArray.cpp @ 1936:8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Thu, 23 Dec 2010 18:13:28 +0100 |
parents | fd5d4527cdf5 |
children | 06f017f7daa7 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
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:
1506
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
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:
1506
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_vframeArray.cpp.incl" | |
27 | |
28 | |
29 int vframeArrayElement:: bci(void) const { return (_bci == SynchronizationEntryBCI ? 0 : _bci); } | |
30 | |
31 void vframeArrayElement::free_monitors(JavaThread* jt) { | |
32 if (_monitors != NULL) { | |
33 MonitorChunk* chunk = _monitors; | |
34 _monitors = NULL; | |
35 jt->remove_monitor_chunk(chunk); | |
36 delete chunk; | |
37 } | |
38 } | |
39 | |
40 void vframeArrayElement::fill_in(compiledVFrame* vf) { | |
41 | |
42 // Copy the information from the compiled vframe to the | |
43 // interpreter frame we will be creating to replace vf | |
44 | |
45 _method = vf->method(); | |
46 _bci = vf->raw_bci(); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
47 _reexecute = vf->should_reexecute(); |
0 | 48 |
49 int index; | |
50 | |
51 // Get the monitors off-stack | |
52 | |
53 GrowableArray<MonitorInfo*>* list = vf->monitors(); | |
54 if (list->is_empty()) { | |
55 _monitors = NULL; | |
56 } else { | |
57 | |
58 // Allocate monitor chunk | |
59 _monitors = new MonitorChunk(list->length()); | |
60 vf->thread()->add_monitor_chunk(_monitors); | |
61 | |
62 // Migrate the BasicLocks from the stack to the monitor chunk | |
63 for (index = 0; index < list->length(); index++) { | |
64 MonitorInfo* monitor = list->at(index); | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
65 assert(!monitor->owner_is_scalar_replaced(), "object should be reallocated already"); |
0 | 66 assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased"); |
67 BasicObjectLock* dest = _monitors->at(index); | |
68 dest->set_obj(monitor->owner()); | |
69 monitor->lock()->move_to(monitor->owner(), dest->lock()); | |
70 } | |
71 } | |
72 | |
73 // Convert the vframe locals and expressions to off stack | |
74 // values. Because we will not gc all oops can be converted to | |
75 // intptr_t (i.e. a stack slot) and we are fine. This is | |
76 // good since we are inside a HandleMark and the oops in our | |
77 // collection would go away between packing them here and | |
78 // unpacking them in unpack_on_stack. | |
79 | |
80 // First the locals go off-stack | |
81 | |
82 // FIXME this seems silly it creates a StackValueCollection | |
83 // in order to get the size to then copy them and | |
84 // convert the types to intptr_t size slots. Seems like it | |
85 // could do it in place... Still uses less memory than the | |
86 // old way though | |
87 | |
88 StackValueCollection *locs = vf->locals(); | |
89 _locals = new StackValueCollection(locs->size()); | |
90 for(index = 0; index < locs->size(); index++) { | |
91 StackValue* value = locs->at(index); | |
92 switch(value->type()) { | |
93 case T_OBJECT: | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
94 assert(!value->obj_is_scalar_replaced(), "object should be reallocated already"); |
0 | 95 // preserve object type |
96 _locals->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT )); | |
97 break; | |
98 case T_CONFLICT: | |
99 // A dead local. Will be initialized to null/zero. | |
100 _locals->add( new StackValue()); | |
101 break; | |
102 case T_INT: | |
103 _locals->add( new StackValue(value->get_int())); | |
104 break; | |
105 default: | |
106 ShouldNotReachHere(); | |
107 } | |
108 } | |
109 | |
110 // Now the expressions off-stack | |
111 // Same silliness as above | |
112 | |
113 StackValueCollection *exprs = vf->expressions(); | |
114 _expressions = new StackValueCollection(exprs->size()); | |
115 for(index = 0; index < exprs->size(); index++) { | |
116 StackValue* value = exprs->at(index); | |
117 switch(value->type()) { | |
118 case T_OBJECT: | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
119 assert(!value->obj_is_scalar_replaced(), "object should be reallocated already"); |
0 | 120 // preserve object type |
121 _expressions->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT )); | |
122 break; | |
123 case T_CONFLICT: | |
124 // A dead stack element. Will be initialized to null/zero. | |
125 // This can occur when the compiler emits a state in which stack | |
126 // elements are known to be dead (because of an imminent exception). | |
127 _expressions->add( new StackValue()); | |
128 break; | |
129 case T_INT: | |
130 _expressions->add( new StackValue(value->get_int())); | |
131 break; | |
132 default: | |
133 ShouldNotReachHere(); | |
134 } | |
135 } | |
136 } | |
137 | |
138 int unpack_counter = 0; | |
139 | |
140 void vframeArrayElement::unpack_on_stack(int callee_parameters, | |
141 int callee_locals, | |
142 frame* caller, | |
143 bool is_top_frame, | |
144 int exec_mode) { | |
145 JavaThread* thread = (JavaThread*) Thread::current(); | |
146 | |
147 // Look at bci and decide on bcp and continuation pc | |
148 address bcp; | |
149 // C++ interpreter doesn't need a pc since it will figure out what to do when it | |
150 // begins execution | |
151 address pc; | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
152 bool use_next_mdp = false; // true if we should use the mdp associated with the next bci |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
153 // rather than the one associated with bcp |
0 | 154 if (raw_bci() == SynchronizationEntryBCI) { |
155 // We are deoptimizing while hanging in prologue code for synchronized method | |
156 bcp = method()->bcp_from(0); // first byte code | |
157 pc = Interpreter::deopt_entry(vtos, 0); // step = 0 since we don't skip current bytecode | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
158 } else if (should_reexecute()) { //reexecute this bytecode |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
159 assert(is_top_frame, "reexecute allowed only for the top frame"); |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
160 bcp = method()->bcp_from(bci()); |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
161 pc = Interpreter::deopt_reexecute_entry(method(), bcp); |
0 | 162 } else { |
163 bcp = method()->bcp_from(bci()); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
164 pc = Interpreter::deopt_continue_after_entry(method(), bcp, callee_parameters, is_top_frame); |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
165 use_next_mdp = true; |
0 | 166 } |
167 assert(Bytecodes::is_defined(*bcp), "must be a valid bytecode"); | |
168 | |
169 // Monitorenter and pending exceptions: | |
170 // | |
171 // For Compiler2, there should be no pending exception when deoptimizing at monitorenter | |
172 // because there is no safepoint at the null pointer check (it is either handled explicitly | |
173 // or prior to the monitorenter) and asynchronous exceptions are not made "pending" by the | |
174 // runtime interface for the slow case (see JRT_ENTRY_FOR_MONITORENTER). If an asynchronous | |
175 // exception was processed, the bytecode pointer would have to be extended one bytecode beyond | |
176 // the monitorenter to place it in the proper exception range. | |
177 // | |
178 // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter, | |
179 // in which case bcp should point to the monitorenter since it is within the exception's range. | |
180 | |
181 assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame"); | |
1814
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1603
diff
changeset
|
182 assert(thread->deopt_nmethod() != NULL, "nmethod should be known"); |
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1603
diff
changeset
|
183 guarantee(!(thread->deopt_nmethod()->is_compiled_by_c2() && |
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1603
diff
changeset
|
184 *bcp == Bytecodes::_monitorenter && |
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1603
diff
changeset
|
185 exec_mode == Deoptimization::Unpack_exception), |
fd5d4527cdf5
6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents:
1603
diff
changeset
|
186 "shouldn't get exception during monitorenter"); |
0 | 187 |
188 int popframe_preserved_args_size_in_bytes = 0; | |
189 int popframe_preserved_args_size_in_words = 0; | |
190 if (is_top_frame) { | |
1255
e3a4305c6bc3
6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents:
903
diff
changeset
|
191 JvmtiThreadState *state = thread->jvmti_thread_state(); |
0 | 192 if (JvmtiExport::can_pop_frame() && |
193 (thread->has_pending_popframe() || thread->popframe_forcing_deopt_reexecution())) { | |
194 if (thread->has_pending_popframe()) { | |
195 // Pop top frame after deoptimization | |
196 #ifndef CC_INTERP | |
197 pc = Interpreter::remove_activation_preserving_args_entry(); | |
198 #else | |
199 // Do an uncommon trap type entry. c++ interpreter will know | |
200 // to pop frame and preserve the args | |
201 pc = Interpreter::deopt_entry(vtos, 0); | |
202 use_next_mdp = false; | |
203 #endif | |
204 } else { | |
205 // Reexecute invoke in top frame | |
206 pc = Interpreter::deopt_entry(vtos, 0); | |
207 use_next_mdp = false; | |
208 popframe_preserved_args_size_in_bytes = in_bytes(thread->popframe_preserved_args_size()); | |
209 // Note: the PopFrame-related extension of the expression stack size is done in | |
210 // Deoptimization::fetch_unroll_info_helper | |
211 popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words()); | |
212 } | |
213 } else if (JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { | |
214 // Force early return from top frame after deoptimization | |
215 #ifndef CC_INTERP | |
216 pc = Interpreter::remove_activation_early_entry(state->earlyret_tos()); | |
217 #else | |
218 // TBD: Need to implement ForceEarlyReturn for CC_INTERP (ia64) | |
219 #endif | |
220 } else { | |
221 // Possibly override the previous pc computation of the top (youngest) frame | |
222 switch (exec_mode) { | |
223 case Deoptimization::Unpack_deopt: | |
224 // use what we've got | |
225 break; | |
226 case Deoptimization::Unpack_exception: | |
227 // exception is pending | |
1295 | 228 pc = SharedRuntime::raw_exception_handler_for_return_address(thread, pc); |
0 | 229 // [phh] We're going to end up in some handler or other, so it doesn't |
230 // matter what mdp we point to. See exception_handler_for_exception() | |
231 // in interpreterRuntime.cpp. | |
232 break; | |
233 case Deoptimization::Unpack_uncommon_trap: | |
234 case Deoptimization::Unpack_reexecute: | |
235 // redo last byte code | |
236 pc = Interpreter::deopt_entry(vtos, 0); | |
237 use_next_mdp = false; | |
238 break; | |
239 default: | |
240 ShouldNotReachHere(); | |
241 } | |
242 } | |
243 } | |
244 | |
245 // Setup the interpreter frame | |
246 | |
247 assert(method() != NULL, "method must exist"); | |
248 int temps = expressions()->size(); | |
249 | |
250 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors(); | |
251 | |
252 Interpreter::layout_activation(method(), | |
253 temps + callee_parameters, | |
254 popframe_preserved_args_size_in_words, | |
255 locks, | |
256 callee_parameters, | |
257 callee_locals, | |
258 caller, | |
259 iframe(), | |
260 is_top_frame); | |
261 | |
262 // Update the pc in the frame object and overwrite the temporary pc | |
263 // we placed in the skeletal frame now that we finally know the | |
264 // exact interpreter address we should use. | |
265 | |
266 _frame.patch_pc(thread, pc); | |
267 | |
268 assert (!method()->is_synchronized() || locks > 0, "synchronized methods must have monitors"); | |
269 | |
270 BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin(); | |
271 for (int index = 0; index < locks; index++) { | |
272 top = iframe()->previous_monitor_in_interpreter_frame(top); | |
273 BasicObjectLock* src = _monitors->at(index); | |
274 top->set_obj(src->obj()); | |
275 src->lock()->move_to(src->obj(), top->lock()); | |
276 } | |
277 if (ProfileInterpreter) { | |
278 iframe()->interpreter_frame_set_mdx(0); // clear out the mdp. | |
279 } | |
280 iframe()->interpreter_frame_set_bcx((intptr_t)bcp); // cannot use bcp because frame is not initialized yet | |
281 if (ProfileInterpreter) { | |
282 methodDataOop mdo = method()->method_data(); | |
283 if (mdo != NULL) { | |
284 int bci = iframe()->interpreter_frame_bci(); | |
285 if (use_next_mdp) ++bci; | |
286 address mdp = mdo->bci_to_dp(bci); | |
287 iframe()->interpreter_frame_set_mdp(mdp); | |
288 } | |
289 } | |
290 | |
291 // Unpack expression stack | |
292 // If this is an intermediate frame (i.e. not top frame) then this | |
293 // only unpacks the part of the expression stack not used by callee | |
294 // as parameters. The callee parameters are unpacked as part of the | |
295 // callee locals. | |
296 int i; | |
297 for(i = 0; i < expressions()->size(); i++) { | |
298 StackValue *value = expressions()->at(i); | |
299 intptr_t* addr = iframe()->interpreter_frame_expression_stack_at(i); | |
300 switch(value->type()) { | |
301 case T_INT: | |
302 *addr = value->get_int(); | |
1936
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
303 #ifndef PRODUCT |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
304 if (TraceDeoptimization) { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
305 tty->print_cr("Reconstructed expression %d (INT): %d", i, (int)(*addr)); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
306 } |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
307 #endif |
0 | 308 break; |
309 case T_OBJECT: | |
310 *addr = value->get_int(T_OBJECT); | |
1936
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
311 #ifndef PRODUCT |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
312 if (TraceDeoptimization) { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
313 tty->print("Reconstructed expression %d (OBJECT): ", i); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
314 oop o = (oop)(*addr); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
315 if (o == NULL) { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
316 tty->print_cr("NULL"); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
317 } else { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
318 tty->print_cr(err_msg("%s", o->blueprint()->name()->as_C_string())); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
319 } |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
320 } |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
321 #endif |
0 | 322 break; |
323 case T_CONFLICT: | |
324 // A dead stack slot. Initialize to null in case it is an oop. | |
325 *addr = NULL_WORD; | |
326 break; | |
327 default: | |
328 ShouldNotReachHere(); | |
329 } | |
330 } | |
331 | |
332 | |
333 // Unpack the locals | |
334 for(i = 0; i < locals()->size(); i++) { | |
335 StackValue *value = locals()->at(i); | |
336 intptr_t* addr = iframe()->interpreter_frame_local_at(i); | |
337 switch(value->type()) { | |
338 case T_INT: | |
339 *addr = value->get_int(); | |
1936
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
340 #ifndef PRODUCT |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
341 if (TraceDeoptimization) { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
342 tty->print_cr("Reconstructed local %d (INT): %d", i, (int)(*addr)); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
343 } |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
344 #endif |
0 | 345 break; |
346 case T_OBJECT: | |
347 *addr = value->get_int(T_OBJECT); | |
1936
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
348 #ifndef PRODUCT |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
349 if (TraceDeoptimization) { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
350 tty->print("Reconstructed local %d (OBJECT): ", i); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
351 oop o = (oop)(*addr); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
352 if (o == NULL) { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
353 tty->print_cr("NULL"); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
354 } else { |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
355 tty->print_cr(err_msg("%s", o->blueprint()->name()->as_C_string())); |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
356 } |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
357 } |
8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1814
diff
changeset
|
358 #endif |
0 | 359 break; |
360 case T_CONFLICT: | |
361 // A dead location. If it is an oop then we need a NULL to prevent GC from following it | |
362 *addr = NULL_WORD; | |
363 break; | |
364 default: | |
365 ShouldNotReachHere(); | |
366 } | |
367 } | |
368 | |
369 if (is_top_frame && JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) { | |
370 // An interpreted frame was popped but it returns to a deoptimized | |
371 // frame. The incoming arguments to the interpreted activation | |
372 // were preserved in thread-local storage by the | |
373 // remove_activation_preserving_args_entry in the interpreter; now | |
374 // we put them back into the just-unpacked interpreter frame. | |
375 // Note that this assumes that the locals arena grows toward lower | |
376 // addresses. | |
377 if (popframe_preserved_args_size_in_words != 0) { | |
378 void* saved_args = thread->popframe_preserved_args(); | |
379 assert(saved_args != NULL, "must have been saved by interpreter"); | |
380 #ifdef ASSERT | |
381 assert(popframe_preserved_args_size_in_words <= | |
1506 | 382 iframe()->interpreter_frame_expression_stack_size()*Interpreter::stackElementWords, |
0 | 383 "expression stack size should have been extended"); |
384 #endif // ASSERT | |
385 int top_element = iframe()->interpreter_frame_expression_stack_size()-1; | |
386 intptr_t* base; | |
387 if (frame::interpreter_frame_expression_stack_direction() < 0) { | |
388 base = iframe()->interpreter_frame_expression_stack_at(top_element); | |
389 } else { | |
390 base = iframe()->interpreter_frame_expression_stack(); | |
391 } | |
1603
d93949c5bdcc
6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents:
1552
diff
changeset
|
392 Copy::conjoint_jbytes(saved_args, |
d93949c5bdcc
6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents:
1552
diff
changeset
|
393 base, |
d93949c5bdcc
6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents:
1552
diff
changeset
|
394 popframe_preserved_args_size_in_bytes); |
0 | 395 thread->popframe_free_preserved_args(); |
396 } | |
397 } | |
398 | |
399 #ifndef PRODUCT | |
400 if (TraceDeoptimization && Verbose) { | |
401 ttyLocker ttyl; | |
402 tty->print_cr("[%d Interpreted Frame]", ++unpack_counter); | |
403 iframe()->print_on(tty); | |
404 RegisterMap map(thread); | |
405 vframe* f = vframe::new_vframe(iframe(), &map, thread); | |
406 f->print(); | |
407 | |
408 tty->print_cr("locals size %d", locals()->size()); | |
409 tty->print_cr("expression size %d", expressions()->size()); | |
410 | |
411 method()->print_value(); | |
412 tty->cr(); | |
413 // method()->print_codes(); | |
414 } else if (TraceDeoptimization) { | |
415 tty->print(" "); | |
416 method()->print_value(); | |
417 Bytecodes::Code code = Bytecodes::java_code_at(bcp); | |
418 int bci = method()->bci_from(bcp); | |
419 tty->print(" - %s", Bytecodes::name(code)); | |
420 tty->print(" @ bci %d ", bci); | |
421 tty->print_cr("sp = " PTR_FORMAT, iframe()->sp()); | |
422 } | |
423 #endif // PRODUCT | |
424 | |
425 // The expression stack and locals are in the resource area don't leave | |
426 // a dangling pointer in the vframeArray we leave around for debug | |
427 // purposes | |
428 | |
429 _locals = _expressions = NULL; | |
430 | |
431 } | |
432 | |
433 int vframeArrayElement::on_stack_size(int callee_parameters, | |
434 int callee_locals, | |
435 bool is_top_frame, | |
436 int popframe_extra_stack_expression_els) const { | |
437 assert(method()->max_locals() == locals()->size(), "just checking"); | |
438 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors(); | |
439 int temps = expressions()->size(); | |
440 return Interpreter::size_activation(method(), | |
441 temps + callee_parameters, | |
442 popframe_extra_stack_expression_els, | |
443 locks, | |
444 callee_parameters, | |
445 callee_locals, | |
446 is_top_frame); | |
447 } | |
448 | |
449 | |
450 | |
451 vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, | |
452 RegisterMap *reg_map, frame sender, frame caller, frame self) { | |
453 | |
454 // Allocate the vframeArray | |
455 vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part | |
456 sizeof(vframeArrayElement) * (chunk->length() - 1), // variable part | |
457 "vframeArray::allocate"); | |
458 result->_frames = chunk->length(); | |
459 result->_owner_thread = thread; | |
460 result->_sender = sender; | |
461 result->_caller = caller; | |
462 result->_original = self; | |
463 result->set_unroll_block(NULL); // initialize it | |
464 result->fill_in(thread, frame_size, chunk, reg_map); | |
465 return result; | |
466 } | |
467 | |
468 void vframeArray::fill_in(JavaThread* thread, | |
469 int frame_size, | |
470 GrowableArray<compiledVFrame*>* chunk, | |
471 const RegisterMap *reg_map) { | |
472 // Set owner first, it is used when adding monitor chunks | |
473 | |
474 _frame_size = frame_size; | |
475 for(int i = 0; i < chunk->length(); i++) { | |
476 element(i)->fill_in(chunk->at(i)); | |
477 } | |
478 | |
479 // Copy registers for callee-saved registers | |
480 if (reg_map != NULL) { | |
481 for(int i = 0; i < RegisterMap::reg_count; i++) { | |
482 #ifdef AMD64 | |
483 // The register map has one entry for every int (32-bit value), so | |
484 // 64-bit physical registers have two entries in the map, one for | |
485 // each half. Ignore the high halves of 64-bit registers, just like | |
486 // frame::oopmapreg_to_location does. | |
487 // | |
488 // [phh] FIXME: this is a temporary hack! This code *should* work | |
489 // correctly w/o this hack, possibly by changing RegisterMap::pd_location | |
490 // in frame_amd64.cpp and the values of the phantom high half registers | |
491 // in amd64.ad. | |
492 // if (VMReg::Name(i) < SharedInfo::stack0 && is_even(i)) { | |
493 intptr_t* src = (intptr_t*) reg_map->location(VMRegImpl::as_VMReg(i)); | |
494 _callee_registers[i] = src != NULL ? *src : NULL_WORD; | |
495 // } else { | |
496 // jint* src = (jint*) reg_map->location(VMReg::Name(i)); | |
497 // _callee_registers[i] = src != NULL ? *src : NULL_WORD; | |
498 // } | |
499 #else | |
500 jint* src = (jint*) reg_map->location(VMRegImpl::as_VMReg(i)); | |
501 _callee_registers[i] = src != NULL ? *src : NULL_WORD; | |
502 #endif | |
503 if (src == NULL) { | |
504 set_location_valid(i, false); | |
505 } else { | |
506 set_location_valid(i, true); | |
507 jint* dst = (jint*) register_location(i); | |
508 *dst = *src; | |
509 } | |
510 } | |
511 } | |
512 } | |
513 | |
514 void vframeArray::unpack_to_stack(frame &unpack_frame, int exec_mode) { | |
515 // stack picture | |
516 // unpack_frame | |
517 // [new interpreter frames ] (frames are skeletal but walkable) | |
518 // caller_frame | |
519 // | |
520 // This routine fills in the missing data for the skeletal interpreter frames | |
521 // in the above picture. | |
522 | |
523 // Find the skeletal interpreter frames to unpack into | |
524 RegisterMap map(JavaThread::current(), false); | |
525 // Get the youngest frame we will unpack (last to be unpacked) | |
526 frame me = unpack_frame.sender(&map); | |
527 int index; | |
528 for (index = 0; index < frames(); index++ ) { | |
529 *element(index)->iframe() = me; | |
530 // Get the caller frame (possibly skeletal) | |
531 me = me.sender(&map); | |
532 } | |
533 | |
534 frame caller_frame = me; | |
535 | |
536 // Do the unpacking of interpreter frames; the frame at index 0 represents the top activation, so it has no callee | |
537 | |
538 // Unpack the frames from the oldest (frames() -1) to the youngest (0) | |
539 | |
540 for (index = frames() - 1; index >= 0 ; index--) { | |
541 int callee_parameters = index == 0 ? 0 : element(index-1)->method()->size_of_parameters(); | |
542 int callee_locals = index == 0 ? 0 : element(index-1)->method()->max_locals(); | |
543 element(index)->unpack_on_stack(callee_parameters, | |
544 callee_locals, | |
545 &caller_frame, | |
546 index == 0, | |
547 exec_mode); | |
548 if (index == frames() - 1) { | |
549 Deoptimization::unwind_callee_save_values(element(index)->iframe(), this); | |
550 } | |
551 caller_frame = *element(index)->iframe(); | |
552 } | |
553 | |
554 | |
555 deallocate_monitor_chunks(); | |
556 } | |
557 | |
558 void vframeArray::deallocate_monitor_chunks() { | |
559 JavaThread* jt = JavaThread::current(); | |
560 for (int index = 0; index < frames(); index++ ) { | |
561 element(index)->free_monitors(jt); | |
562 } | |
563 } | |
564 | |
565 #ifndef PRODUCT | |
566 | |
567 bool vframeArray::structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk) { | |
568 if (owner_thread() != thread) return false; | |
569 int index = 0; | |
570 #if 0 // FIXME can't do this comparison | |
571 | |
572 // Compare only within vframe array. | |
573 for (deoptimizedVFrame* vf = deoptimizedVFrame::cast(vframe_at(first_index())); vf; vf = vf->deoptimized_sender_or_null()) { | |
574 if (index >= chunk->length() || !vf->structural_compare(chunk->at(index))) return false; | |
575 index++; | |
576 } | |
577 if (index != chunk->length()) return false; | |
578 #endif | |
579 | |
580 return true; | |
581 } | |
582 | |
583 #endif | |
584 | |
585 address vframeArray::register_location(int i) const { | |
586 assert(0 <= i && i < RegisterMap::reg_count, "index out of bounds"); | |
587 return (address) & _callee_registers[i]; | |
588 } | |
589 | |
590 | |
591 #ifndef PRODUCT | |
592 | |
593 // Printing | |
594 | |
595 // Note: we cannot have print_on as const, as we allocate inside the method | |
596 void vframeArray::print_on_2(outputStream* st) { | |
597 st->print_cr(" - sp: " INTPTR_FORMAT, sp()); | |
598 st->print(" - thread: "); | |
599 Thread::current()->print(); | |
600 st->print_cr(" - frame size: %d", frame_size()); | |
601 for (int index = 0; index < frames() ; index++ ) { | |
602 element(index)->print(st); | |
603 } | |
604 } | |
605 | |
606 void vframeArrayElement::print(outputStream* st) { | |
1255
e3a4305c6bc3
6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents:
903
diff
changeset
|
607 st->print_cr(" - interpreter_frame -> sp: " INTPTR_FORMAT, iframe()->sp()); |
0 | 608 } |
609 | |
610 void vframeArray::print_value_on(outputStream* st) const { | |
611 st->print_cr("vframeArray [%d] ", frames()); | |
612 } | |
613 | |
614 | |
615 #endif |