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