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