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