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