author | valeriep |
Mon, 15 Nov 2010 14:32:49 -0800 | |
changeset 7268 | 4e3088f05c63 |
parent 5547 | f4b087cbb361 |
child 7397 | 5b173b4ca846 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2534
diff
changeset
|
2 |
* Copyright (c) 2007, 2009, 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:
2534
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2534
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:
2534
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
#include "incls/_precompiled.incl" |
|
26 |
#include "incls/_cppInterpreter_x86.cpp.incl" |
|
27 |
||
28 |
#ifdef CC_INTERP |
|
29 |
||
30 |
// Routine exists to make tracebacks look decent in debugger |
|
31 |
// while we are recursed in the frame manager/c++ interpreter. |
|
32 |
// We could use an address in the frame manager but having |
|
33 |
// frames look natural in the debugger is a plus. |
|
34 |
extern "C" void RecursiveInterpreterActivation(interpreterState istate ) |
|
35 |
{ |
|
36 |
// |
|
37 |
ShouldNotReachHere(); |
|
38 |
} |
|
39 |
||
40 |
||
41 |
#define __ _masm-> |
|
42 |
#define STATE(field_name) (Address(state, byte_offset_of(BytecodeInterpreter, field_name))) |
|
43 |
||
44 |
Label fast_accessor_slow_entry_path; // fast accessor methods need to be able to jmp to unsynchronized |
|
45 |
// c++ interpreter entry point this holds that entry point label. |
|
46 |
||
1066 | 47 |
// default registers for state and sender_sp |
48 |
// state and sender_sp are the same on 32bit because we have no choice. |
|
49 |
// state could be rsi on 64bit but it is an arg reg and not callee save |
|
50 |
// so r13 is better choice. |
|
51 |
||
52 |
const Register state = NOT_LP64(rsi) LP64_ONLY(r13); |
|
53 |
const Register sender_sp_on_entry = NOT_LP64(rsi) LP64_ONLY(r13); |
|
54 |
||
1 | 55 |
// NEEDED for JVMTI? |
56 |
// address AbstractInterpreter::_remove_activation_preserving_args_entry; |
|
57 |
||
58 |
static address unctrap_frame_manager_entry = NULL; |
|
59 |
||
60 |
static address deopt_frame_manager_return_atos = NULL; |
|
61 |
static address deopt_frame_manager_return_btos = NULL; |
|
62 |
static address deopt_frame_manager_return_itos = NULL; |
|
63 |
static address deopt_frame_manager_return_ltos = NULL; |
|
64 |
static address deopt_frame_manager_return_ftos = NULL; |
|
65 |
static address deopt_frame_manager_return_dtos = NULL; |
|
66 |
static address deopt_frame_manager_return_vtos = NULL; |
|
67 |
||
68 |
int AbstractInterpreter::BasicType_as_index(BasicType type) { |
|
69 |
int i = 0; |
|
70 |
switch (type) { |
|
71 |
case T_BOOLEAN: i = 0; break; |
|
72 |
case T_CHAR : i = 1; break; |
|
73 |
case T_BYTE : i = 2; break; |
|
74 |
case T_SHORT : i = 3; break; |
|
75 |
case T_INT : i = 4; break; |
|
76 |
case T_VOID : i = 5; break; |
|
77 |
case T_FLOAT : i = 8; break; |
|
78 |
case T_LONG : i = 9; break; |
|
79 |
case T_DOUBLE : i = 6; break; |
|
80 |
case T_OBJECT : // fall through |
|
81 |
case T_ARRAY : i = 7; break; |
|
82 |
default : ShouldNotReachHere(); |
|
83 |
} |
|
84 |
assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds"); |
|
85 |
return i; |
|
86 |
} |
|
87 |
||
88 |
// Is this pc anywhere within code owned by the interpreter? |
|
89 |
// This only works for pc that might possibly be exposed to frame |
|
90 |
// walkers. It clearly misses all of the actual c++ interpreter |
|
91 |
// implementation |
|
92 |
bool CppInterpreter::contains(address pc) { |
|
93 |
return (_code->contains(pc) || |
|
94 |
pc == CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation)); |
|
95 |
} |
|
96 |
||
97 |
||
98 |
address CppInterpreterGenerator::generate_result_handler_for(BasicType type) { |
|
99 |
address entry = __ pc(); |
|
100 |
switch (type) { |
|
101 |
case T_BOOLEAN: __ c2bool(rax); break; |
|
102 |
case T_CHAR : __ andl(rax, 0xFFFF); break; |
|
103 |
case T_BYTE : __ sign_extend_byte (rax); break; |
|
104 |
case T_SHORT : __ sign_extend_short(rax); break; |
|
105 |
case T_VOID : // fall thru |
|
106 |
case T_LONG : // fall thru |
|
107 |
case T_INT : /* nothing to do */ break; |
|
1066 | 108 |
|
1 | 109 |
case T_DOUBLE : |
110 |
case T_FLOAT : |
|
1066 | 111 |
{ |
112 |
const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); |
|
113 |
__ pop(t); // remove return address first |
|
1 | 114 |
// Must return a result for interpreter or compiler. In SSE |
115 |
// mode, results are returned in xmm0 and the FPU stack must |
|
116 |
// be empty. |
|
117 |
if (type == T_FLOAT && UseSSE >= 1) { |
|
1066 | 118 |
#ifndef _LP64 |
1 | 119 |
// Load ST0 |
120 |
__ fld_d(Address(rsp, 0)); |
|
121 |
// Store as float and empty fpu stack |
|
122 |
__ fstp_s(Address(rsp, 0)); |
|
1066 | 123 |
#endif // !_LP64 |
1 | 124 |
// and reload |
125 |
__ movflt(xmm0, Address(rsp, 0)); |
|
126 |
} else if (type == T_DOUBLE && UseSSE >= 2 ) { |
|
127 |
__ movdbl(xmm0, Address(rsp, 0)); |
|
128 |
} else { |
|
129 |
// restore ST0 |
|
130 |
__ fld_d(Address(rsp, 0)); |
|
131 |
} |
|
132 |
// and pop the temp |
|
1066 | 133 |
__ addptr(rsp, 2 * wordSize); |
134 |
__ push(t); // restore return address |
|
1 | 135 |
} |
136 |
break; |
|
137 |
case T_OBJECT : |
|
138 |
// retrieve result from frame |
|
1066 | 139 |
__ movptr(rax, STATE(_oop_temp)); |
1 | 140 |
// and verify it |
141 |
__ verify_oop(rax); |
|
142 |
break; |
|
143 |
default : ShouldNotReachHere(); |
|
144 |
} |
|
145 |
__ ret(0); // return from result handler |
|
146 |
return entry; |
|
147 |
} |
|
148 |
||
149 |
// tosca based result to c++ interpreter stack based result. |
|
150 |
// Result goes to top of native stack. |
|
151 |
||
152 |
#undef EXTEND // SHOULD NOT BE NEEDED |
|
153 |
address CppInterpreterGenerator::generate_tosca_to_stack_converter(BasicType type) { |
|
154 |
// A result is in the tosca (abi result) from either a native method call or compiled |
|
155 |
// code. Place this result on the java expression stack so C++ interpreter can use it. |
|
156 |
address entry = __ pc(); |
|
157 |
||
158 |
const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); |
|
1066 | 159 |
__ pop(t); // remove return address first |
1 | 160 |
switch (type) { |
161 |
case T_VOID: |
|
162 |
break; |
|
163 |
case T_BOOLEAN: |
|
164 |
#ifdef EXTEND |
|
165 |
__ c2bool(rax); |
|
166 |
#endif |
|
1066 | 167 |
__ push(rax); |
1 | 168 |
break; |
169 |
case T_CHAR : |
|
170 |
#ifdef EXTEND |
|
171 |
__ andl(rax, 0xFFFF); |
|
172 |
#endif |
|
1066 | 173 |
__ push(rax); |
1 | 174 |
break; |
175 |
case T_BYTE : |
|
176 |
#ifdef EXTEND |
|
177 |
__ sign_extend_byte (rax); |
|
178 |
#endif |
|
1066 | 179 |
__ push(rax); |
1 | 180 |
break; |
181 |
case T_SHORT : |
|
182 |
#ifdef EXTEND |
|
183 |
__ sign_extend_short(rax); |
|
184 |
#endif |
|
1066 | 185 |
__ push(rax); |
1 | 186 |
break; |
187 |
case T_LONG : |
|
1066 | 188 |
__ push(rdx); // pushes useless junk on 64bit |
189 |
__ push(rax); |
|
1 | 190 |
break; |
191 |
case T_INT : |
|
1066 | 192 |
__ push(rax); |
1 | 193 |
break; |
194 |
case T_FLOAT : |
|
1066 | 195 |
// Result is in ST(0)/xmm0 |
196 |
__ subptr(rsp, wordSize); |
|
1 | 197 |
if ( UseSSE < 1) { |
1066 | 198 |
__ fstp_s(Address(rsp, 0)); |
1 | 199 |
} else { |
200 |
__ movflt(Address(rsp, 0), xmm0); |
|
201 |
} |
|
202 |
break; |
|
203 |
case T_DOUBLE : |
|
1066 | 204 |
__ subptr(rsp, 2*wordSize); |
1 | 205 |
if ( UseSSE < 2 ) { |
1066 | 206 |
__ fstp_d(Address(rsp, 0)); |
1 | 207 |
} else { |
208 |
__ movdbl(Address(rsp, 0), xmm0); |
|
209 |
} |
|
210 |
break; |
|
211 |
case T_OBJECT : |
|
212 |
__ verify_oop(rax); // verify it |
|
1066 | 213 |
__ push(rax); |
1 | 214 |
break; |
215 |
default : ShouldNotReachHere(); |
|
216 |
} |
|
217 |
__ jmp(t); // return from result handler |
|
218 |
return entry; |
|
219 |
} |
|
220 |
||
221 |
address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) { |
|
222 |
// A result is in the java expression stack of the interpreted method that has just |
|
223 |
// returned. Place this result on the java expression stack of the caller. |
|
224 |
// |
|
1066 | 225 |
// The current interpreter activation in rsi/r13 is for the method just returning its |
1 | 226 |
// result. So we know that the result of this method is on the top of the current |
227 |
// execution stack (which is pre-pushed) and will be return to the top of the caller |
|
228 |
// stack. The top of the callers stack is the bottom of the locals of the current |
|
229 |
// activation. |
|
230 |
// Because of the way activation are managed by the frame manager the value of rsp is |
|
231 |
// below both the stack top of the current activation and naturally the stack top |
|
232 |
// of the calling activation. This enable this routine to leave the return address |
|
233 |
// to the frame manager on the stack and do a vanilla return. |
|
234 |
// |
|
1066 | 235 |
// On entry: rsi/r13 - interpreter state of activation returning a (potential) result |
236 |
// On Return: rsi/r13 - unchanged |
|
1 | 237 |
// rax - new stack top for caller activation (i.e. activation in _prev_link) |
238 |
// |
|
239 |
// Can destroy rdx, rcx. |
|
240 |
// |
|
241 |
||
242 |
address entry = __ pc(); |
|
243 |
const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); |
|
244 |
switch (type) { |
|
245 |
case T_VOID: |
|
1066 | 246 |
__ movptr(rax, STATE(_locals)); // pop parameters get new stack value |
247 |
__ addptr(rax, wordSize); // account for prepush before we return |
|
1 | 248 |
break; |
249 |
case T_FLOAT : |
|
250 |
case T_BOOLEAN: |
|
251 |
case T_CHAR : |
|
252 |
case T_BYTE : |
|
253 |
case T_SHORT : |
|
254 |
case T_INT : |
|
255 |
// 1 word result |
|
1066 | 256 |
__ movptr(rdx, STATE(_stack)); |
257 |
__ movptr(rax, STATE(_locals)); // address for result |
|
1 | 258 |
__ movl(rdx, Address(rdx, wordSize)); // get result |
1066 | 259 |
__ movptr(Address(rax, 0), rdx); // and store it |
1 | 260 |
break; |
261 |
case T_LONG : |
|
262 |
case T_DOUBLE : |
|
263 |
// return top two words on current expression stack to caller's expression stack |
|
264 |
// The caller's expression stack is adjacent to the current frame manager's intepretState |
|
265 |
// except we allocated one extra word for this intepretState so we won't overwrite it |
|
266 |
// when we return a two word result. |
|
267 |
||
1066 | 268 |
__ movptr(rax, STATE(_locals)); // address for result |
269 |
__ movptr(rcx, STATE(_stack)); |
|
270 |
__ subptr(rax, wordSize); // need addition word besides locals[0] |
|
271 |
__ movptr(rdx, Address(rcx, 2*wordSize)); // get result word (junk in 64bit) |
|
272 |
__ movptr(Address(rax, wordSize), rdx); // and store it |
|
273 |
__ movptr(rdx, Address(rcx, wordSize)); // get result word |
|
274 |
__ movptr(Address(rax, 0), rdx); // and store it |
|
1 | 275 |
break; |
276 |
case T_OBJECT : |
|
1066 | 277 |
__ movptr(rdx, STATE(_stack)); |
278 |
__ movptr(rax, STATE(_locals)); // address for result |
|
279 |
__ movptr(rdx, Address(rdx, wordSize)); // get result |
|
1 | 280 |
__ verify_oop(rdx); // verify it |
1066 | 281 |
__ movptr(Address(rax, 0), rdx); // and store it |
1 | 282 |
break; |
283 |
default : ShouldNotReachHere(); |
|
284 |
} |
|
285 |
__ ret(0); |
|
286 |
return entry; |
|
287 |
} |
|
288 |
||
289 |
address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicType type) { |
|
290 |
// A result is in the java expression stack of the interpreted method that has just |
|
291 |
// returned. Place this result in the native abi that the caller expects. |
|
292 |
// |
|
293 |
// Similar to generate_stack_to_stack_converter above. Called at a similar time from the |
|
294 |
// frame manager execept in this situation the caller is native code (c1/c2/call_stub) |
|
295 |
// and so rather than return result onto caller's java expression stack we return the |
|
296 |
// result in the expected location based on the native abi. |
|
1066 | 297 |
// On entry: rsi/r13 - interpreter state of activation returning a (potential) result |
298 |
// On Return: rsi/r13 - unchanged |
|
1 | 299 |
// Other registers changed [rax/rdx/ST(0) as needed for the result returned] |
300 |
||
301 |
address entry = __ pc(); |
|
302 |
switch (type) { |
|
303 |
case T_VOID: |
|
304 |
break; |
|
305 |
case T_BOOLEAN: |
|
306 |
case T_CHAR : |
|
307 |
case T_BYTE : |
|
308 |
case T_SHORT : |
|
309 |
case T_INT : |
|
1066 | 310 |
__ movptr(rdx, STATE(_stack)); // get top of stack |
1 | 311 |
__ movl(rax, Address(rdx, wordSize)); // get result word 1 |
312 |
break; |
|
313 |
case T_LONG : |
|
1066 | 314 |
__ movptr(rdx, STATE(_stack)); // get top of stack |
315 |
__ movptr(rax, Address(rdx, wordSize)); // get result low word |
|
316 |
NOT_LP64(__ movl(rdx, Address(rdx, 2*wordSize));) // get result high word |
|
1 | 317 |
break; |
318 |
case T_FLOAT : |
|
1066 | 319 |
__ movptr(rdx, STATE(_stack)); // get top of stack |
1 | 320 |
if ( UseSSE >= 1) { |
321 |
__ movflt(xmm0, Address(rdx, wordSize)); |
|
322 |
} else { |
|
323 |
__ fld_s(Address(rdx, wordSize)); // pushd float result |
|
324 |
} |
|
325 |
break; |
|
326 |
case T_DOUBLE : |
|
1066 | 327 |
__ movptr(rdx, STATE(_stack)); // get top of stack |
1 | 328 |
if ( UseSSE > 1) { |
329 |
__ movdbl(xmm0, Address(rdx, wordSize)); |
|
330 |
} else { |
|
331 |
__ fld_d(Address(rdx, wordSize)); // push double result |
|
332 |
} |
|
333 |
break; |
|
334 |
case T_OBJECT : |
|
1066 | 335 |
__ movptr(rdx, STATE(_stack)); // get top of stack |
336 |
__ movptr(rax, Address(rdx, wordSize)); // get result word 1 |
|
1 | 337 |
__ verify_oop(rax); // verify it |
338 |
break; |
|
339 |
default : ShouldNotReachHere(); |
|
340 |
} |
|
341 |
__ ret(0); |
|
342 |
return entry; |
|
343 |
} |
|
344 |
||
345 |
address CppInterpreter::return_entry(TosState state, int length) { |
|
346 |
// make it look good in the debugger |
|
347 |
return CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation); |
|
348 |
} |
|
349 |
||
350 |
address CppInterpreter::deopt_entry(TosState state, int length) { |
|
351 |
address ret = NULL; |
|
352 |
if (length != 0) { |
|
353 |
switch (state) { |
|
354 |
case atos: ret = deopt_frame_manager_return_atos; break; |
|
355 |
case btos: ret = deopt_frame_manager_return_btos; break; |
|
356 |
case ctos: |
|
357 |
case stos: |
|
358 |
case itos: ret = deopt_frame_manager_return_itos; break; |
|
359 |
case ltos: ret = deopt_frame_manager_return_ltos; break; |
|
360 |
case ftos: ret = deopt_frame_manager_return_ftos; break; |
|
361 |
case dtos: ret = deopt_frame_manager_return_dtos; break; |
|
362 |
case vtos: ret = deopt_frame_manager_return_vtos; break; |
|
363 |
} |
|
364 |
} else { |
|
365 |
ret = unctrap_frame_manager_entry; // re-execute the bytecode ( e.g. uncommon trap) |
|
366 |
} |
|
367 |
assert(ret != NULL, "Not initialized"); |
|
368 |
return ret; |
|
369 |
} |
|
370 |
||
371 |
// C++ Interpreter |
|
372 |
void CppInterpreterGenerator::generate_compute_interpreter_state(const Register state, |
|
373 |
const Register locals, |
|
374 |
const Register sender_sp, |
|
375 |
bool native) { |
|
376 |
||
377 |
// On entry the "locals" argument points to locals[0] (or where it would be in case no locals in |
|
378 |
// a static method). "state" contains any previous frame manager state which we must save a link |
|
379 |
// to in the newly generated state object. On return "state" is a pointer to the newly allocated |
|
380 |
// state object. We must allocate and initialize a new interpretState object and the method |
|
381 |
// expression stack. Because the returned result (if any) of the method will be placed on the caller's |
|
382 |
// expression stack and this will overlap with locals[0] (and locals[1] if double/long) we must |
|
383 |
// be sure to leave space on the caller's stack so that this result will not overwrite values when |
|
384 |
// locals[0] and locals[1] do not exist (and in fact are return address and saved rbp). So when |
|
385 |
// we are non-native we in essence ensure that locals[0-1] exist. We play an extra trick in |
|
386 |
// non-product builds and initialize this last local with the previous interpreterState as |
|
387 |
// this makes things look real nice in the debugger. |
|
388 |
||
389 |
// State on entry |
|
390 |
// Assumes locals == &locals[0] |
|
391 |
// Assumes state == any previous frame manager state (assuming call path from c++ interpreter) |
|
392 |
// Assumes rax = return address |
|
393 |
// rcx == senders_sp |
|
394 |
// rbx == method |
|
395 |
// Modifies rcx, rdx, rax |
|
396 |
// Returns: |
|
397 |
// state == address of new interpreterState |
|
398 |
// rsp == bottom of method's expression stack. |
|
399 |
||
400 |
const Address const_offset (rbx, methodOopDesc::const_offset()); |
|
401 |
||
402 |
||
403 |
// On entry sp is the sender's sp. This includes the space for the arguments |
|
404 |
// that the sender pushed. If the sender pushed no args (a static) and the |
|
405 |
// caller returns a long then we need two words on the sender's stack which |
|
406 |
// are not present (although when we return a restore full size stack the |
|
407 |
// space will be present). If we didn't allocate two words here then when |
|
408 |
// we "push" the result of the caller's stack we would overwrite the return |
|
409 |
// address and the saved rbp. Not good. So simply allocate 2 words now |
|
410 |
// just to be safe. This is the "static long no_params() method" issue. |
|
411 |
// See Lo.java for a testcase. |
|
412 |
// We don't need this for native calls because they return result in |
|
413 |
// register and the stack is expanded in the caller before we store |
|
414 |
// the results on the stack. |
|
415 |
||
416 |
if (!native) { |
|
417 |
#ifdef PRODUCT |
|
1066 | 418 |
__ subptr(rsp, 2*wordSize); |
1 | 419 |
#else /* PRODUCT */ |
1066 | 420 |
__ push((int32_t)NULL_WORD); |
421 |
__ push(state); // make it look like a real argument |
|
1 | 422 |
#endif /* PRODUCT */ |
423 |
} |
|
424 |
||
425 |
// Now that we are assure of space for stack result, setup typical linkage |
|
426 |
||
1066 | 427 |
__ push(rax); |
1 | 428 |
__ enter(); |
429 |
||
1066 | 430 |
__ mov(rax, state); // save current state |
431 |
||
432 |
__ lea(rsp, Address(rsp, -(int)sizeof(BytecodeInterpreter))); |
|
433 |
__ mov(state, rsp); |
|
434 |
||
435 |
// rsi/r13 == state/locals rax == prevstate |
|
1 | 436 |
|
437 |
// initialize the "shadow" frame so that use since C++ interpreter not directly |
|
438 |
// recursive. Simpler to recurse but we can't trim expression stack as we call |
|
439 |
// new methods. |
|
1066 | 440 |
__ movptr(STATE(_locals), locals); // state->_locals = locals() |
441 |
__ movptr(STATE(_self_link), state); // point to self |
|
442 |
__ movptr(STATE(_prev_link), rax); // state->_link = state on entry (NULL or previous state) |
|
443 |
__ movptr(STATE(_sender_sp), sender_sp); // state->_sender_sp = sender_sp |
|
444 |
#ifdef _LP64 |
|
445 |
__ movptr(STATE(_thread), r15_thread); // state->_bcp = codes() |
|
446 |
#else |
|
1 | 447 |
__ get_thread(rax); // get vm's javathread* |
1066 | 448 |
__ movptr(STATE(_thread), rax); // state->_bcp = codes() |
449 |
#endif // _LP64 |
|
450 |
__ movptr(rdx, Address(rbx, methodOopDesc::const_offset())); // get constantMethodOop |
|
451 |
__ lea(rdx, Address(rdx, constMethodOopDesc::codes_offset())); // get code base |
|
1 | 452 |
if (native) { |
1066 | 453 |
__ movptr(STATE(_bcp), (int32_t)NULL_WORD); // state->_bcp = NULL |
1 | 454 |
} else { |
1066 | 455 |
__ movptr(STATE(_bcp), rdx); // state->_bcp = codes() |
1 | 456 |
} |
1066 | 457 |
__ xorptr(rdx, rdx); |
458 |
__ movptr(STATE(_oop_temp), rdx); // state->_oop_temp = NULL (only really needed for native) |
|
459 |
__ movptr(STATE(_mdx), rdx); // state->_mdx = NULL |
|
460 |
__ movptr(rdx, Address(rbx, methodOopDesc::constants_offset())); |
|
461 |
__ movptr(rdx, Address(rdx, constantPoolOopDesc::cache_offset_in_bytes())); |
|
462 |
__ movptr(STATE(_constants), rdx); // state->_constants = constants() |
|
463 |
||
464 |
__ movptr(STATE(_method), rbx); // state->_method = method() |
|
465 |
__ movl(STATE(_msg), (int32_t) BytecodeInterpreter::method_entry); // state->_msg = initial method entry |
|
466 |
__ movptr(STATE(_result._to_call._callee), (int32_t) NULL_WORD); // state->_result._to_call._callee_callee = NULL |
|
467 |
||
468 |
||
469 |
__ movptr(STATE(_monitor_base), rsp); // set monitor block bottom (grows down) this would point to entry [0] |
|
1 | 470 |
// entries run from -1..x where &monitor[x] == |
471 |
||
472 |
{ |
|
473 |
// Must not attempt to lock method until we enter interpreter as gc won't be able to find the |
|
474 |
// initial frame. However we allocate a free monitor so we don't have to shuffle the expression stack |
|
475 |
// immediately. |
|
476 |
||
477 |
// synchronize method |
|
478 |
const Address access_flags (rbx, methodOopDesc::access_flags_offset()); |
|
479 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
480 |
Label not_synced; |
|
481 |
||
482 |
__ movl(rax, access_flags); |
|
483 |
__ testl(rax, JVM_ACC_SYNCHRONIZED); |
|
484 |
__ jcc(Assembler::zero, not_synced); |
|
485 |
||
486 |
// Allocate initial monitor and pre initialize it |
|
487 |
// get synchronization object |
|
488 |
||
489 |
Label done; |
|
490 |
const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); |
|
491 |
__ movl(rax, access_flags); |
|
492 |
__ testl(rax, JVM_ACC_STATIC); |
|
1066 | 493 |
__ movptr(rax, Address(locals, 0)); // get receiver (assume this is frequent case) |
1 | 494 |
__ jcc(Assembler::zero, done); |
1066 | 495 |
__ movptr(rax, Address(rbx, methodOopDesc::constants_offset())); |
496 |
__ movptr(rax, Address(rax, constantPoolOopDesc::pool_holder_offset_in_bytes())); |
|
497 |
__ movptr(rax, Address(rax, mirror_offset)); |
|
1 | 498 |
__ bind(done); |
499 |
// add space for monitor & lock |
|
1066 | 500 |
__ subptr(rsp, entry_size); // add space for a monitor entry |
501 |
__ movptr(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); // store object |
|
1 | 502 |
__ bind(not_synced); |
503 |
} |
|
504 |
||
1066 | 505 |
__ movptr(STATE(_stack_base), rsp); // set expression stack base ( == &monitors[-count]) |
1 | 506 |
if (native) { |
1066 | 507 |
__ movptr(STATE(_stack), rsp); // set current expression stack tos |
508 |
__ movptr(STATE(_stack_limit), rsp); |
|
1 | 509 |
} else { |
1066 | 510 |
__ subptr(rsp, wordSize); // pre-push stack |
511 |
__ movptr(STATE(_stack), rsp); // set current expression stack tos |
|
1 | 512 |
|
513 |
// compute full expression stack limit |
|
514 |
||
515 |
const Address size_of_stack (rbx, methodOopDesc::max_stack_offset()); |
|
2534 | 516 |
const int extra_stack = 0; //6815692//methodOopDesc::extra_stack_words(); |
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
517 |
__ load_unsigned_short(rdx, size_of_stack); // get size of expression stack in words |
1066 | 518 |
__ negptr(rdx); // so we can subtract in next step |
1 | 519 |
// Allocate expression stack |
2534 | 520 |
__ lea(rsp, Address(rsp, rdx, Address::times_ptr, -extra_stack)); |
1066 | 521 |
__ movptr(STATE(_stack_limit), rsp); |
1 | 522 |
} |
523 |
||
1066 | 524 |
#ifdef _LP64 |
525 |
// Make sure stack is properly aligned and sized for the abi |
|
526 |
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
|
2131 | 527 |
__ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI) |
1066 | 528 |
#endif // _LP64 |
529 |
||
530 |
||
531 |
||
1 | 532 |
} |
533 |
||
534 |
// Helpers for commoning out cases in the various type of method entries. |
|
535 |
// |
|
536 |
||
537 |
// increment invocation count & check for overflow |
|
538 |
// |
|
539 |
// Note: checking for negative value instead of overflow |
|
540 |
// so we have a 'sticky' overflow test |
|
541 |
// |
|
542 |
// rbx,: method |
|
543 |
// rcx: invocation counter |
|
544 |
// |
|
545 |
void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) { |
|
546 |
||
547 |
const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset()); |
|
548 |
const Address backedge_counter (rbx, methodOopDesc::backedge_counter_offset() + InvocationCounter::counter_offset()); |
|
549 |
||
550 |
if (ProfileInterpreter) { // %%% Merge this into methodDataOop |
|
1066 | 551 |
__ incrementl(Address(rbx,methodOopDesc::interpreter_invocation_counter_offset())); |
1 | 552 |
} |
553 |
// Update standard invocation counters |
|
554 |
__ movl(rax, backedge_counter); // load backedge counter |
|
555 |
||
556 |
__ increment(rcx, InvocationCounter::count_increment); |
|
557 |
__ andl(rax, InvocationCounter::count_mask_value); // mask out the status bits |
|
558 |
||
559 |
__ movl(invocation_counter, rcx); // save invocation count |
|
560 |
__ addl(rcx, rax); // add both counters |
|
561 |
||
562 |
// profile_method is non-null only for interpreted method so |
|
563 |
// profile_method != NULL == !native_call |
|
564 |
// BytecodeInterpreter only calls for native so code is elided. |
|
565 |
||
566 |
__ cmp32(rcx, |
|
567 |
ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit)); |
|
568 |
__ jcc(Assembler::aboveEqual, *overflow); |
|
569 |
||
570 |
} |
|
571 |
||
572 |
void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { |
|
573 |
||
574 |
// C++ interpreter on entry |
|
1066 | 575 |
// rsi/r13 - new interpreter state pointer |
1 | 576 |
// rbp - interpreter frame pointer |
577 |
// rbx - method |
|
578 |
||
579 |
// On return (i.e. jump to entry_point) [ back to invocation of interpreter ] |
|
580 |
// rbx, - method |
|
581 |
// rcx - rcvr (assuming there is one) |
|
582 |
// top of stack return address of interpreter caller |
|
583 |
// rsp - sender_sp |
|
584 |
||
585 |
// C++ interpreter only |
|
1066 | 586 |
// rsi/r13 - previous interpreter state pointer |
1 | 587 |
|
588 |
const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset()); |
|
589 |
||
590 |
// InterpreterRuntime::frequency_counter_overflow takes one argument |
|
591 |
// indicating if the counter overflow occurs at a backwards branch (non-NULL bcp). |
|
592 |
// The call returns the address of the verified entry point for the method or NULL |
|
593 |
// if the compilation did not complete (either went background or bailed out). |
|
1066 | 594 |
__ movptr(rax, (int32_t)false); |
1 | 595 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), rax); |
596 |
||
597 |
// for c++ interpreter can rsi really be munged? |
|
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
598 |
__ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); // restore state |
1066 | 599 |
__ movptr(rbx, Address(state, byte_offset_of(BytecodeInterpreter, _method))); // restore method |
600 |
__ movptr(rdi, Address(state, byte_offset_of(BytecodeInterpreter, _locals))); // get locals pointer |
|
601 |
||
1 | 602 |
__ jmp(*do_continue, relocInfo::none); |
603 |
||
604 |
} |
|
605 |
||
606 |
void InterpreterGenerator::generate_stack_overflow_check(void) { |
|
607 |
// see if we've got enough room on the stack for locals plus overhead. |
|
608 |
// the expression stack grows down incrementally, so the normal guard |
|
609 |
// page mechanism will work for that. |
|
610 |
// |
|
611 |
// Registers live on entry: |
|
612 |
// |
|
613 |
// Asm interpreter |
|
614 |
// rdx: number of additional locals this frame needs (what we must check) |
|
615 |
// rbx,: methodOop |
|
616 |
||
617 |
// C++ Interpreter |
|
1066 | 618 |
// rsi/r13: previous interpreter frame state object |
1 | 619 |
// rdi: &locals[0] |
620 |
// rcx: # of locals |
|
621 |
// rdx: number of additional locals this frame needs (what we must check) |
|
622 |
// rbx: methodOop |
|
623 |
||
624 |
// destroyed on exit |
|
625 |
// rax, |
|
626 |
||
627 |
// NOTE: since the additional locals are also always pushed (wasn't obvious in |
|
628 |
// generate_method_entry) so the guard should work for them too. |
|
629 |
// |
|
630 |
||
631 |
// monitor entry size: see picture of stack set (generate_method_entry) and frame_i486.hpp |
|
632 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
633 |
||
634 |
// total overhead size: entry_size + (saved rbp, thru expr stack bottom). |
|
635 |
// be sure to change this if you add/subtract anything to/from the overhead area |
|
636 |
const int overhead_size = (int)sizeof(BytecodeInterpreter); |
|
637 |
||
638 |
const int page_size = os::vm_page_size(); |
|
639 |
||
640 |
Label after_frame_check; |
|
641 |
||
642 |
// compute rsp as if this were going to be the last frame on |
|
643 |
// the stack before the red zone |
|
644 |
||
645 |
Label after_frame_check_pop; |
|
646 |
||
647 |
// save rsi == caller's bytecode ptr (c++ previous interp. state) |
|
648 |
// QQQ problem here?? rsi overload???? |
|
1066 | 649 |
__ push(state); |
650 |
||
651 |
const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rsi); |
|
652 |
||
653 |
NOT_LP64(__ get_thread(thread)); |
|
1 | 654 |
|
655 |
const Address stack_base(thread, Thread::stack_base_offset()); |
|
656 |
const Address stack_size(thread, Thread::stack_size_offset()); |
|
657 |
||
658 |
// locals + overhead, in bytes |
|
659 |
const Address size_of_stack (rbx, methodOopDesc::max_stack_offset()); |
|
660 |
// Always give one monitor to allow us to start interp if sync method. |
|
661 |
// Any additional monitors need a check when moving the expression stack |
|
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
662 |
const int one_monitor = frame::interpreter_frame_monitor_size() * wordSize; |
2534 | 663 |
const int extra_stack = 0; //6815692//methodOopDesc::extra_stack_entries(); |
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
664 |
__ load_unsigned_short(rax, size_of_stack); // get size of expression stack in words |
2534 | 665 |
__ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), extra_stack + one_monitor)); |
1066 | 666 |
__ lea(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size)); |
1 | 667 |
|
668 |
#ifdef ASSERT |
|
669 |
Label stack_base_okay, stack_size_okay; |
|
670 |
// verify that thread stack base is non-zero |
|
1066 | 671 |
__ cmpptr(stack_base, (int32_t)0); |
1 | 672 |
__ jcc(Assembler::notEqual, stack_base_okay); |
673 |
__ stop("stack base is zero"); |
|
674 |
__ bind(stack_base_okay); |
|
675 |
// verify that thread stack size is non-zero |
|
1066 | 676 |
__ cmpptr(stack_size, (int32_t)0); |
1 | 677 |
__ jcc(Assembler::notEqual, stack_size_okay); |
678 |
__ stop("stack size is zero"); |
|
679 |
__ bind(stack_size_okay); |
|
680 |
#endif |
|
681 |
||
682 |
// Add stack base to locals and subtract stack size |
|
1066 | 683 |
__ addptr(rax, stack_base); |
684 |
__ subptr(rax, stack_size); |
|
1 | 685 |
|
686 |
// We should have a magic number here for the size of the c++ interpreter frame. |
|
687 |
// We can't actually tell this ahead of time. The debug version size is around 3k |
|
688 |
// product is 1k and fastdebug is 4k |
|
689 |
const int slop = 6 * K; |
|
690 |
||
691 |
// Use the maximum number of pages we might bang. |
|
692 |
const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages : |
|
693 |
(StackRedPages+StackYellowPages); |
|
694 |
// Only need this if we are stack banging which is temporary while |
|
695 |
// we're debugging. |
|
1066 | 696 |
__ addptr(rax, slop + 2*max_pages * page_size); |
1 | 697 |
|
698 |
// check against the current stack bottom |
|
1066 | 699 |
__ cmpptr(rsp, rax); |
1 | 700 |
__ jcc(Assembler::above, after_frame_check_pop); |
701 |
||
1066 | 702 |
__ pop(state); // get c++ prev state. |
1 | 703 |
|
704 |
// throw exception return address becomes throwing pc |
|
705 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError)); |
|
706 |
||
707 |
// all done with frame size check |
|
708 |
__ bind(after_frame_check_pop); |
|
1066 | 709 |
__ pop(state); |
1 | 710 |
|
711 |
__ bind(after_frame_check); |
|
712 |
} |
|
713 |
||
714 |
// Find preallocated monitor and lock method (C++ interpreter) |
|
715 |
// rbx - methodOop |
|
716 |
// |
|
717 |
void InterpreterGenerator::lock_method(void) { |
|
1066 | 718 |
// assumes state == rsi/r13 == pointer to current interpreterState |
719 |
// minimally destroys rax, rdx|c_rarg1, rdi |
|
1 | 720 |
// |
721 |
// synchronize method |
|
722 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
723 |
const Address access_flags (rbx, methodOopDesc::access_flags_offset()); |
|
724 |
||
1066 | 725 |
const Register monitor = NOT_LP64(rdx) LP64_ONLY(c_rarg1); |
726 |
||
1 | 727 |
// find initial monitor i.e. monitors[-1] |
1066 | 728 |
__ movptr(monitor, STATE(_monitor_base)); // get monitor bottom limit |
729 |
__ subptr(monitor, entry_size); // point to initial monitor |
|
1 | 730 |
|
731 |
#ifdef ASSERT |
|
732 |
{ Label L; |
|
733 |
__ movl(rax, access_flags); |
|
734 |
__ testl(rax, JVM_ACC_SYNCHRONIZED); |
|
735 |
__ jcc(Assembler::notZero, L); |
|
736 |
__ stop("method doesn't need synchronization"); |
|
737 |
__ bind(L); |
|
738 |
} |
|
739 |
#endif // ASSERT |
|
740 |
// get synchronization object |
|
741 |
{ Label done; |
|
742 |
const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); |
|
743 |
__ movl(rax, access_flags); |
|
1066 | 744 |
__ movptr(rdi, STATE(_locals)); // prepare to get receiver (assume common case) |
1 | 745 |
__ testl(rax, JVM_ACC_STATIC); |
1066 | 746 |
__ movptr(rax, Address(rdi, 0)); // get receiver (assume this is frequent case) |
1 | 747 |
__ jcc(Assembler::zero, done); |
1066 | 748 |
__ movptr(rax, Address(rbx, methodOopDesc::constants_offset())); |
749 |
__ movptr(rax, Address(rax, constantPoolOopDesc::pool_holder_offset_in_bytes())); |
|
750 |
__ movptr(rax, Address(rax, mirror_offset)); |
|
1 | 751 |
__ bind(done); |
752 |
} |
|
753 |
#ifdef ASSERT |
|
754 |
{ Label L; |
|
1066 | 755 |
__ cmpptr(rax, Address(monitor, BasicObjectLock::obj_offset_in_bytes())); // correct object? |
1 | 756 |
__ jcc(Assembler::equal, L); |
757 |
__ stop("wrong synchronization lobject"); |
|
758 |
__ bind(L); |
|
759 |
} |
|
760 |
#endif // ASSERT |
|
1066 | 761 |
// can destroy rax, rdx|c_rarg1, rcx, and (via call_VM) rdi! |
762 |
__ lock_object(monitor); |
|
1 | 763 |
} |
764 |
||
765 |
// Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry |
|
766 |
||
767 |
address InterpreterGenerator::generate_accessor_entry(void) { |
|
768 |
||
1066 | 769 |
// rbx: methodOop |
770 |
||
771 |
// rsi/r13: senderSP must preserved for slow path, set SP to it on fast path |
|
1 | 772 |
|
773 |
Label xreturn_path; |
|
774 |
||
775 |
// do fastpath for resolved accessor methods |
|
776 |
if (UseFastAccessorMethods) { |
|
777 |
||
778 |
address entry_point = __ pc(); |
|
779 |
||
780 |
Label slow_path; |
|
781 |
// If we need a safepoint check, generate full interpreter entry. |
|
782 |
ExternalAddress state(SafepointSynchronize::address_of_state()); |
|
783 |
__ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), |
|
784 |
SafepointSynchronize::_not_synchronized); |
|
785 |
||
786 |
__ jcc(Assembler::notEqual, slow_path); |
|
787 |
// ASM/C++ Interpreter |
|
788 |
// Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; parameter size = 1 |
|
789 |
// Note: We can only use this code if the getfield has been resolved |
|
790 |
// and if we don't have a null-pointer exception => check for |
|
791 |
// these conditions first and use slow path if necessary. |
|
792 |
// rbx,: method |
|
793 |
// rcx: receiver |
|
1066 | 794 |
__ movptr(rax, Address(rsp, wordSize)); |
1 | 795 |
|
796 |
// check if local 0 != NULL and read field |
|
1066 | 797 |
__ testptr(rax, rax); |
1 | 798 |
__ jcc(Assembler::zero, slow_path); |
799 |
||
1066 | 800 |
__ movptr(rdi, Address(rbx, methodOopDesc::constants_offset())); |
1 | 801 |
// read first instruction word and extract bytecode @ 1 and index @ 2 |
1066 | 802 |
__ movptr(rdx, Address(rbx, methodOopDesc::const_offset())); |
1 | 803 |
__ movl(rdx, Address(rdx, constMethodOopDesc::codes_offset())); |
804 |
// Shift codes right to get the index on the right. |
|
805 |
// The bytecode fetched looks like <index><0xb4><0x2a> |
|
806 |
__ shrl(rdx, 2*BitsPerByte); |
|
807 |
__ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); |
|
1066 | 808 |
__ movptr(rdi, Address(rdi, constantPoolOopDesc::cache_offset_in_bytes())); |
1 | 809 |
|
810 |
// rax,: local 0 |
|
811 |
// rbx,: method |
|
812 |
// rcx: receiver - do not destroy since it is needed for slow path! |
|
813 |
// rcx: scratch |
|
814 |
// rdx: constant pool cache index |
|
815 |
// rdi: constant pool cache |
|
1066 | 816 |
// rsi/r13: sender sp |
1 | 817 |
|
818 |
// check if getfield has been resolved and read constant pool cache entry |
|
819 |
// check the validity of the cache entry by testing whether _indices field |
|
820 |
// contains Bytecode::_getfield in b1 byte. |
|
821 |
assert(in_words(ConstantPoolCacheEntry::size()) == 4, "adjust shift below"); |
|
822 |
__ movl(rcx, |
|
823 |
Address(rdi, |
|
824 |
rdx, |
|
1066 | 825 |
Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::indices_offset())); |
1 | 826 |
__ shrl(rcx, 2*BitsPerByte); |
827 |
__ andl(rcx, 0xFF); |
|
828 |
__ cmpl(rcx, Bytecodes::_getfield); |
|
829 |
__ jcc(Assembler::notEqual, slow_path); |
|
830 |
||
831 |
// Note: constant pool entry is not valid before bytecode is resolved |
|
1066 | 832 |
__ movptr(rcx, |
1 | 833 |
Address(rdi, |
834 |
rdx, |
|
1066 | 835 |
Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset())); |
1 | 836 |
__ movl(rdx, |
837 |
Address(rdi, |
|
838 |
rdx, |
|
1066 | 839 |
Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::flags_offset())); |
1 | 840 |
|
841 |
Label notByte, notShort, notChar; |
|
842 |
const Address field_address (rax, rcx, Address::times_1); |
|
843 |
||
844 |
// Need to differentiate between igetfield, agetfield, bgetfield etc. |
|
845 |
// because they are different sizes. |
|
846 |
// Use the type from the constant pool cache |
|
847 |
__ shrl(rdx, ConstantPoolCacheEntry::tosBits); |
|
848 |
// Make sure we don't need to mask rdx for tosBits after the above shift |
|
849 |
ConstantPoolCacheEntry::verify_tosBits(); |
|
1066 | 850 |
#ifdef _LP64 |
851 |
Label notObj; |
|
852 |
__ cmpl(rdx, atos); |
|
853 |
__ jcc(Assembler::notEqual, notObj); |
|
854 |
// atos |
|
855 |
__ movptr(rax, field_address); |
|
856 |
__ jmp(xreturn_path); |
|
857 |
||
858 |
__ bind(notObj); |
|
859 |
#endif // _LP64 |
|
1 | 860 |
__ cmpl(rdx, btos); |
861 |
__ jcc(Assembler::notEqual, notByte); |
|
862 |
__ load_signed_byte(rax, field_address); |
|
863 |
__ jmp(xreturn_path); |
|
864 |
||
865 |
__ bind(notByte); |
|
866 |
__ cmpl(rdx, stos); |
|
867 |
__ jcc(Assembler::notEqual, notShort); |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
868 |
__ load_signed_short(rax, field_address); |
1 | 869 |
__ jmp(xreturn_path); |
870 |
||
871 |
__ bind(notShort); |
|
872 |
__ cmpl(rdx, ctos); |
|
873 |
__ jcc(Assembler::notEqual, notChar); |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
874 |
__ load_unsigned_short(rax, field_address); |
1 | 875 |
__ jmp(xreturn_path); |
876 |
||
877 |
__ bind(notChar); |
|
878 |
#ifdef ASSERT |
|
879 |
Label okay; |
|
1066 | 880 |
#ifndef _LP64 |
1 | 881 |
__ cmpl(rdx, atos); |
882 |
__ jcc(Assembler::equal, okay); |
|
1066 | 883 |
#endif // _LP64 |
1 | 884 |
__ cmpl(rdx, itos); |
885 |
__ jcc(Assembler::equal, okay); |
|
886 |
__ stop("what type is this?"); |
|
887 |
__ bind(okay); |
|
888 |
#endif // ASSERT |
|
889 |
// All the rest are a 32 bit wordsize |
|
890 |
__ movl(rax, field_address); |
|
891 |
||
892 |
__ bind(xreturn_path); |
|
893 |
||
894 |
// _ireturn/_areturn |
|
1066 | 895 |
__ pop(rdi); // get return address |
896 |
__ mov(rsp, sender_sp_on_entry); // set sp to sender sp |
|
1 | 897 |
__ jmp(rdi); |
898 |
||
899 |
// generate a vanilla interpreter entry as the slow path |
|
900 |
__ bind(slow_path); |
|
901 |
// We will enter c++ interpreter looking like it was |
|
902 |
// called by the call_stub this will cause it to return |
|
903 |
// a tosca result to the invoker which might have been |
|
904 |
// the c++ interpreter itself. |
|
905 |
||
906 |
__ jmp(fast_accessor_slow_entry_path); |
|
907 |
return entry_point; |
|
908 |
||
909 |
} else { |
|
910 |
return NULL; |
|
911 |
} |
|
912 |
||
913 |
} |
|
914 |
||
915 |
// |
|
916 |
// C++ Interpreter stub for calling a native method. |
|
917 |
// This sets up a somewhat different looking stack for calling the native method |
|
918 |
// than the typical interpreter frame setup but still has the pointer to |
|
919 |
// an interpreter state. |
|
920 |
// |
|
921 |
||
922 |
address InterpreterGenerator::generate_native_entry(bool synchronized) { |
|
923 |
// determine code generation flags |
|
924 |
bool inc_counter = UseCompiler || CountCompiledCalls; |
|
925 |
||
926 |
// rbx: methodOop |
|
927 |
// rcx: receiver (unused) |
|
1066 | 928 |
// rsi/r13: previous interpreter state (if called from C++ interpreter) must preserve |
929 |
// in any case. If called via c1/c2/call_stub rsi/r13 is junk (to use) but harmless |
|
1 | 930 |
// to save/restore. |
931 |
address entry_point = __ pc(); |
|
932 |
||
933 |
const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset()); |
|
934 |
const Address size_of_locals (rbx, methodOopDesc::size_of_locals_offset()); |
|
935 |
const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset()); |
|
936 |
const Address access_flags (rbx, methodOopDesc::access_flags_offset()); |
|
937 |
||
1066 | 938 |
// rsi/r13 == state/locals rdi == prevstate |
1 | 939 |
const Register locals = rdi; |
940 |
||
941 |
// get parameter size (always needed) |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
942 |
__ load_unsigned_short(rcx, size_of_parameters); |
1 | 943 |
|
944 |
// rbx: methodOop |
|
945 |
// rcx: size of parameters |
|
1066 | 946 |
__ pop(rax); // get return address |
1 | 947 |
// for natives the size of locals is zero |
948 |
||
949 |
// compute beginning of parameters /locals |
|
1066 | 950 |
__ lea(locals, Address(rsp, rcx, Address::times_ptr, -wordSize)); |
1 | 951 |
|
952 |
// initialize fixed part of activation frame |
|
953 |
||
954 |
// Assumes rax = return address |
|
955 |
||
956 |
// allocate and initialize new interpreterState and method expression stack |
|
957 |
// IN(locals) -> locals |
|
958 |
// IN(state) -> previous frame manager state (NULL from stub/c1/c2) |
|
959 |
// destroys rax, rcx, rdx |
|
960 |
// OUT (state) -> new interpreterState |
|
961 |
// OUT(rsp) -> bottom of methods expression stack |
|
962 |
||
963 |
// save sender_sp |
|
1066 | 964 |
__ mov(rcx, sender_sp_on_entry); |
1 | 965 |
// start with NULL previous state |
1066 | 966 |
__ movptr(state, (int32_t)NULL_WORD); |
1 | 967 |
generate_compute_interpreter_state(state, locals, rcx, true); |
968 |
||
969 |
#ifdef ASSERT |
|
970 |
{ Label L; |
|
1066 | 971 |
__ movptr(rax, STATE(_stack_base)); |
972 |
#ifdef _LP64 |
|
973 |
// duplicate the alignment rsp got after setting stack_base |
|
974 |
__ subptr(rax, frame::arg_reg_save_area_bytes); // windows |
|
2131 | 975 |
__ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI) |
1066 | 976 |
#endif // _LP64 |
977 |
__ cmpptr(rax, rsp); |
|
1 | 978 |
__ jcc(Assembler::equal, L); |
979 |
__ stop("broken stack frame setup in interpreter"); |
|
980 |
__ bind(L); |
|
981 |
} |
|
982 |
#endif |
|
983 |
||
984 |
if (inc_counter) __ movl(rcx, invocation_counter); // (pre-)fetch invocation count |
|
985 |
||
1066 | 986 |
const Register unlock_thread = LP64_ONLY(r15_thread) NOT_LP64(rax); |
987 |
NOT_LP64(__ movptr(unlock_thread, STATE(_thread));) // get thread |
|
1 | 988 |
// Since at this point in the method invocation the exception handler |
989 |
// would try to exit the monitor of synchronized methods which hasn't |
|
990 |
// been entered yet, we set the thread local variable |
|
991 |
// _do_not_unlock_if_synchronized to true. The remove_activation will |
|
992 |
// check this flag. |
|
993 |
||
1066 | 994 |
const Address do_not_unlock_if_synchronized(unlock_thread, |
1 | 995 |
in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); |
996 |
__ movbool(do_not_unlock_if_synchronized, true); |
|
997 |
||
998 |
// make sure method is native & not abstract |
|
999 |
#ifdef ASSERT |
|
1000 |
__ movl(rax, access_flags); |
|
1001 |
{ |
|
1002 |
Label L; |
|
1003 |
__ testl(rax, JVM_ACC_NATIVE); |
|
1004 |
__ jcc(Assembler::notZero, L); |
|
1005 |
__ stop("tried to execute non-native method as native"); |
|
1006 |
__ bind(L); |
|
1007 |
} |
|
1008 |
{ Label L; |
|
1009 |
__ testl(rax, JVM_ACC_ABSTRACT); |
|
1010 |
__ jcc(Assembler::zero, L); |
|
1011 |
__ stop("tried to execute abstract method in interpreter"); |
|
1012 |
__ bind(L); |
|
1013 |
} |
|
1014 |
#endif |
|
1015 |
||
1016 |
||
1017 |
// increment invocation count & check for overflow |
|
1018 |
Label invocation_counter_overflow; |
|
1019 |
if (inc_counter) { |
|
1020 |
generate_counter_incr(&invocation_counter_overflow, NULL, NULL); |
|
1021 |
} |
|
1022 |
||
1023 |
Label continue_after_compile; |
|
1024 |
||
1025 |
__ bind(continue_after_compile); |
|
1026 |
||
1027 |
bang_stack_shadow_pages(true); |
|
1028 |
||
1029 |
// reset the _do_not_unlock_if_synchronized flag |
|
1066 | 1030 |
NOT_LP64(__ movl(rax, STATE(_thread));) // get thread |
1 | 1031 |
__ movbool(do_not_unlock_if_synchronized, false); |
1032 |
||
1033 |
||
1034 |
// check for synchronized native methods |
|
1035 |
// |
|
1036 |
// Note: This must happen *after* invocation counter check, since |
|
1037 |
// when overflow happens, the method should not be locked. |
|
1038 |
if (synchronized) { |
|
1039 |
// potentially kills rax, rcx, rdx, rdi |
|
1040 |
lock_method(); |
|
1041 |
} else { |
|
1042 |
// no synchronization necessary |
|
1043 |
#ifdef ASSERT |
|
1044 |
{ Label L; |
|
1045 |
__ movl(rax, access_flags); |
|
1046 |
__ testl(rax, JVM_ACC_SYNCHRONIZED); |
|
1047 |
__ jcc(Assembler::zero, L); |
|
1048 |
__ stop("method needs synchronization"); |
|
1049 |
__ bind(L); |
|
1050 |
} |
|
1051 |
#endif |
|
1052 |
} |
|
1053 |
||
1054 |
// start execution |
|
1055 |
||
1056 |
// jvmti support |
|
1057 |
__ notify_method_entry(); |
|
1058 |
||
1059 |
// work registers |
|
1060 |
const Register method = rbx; |
|
1066 | 1061 |
const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rdi); |
1062 |
const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); // rcx|rscratch1 |
|
1 | 1063 |
|
1064 |
// allocate space for parameters |
|
1066 | 1065 |
__ movptr(method, STATE(_method)); |
1 | 1066 |
__ verify_oop(method); |
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
1067 |
__ load_unsigned_short(t, Address(method, methodOopDesc::size_of_parameters_offset())); |
1 | 1068 |
__ shll(t, 2); |
1066 | 1069 |
#ifdef _LP64 |
1070 |
__ subptr(rsp, t); |
|
1071 |
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
|
2131 | 1072 |
__ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI) |
1066 | 1073 |
#else |
1074 |
__ addptr(t, 2*wordSize); // allocate two more slots for JNIEnv and possible mirror |
|
1075 |
__ subptr(rsp, t); |
|
1076 |
__ andptr(rsp, -(StackAlignmentInBytes)); // gcc needs 16 byte aligned stacks to do XMM intrinsics |
|
1077 |
#endif // _LP64 |
|
1 | 1078 |
|
1079 |
// get signature handler |
|
1080 |
Label pending_exception_present; |
|
1081 |
||
1082 |
{ Label L; |
|
1066 | 1083 |
__ movptr(t, Address(method, methodOopDesc::signature_handler_offset())); |
1084 |
__ testptr(t, t); |
|
1 | 1085 |
__ jcc(Assembler::notZero, L); |
1086 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method, false); |
|
1066 | 1087 |
__ movptr(method, STATE(_method)); |
1088 |
__ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
|
1 | 1089 |
__ jcc(Assembler::notEqual, pending_exception_present); |
1090 |
__ verify_oop(method); |
|
1066 | 1091 |
__ movptr(t, Address(method, methodOopDesc::signature_handler_offset())); |
1 | 1092 |
__ bind(L); |
1093 |
} |
|
1094 |
#ifdef ASSERT |
|
1095 |
{ |
|
1096 |
Label L; |
|
1066 | 1097 |
__ push(t); |
1 | 1098 |
__ get_thread(t); // get vm's javathread* |
1066 | 1099 |
__ cmpptr(t, STATE(_thread)); |
1 | 1100 |
__ jcc(Assembler::equal, L); |
1101 |
__ int3(); |
|
1102 |
__ bind(L); |
|
1066 | 1103 |
__ pop(t); |
1 | 1104 |
} |
1105 |
#endif // |
|
1106 |
||
1066 | 1107 |
const Register from_ptr = InterpreterRuntime::SignatureHandlerGenerator::from(); |
1 | 1108 |
// call signature handler |
1109 |
assert(InterpreterRuntime::SignatureHandlerGenerator::to () == rsp, "adjust this code"); |
|
1066 | 1110 |
|
1 | 1111 |
// The generated handlers do not touch RBX (the method oop). |
1112 |
// However, large signatures cannot be cached and are generated |
|
1113 |
// each time here. The slow-path generator will blow RBX |
|
1114 |
// sometime, so we must reload it after the call. |
|
1066 | 1115 |
__ movptr(from_ptr, STATE(_locals)); // get the from pointer |
1 | 1116 |
__ call(t); |
1066 | 1117 |
__ movptr(method, STATE(_method)); |
1 | 1118 |
__ verify_oop(method); |
1119 |
||
1120 |
// result handler is in rax |
|
1121 |
// set result handler |
|
1066 | 1122 |
__ movptr(STATE(_result_handler), rax); |
1123 |
||
1124 |
||
1125 |
// get native function entry point |
|
1126 |
{ Label L; |
|
1127 |
__ movptr(rax, Address(method, methodOopDesc::native_function_offset())); |
|
1128 |
__ testptr(rax, rax); |
|
1129 |
__ jcc(Assembler::notZero, L); |
|
1130 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method); |
|
1131 |
__ movptr(method, STATE(_method)); |
|
1132 |
__ verify_oop(method); |
|
1133 |
__ movptr(rax, Address(method, methodOopDesc::native_function_offset())); |
|
1134 |
__ bind(L); |
|
1135 |
} |
|
1 | 1136 |
|
1137 |
// pass mirror handle if static call |
|
1138 |
{ Label L; |
|
1139 |
const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); |
|
1140 |
__ movl(t, Address(method, methodOopDesc::access_flags_offset())); |
|
1141 |
__ testl(t, JVM_ACC_STATIC); |
|
1142 |
__ jcc(Assembler::zero, L); |
|
1143 |
// get mirror |
|
1066 | 1144 |
__ movptr(t, Address(method, methodOopDesc:: constants_offset())); |
1145 |
__ movptr(t, Address(t, constantPoolOopDesc::pool_holder_offset_in_bytes())); |
|
1146 |
__ movptr(t, Address(t, mirror_offset)); |
|
1 | 1147 |
// copy mirror into activation object |
1066 | 1148 |
__ movptr(STATE(_oop_temp), t); |
1 | 1149 |
// pass handle to mirror |
1066 | 1150 |
#ifdef _LP64 |
1151 |
__ lea(c_rarg1, STATE(_oop_temp)); |
|
1152 |
#else |
|
1153 |
__ lea(t, STATE(_oop_temp)); |
|
1154 |
__ movptr(Address(rsp, wordSize), t); |
|
1155 |
#endif // _LP64 |
|
1 | 1156 |
__ bind(L); |
1157 |
} |
|
1158 |
#ifdef ASSERT |
|
1159 |
{ |
|
1160 |
Label L; |
|
1066 | 1161 |
__ push(t); |
1 | 1162 |
__ get_thread(t); // get vm's javathread* |
1066 | 1163 |
__ cmpptr(t, STATE(_thread)); |
1 | 1164 |
__ jcc(Assembler::equal, L); |
1165 |
__ int3(); |
|
1166 |
__ bind(L); |
|
1066 | 1167 |
__ pop(t); |
1 | 1168 |
} |
1169 |
#endif // |
|
1170 |
||
1171 |
// pass JNIEnv |
|
1066 | 1172 |
#ifdef _LP64 |
1173 |
__ lea(c_rarg0, Address(thread, JavaThread::jni_environment_offset())); |
|
1174 |
#else |
|
1175 |
__ movptr(thread, STATE(_thread)); // get thread |
|
1176 |
__ lea(t, Address(thread, JavaThread::jni_environment_offset())); |
|
1177 |
||
1178 |
__ movptr(Address(rsp, 0), t); |
|
1179 |
#endif // _LP64 |
|
1180 |
||
1 | 1181 |
#ifdef ASSERT |
1182 |
{ |
|
1183 |
Label L; |
|
1066 | 1184 |
__ push(t); |
1 | 1185 |
__ get_thread(t); // get vm's javathread* |
1066 | 1186 |
__ cmpptr(t, STATE(_thread)); |
1 | 1187 |
__ jcc(Assembler::equal, L); |
1188 |
__ int3(); |
|
1189 |
__ bind(L); |
|
1066 | 1190 |
__ pop(t); |
1 | 1191 |
} |
1192 |
#endif // |
|
1193 |
||
1194 |
#ifdef ASSERT |
|
1195 |
{ Label L; |
|
1196 |
__ movl(t, Address(thread, JavaThread::thread_state_offset())); |
|
1197 |
__ cmpl(t, _thread_in_Java); |
|
1198 |
__ jcc(Assembler::equal, L); |
|
1199 |
__ stop("Wrong thread state in native stub"); |
|
1200 |
__ bind(L); |
|
1201 |
} |
|
1202 |
#endif |
|
1203 |
||
1204 |
// Change state to native (we save the return address in the thread, since it might not |
|
1205 |
// be pushed on the stack when we do a a stack traversal). It is enough that the pc() |
|
1206 |
// points into the right code segment. It does not have to be the correct return pc. |
|
1207 |
||
1208 |
__ set_last_Java_frame(thread, noreg, rbp, __ pc()); |
|
1209 |
||
1210 |
__ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native); |
|
1211 |
||
1212 |
__ call(rax); |
|
1213 |
||
1214 |
// result potentially in rdx:rax or ST0 |
|
1066 | 1215 |
__ movptr(method, STATE(_method)); |
1216 |
NOT_LP64(__ movptr(thread, STATE(_thread));) // get thread |
|
1 | 1217 |
|
1218 |
// The potential result is in ST(0) & rdx:rax |
|
1219 |
// With C++ interpreter we leave any possible result in ST(0) until we are in result handler and then |
|
1220 |
// we do the appropriate stuff for returning the result. rdx:rax must always be saved because just about |
|
1221 |
// anything we do here will destroy it, st(0) is only saved if we re-enter the vm where it would |
|
1222 |
// be destroyed. |
|
1223 |
// It is safe to do these pushes because state is _thread_in_native and return address will be found |
|
1224 |
// via _last_native_pc and not via _last_jave_sp |
|
1225 |
||
1066 | 1226 |
// Must save the value of ST(0)/xmm0 since it could be destroyed before we get to result handler |
1 | 1227 |
{ Label Lpush, Lskip; |
1228 |
ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT)); |
|
1229 |
ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE)); |
|
1230 |
__ cmpptr(STATE(_result_handler), float_handler.addr()); |
|
1231 |
__ jcc(Assembler::equal, Lpush); |
|
1232 |
__ cmpptr(STATE(_result_handler), double_handler.addr()); |
|
1233 |
__ jcc(Assembler::notEqual, Lskip); |
|
1234 |
__ bind(Lpush); |
|
1066 | 1235 |
__ subptr(rsp, 2*wordSize); |
1236 |
if ( UseSSE < 2 ) { |
|
1237 |
__ fstp_d(Address(rsp, 0)); |
|
1238 |
} else { |
|
1239 |
__ movdbl(Address(rsp, 0), xmm0); |
|
1240 |
} |
|
1 | 1241 |
__ bind(Lskip); |
1242 |
} |
|
1243 |
||
1066 | 1244 |
// save rax:rdx for potential use by result handler. |
1245 |
__ push(rax); |
|
1246 |
#ifndef _LP64 |
|
1247 |
__ push(rdx); |
|
1248 |
#endif // _LP64 |
|
1 | 1249 |
|
1250 |
// Either restore the MXCSR register after returning from the JNI Call |
|
1251 |
// or verify that it wasn't changed. |
|
1252 |
if (VM_Version::supports_sse()) { |
|
1253 |
if (RestoreMXCSROnJNICalls) { |
|
1254 |
__ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); |
|
1255 |
} |
|
1256 |
else if (CheckJNICalls ) { |
|
1066 | 1257 |
__ call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); |
1 | 1258 |
} |
1259 |
} |
|
1260 |
||
1066 | 1261 |
#ifndef _LP64 |
1 | 1262 |
// Either restore the x87 floating pointer control word after returning |
1263 |
// from the JNI call or verify that it wasn't changed. |
|
1264 |
if (CheckJNICalls) { |
|
1066 | 1265 |
__ call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); |
1 | 1266 |
} |
1066 | 1267 |
#endif // _LP64 |
1 | 1268 |
|
1269 |
||
1270 |
// change thread state |
|
1271 |
__ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans); |
|
1272 |
if(os::is_MP()) { |
|
1273 |
// Write serialization page so VM thread can do a pseudo remote membar. |
|
1274 |
// We use the current thread pointer to calculate a thread specific |
|
1275 |
// offset to write to within the page. This minimizes bus traffic |
|
1276 |
// due to cache line collision. |
|
1277 |
__ serialize_memory(thread, rcx); |
|
1278 |
} |
|
1279 |
||
1280 |
// check for safepoint operation in progress and/or pending suspend requests |
|
1281 |
{ Label Continue; |
|
1282 |
||
1283 |
__ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), |
|
1284 |
SafepointSynchronize::_not_synchronized); |
|
1285 |
||
1286 |
// threads running native code and they are expected to self-suspend |
|
1287 |
// when leaving the _thread_in_native state. We need to check for |
|
1288 |
// pending suspend requests here. |
|
1289 |
Label L; |
|
1290 |
__ jcc(Assembler::notEqual, L); |
|
1291 |
__ cmpl(Address(thread, JavaThread::suspend_flags_offset()), 0); |
|
1292 |
__ jcc(Assembler::equal, Continue); |
|
1293 |
__ bind(L); |
|
1294 |
||
1295 |
// Don't use call_VM as it will see a possible pending exception and forward it |
|
1296 |
// and never return here preventing us from clearing _last_native_pc down below. |
|
1297 |
// Also can't use call_VM_leaf either as it will check to see if rsi & rdi are |
|
1066 | 1298 |
// preserved and correspond to the bcp/locals pointers. |
1 | 1299 |
// |
1066 | 1300 |
|
1301 |
((MacroAssembler*)_masm)->call_VM_leaf(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans), |
|
1302 |
thread); |
|
1 | 1303 |
__ increment(rsp, wordSize); |
1304 |
||
1066 | 1305 |
__ movptr(method, STATE(_method)); |
1 | 1306 |
__ verify_oop(method); |
1066 | 1307 |
__ movptr(thread, STATE(_thread)); // get thread |
1 | 1308 |
|
1309 |
__ bind(Continue); |
|
1310 |
} |
|
1311 |
||
1312 |
// change thread state |
|
1313 |
__ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java); |
|
1314 |
||
1315 |
__ reset_last_Java_frame(thread, true, true); |
|
1316 |
||
1317 |
// reset handle block |
|
1066 | 1318 |
__ movptr(t, Address(thread, JavaThread::active_handles_offset())); |
1319 |
__ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); |
|
1 | 1320 |
|
1321 |
// If result was an oop then unbox and save it in the frame |
|
1322 |
{ Label L; |
|
1323 |
Label no_oop, store_result; |
|
1324 |
ExternalAddress oop_handler(AbstractInterpreter::result_handler(T_OBJECT)); |
|
1325 |
__ cmpptr(STATE(_result_handler), oop_handler.addr()); |
|
1326 |
__ jcc(Assembler::notEqual, no_oop); |
|
1066 | 1327 |
#ifndef _LP64 |
1328 |
__ pop(rdx); |
|
1329 |
#endif // _LP64 |
|
1330 |
__ pop(rax); |
|
1331 |
__ testptr(rax, rax); |
|
1 | 1332 |
__ jcc(Assembler::zero, store_result); |
1333 |
// unbox |
|
1066 | 1334 |
__ movptr(rax, Address(rax, 0)); |
1 | 1335 |
__ bind(store_result); |
1066 | 1336 |
__ movptr(STATE(_oop_temp), rax); |
1 | 1337 |
// keep stack depth as expected by pushing oop which will eventually be discarded |
1066 | 1338 |
__ push(rax); |
1339 |
#ifndef _LP64 |
|
1340 |
__ push(rdx); |
|
1341 |
#endif // _LP64 |
|
1 | 1342 |
__ bind(no_oop); |
1343 |
} |
|
1344 |
||
1345 |
{ |
|
1346 |
Label no_reguard; |
|
1347 |
__ cmpl(Address(thread, JavaThread::stack_guard_state_offset()), JavaThread::stack_guard_yellow_disabled); |
|
1348 |
__ jcc(Assembler::notEqual, no_reguard); |
|
1349 |
||
1066 | 1350 |
__ pusha(); |
1 | 1351 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages))); |
1066 | 1352 |
__ popa(); |
1 | 1353 |
|
1354 |
__ bind(no_reguard); |
|
1355 |
} |
|
1356 |
||
1357 |
||
1358 |
// QQQ Seems like for native methods we simply return and the caller will see the pending |
|
1359 |
// exception and do the right thing. Certainly the interpreter will, don't know about |
|
1360 |
// compiled methods. |
|
1361 |
// Seems that the answer to above is no this is wrong. The old code would see the exception |
|
1362 |
// and forward it before doing the unlocking and notifying jvmdi that method has exited. |
|
1363 |
// This seems wrong need to investigate the spec. |
|
1364 |
||
1365 |
// handle exceptions (exception handling will handle unlocking!) |
|
1366 |
{ Label L; |
|
1066 | 1367 |
__ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
1 | 1368 |
__ jcc(Assembler::zero, L); |
1369 |
__ bind(pending_exception_present); |
|
1370 |
||
1371 |
// There are potential results on the stack (rax/rdx, ST(0)) we ignore these and simply |
|
1372 |
// return and let caller deal with exception. This skips the unlocking here which |
|
1373 |
// seems wrong but seems to be what asm interpreter did. Can't find this in the spec. |
|
1374 |
// Note: must preverve method in rbx |
|
1375 |
// |
|
1376 |
||
1377 |
// remove activation |
|
1378 |
||
1066 | 1379 |
__ movptr(t, STATE(_sender_sp)); |
1 | 1380 |
__ leave(); // remove frame anchor |
1066 | 1381 |
__ pop(rdi); // get return address |
1382 |
__ movptr(state, STATE(_prev_link)); // get previous state for return |
|
1383 |
__ mov(rsp, t); // set sp to sender sp |
|
1384 |
__ push(rdi); // push throwing pc |
|
1 | 1385 |
// The skips unlocking!! This seems to be what asm interpreter does but seems |
1386 |
// very wrong. Not clear if this violates the spec. |
|
1387 |
__ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); |
|
1388 |
__ bind(L); |
|
1389 |
} |
|
1390 |
||
1391 |
// do unlocking if necessary |
|
1392 |
{ Label L; |
|
1393 |
__ movl(t, Address(method, methodOopDesc::access_flags_offset())); |
|
1394 |
__ testl(t, JVM_ACC_SYNCHRONIZED); |
|
1395 |
__ jcc(Assembler::zero, L); |
|
1396 |
// the code below should be shared with interpreter macro assembler implementation |
|
1397 |
{ Label unlock; |
|
1066 | 1398 |
const Register monitor = NOT_LP64(rdx) LP64_ONLY(c_rarg1); |
1 | 1399 |
// BasicObjectLock will be first in list, since this is a synchronized method. However, need |
1400 |
// to check that the object has not been unlocked by an explicit monitorexit bytecode. |
|
1066 | 1401 |
__ movptr(monitor, STATE(_monitor_base)); |
1402 |
__ subptr(monitor, frame::interpreter_frame_monitor_size() * wordSize); // address of initial monitor |
|
1403 |
||
1404 |
__ movptr(t, Address(monitor, BasicObjectLock::obj_offset_in_bytes())); |
|
1405 |
__ testptr(t, t); |
|
1 | 1406 |
__ jcc(Assembler::notZero, unlock); |
1407 |
||
1408 |
// Entry already unlocked, need to throw exception |
|
1409 |
__ MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); |
|
1410 |
__ should_not_reach_here(); |
|
1411 |
||
1412 |
__ bind(unlock); |
|
1066 | 1413 |
__ unlock_object(monitor); |
1 | 1414 |
// unlock can blow rbx so restore it for path that needs it below |
1066 | 1415 |
__ movptr(method, STATE(_method)); |
1 | 1416 |
} |
1417 |
__ bind(L); |
|
1418 |
} |
|
1419 |
||
1420 |
// jvmti support |
|
1421 |
// Note: This must happen _after_ handling/throwing any exceptions since |
|
1422 |
// the exception handler code notifies the runtime of method exits |
|
1423 |
// too. If this happens before, method entry/exit notifications are |
|
1424 |
// not properly paired (was bug - gri 11/22/99). |
|
1425 |
__ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI); |
|
1426 |
||
1427 |
// restore potential result in rdx:rax, call result handler to restore potential result in ST0 & handle result |
|
1066 | 1428 |
#ifndef _LP64 |
1429 |
__ pop(rdx); |
|
1430 |
#endif // _LP64 |
|
1431 |
__ pop(rax); |
|
1432 |
__ movptr(t, STATE(_result_handler)); // get result handler |
|
1 | 1433 |
__ call(t); // call result handler to convert to tosca form |
1434 |
||
1435 |
// remove activation |
|
1436 |
||
1066 | 1437 |
__ movptr(t, STATE(_sender_sp)); |
1 | 1438 |
|
1439 |
__ leave(); // remove frame anchor |
|
1066 | 1440 |
__ pop(rdi); // get return address |
1441 |
__ movptr(state, STATE(_prev_link)); // get previous state for return (if c++ interpreter was caller) |
|
1442 |
__ mov(rsp, t); // set sp to sender sp |
|
1 | 1443 |
__ jmp(rdi); |
1444 |
||
1445 |
// invocation counter overflow |
|
1446 |
if (inc_counter) { |
|
1447 |
// Handle overflow of counter and compile method |
|
1448 |
__ bind(invocation_counter_overflow); |
|
1449 |
generate_counter_overflow(&continue_after_compile); |
|
1450 |
} |
|
1451 |
||
1452 |
return entry_point; |
|
1453 |
} |
|
1454 |
||
1455 |
// Generate entries that will put a result type index into rcx |
|
1456 |
void CppInterpreterGenerator::generate_deopt_handling() { |
|
1457 |
||
1458 |
Label return_from_deopt_common; |
|
1459 |
||
1460 |
// Generate entries that will put a result type index into rcx |
|
1461 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1462 |
deopt_frame_manager_return_atos = __ pc(); |
|
1463 |
||
1464 |
// rax is live here |
|
1465 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_OBJECT)); // Result stub address array index |
|
1466 |
__ jmp(return_from_deopt_common); |
|
1467 |
||
1468 |
||
1469 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1470 |
deopt_frame_manager_return_btos = __ pc(); |
|
1471 |
||
1472 |
// rax is live here |
|
1473 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_BOOLEAN)); // Result stub address array index |
|
1474 |
__ jmp(return_from_deopt_common); |
|
1475 |
||
1476 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1477 |
deopt_frame_manager_return_itos = __ pc(); |
|
1478 |
||
1479 |
// rax is live here |
|
1480 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_INT)); // Result stub address array index |
|
1481 |
__ jmp(return_from_deopt_common); |
|
1482 |
||
1483 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1484 |
||
1485 |
deopt_frame_manager_return_ltos = __ pc(); |
|
1486 |
// rax,rdx are live here |
|
1487 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_LONG)); // Result stub address array index |
|
1488 |
__ jmp(return_from_deopt_common); |
|
1489 |
||
1490 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1491 |
||
1492 |
deopt_frame_manager_return_ftos = __ pc(); |
|
1493 |
// st(0) is live here |
|
1494 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_FLOAT)); // Result stub address array index |
|
1495 |
__ jmp(return_from_deopt_common); |
|
1496 |
||
1497 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1498 |
deopt_frame_manager_return_dtos = __ pc(); |
|
1499 |
||
1500 |
// st(0) is live here |
|
1501 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_DOUBLE)); // Result stub address array index |
|
1502 |
__ jmp(return_from_deopt_common); |
|
1503 |
||
1504 |
// deopt needs to jump to here to enter the interpreter (return a result) |
|
1505 |
deopt_frame_manager_return_vtos = __ pc(); |
|
1506 |
||
1507 |
__ movl(rcx, AbstractInterpreter::BasicType_as_index(T_VOID)); |
|
1508 |
||
1509 |
// Deopt return common |
|
1510 |
// an index is present in rcx that lets us move any possible result being |
|
1511 |
// return to the interpreter's stack |
|
1512 |
// |
|
1513 |
// Because we have a full sized interpreter frame on the youngest |
|
1514 |
// activation the stack is pushed too deep to share the tosca to |
|
1515 |
// stack converters directly. We shrink the stack to the desired |
|
1516 |
// amount and then push result and then re-extend the stack. |
|
1517 |
// We could have the code in size_activation layout a short |
|
1518 |
// frame for the top activation but that would look different |
|
1519 |
// than say sparc (which needs a full size activation because |
|
1520 |
// the windows are in the way. Really it could be short? QQQ |
|
1521 |
// |
|
1522 |
__ bind(return_from_deopt_common); |
|
1523 |
||
1066 | 1524 |
__ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); |
1 | 1525 |
|
1526 |
// setup rsp so we can push the "result" as needed. |
|
1066 | 1527 |
__ movptr(rsp, STATE(_stack)); // trim stack (is prepushed) |
1528 |
__ addptr(rsp, wordSize); // undo prepush |
|
1 | 1529 |
|
1530 |
ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack); |
|
1066 | 1531 |
// Address index(noreg, rcx, Address::times_ptr); |
1532 |
__ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_ptr))); |
|
1533 |
// __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack))); |
|
1 | 1534 |
__ call(rcx); // call result converter |
1535 |
||
1536 |
__ movl(STATE(_msg), (int)BytecodeInterpreter::deopt_resume); |
|
1066 | 1537 |
__ lea(rsp, Address(rsp, -wordSize)); // prepush stack (result if any already present) |
1538 |
__ movptr(STATE(_stack), rsp); // inform interpreter of new stack depth (parameters removed, |
|
1 | 1539 |
// result if any on stack already ) |
1066 | 1540 |
__ movptr(rsp, STATE(_stack_limit)); // restore expression stack to full depth |
1 | 1541 |
} |
1542 |
||
1543 |
// Generate the code to handle a more_monitors message from the c++ interpreter |
|
1544 |
void CppInterpreterGenerator::generate_more_monitors() { |
|
1545 |
||
1546 |
||
1547 |
Label entry, loop; |
|
1548 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
1066 | 1549 |
// 1. compute new pointers // rsp: old expression stack top |
1550 |
__ movptr(rdx, STATE(_stack_base)); // rdx: old expression stack bottom |
|
1551 |
__ subptr(rsp, entry_size); // move expression stack top limit |
|
1552 |
__ subptr(STATE(_stack), entry_size); // update interpreter stack top |
|
1553 |
__ subptr(STATE(_stack_limit), entry_size); // inform interpreter |
|
1554 |
__ subptr(rdx, entry_size); // move expression stack bottom |
|
1555 |
__ movptr(STATE(_stack_base), rdx); // inform interpreter |
|
1556 |
__ movptr(rcx, STATE(_stack)); // set start value for copy loop |
|
1 | 1557 |
__ jmp(entry); |
1558 |
// 2. move expression stack contents |
|
1559 |
__ bind(loop); |
|
1066 | 1560 |
__ movptr(rbx, Address(rcx, entry_size)); // load expression stack word from old location |
1561 |
__ movptr(Address(rcx, 0), rbx); // and store it at new location |
|
1562 |
__ addptr(rcx, wordSize); // advance to next word |
|
1 | 1563 |
__ bind(entry); |
1066 | 1564 |
__ cmpptr(rcx, rdx); // check if bottom reached |
1565 |
__ jcc(Assembler::notEqual, loop); // if not at bottom then copy next word |
|
1 | 1566 |
// now zero the slot so we can find it. |
1066 | 1567 |
__ movptr(Address(rdx, BasicObjectLock::obj_offset_in_bytes()), (int32_t) NULL_WORD); |
1 | 1568 |
__ movl(STATE(_msg), (int)BytecodeInterpreter::got_monitors); |
1569 |
} |
|
1570 |
||
1571 |
||
1572 |
// Initial entry to C++ interpreter from the call_stub. |
|
1573 |
// This entry point is called the frame manager since it handles the generation |
|
1574 |
// of interpreter activation frames via requests directly from the vm (via call_stub) |
|
1575 |
// and via requests from the interpreter. The requests from the call_stub happen |
|
1576 |
// directly thru the entry point. Requests from the interpreter happen via returning |
|
1577 |
// from the interpreter and examining the message the interpreter has returned to |
|
1578 |
// the frame manager. The frame manager can take the following requests: |
|
1579 |
||
1580 |
// NO_REQUEST - error, should never happen. |
|
1581 |
// MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and |
|
1582 |
// allocate a new monitor. |
|
1583 |
// CALL_METHOD - setup a new activation to call a new method. Very similar to what |
|
1584 |
// happens during entry during the entry via the call stub. |
|
1585 |
// RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub. |
|
1586 |
// |
|
1587 |
// Arguments: |
|
1588 |
// |
|
1589 |
// rbx: methodOop |
|
1590 |
// rcx: receiver - unused (retrieved from stack as needed) |
|
1066 | 1591 |
// rsi/r13: previous frame manager state (NULL from the call_stub/c1/c2) |
1 | 1592 |
// |
1593 |
// |
|
1594 |
// Stack layout at entry |
|
1595 |
// |
|
1596 |
// [ return address ] <--- rsp |
|
1597 |
// [ parameter n ] |
|
1598 |
// ... |
|
1599 |
// [ parameter 1 ] |
|
1600 |
// [ expression stack ] |
|
1601 |
// |
|
1602 |
// |
|
1603 |
// We are free to blow any registers we like because the call_stub which brought us here |
|
1604 |
// initially has preserved the callee save registers already. |
|
1605 |
// |
|
1606 |
// |
|
1607 |
||
1608 |
static address interpreter_frame_manager = NULL; |
|
1609 |
||
1610 |
address InterpreterGenerator::generate_normal_entry(bool synchronized) { |
|
1611 |
||
1612 |
// rbx: methodOop |
|
1066 | 1613 |
// rsi/r13: sender sp |
1 | 1614 |
|
1615 |
// Because we redispatch "recursive" interpreter entries thru this same entry point |
|
1616 |
// the "input" register usage is a little strange and not what you expect coming |
|
1617 |
// from the call_stub. From the call stub rsi/rdi (current/previous) interpreter |
|
1618 |
// state are NULL but on "recursive" dispatches they are what you'd expect. |
|
1619 |
// rsi: current interpreter state (C++ interpreter) must preserve (null from call_stub/c1/c2) |
|
1620 |
||
1621 |
||
1622 |
// A single frame manager is plenty as we don't specialize for synchronized. We could and |
|
1623 |
// the code is pretty much ready. Would need to change the test below and for good measure |
|
1624 |
// modify generate_interpreter_state to only do the (pre) sync stuff stuff for synchronized |
|
1625 |
// routines. Not clear this is worth it yet. |
|
1626 |
||
1627 |
if (interpreter_frame_manager) return interpreter_frame_manager; |
|
1628 |
||
1629 |
address entry_point = __ pc(); |
|
1630 |
||
1631 |
// Fast accessor methods share this entry point. |
|
1632 |
// This works because frame manager is in the same codelet |
|
1633 |
if (UseFastAccessorMethods && !synchronized) __ bind(fast_accessor_slow_entry_path); |
|
1634 |
||
1635 |
Label dispatch_entry_2; |
|
1066 | 1636 |
__ movptr(rcx, sender_sp_on_entry); |
1637 |
__ movptr(state, (int32_t)NULL_WORD); // no current activation |
|
1 | 1638 |
|
1639 |
__ jmp(dispatch_entry_2); |
|
1640 |
||
1641 |
const Register locals = rdi; |
|
1642 |
||
1643 |
Label re_dispatch; |
|
1644 |
||
1645 |
__ bind(re_dispatch); |
|
1646 |
||
1647 |
// save sender sp (doesn't include return address |
|
1066 | 1648 |
__ lea(rcx, Address(rsp, wordSize)); |
1 | 1649 |
|
1650 |
__ bind(dispatch_entry_2); |
|
1651 |
||
1652 |
// save sender sp |
|
1066 | 1653 |
__ push(rcx); |
1 | 1654 |
|
1655 |
const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset()); |
|
1656 |
const Address size_of_locals (rbx, methodOopDesc::size_of_locals_offset()); |
|
1657 |
const Address access_flags (rbx, methodOopDesc::access_flags_offset()); |
|
1658 |
||
1659 |
// const Address monitor_block_top (rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); |
|
1660 |
// const Address monitor_block_bot (rbp, frame::interpreter_frame_initial_sp_offset * wordSize); |
|
1661 |
// const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * wordSize - (int)sizeof(BasicObjectLock)); |
|
1662 |
||
1663 |
// get parameter size (always needed) |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
1664 |
__ load_unsigned_short(rcx, size_of_parameters); |
1 | 1665 |
|
1666 |
// rbx: methodOop |
|
1667 |
// rcx: size of parameters |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
1668 |
__ load_unsigned_short(rdx, size_of_locals); // get size of locals in words |
1 | 1669 |
|
1066 | 1670 |
__ subptr(rdx, rcx); // rdx = no. of additional locals |
1 | 1671 |
|
1672 |
// see if we've got enough room on the stack for locals plus overhead. |
|
1673 |
generate_stack_overflow_check(); // C++ |
|
1674 |
||
1675 |
// c++ interpreter does not use stack banging or any implicit exceptions |
|
1676 |
// leave for now to verify that check is proper. |
|
1677 |
bang_stack_shadow_pages(false); |
|
1678 |
||
1679 |
||
1680 |
||
1681 |
// compute beginning of parameters (rdi) |
|
1066 | 1682 |
__ lea(locals, Address(rsp, rcx, Address::times_ptr, wordSize)); |
1 | 1683 |
|
1684 |
// save sender's sp |
|
1685 |
// __ movl(rcx, rsp); |
|
1686 |
||
1687 |
// get sender's sp |
|
1066 | 1688 |
__ pop(rcx); |
1 | 1689 |
|
1690 |
// get return address |
|
1066 | 1691 |
__ pop(rax); |
1 | 1692 |
|
1693 |
// rdx - # of additional locals |
|
1694 |
// allocate space for locals |
|
1695 |
// explicitly initialize locals |
|
1696 |
{ |
|
1697 |
Label exit, loop; |
|
1066 | 1698 |
__ testl(rdx, rdx); // (32bit ok) |
1 | 1699 |
__ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0 |
1700 |
__ bind(loop); |
|
1066 | 1701 |
__ push((int32_t)NULL_WORD); // initialize local variables |
1 | 1702 |
__ decrement(rdx); // until everything initialized |
1703 |
__ jcc(Assembler::greater, loop); |
|
1704 |
__ bind(exit); |
|
1705 |
} |
|
1706 |
||
1707 |
||
1708 |
// Assumes rax = return address |
|
1709 |
||
1710 |
// allocate and initialize new interpreterState and method expression stack |
|
1711 |
// IN(locals) -> locals |
|
1712 |
// IN(state) -> any current interpreter activation |
|
1713 |
// destroys rax, rcx, rdx, rdi |
|
1714 |
// OUT (state) -> new interpreterState |
|
1715 |
// OUT(rsp) -> bottom of methods expression stack |
|
1716 |
||
1717 |
generate_compute_interpreter_state(state, locals, rcx, false); |
|
1718 |
||
1719 |
// Call interpreter |
|
1720 |
||
1721 |
Label call_interpreter; |
|
1722 |
__ bind(call_interpreter); |
|
1723 |
||
1724 |
// c++ interpreter does not use stack banging or any implicit exceptions |
|
1725 |
// leave for now to verify that check is proper. |
|
1726 |
bang_stack_shadow_pages(false); |
|
1727 |
||
1728 |
||
1729 |
// Call interpreter enter here if message is |
|
1730 |
// set and we know stack size is valid |
|
1731 |
||
1732 |
Label call_interpreter_2; |
|
1733 |
||
1734 |
__ bind(call_interpreter_2); |
|
1735 |
||
1736 |
{ |
|
1066 | 1737 |
const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread); |
1738 |
||
1739 |
#ifdef _LP64 |
|
1740 |
__ mov(c_rarg0, state); |
|
1741 |
#else |
|
1742 |
__ push(state); // push arg to interpreter |
|
1743 |
__ movptr(thread, STATE(_thread)); |
|
1744 |
#endif // _LP64 |
|
1 | 1745 |
|
1746 |
// We can setup the frame anchor with everything we want at this point |
|
1747 |
// as we are thread_in_Java and no safepoints can occur until we go to |
|
1748 |
// vm mode. We do have to clear flags on return from vm but that is it |
|
1749 |
// |
|
1066 | 1750 |
__ movptr(Address(thread, JavaThread::last_Java_fp_offset()), rbp); |
1751 |
__ movptr(Address(thread, JavaThread::last_Java_sp_offset()), rsp); |
|
1 | 1752 |
|
1753 |
// Call the interpreter |
|
1754 |
||
1755 |
RuntimeAddress normal(CAST_FROM_FN_PTR(address, BytecodeInterpreter::run)); |
|
1756 |
RuntimeAddress checking(CAST_FROM_FN_PTR(address, BytecodeInterpreter::runWithChecks)); |
|
1757 |
||
1758 |
__ call(JvmtiExport::can_post_interpreter_events() ? checking : normal); |
|
1066 | 1759 |
NOT_LP64(__ pop(rax);) // discard parameter to run |
1 | 1760 |
// |
1761 |
// state is preserved since it is callee saved |
|
1762 |
// |
|
1763 |
||
1764 |
// reset_last_Java_frame |
|
1765 |
||
1066 | 1766 |
NOT_LP64(__ movl(thread, STATE(_thread));) |
1 | 1767 |
__ reset_last_Java_frame(thread, true, true); |
1768 |
} |
|
1769 |
||
1770 |
// examine msg from interpreter to determine next action |
|
1771 |
||
1772 |
__ movl(rdx, STATE(_msg)); // Get new message |
|
1773 |
||
1774 |
Label call_method; |
|
1775 |
Label return_from_interpreted_method; |
|
1776 |
Label throw_exception; |
|
1777 |
Label bad_msg; |
|
1778 |
Label do_OSR; |
|
1779 |
||
1066 | 1780 |
__ cmpl(rdx, (int32_t)BytecodeInterpreter::call_method); |
1 | 1781 |
__ jcc(Assembler::equal, call_method); |
1066 | 1782 |
__ cmpl(rdx, (int32_t)BytecodeInterpreter::return_from_method); |
1 | 1783 |
__ jcc(Assembler::equal, return_from_interpreted_method); |
1066 | 1784 |
__ cmpl(rdx, (int32_t)BytecodeInterpreter::do_osr); |
1 | 1785 |
__ jcc(Assembler::equal, do_OSR); |
1066 | 1786 |
__ cmpl(rdx, (int32_t)BytecodeInterpreter::throwing_exception); |
1 | 1787 |
__ jcc(Assembler::equal, throw_exception); |
1066 | 1788 |
__ cmpl(rdx, (int32_t)BytecodeInterpreter::more_monitors); |
1 | 1789 |
__ jcc(Assembler::notEqual, bad_msg); |
1790 |
||
1791 |
// Allocate more monitor space, shuffle expression stack.... |
|
1792 |
||
1793 |
generate_more_monitors(); |
|
1794 |
||
1795 |
__ jmp(call_interpreter); |
|
1796 |
||
1797 |
// uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode) |
|
1798 |
unctrap_frame_manager_entry = __ pc(); |
|
1799 |
// |
|
1800 |
// Load the registers we need. |
|
1066 | 1801 |
__ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); |
1802 |
__ movptr(rsp, STATE(_stack_limit)); // restore expression stack to full depth |
|
1 | 1803 |
__ jmp(call_interpreter_2); |
1804 |
||
1805 |
||
1806 |
||
1807 |
//============================================================================= |
|
1808 |
// Returning from a compiled method into a deopted method. The bytecode at the |
|
1809 |
// bcp has completed. The result of the bytecode is in the native abi (the tosca |
|
1810 |
// for the template based interpreter). Any stack space that was used by the |
|
1811 |
// bytecode that has completed has been removed (e.g. parameters for an invoke) |
|
1812 |
// so all that we have to do is place any pending result on the expression stack |
|
1813 |
// and resume execution on the next bytecode. |
|
1814 |
||
1815 |
||
1816 |
generate_deopt_handling(); |
|
1817 |
__ jmp(call_interpreter); |
|
1818 |
||
1819 |
||
1820 |
// Current frame has caught an exception we need to dispatch to the |
|
1821 |
// handler. We can get here because a native interpreter frame caught |
|
1822 |
// an exception in which case there is no handler and we must rethrow |
|
1823 |
// If it is a vanilla interpreted frame the we simply drop into the |
|
1824 |
// interpreter and let it do the lookup. |
|
1825 |
||
1826 |
Interpreter::_rethrow_exception_entry = __ pc(); |
|
1827 |
// rax: exception |
|
1828 |
// rdx: return address/pc that threw exception |
|
1829 |
||
1830 |
Label return_with_exception; |
|
1831 |
Label unwind_and_forward; |
|
1832 |
||
1833 |
// restore state pointer. |
|
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
1834 |
__ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); |
1066 | 1835 |
|
1836 |
__ movptr(rbx, STATE(_method)); // get method |
|
1837 |
#ifdef _LP64 |
|
1838 |
__ movptr(Address(r15_thread, Thread::pending_exception_offset()), rax); |
|
1839 |
#else |
|
1 | 1840 |
__ movl(rcx, STATE(_thread)); // get thread |
1841 |
||
1842 |
// Store exception with interpreter will expect it |
|
1066 | 1843 |
__ movptr(Address(rcx, Thread::pending_exception_offset()), rax); |
1844 |
#endif // _LP64 |
|
1 | 1845 |
|
1846 |
// is current frame vanilla or native? |
|
1847 |
||
1848 |
__ movl(rdx, access_flags); |
|
1849 |
__ testl(rdx, JVM_ACC_NATIVE); |
|
1850 |
__ jcc(Assembler::zero, return_with_exception); // vanilla interpreted frame, handle directly |
|
1851 |
||
1852 |
// We drop thru to unwind a native interpreted frame with a pending exception |
|
1853 |
// We jump here for the initial interpreter frame with exception pending |
|
1854 |
// We unwind the current acivation and forward it to our caller. |
|
1855 |
||
1856 |
__ bind(unwind_and_forward); |
|
1857 |
||
1858 |
// unwind rbp, return stack to unextended value and re-push return address |
|
1859 |
||
1066 | 1860 |
__ movptr(rcx, STATE(_sender_sp)); |
1 | 1861 |
__ leave(); |
1066 | 1862 |
__ pop(rdx); |
1863 |
__ mov(rsp, rcx); |
|
1864 |
__ push(rdx); |
|
1 | 1865 |
__ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); |
1866 |
||
1867 |
// Return point from a call which returns a result in the native abi |
|
1868 |
// (c1/c2/jni-native). This result must be processed onto the java |
|
1869 |
// expression stack. |
|
1870 |
// |
|
1871 |
// A pending exception may be present in which case there is no result present |
|
1872 |
||
1873 |
Label resume_interpreter; |
|
1874 |
Label do_float; |
|
1875 |
Label do_double; |
|
1876 |
Label done_conv; |
|
1877 |
||
1878 |
address compiled_entry = __ pc(); |
|
1879 |
||
1880 |
// The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases |
|
1881 |
if (UseSSE < 2) { |
|
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
1882 |
__ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); |
1066 | 1883 |
__ movptr(rbx, STATE(_result._to_call._callee)); // get method just executed |
1 | 1884 |
__ movl(rcx, Address(rbx, methodOopDesc::result_index_offset())); |
1885 |
__ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_FLOAT)); // Result stub address array index |
|
1886 |
__ jcc(Assembler::equal, do_float); |
|
1887 |
__ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_DOUBLE)); // Result stub address array index |
|
1888 |
__ jcc(Assembler::equal, do_double); |
|
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
1889 |
#if !defined(_LP64) || defined(COMPILER1) || !defined(COMPILER2) |
1 | 1890 |
__ empty_FPU_stack(); |
1891 |
#endif // COMPILER2 |
|
1892 |
__ jmp(done_conv); |
|
1893 |
||
1894 |
__ bind(do_float); |
|
1895 |
#ifdef COMPILER2 |
|
1896 |
for (int i = 1; i < 8; i++) { |
|
1897 |
__ ffree(i); |
|
1898 |
} |
|
1899 |
#endif // COMPILER2 |
|
1900 |
__ jmp(done_conv); |
|
1901 |
__ bind(do_double); |
|
1902 |
#ifdef COMPILER2 |
|
1903 |
for (int i = 1; i < 8; i++) { |
|
1904 |
__ ffree(i); |
|
1905 |
} |
|
1906 |
#endif // COMPILER2 |
|
1907 |
__ jmp(done_conv); |
|
1908 |
} else { |
|
1909 |
__ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled"); |
|
1910 |
__ jmp(done_conv); |
|
1911 |
} |
|
1912 |
||
1066 | 1913 |
#if 0 |
1 | 1914 |
// emit a sentinel we can test for when converting an interpreter |
1915 |
// entry point to a compiled entry point. |
|
1916 |
__ a_long(Interpreter::return_sentinel); |
|
1917 |
__ a_long((int)compiled_entry); |
|
1066 | 1918 |
#endif |
1 | 1919 |
|
1920 |
// Return point to interpreter from compiled/native method |
|
1921 |
||
1922 |
InternalAddress return_from_native_method(__ pc()); |
|
1923 |
||
1924 |
__ bind(done_conv); |
|
1925 |
||
1926 |
||
1927 |
// Result if any is in tosca. The java expression stack is in the state that the |
|
1928 |
// calling convention left it (i.e. params may or may not be present) |
|
1929 |
// Copy the result from tosca and place it on java expression stack. |
|
1930 |
||
1066 | 1931 |
// Restore rsi/r13 as compiled code may not preserve it |
1932 |
||
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
1933 |
__ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); |
1 | 1934 |
|
1935 |
// restore stack to what we had when we left (in case i2c extended it) |
|
1936 |
||
1066 | 1937 |
__ movptr(rsp, STATE(_stack)); |
1938 |
__ lea(rsp, Address(rsp, wordSize)); |
|
1 | 1939 |
|
1940 |
// If there is a pending exception then we don't really have a result to process |
|
1941 |
||
1066 | 1942 |
#ifdef _LP64 |
1943 |
__ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
|
1944 |
#else |
|
1945 |
__ movptr(rcx, STATE(_thread)); // get thread |
|
1946 |
__ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
|
1896
cce23a9ff495
6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents:
1217
diff
changeset
|
1947 |
#endif // _LP64 |
1 | 1948 |
__ jcc(Assembler::notZero, return_with_exception); |
1949 |
||
1950 |
// get method just executed |
|
1066 | 1951 |
__ movptr(rbx, STATE(_result._to_call._callee)); |
1 | 1952 |
|
1953 |
// callee left args on top of expression stack, remove them |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
1954 |
__ load_unsigned_short(rcx, Address(rbx, methodOopDesc::size_of_parameters_offset())); |
1066 | 1955 |
__ lea(rsp, Address(rsp, rcx, Address::times_ptr)); |
1 | 1956 |
|
1957 |
__ movl(rcx, Address(rbx, methodOopDesc::result_index_offset())); |
|
1958 |
ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack); |
|
1066 | 1959 |
// Address index(noreg, rax, Address::times_ptr); |
1960 |
__ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_ptr))); |
|
1961 |
// __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack))); |
|
1 | 1962 |
__ call(rcx); // call result converter |
1963 |
__ jmp(resume_interpreter); |
|
1964 |
||
1965 |
// An exception is being caught on return to a vanilla interpreter frame. |
|
1966 |
// Empty the stack and resume interpreter |
|
1967 |
||
1968 |
__ bind(return_with_exception); |
|
1969 |
||
1970 |
// Exception present, empty stack |
|
1066 | 1971 |
__ movptr(rsp, STATE(_stack_base)); |
1 | 1972 |
__ jmp(resume_interpreter); |
1973 |
||
1974 |
// Return from interpreted method we return result appropriate to the caller (i.e. "recursive" |
|
1975 |
// interpreter call, or native) and unwind this interpreter activation. |
|
1976 |
// All monitors should be unlocked. |
|
1977 |
||
1978 |
__ bind(return_from_interpreted_method); |
|
1979 |
||
1980 |
Label return_to_initial_caller; |
|
1981 |
||
1066 | 1982 |
__ movptr(rbx, STATE(_method)); // get method just executed |
1983 |
__ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD); // returning from "recursive" interpreter call? |
|
1 | 1984 |
__ movl(rax, Address(rbx, methodOopDesc::result_index_offset())); // get result type index |
1985 |
__ jcc(Assembler::equal, return_to_initial_caller); // back to native code (call_stub/c1/c2) |
|
1986 |
||
1987 |
// Copy result to callers java stack |
|
1988 |
ExternalAddress stack_to_stack((address)CppInterpreter::_stack_to_stack); |
|
1066 | 1989 |
// Address index(noreg, rax, Address::times_ptr); |
1990 |
||
1991 |
__ movptr(rax, ArrayAddress(stack_to_stack, Address(noreg, rax, Address::times_ptr))); |
|
1992 |
// __ movl(rax, Address(noreg, rax, Address::times_ptr, int(AbstractInterpreter::_stack_to_stack))); |
|
1 | 1993 |
__ call(rax); // call result converter |
1994 |
||
1995 |
Label unwind_recursive_activation; |
|
1996 |
__ bind(unwind_recursive_activation); |
|
1997 |
||
1998 |
// returning to interpreter method from "recursive" interpreter call |
|
1999 |
// result converter left rax pointing to top of the java stack for method we are returning |
|
2000 |
// to. Now all we must do is unwind the state from the completed call |
|
2001 |
||
1066 | 2002 |
__ movptr(state, STATE(_prev_link)); // unwind state |
1 | 2003 |
__ leave(); // pop the frame |
1066 | 2004 |
__ mov(rsp, rax); // unwind stack to remove args |
1 | 2005 |
|
2006 |
// Resume the interpreter. The current frame contains the current interpreter |
|
2007 |
// state object. |
|
2008 |
// |
|
2009 |
||
2010 |
__ bind(resume_interpreter); |
|
2011 |
||
2012 |
// state == interpreterState object for method we are resuming |
|
2013 |
||
2014 |
__ movl(STATE(_msg), (int)BytecodeInterpreter::method_resume); |
|
1066 | 2015 |
__ lea(rsp, Address(rsp, -wordSize)); // prepush stack (result if any already present) |
2016 |
__ movptr(STATE(_stack), rsp); // inform interpreter of new stack depth (parameters removed, |
|
1 | 2017 |
// result if any on stack already ) |
1066 | 2018 |
__ movptr(rsp, STATE(_stack_limit)); // restore expression stack to full depth |
1 | 2019 |
__ jmp(call_interpreter_2); // No need to bang |
2020 |
||
2021 |
// interpreter returning to native code (call_stub/c1/c2) |
|
2022 |
// convert result and unwind initial activation |
|
2023 |
// rax - result index |
|
2024 |
||
2025 |
__ bind(return_to_initial_caller); |
|
2026 |
ExternalAddress stack_to_native((address)CppInterpreter::_stack_to_native_abi); |
|
1066 | 2027 |
// Address index(noreg, rax, Address::times_ptr); |
2028 |
||
2029 |
__ movptr(rax, ArrayAddress(stack_to_native, Address(noreg, rax, Address::times_ptr))); |
|
1 | 2030 |
__ call(rax); // call result converter |
2031 |
||
2032 |
Label unwind_initial_activation; |
|
2033 |
__ bind(unwind_initial_activation); |
|
2034 |
||
2035 |
// RETURN TO CALL_STUB/C1/C2 code (result if any in rax/rdx ST(0)) |
|
2036 |
||
2037 |
/* Current stack picture |
|
2038 |
||
2039 |
[ incoming parameters ] |
|
2040 |
[ extra locals ] |
|
2041 |
[ return address to CALL_STUB/C1/C2] |
|
2042 |
fp -> [ CALL_STUB/C1/C2 fp ] |
|
2043 |
BytecodeInterpreter object |
|
2044 |
expression stack |
|
2045 |
sp -> |
|
2046 |
||
2047 |
*/ |
|
2048 |
||
2049 |
// return restoring the stack to the original sender_sp value |
|
2050 |
||
1066 | 2051 |
__ movptr(rcx, STATE(_sender_sp)); |
1 | 2052 |
__ leave(); |
1066 | 2053 |
__ pop(rdi); // get return address |
1 | 2054 |
// set stack to sender's sp |
1066 | 2055 |
__ mov(rsp, rcx); |
1 | 2056 |
__ jmp(rdi); // return to call_stub |
2057 |
||
2058 |
// OSR request, adjust return address to make current frame into adapter frame |
|
2059 |
// and enter OSR nmethod |
|
2060 |
||
2061 |
__ bind(do_OSR); |
|
2062 |
||
2063 |
Label remove_initial_frame; |
|
2064 |
||
2065 |
// We are going to pop this frame. Is there another interpreter frame underneath |
|
2066 |
// it or is it callstub/compiled? |
|
2067 |
||
2068 |
// Move buffer to the expected parameter location |
|
1066 | 2069 |
__ movptr(rcx, STATE(_result._osr._osr_buf)); |
2070 |
||
2071 |
__ movptr(rax, STATE(_result._osr._osr_entry)); |
|
2072 |
||
2073 |
__ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD); // returning from "recursive" interpreter call? |
|
1 | 2074 |
__ jcc(Assembler::equal, remove_initial_frame); // back to native code (call_stub/c1/c2) |
2075 |
||
1066 | 2076 |
__ movptr(sender_sp_on_entry, STATE(_sender_sp)); // get sender's sp in expected register |
1 | 2077 |
__ leave(); // pop the frame |
1066 | 2078 |
__ mov(rsp, sender_sp_on_entry); // trim any stack expansion |
1 | 2079 |
|
2080 |
||
2081 |
// We know we are calling compiled so push specialized return |
|
2082 |
// method uses specialized entry, push a return so we look like call stub setup |
|
2083 |
// this path will handle fact that result is returned in registers and not |
|
2084 |
// on the java stack. |
|
2085 |
||
2086 |
__ pushptr(return_from_native_method.addr()); |
|
2087 |
||
2088 |
__ jmp(rax); |
|
2089 |
||
2090 |
__ bind(remove_initial_frame); |
|
2091 |
||
1066 | 2092 |
__ movptr(rdx, STATE(_sender_sp)); |
1 | 2093 |
__ leave(); |
2094 |
// get real return |
|
1066 | 2095 |
__ pop(rsi); |
1 | 2096 |
// set stack to sender's sp |
1066 | 2097 |
__ mov(rsp, rdx); |
1 | 2098 |
// repush real return |
1066 | 2099 |
__ push(rsi); |
1 | 2100 |
// Enter OSR nmethod |
2101 |
__ jmp(rax); |
|
2102 |
||
2103 |
||
2104 |
||
2105 |
||
2106 |
// Call a new method. All we do is (temporarily) trim the expression stack |
|
2107 |
// push a return address to bring us back to here and leap to the new entry. |
|
2108 |
||
2109 |
__ bind(call_method); |
|
2110 |
||
2111 |
// stack points to next free location and not top element on expression stack |
|
2112 |
// method expects sp to be pointing to topmost element |
|
2113 |
||
1066 | 2114 |
__ movptr(rsp, STATE(_stack)); // pop args to c++ interpreter, set sp to java stack top |
2115 |
__ lea(rsp, Address(rsp, wordSize)); |
|
2116 |
||
2117 |
__ movptr(rbx, STATE(_result._to_call._callee)); // get method to execute |
|
1 | 2118 |
|
2119 |
// don't need a return address if reinvoking interpreter |
|
2120 |
||
2121 |
// Make it look like call_stub calling conventions |
|
2122 |
||
2123 |
// Get (potential) receiver |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
2124 |
__ load_unsigned_short(rcx, size_of_parameters); // get size of parameters in words |
1 | 2125 |
|
2126 |
ExternalAddress recursive(CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation)); |
|
2127 |
__ pushptr(recursive.addr()); // make it look good in the debugger |
|
2128 |
||
2129 |
InternalAddress entry(entry_point); |
|
2130 |
__ cmpptr(STATE(_result._to_call._callee_entry_point), entry.addr()); // returning to interpreter? |
|
2131 |
__ jcc(Assembler::equal, re_dispatch); // yes |
|
2132 |
||
1066 | 2133 |
__ pop(rax); // pop dummy address |
1 | 2134 |
|
2135 |
||
2136 |
// get specialized entry |
|
1066 | 2137 |
__ movptr(rax, STATE(_result._to_call._callee_entry_point)); |
1 | 2138 |
// set sender SP |
1066 | 2139 |
__ mov(sender_sp_on_entry, rsp); |
1 | 2140 |
|
2141 |
// method uses specialized entry, push a return so we look like call stub setup |
|
2142 |
// this path will handle fact that result is returned in registers and not |
|
2143 |
// on the java stack. |
|
2144 |
||
2145 |
__ pushptr(return_from_native_method.addr()); |
|
2146 |
||
2147 |
__ jmp(rax); |
|
2148 |
||
2149 |
__ bind(bad_msg); |
|
2150 |
__ stop("Bad message from interpreter"); |
|
2151 |
||
2152 |
// Interpreted method "returned" with an exception pass it on... |
|
2153 |
// Pass result, unwind activation and continue/return to interpreter/call_stub |
|
2154 |
// We handle result (if any) differently based on return to interpreter or call_stub |
|
2155 |
||
2156 |
Label unwind_initial_with_pending_exception; |
|
2157 |
||
2158 |
__ bind(throw_exception); |
|
1066 | 2159 |
__ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD); // returning from recursive interpreter call? |
1 | 2160 |
__ jcc(Assembler::equal, unwind_initial_with_pending_exception); // no, back to native code (call_stub/c1/c2) |
1066 | 2161 |
__ movptr(rax, STATE(_locals)); // pop parameters get new stack value |
2162 |
__ addptr(rax, wordSize); // account for prepush before we return |
|
1 | 2163 |
__ jmp(unwind_recursive_activation); |
2164 |
||
2165 |
__ bind(unwind_initial_with_pending_exception); |
|
2166 |
||
2167 |
// We will unwind the current (initial) interpreter frame and forward |
|
2168 |
// the exception to the caller. We must put the exception in the |
|
2169 |
// expected register and clear pending exception and then forward. |
|
2170 |
||
2171 |
__ jmp(unwind_and_forward); |
|
2172 |
||
2173 |
interpreter_frame_manager = entry_point; |
|
2174 |
return entry_point; |
|
2175 |
} |
|
2176 |
||
2177 |
address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) { |
|
2178 |
// determine code generation flags |
|
2179 |
bool synchronized = false; |
|
2180 |
address entry_point = NULL; |
|
2181 |
||
2182 |
switch (kind) { |
|
2183 |
case Interpreter::zerolocals : break; |
|
2184 |
case Interpreter::zerolocals_synchronized: synchronized = true; break; |
|
2185 |
case Interpreter::native : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false); break; |
|
2186 |
case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true); break; |
|
2187 |
case Interpreter::empty : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry(); break; |
|
2188 |
case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break; |
|
2189 |
case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break; |
|
2534 | 2190 |
case Interpreter::method_handle : entry_point = ((InterpreterGenerator*)this)->generate_method_handle_entry(); break; |
1 | 2191 |
|
2192 |
case Interpreter::java_lang_math_sin : // fall thru |
|
2193 |
case Interpreter::java_lang_math_cos : // fall thru |
|
2194 |
case Interpreter::java_lang_math_tan : // fall thru |
|
2195 |
case Interpreter::java_lang_math_abs : // fall thru |
|
2196 |
case Interpreter::java_lang_math_log : // fall thru |
|
2197 |
case Interpreter::java_lang_math_log10 : // fall thru |
|
2198 |
case Interpreter::java_lang_math_sqrt : entry_point = ((InterpreterGenerator*)this)->generate_math_entry(kind); break; |
|
2199 |
default : ShouldNotReachHere(); break; |
|
2200 |
} |
|
2201 |
||
2202 |
if (entry_point) return entry_point; |
|
2203 |
||
2204 |
return ((InterpreterGenerator*)this)->generate_normal_entry(synchronized); |
|
2205 |
||
2206 |
} |
|
2207 |
||
2208 |
InterpreterGenerator::InterpreterGenerator(StubQueue* code) |
|
2209 |
: CppInterpreterGenerator(code) { |
|
2210 |
generate_all(); // down here so it can be "virtual" |
|
2211 |
} |
|
2212 |
||
2213 |
// Deoptimization helpers for C++ interpreter |
|
2214 |
||
2215 |
// How much stack a method activation needs in words. |
|
2216 |
int AbstractInterpreter::size_top_interpreter_activation(methodOop method) { |
|
2217 |
||
2218 |
const int stub_code = 4; // see generate_call_stub |
|
2219 |
// Save space for one monitor to get into the interpreted method in case |
|
2220 |
// the method is synchronized |
|
2221 |
int monitor_size = method->is_synchronized() ? |
|
2222 |
1*frame::interpreter_frame_monitor_size() : 0; |
|
2223 |
||
2224 |
// total static overhead size. Account for interpreter state object, return |
|
2225 |
// address, saved rbp and 2 words for a "static long no_params() method" issue. |
|
2226 |
||
2227 |
const int overhead_size = sizeof(BytecodeInterpreter)/wordSize + |
|
2228 |
( frame::sender_sp_offset - frame::link_offset) + 2; |
|
2229 |
||
2534 | 2230 |
const int extra_stack = 0; //6815692//methodOopDesc::extra_stack_entries(); |
2231 |
const int method_stack = (method->max_locals() + method->max_stack() + extra_stack) * |
|
1 | 2232 |
Interpreter::stackElementWords(); |
2233 |
return overhead_size + method_stack + stub_code; |
|
2234 |
} |
|
2235 |
||
2236 |
// returns the activation size. |
|
2237 |
static int size_activation_helper(int extra_locals_size, int monitor_size) { |
|
2238 |
return (extra_locals_size + // the addition space for locals |
|
2239 |
2*BytesPerWord + // return address and saved rbp |
|
2240 |
2*BytesPerWord + // "static long no_params() method" issue |
|
2241 |
sizeof(BytecodeInterpreter) + // interpreterState |
|
2242 |
monitor_size); // monitors |
|
2243 |
} |
|
2244 |
||
2245 |
void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill, |
|
2246 |
frame* caller, |
|
2247 |
frame* current, |
|
2248 |
methodOop method, |
|
2249 |
intptr_t* locals, |
|
2250 |
intptr_t* stack, |
|
2251 |
intptr_t* stack_base, |
|
2252 |
intptr_t* monitor_base, |
|
2253 |
intptr_t* frame_bottom, |
|
2254 |
bool is_top_frame |
|
2255 |
) |
|
2256 |
{ |
|
2257 |
// What about any vtable? |
|
2258 |
// |
|
2259 |
to_fill->_thread = JavaThread::current(); |
|
2260 |
// This gets filled in later but make it something recognizable for now |
|
2261 |
to_fill->_bcp = method->code_base(); |
|
2262 |
to_fill->_locals = locals; |
|
2263 |
to_fill->_constants = method->constants()->cache(); |
|
2264 |
to_fill->_method = method; |
|
2265 |
to_fill->_mdx = NULL; |
|
2266 |
to_fill->_stack = stack; |
|
2267 |
if (is_top_frame && JavaThread::current()->popframe_forcing_deopt_reexecution() ) { |
|
2268 |
to_fill->_msg = deopt_resume2; |
|
2269 |
} else { |
|
2270 |
to_fill->_msg = method_resume; |
|
2271 |
} |
|
2272 |
to_fill->_result._to_call._bcp_advance = 0; |
|
2273 |
to_fill->_result._to_call._callee_entry_point = NULL; // doesn't matter to anyone |
|
2274 |
to_fill->_result._to_call._callee = NULL; // doesn't matter to anyone |
|
2275 |
to_fill->_prev_link = NULL; |
|
2276 |
||
2277 |
to_fill->_sender_sp = caller->unextended_sp(); |
|
2278 |
||
2279 |
if (caller->is_interpreted_frame()) { |
|
2280 |
interpreterState prev = caller->get_interpreterState(); |
|
2281 |
to_fill->_prev_link = prev; |
|
2282 |
// *current->register_addr(GR_Iprev_state) = (intptr_t) prev; |
|
2283 |
// Make the prev callee look proper |
|
2284 |
prev->_result._to_call._callee = method; |
|
2285 |
if (*prev->_bcp == Bytecodes::_invokeinterface) { |
|
2286 |
prev->_result._to_call._bcp_advance = 5; |
|
2287 |
} else { |
|
2288 |
prev->_result._to_call._bcp_advance = 3; |
|
2289 |
} |
|
2290 |
} |
|
2291 |
to_fill->_oop_temp = NULL; |
|
2292 |
to_fill->_stack_base = stack_base; |
|
2293 |
// Need +1 here because stack_base points to the word just above the first expr stack entry |
|
2294 |
// and stack_limit is supposed to point to the word just below the last expr stack entry. |
|
2295 |
// See generate_compute_interpreter_state. |
|
2534 | 2296 |
int extra_stack = 0; //6815692//methodOopDesc::extra_stack_entries(); |
2297 |
to_fill->_stack_limit = stack_base - (method->max_stack() + extra_stack + 1); |
|
1 | 2298 |
to_fill->_monitor_base = (BasicObjectLock*) monitor_base; |
2299 |
||
2300 |
to_fill->_self_link = to_fill; |
|
2301 |
assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base, |
|
2302 |
"Stack top out of range"); |
|
2303 |
} |
|
2304 |
||
2305 |
int AbstractInterpreter::layout_activation(methodOop method, |
|
2306 |
int tempcount, // |
|
2307 |
int popframe_extra_args, |
|
2308 |
int moncount, |
|
2309 |
int callee_param_count, |
|
2310 |
int callee_locals, |
|
2311 |
frame* caller, |
|
2312 |
frame* interpreter_frame, |
|
2313 |
bool is_top_frame) { |
|
2314 |
||
2315 |
assert(popframe_extra_args == 0, "FIX ME"); |
|
2316 |
// NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state() |
|
2317 |
// does as far as allocating an interpreter frame. |
|
2318 |
// If interpreter_frame!=NULL, set up the method, locals, and monitors. |
|
2319 |
// The frame interpreter_frame, if not NULL, is guaranteed to be the right size, |
|
2320 |
// as determined by a previous call to this method. |
|
2321 |
// It is also guaranteed to be walkable even though it is in a skeletal state |
|
2322 |
// NOTE: return size is in words not bytes |
|
2323 |
// NOTE: tempcount is the current size of the java expression stack. For top most |
|
2324 |
// frames we will allocate a full sized expression stack and not the curback |
|
2325 |
// version that non-top frames have. |
|
2326 |
||
2327 |
// Calculate the amount our frame will be adjust by the callee. For top frame |
|
2328 |
// this is zero. |
|
2329 |
||
2330 |
// NOTE: ia64 seems to do this wrong (or at least backwards) in that it |
|
2331 |
// calculates the extra locals based on itself. Not what the callee does |
|
2332 |
// to it. So it ignores last_frame_adjust value. Seems suspicious as far |
|
2333 |
// as getting sender_sp correct. |
|
2334 |
||
2335 |
int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord; |
|
2336 |
int monitor_size = sizeof(BasicObjectLock) * moncount; |
|
2337 |
||
2338 |
// First calculate the frame size without any java expression stack |
|
2339 |
int short_frame_size = size_activation_helper(extra_locals_size, |
|
2340 |
monitor_size); |
|
2341 |
||
2342 |
// Now with full size expression stack |
|
2534 | 2343 |
int extra_stack = 0; //6815692//methodOopDesc::extra_stack_entries(); |
2344 |
int full_frame_size = short_frame_size + (method->max_stack() + extra_stack) * BytesPerWord; |
|
1 | 2345 |
|
2346 |
// and now with only live portion of the expression stack |
|
2347 |
short_frame_size = short_frame_size + tempcount * BytesPerWord; |
|
2348 |
||
2349 |
// the size the activation is right now. Only top frame is full size |
|
2350 |
int frame_size = (is_top_frame ? full_frame_size : short_frame_size); |
|
2351 |
||
2352 |
if (interpreter_frame != NULL) { |
|
2353 |
#ifdef ASSERT |
|
2354 |
assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable"); |
|
2355 |
#endif |
|
2356 |
||
2357 |
// MUCHO HACK |
|
2358 |
||
2359 |
intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size)); |
|
2360 |
||
2361 |
/* Now fillin the interpreterState object */ |
|
2362 |
||
2363 |
// The state object is the first thing on the frame and easily located |
|
2364 |
||
2365 |
interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter)); |
|
2366 |
||
2367 |
||
2368 |
// Find the locals pointer. This is rather simple on x86 because there is no |
|
2369 |
// confusing rounding at the callee to account for. We can trivially locate |
|
2370 |
// our locals based on the current fp(). |
|
2371 |
// Note: the + 2 is for handling the "static long no_params() method" issue. |
|
2372 |
// (too bad I don't really remember that issue well...) |
|
2373 |
||
2374 |
intptr_t* locals; |
|
2375 |
// If the caller is interpreted we need to make sure that locals points to the first |
|
2376 |
// argument that the caller passed and not in an area where the stack might have been extended. |
|
2377 |
// because the stack to stack to converter needs a proper locals value in order to remove the |
|
2378 |
// arguments from the caller and place the result in the proper location. Hmm maybe it'd be |
|
2379 |
// simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code |
|
2380 |
// adjust the stack?? HMMM QQQ |
|
2381 |
// |
|
2382 |
if (caller->is_interpreted_frame()) { |
|
2383 |
// locals must agree with the caller because it will be used to set the |
|
2384 |
// caller's tos when we return. |
|
2385 |
interpreterState prev = caller->get_interpreterState(); |
|
2386 |
// stack() is prepushed. |
|
2387 |
locals = prev->stack() + method->size_of_parameters(); |
|
2388 |
// locals = caller->unextended_sp() + (method->size_of_parameters() - 1); |
|
2389 |
if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) { |
|
2390 |
// os::breakpoint(); |
|
2391 |
} |
|
2392 |
} else { |
|
2393 |
// this is where a c2i would have placed locals (except for the +2) |
|
2394 |
locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2; |
|
2395 |
} |
|
2396 |
||
2397 |
intptr_t* monitor_base = (intptr_t*) cur_state; |
|
2398 |
intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size); |
|
2399 |
/* +1 because stack is always prepushed */ |
|
2400 |
intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord); |
|
2401 |
||
2402 |
||
2403 |
BytecodeInterpreter::layout_interpreterState(cur_state, |
|
2404 |
caller, |
|
2405 |
interpreter_frame, |
|
2406 |
method, |
|
2407 |
locals, |
|
2408 |
stack, |
|
2409 |
stack_base, |
|
2410 |
monitor_base, |
|
2411 |
frame_bottom, |
|
2412 |
is_top_frame); |
|
2413 |
||
2414 |
// BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp()); |
|
2415 |
} |
|
2416 |
return frame_size/BytesPerWord; |
|
2417 |
} |
|
2418 |
||
2419 |
#endif // CC_INTERP (all) |