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