comparison src/cpu/x86/vm/cppInterpreter_x86.cpp @ 304:dc7f315e41f7

5108146: Merge i486 and amd64 cpu directories 6459804: Want client (c1) compiler for x86_64 (amd64) for faster start-up Reviewed-by: kvn
author never
date Wed, 27 Aug 2008 00:21:55 -0700
parents a61af66fc99e
children 9ee9cf798b59
comparison
equal deleted inserted replaced
303:fa4d1d240383 304:dc7f315e41f7
42 #define STATE(field_name) (Address(state, byte_offset_of(BytecodeInterpreter, field_name))) 42 #define STATE(field_name) (Address(state, byte_offset_of(BytecodeInterpreter, field_name)))
43 43
44 Label fast_accessor_slow_entry_path; // fast accessor methods need to be able to jmp to unsynchronized 44 Label fast_accessor_slow_entry_path; // fast accessor methods need to be able to jmp to unsynchronized
45 // c++ interpreter entry point this holds that entry point label. 45 // c++ interpreter entry point this holds that entry point label.
46 46
47 // default registers for state and sender_sp
48 // state and sender_sp are the same on 32bit because we have no choice.
49 // state could be rsi on 64bit but it is an arg reg and not callee save
50 // so r13 is better choice.
51
52 const Register state = NOT_LP64(rsi) LP64_ONLY(r13);
53 const Register sender_sp_on_entry = NOT_LP64(rsi) LP64_ONLY(r13);
54
47 // NEEDED for JVMTI? 55 // NEEDED for JVMTI?
48 // address AbstractInterpreter::_remove_activation_preserving_args_entry; 56 // address AbstractInterpreter::_remove_activation_preserving_args_entry;
49 57
50 static address unctrap_frame_manager_entry = NULL; 58 static address unctrap_frame_manager_entry = NULL;
51 59
86 pc == CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation)); 94 pc == CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation));
87 } 95 }
88 96
89 97
90 address CppInterpreterGenerator::generate_result_handler_for(BasicType type) { 98 address CppInterpreterGenerator::generate_result_handler_for(BasicType type) {
91 const Register state = rsi; // current activation object, valid on entry
92 address entry = __ pc(); 99 address entry = __ pc();
93 switch (type) { 100 switch (type) {
94 case T_BOOLEAN: __ c2bool(rax); break; 101 case T_BOOLEAN: __ c2bool(rax); break;
95 case T_CHAR : __ andl(rax, 0xFFFF); break; 102 case T_CHAR : __ andl(rax, 0xFFFF); break;
96 case T_BYTE : __ sign_extend_byte (rax); break; 103 case T_BYTE : __ sign_extend_byte (rax); break;
97 case T_SHORT : __ sign_extend_short(rax); break; 104 case T_SHORT : __ sign_extend_short(rax); break;
98 case T_VOID : // fall thru 105 case T_VOID : // fall thru
99 case T_LONG : // fall thru 106 case T_LONG : // fall thru
100 case T_INT : /* nothing to do */ break; 107 case T_INT : /* nothing to do */ break;
108
101 case T_DOUBLE : 109 case T_DOUBLE :
102 case T_FLOAT : 110 case T_FLOAT :
103 { const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); 111 {
104 __ popl(t); // remove return address first 112 const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp();
105 __ pop_dtos_to_rsp(); 113 __ pop(t); // remove return address first
106 // Must return a result for interpreter or compiler. In SSE 114 // Must return a result for interpreter or compiler. In SSE
107 // mode, results are returned in xmm0 and the FPU stack must 115 // mode, results are returned in xmm0 and the FPU stack must
108 // be empty. 116 // be empty.
109 if (type == T_FLOAT && UseSSE >= 1) { 117 if (type == T_FLOAT && UseSSE >= 1) {
118 #ifndef _LP64
110 // Load ST0 119 // Load ST0
111 __ fld_d(Address(rsp, 0)); 120 __ fld_d(Address(rsp, 0));
112 // Store as float and empty fpu stack 121 // Store as float and empty fpu stack
113 __ fstp_s(Address(rsp, 0)); 122 __ fstp_s(Address(rsp, 0));
123 #endif // !_LP64
114 // and reload 124 // and reload
115 __ movflt(xmm0, Address(rsp, 0)); 125 __ movflt(xmm0, Address(rsp, 0));
116 } else if (type == T_DOUBLE && UseSSE >= 2 ) { 126 } else if (type == T_DOUBLE && UseSSE >= 2 ) {
117 __ movdbl(xmm0, Address(rsp, 0)); 127 __ movdbl(xmm0, Address(rsp, 0));
118 } else { 128 } else {
119 // restore ST0 129 // restore ST0
120 __ fld_d(Address(rsp, 0)); 130 __ fld_d(Address(rsp, 0));
121 } 131 }
122 // and pop the temp 132 // and pop the temp
123 __ addl(rsp, 2 * wordSize); 133 __ addptr(rsp, 2 * wordSize);
124 __ pushl(t); // restore return address 134 __ push(t); // restore return address
125 } 135 }
126 break; 136 break;
127 case T_OBJECT : 137 case T_OBJECT :
128 // retrieve result from frame 138 // retrieve result from frame
129 __ movl(rax, STATE(_oop_temp)); 139 __ movptr(rax, STATE(_oop_temp));
130 // and verify it 140 // and verify it
131 __ verify_oop(rax); 141 __ verify_oop(rax);
132 break; 142 break;
133 default : ShouldNotReachHere(); 143 default : ShouldNotReachHere();
134 } 144 }
144 // A result is in the tosca (abi result) from either a native method call or compiled 154 // A result is in the tosca (abi result) from either a native method call or compiled
145 // code. Place this result on the java expression stack so C++ interpreter can use it. 155 // code. Place this result on the java expression stack so C++ interpreter can use it.
146 address entry = __ pc(); 156 address entry = __ pc();
147 157
148 const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); 158 const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp();
149 __ popl(t); // remove return address first 159 __ pop(t); // remove return address first
150 switch (type) { 160 switch (type) {
151 case T_VOID: 161 case T_VOID:
152 break; 162 break;
153 case T_BOOLEAN: 163 case T_BOOLEAN:
154 #ifdef EXTEND 164 #ifdef EXTEND
155 __ c2bool(rax); 165 __ c2bool(rax);
156 #endif 166 #endif
157 __ pushl(rax); 167 __ push(rax);
158 break; 168 break;
159 case T_CHAR : 169 case T_CHAR :
160 #ifdef EXTEND 170 #ifdef EXTEND
161 __ andl(rax, 0xFFFF); 171 __ andl(rax, 0xFFFF);
162 #endif 172 #endif
163 __ pushl(rax); 173 __ push(rax);
164 break; 174 break;
165 case T_BYTE : 175 case T_BYTE :
166 #ifdef EXTEND 176 #ifdef EXTEND
167 __ sign_extend_byte (rax); 177 __ sign_extend_byte (rax);
168 #endif 178 #endif
169 __ pushl(rax); 179 __ push(rax);
170 break; 180 break;
171 case T_SHORT : 181 case T_SHORT :
172 #ifdef EXTEND 182 #ifdef EXTEND
173 __ sign_extend_short(rax); 183 __ sign_extend_short(rax);
174 #endif 184 #endif
175 __ pushl(rax); 185 __ push(rax);
176 break; 186 break;
177 case T_LONG : 187 case T_LONG :
178 __ pushl(rdx); 188 __ push(rdx); // pushes useless junk on 64bit
179 __ pushl(rax); 189 __ push(rax);
180 break; 190 break;
181 case T_INT : 191 case T_INT :
182 __ pushl(rax); 192 __ push(rax);
183 break; 193 break;
184 case T_FLOAT : 194 case T_FLOAT :
185 // Result is in ST(0) 195 // Result is in ST(0)/xmm0
196 __ subptr(rsp, wordSize);
186 if ( UseSSE < 1) { 197 if ( UseSSE < 1) {
187 __ push(ftos); // and save it 198 __ fstp_s(Address(rsp, 0));
188 } else { 199 } else {
189 __ subl(rsp, wordSize);
190 __ movflt(Address(rsp, 0), xmm0); 200 __ movflt(Address(rsp, 0), xmm0);
191 } 201 }
192 break; 202 break;
193 case T_DOUBLE : 203 case T_DOUBLE :
204 __ subptr(rsp, 2*wordSize);
194 if ( UseSSE < 2 ) { 205 if ( UseSSE < 2 ) {
195 __ push(dtos); // put ST0 on java stack 206 __ fstp_d(Address(rsp, 0));
196 } else { 207 } else {
197 __ subl(rsp, 2*wordSize);
198 __ movdbl(Address(rsp, 0), xmm0); 208 __ movdbl(Address(rsp, 0), xmm0);
199 } 209 }
200 break; 210 break;
201 case T_OBJECT : 211 case T_OBJECT :
202 __ verify_oop(rax); // verify it 212 __ verify_oop(rax); // verify it
203 __ pushl(rax); 213 __ push(rax);
204 break; 214 break;
205 default : ShouldNotReachHere(); 215 default : ShouldNotReachHere();
206 } 216 }
207 __ jmp(t); // return from result handler 217 __ jmp(t); // return from result handler
208 return entry; 218 return entry;
210 220
211 address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) { 221 address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) {
212 // A result is in the java expression stack of the interpreted method that has just 222 // A result is in the java expression stack of the interpreted method that has just
213 // returned. Place this result on the java expression stack of the caller. 223 // returned. Place this result on the java expression stack of the caller.
214 // 224 //
215 // The current interpreter activation in rsi is for the method just returning its 225 // The current interpreter activation in rsi/r13 is for the method just returning its
216 // result. So we know that the result of this method is on the top of the current 226 // result. So we know that the result of this method is on the top of the current
217 // execution stack (which is pre-pushed) and will be return to the top of the caller 227 // execution stack (which is pre-pushed) and will be return to the top of the caller
218 // stack. The top of the callers stack is the bottom of the locals of the current 228 // stack. The top of the callers stack is the bottom of the locals of the current
219 // activation. 229 // activation.
220 // Because of the way activation are managed by the frame manager the value of rsp is 230 // Because of the way activation are managed by the frame manager the value of rsp is
221 // below both the stack top of the current activation and naturally the stack top 231 // below both the stack top of the current activation and naturally the stack top
222 // of the calling activation. This enable this routine to leave the return address 232 // of the calling activation. This enable this routine to leave the return address
223 // to the frame manager on the stack and do a vanilla return. 233 // to the frame manager on the stack and do a vanilla return.
224 // 234 //
225 // On entry: rsi - interpreter state of activation returning a (potential) result 235 // On entry: rsi/r13 - interpreter state of activation returning a (potential) result
226 // On Return: rsi - unchanged 236 // On Return: rsi/r13 - unchanged
227 // rax - new stack top for caller activation (i.e. activation in _prev_link) 237 // rax - new stack top for caller activation (i.e. activation in _prev_link)
228 // 238 //
229 // Can destroy rdx, rcx. 239 // Can destroy rdx, rcx.
230 // 240 //
231 241
232 address entry = __ pc(); 242 address entry = __ pc();
233 const Register state = rsi; // current activation object, valid on entry
234 const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); 243 const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp();
235 switch (type) { 244 switch (type) {
236 case T_VOID: 245 case T_VOID:
237 __ movl(rax, STATE(_locals)); // pop parameters get new stack value 246 __ movptr(rax, STATE(_locals)); // pop parameters get new stack value
238 __ addl(rax, wordSize); // account for prepush before we return 247 __ addptr(rax, wordSize); // account for prepush before we return
239 break; 248 break;
240 case T_FLOAT : 249 case T_FLOAT :
241 case T_BOOLEAN: 250 case T_BOOLEAN:
242 case T_CHAR : 251 case T_CHAR :
243 case T_BYTE : 252 case T_BYTE :
244 case T_SHORT : 253 case T_SHORT :
245 case T_INT : 254 case T_INT :
246 // 1 word result 255 // 1 word result
247 __ movl(rdx, STATE(_stack)); 256 __ movptr(rdx, STATE(_stack));
248 __ movl(rax, STATE(_locals)); // address for result 257 __ movptr(rax, STATE(_locals)); // address for result
249 __ movl(rdx, Address(rdx, wordSize)); // get result 258 __ movl(rdx, Address(rdx, wordSize)); // get result
250 __ movl(Address(rax, 0), rdx); // and store it 259 __ movptr(Address(rax, 0), rdx); // and store it
251 break; 260 break;
252 case T_LONG : 261 case T_LONG :
253 case T_DOUBLE : 262 case T_DOUBLE :
254 // return top two words on current expression stack to caller's expression stack 263 // return top two words on current expression stack to caller's expression stack
255 // The caller's expression stack is adjacent to the current frame manager's intepretState 264 // The caller's expression stack is adjacent to the current frame manager's intepretState
256 // except we allocated one extra word for this intepretState so we won't overwrite it 265 // except we allocated one extra word for this intepretState so we won't overwrite it
257 // when we return a two word result. 266 // when we return a two word result.
258 267
259 __ movl(rax, STATE(_locals)); // address for result 268 __ movptr(rax, STATE(_locals)); // address for result
260 __ movl(rcx, STATE(_stack)); 269 __ movptr(rcx, STATE(_stack));
261 __ subl(rax, wordSize); // need addition word besides locals[0] 270 __ subptr(rax, wordSize); // need addition word besides locals[0]
262 __ movl(rdx, Address(rcx, 2*wordSize)); // get result word 271 __ movptr(rdx, Address(rcx, 2*wordSize)); // get result word (junk in 64bit)
263 __ movl(Address(rax, wordSize), rdx); // and store it 272 __ movptr(Address(rax, wordSize), rdx); // and store it
264 __ movl(rdx, Address(rcx, wordSize)); // get result word 273 __ movptr(rdx, Address(rcx, wordSize)); // get result word
265 __ movl(Address(rax, 0), rdx); // and store it 274 __ movptr(Address(rax, 0), rdx); // and store it
266 break; 275 break;
267 case T_OBJECT : 276 case T_OBJECT :
268 __ movl(rdx, STATE(_stack)); 277 __ movptr(rdx, STATE(_stack));
269 __ movl(rax, STATE(_locals)); // address for result 278 __ movptr(rax, STATE(_locals)); // address for result
270 __ movl(rdx, Address(rdx, wordSize)); // get result 279 __ movptr(rdx, Address(rdx, wordSize)); // get result
271 __ verify_oop(rdx); // verify it 280 __ verify_oop(rdx); // verify it
272 __ movl(Address(rax, 0), rdx); // and store it 281 __ movptr(Address(rax, 0), rdx); // and store it
273 break; 282 break;
274 default : ShouldNotReachHere(); 283 default : ShouldNotReachHere();
275 } 284 }
276 __ ret(0); 285 __ ret(0);
277 return entry; 286 return entry;
283 // 292 //
284 // Similar to generate_stack_to_stack_converter above. Called at a similar time from the 293 // Similar to generate_stack_to_stack_converter above. Called at a similar time from the
285 // frame manager execept in this situation the caller is native code (c1/c2/call_stub) 294 // frame manager execept in this situation the caller is native code (c1/c2/call_stub)
286 // and so rather than return result onto caller's java expression stack we return the 295 // and so rather than return result onto caller's java expression stack we return the
287 // result in the expected location based on the native abi. 296 // result in the expected location based on the native abi.
288 // On entry: rsi - interpreter state of activation returning a (potential) result 297 // On entry: rsi/r13 - interpreter state of activation returning a (potential) result
289 // On Return: rsi - unchanged 298 // On Return: rsi/r13 - unchanged
290 // Other registers changed [rax/rdx/ST(0) as needed for the result returned] 299 // Other registers changed [rax/rdx/ST(0) as needed for the result returned]
291 300
292 address entry = __ pc(); 301 address entry = __ pc();
293 const Register state = rsi; // current activation object, valid on entry
294 switch (type) { 302 switch (type) {
295 case T_VOID: 303 case T_VOID:
296 break; 304 break;
297 case T_BOOLEAN: 305 case T_BOOLEAN:
298 case T_CHAR : 306 case T_CHAR :
299 case T_BYTE : 307 case T_BYTE :
300 case T_SHORT : 308 case T_SHORT :
301 case T_INT : 309 case T_INT :
302 __ movl(rdx, STATE(_stack)); // get top of stack 310 __ movptr(rdx, STATE(_stack)); // get top of stack
303 __ movl(rax, Address(rdx, wordSize)); // get result word 1 311 __ movl(rax, Address(rdx, wordSize)); // get result word 1
304 break; 312 break;
305 case T_LONG : 313 case T_LONG :
306 __ movl(rdx, STATE(_stack)); // get top of stack 314 __ movptr(rdx, STATE(_stack)); // get top of stack
307 __ movl(rax, Address(rdx, wordSize)); // get result low word 315 __ movptr(rax, Address(rdx, wordSize)); // get result low word
308 __ movl(rdx, Address(rdx, 2*wordSize)); // get result high word 316 NOT_LP64(__ movl(rdx, Address(rdx, 2*wordSize));) // get result high word
309 break;
310 break; 317 break;
311 case T_FLOAT : 318 case T_FLOAT :
312 __ movl(rdx, STATE(_stack)); // get top of stack 319 __ movptr(rdx, STATE(_stack)); // get top of stack
313 if ( UseSSE >= 1) { 320 if ( UseSSE >= 1) {
314 __ movflt(xmm0, Address(rdx, wordSize)); 321 __ movflt(xmm0, Address(rdx, wordSize));
315 } else { 322 } else {
316 __ fld_s(Address(rdx, wordSize)); // pushd float result 323 __ fld_s(Address(rdx, wordSize)); // pushd float result
317 } 324 }
318 break; 325 break;
319 case T_DOUBLE : 326 case T_DOUBLE :
320 __ movl(rdx, STATE(_stack)); // get top of stack 327 __ movptr(rdx, STATE(_stack)); // get top of stack
321 if ( UseSSE > 1) { 328 if ( UseSSE > 1) {
322 __ movdbl(xmm0, Address(rdx, wordSize)); 329 __ movdbl(xmm0, Address(rdx, wordSize));
323 } else { 330 } else {
324 __ fld_d(Address(rdx, wordSize)); // push double result 331 __ fld_d(Address(rdx, wordSize)); // push double result
325 } 332 }
326 break; 333 break;
327 case T_OBJECT : 334 case T_OBJECT :
328 __ movl(rdx, STATE(_stack)); // get top of stack 335 __ movptr(rdx, STATE(_stack)); // get top of stack
329 __ movl(rax, Address(rdx, wordSize)); // get result word 1 336 __ movptr(rax, Address(rdx, wordSize)); // get result word 1
330 __ verify_oop(rax); // verify it 337 __ verify_oop(rax); // verify it
331 break; 338 break;
332 default : ShouldNotReachHere(); 339 default : ShouldNotReachHere();
333 } 340 }
334 __ ret(0); 341 __ ret(0);
406 // register and the stack is expanded in the caller before we store 413 // register and the stack is expanded in the caller before we store
407 // the results on the stack. 414 // the results on the stack.
408 415
409 if (!native) { 416 if (!native) {
410 #ifdef PRODUCT 417 #ifdef PRODUCT
411 __ subl(rsp, 2*wordSize); 418 __ subptr(rsp, 2*wordSize);
412 #else /* PRODUCT */ 419 #else /* PRODUCT */
413 __ pushl((int)NULL); 420 __ push((int32_t)NULL_WORD);
414 __ pushl(state); // make it look like a real argument 421 __ push(state); // make it look like a real argument
415 #endif /* PRODUCT */ 422 #endif /* PRODUCT */
416 } 423 }
417 424
418 // Now that we are assure of space for stack result, setup typical linkage 425 // Now that we are assure of space for stack result, setup typical linkage
419 426
420 __ pushl(rax); 427 __ push(rax);
421 __ enter(); 428 __ enter();
422 429
423 __ movl(rax, state); // save current state 430 __ mov(rax, state); // save current state
424 431
425 __ leal(rsp, Address(rsp, -(int)sizeof(BytecodeInterpreter))); 432 __ lea(rsp, Address(rsp, -(int)sizeof(BytecodeInterpreter)));
426 __ movl(state, rsp); 433 __ mov(state, rsp);
427 434
428 // rsi == state/locals rax == prevstate 435 // rsi/r13 == state/locals rax == prevstate
429 436
430 // initialize the "shadow" frame so that use since C++ interpreter not directly 437 // initialize the "shadow" frame so that use since C++ interpreter not directly
431 // recursive. Simpler to recurse but we can't trim expression stack as we call 438 // recursive. Simpler to recurse but we can't trim expression stack as we call
432 // new methods. 439 // new methods.
433 __ movl(STATE(_locals), locals); // state->_locals = locals() 440 __ movptr(STATE(_locals), locals); // state->_locals = locals()
434 __ movl(STATE(_self_link), state); // point to self 441 __ movptr(STATE(_self_link), state); // point to self
435 __ movl(STATE(_prev_link), rax); // state->_link = state on entry (NULL or previous state) 442 __ movptr(STATE(_prev_link), rax); // state->_link = state on entry (NULL or previous state)
436 __ movl(STATE(_sender_sp), sender_sp); // state->_sender_sp = sender_sp 443 __ movptr(STATE(_sender_sp), sender_sp); // state->_sender_sp = sender_sp
444 #ifdef _LP64
445 __ movptr(STATE(_thread), r15_thread); // state->_bcp = codes()
446 #else
437 __ get_thread(rax); // get vm's javathread* 447 __ get_thread(rax); // get vm's javathread*
438 __ movl(STATE(_thread), rax); // state->_bcp = codes() 448 __ movptr(STATE(_thread), rax); // state->_bcp = codes()
439 __ movl(rdx, Address(rbx, methodOopDesc::const_offset())); // get constantMethodOop 449 #endif // _LP64
440 __ leal(rdx, Address(rdx, constMethodOopDesc::codes_offset())); // get code base 450 __ movptr(rdx, Address(rbx, methodOopDesc::const_offset())); // get constantMethodOop
451 __ lea(rdx, Address(rdx, constMethodOopDesc::codes_offset())); // get code base
441 if (native) { 452 if (native) {
442 __ movl(STATE(_bcp), (intptr_t)NULL); // state->_bcp = NULL 453 __ movptr(STATE(_bcp), (int32_t)NULL_WORD); // state->_bcp = NULL
443 } else { 454 } else {
444 __ movl(STATE(_bcp), rdx); // state->_bcp = codes() 455 __ movptr(STATE(_bcp), rdx); // state->_bcp = codes()
445 } 456 }
446 __ xorl(rdx, rdx); 457 __ xorptr(rdx, rdx);
447 __ movl(STATE(_oop_temp), rdx); // state->_oop_temp = NULL (only really needed for native) 458 __ movptr(STATE(_oop_temp), rdx); // state->_oop_temp = NULL (only really needed for native)
448 __ movl(STATE(_mdx), rdx); // state->_mdx = NULL 459 __ movptr(STATE(_mdx), rdx); // state->_mdx = NULL
449 __ movl(rdx, Address(rbx, methodOopDesc::constants_offset())); 460 __ movptr(rdx, Address(rbx, methodOopDesc::constants_offset()));
450 __ movl(rdx, Address(rdx, constantPoolOopDesc::cache_offset_in_bytes())); 461 __ movptr(rdx, Address(rdx, constantPoolOopDesc::cache_offset_in_bytes()));
451 __ movl(STATE(_constants), rdx); // state->_constants = constants() 462 __ movptr(STATE(_constants), rdx); // state->_constants = constants()
452 463
453 __ movl(STATE(_method), rbx); // state->_method = method() 464 __ movptr(STATE(_method), rbx); // state->_method = method()
454 __ movl(STATE(_msg), (int) BytecodeInterpreter::method_entry); // state->_msg = initial method entry 465 __ movl(STATE(_msg), (int32_t) BytecodeInterpreter::method_entry); // state->_msg = initial method entry
455 __ movl(STATE(_result._to_call._callee), (int) NULL); // state->_result._to_call._callee_callee = NULL 466 __ movptr(STATE(_result._to_call._callee), (int32_t) NULL_WORD); // state->_result._to_call._callee_callee = NULL
456 467
457 468
458 __ movl(STATE(_monitor_base), rsp); // set monitor block bottom (grows down) this would point to entry [0] 469 __ movptr(STATE(_monitor_base), rsp); // set monitor block bottom (grows down) this would point to entry [0]
459 // entries run from -1..x where &monitor[x] == 470 // entries run from -1..x where &monitor[x] ==
460 471
461 { 472 {
462 // Must not attempt to lock method until we enter interpreter as gc won't be able to find the 473 // Must not attempt to lock method until we enter interpreter as gc won't be able to find the
463 // initial frame. However we allocate a free monitor so we don't have to shuffle the expression stack 474 // initial frame. However we allocate a free monitor so we don't have to shuffle the expression stack
477 488
478 Label done; 489 Label done;
479 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); 490 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
480 __ movl(rax, access_flags); 491 __ movl(rax, access_flags);
481 __ testl(rax, JVM_ACC_STATIC); 492 __ testl(rax, JVM_ACC_STATIC);
482 __ movl(rax, Address(locals, 0)); // get receiver (assume this is frequent case) 493 __ movptr(rax, Address(locals, 0)); // get receiver (assume this is frequent case)
483 __ jcc(Assembler::zero, done); 494 __ jcc(Assembler::zero, done);
484 __ movl(rax, Address(rbx, methodOopDesc::constants_offset())); 495 __ movptr(rax, Address(rbx, methodOopDesc::constants_offset()));
485 __ movl(rax, Address(rax, constantPoolOopDesc::pool_holder_offset_in_bytes())); 496 __ movptr(rax, Address(rax, constantPoolOopDesc::pool_holder_offset_in_bytes()));
486 __ movl(rax, Address(rax, mirror_offset)); 497 __ movptr(rax, Address(rax, mirror_offset));
487 __ bind(done); 498 __ bind(done);
488 // add space for monitor & lock 499 // add space for monitor & lock
489 __ subl(rsp, entry_size); // add space for a monitor entry 500 __ subptr(rsp, entry_size); // add space for a monitor entry
490 __ movl(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); // store object 501 __ movptr(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); // store object
491 __ bind(not_synced); 502 __ bind(not_synced);
492 } 503 }
493 504
494 __ movl(STATE(_stack_base), rsp); // set expression stack base ( == &monitors[-count]) 505 __ movptr(STATE(_stack_base), rsp); // set expression stack base ( == &monitors[-count])
495 if (native) { 506 if (native) {
496 __ movl(STATE(_stack), rsp); // set current expression stack tos 507 __ movptr(STATE(_stack), rsp); // set current expression stack tos
497 __ movl(STATE(_stack_limit), rsp); 508 __ movptr(STATE(_stack_limit), rsp);
498 } else { 509 } else {
499 __ subl(rsp, wordSize); // pre-push stack 510 __ subptr(rsp, wordSize); // pre-push stack
500 __ movl(STATE(_stack), rsp); // set current expression stack tos 511 __ movptr(STATE(_stack), rsp); // set current expression stack tos
501 512
502 // compute full expression stack limit 513 // compute full expression stack limit
503 514
504 const Address size_of_stack (rbx, methodOopDesc::max_stack_offset()); 515 const Address size_of_stack (rbx, methodOopDesc::max_stack_offset());
505 __ load_unsigned_word(rdx, size_of_stack); // get size of expression stack in words 516 __ load_unsigned_word(rdx, size_of_stack); // get size of expression stack in words
506 __ negl(rdx); // so we can subtract in next step 517 __ negptr(rdx); // so we can subtract in next step
507 // Allocate expression stack 518 // Allocate expression stack
508 __ leal(rsp, Address(rsp, rdx, Address::times_4)); 519 __ lea(rsp, Address(rsp, rdx, Address::times_ptr));
509 __ movl(STATE(_stack_limit), rsp); 520 __ movptr(STATE(_stack_limit), rsp);
510 } 521 }
522
523 #ifdef _LP64
524 // Make sure stack is properly aligned and sized for the abi
525 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
526 __ andptr(rsp, -16); // must be 16 byte boundry (see amd64 ABI)
527 #endif // _LP64
528
529
511 530
512 } 531 }
513 532
514 // Helpers for commoning out cases in the various type of method entries. 533 // Helpers for commoning out cases in the various type of method entries.
515 // 534 //
526 545
527 const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset()); 546 const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset());
528 const Address backedge_counter (rbx, methodOopDesc::backedge_counter_offset() + InvocationCounter::counter_offset()); 547 const Address backedge_counter (rbx, methodOopDesc::backedge_counter_offset() + InvocationCounter::counter_offset());
529 548
530 if (ProfileInterpreter) { // %%% Merge this into methodDataOop 549 if (ProfileInterpreter) { // %%% Merge this into methodDataOop
531 __ increment(Address(rbx,methodOopDesc::interpreter_invocation_counter_offset())); 550 __ incrementl(Address(rbx,methodOopDesc::interpreter_invocation_counter_offset()));
532 } 551 }
533 // Update standard invocation counters 552 // Update standard invocation counters
534 __ movl(rax, backedge_counter); // load backedge counter 553 __ movl(rax, backedge_counter); // load backedge counter
535 554
536 __ increment(rcx, InvocationCounter::count_increment); 555 __ increment(rcx, InvocationCounter::count_increment);
550 } 569 }
551 570
552 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { 571 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) {
553 572
554 // C++ interpreter on entry 573 // C++ interpreter on entry
555 // rsi - new interpreter state pointer 574 // rsi/r13 - new interpreter state pointer
556 // rbp - interpreter frame pointer 575 // rbp - interpreter frame pointer
557 // rbx - method 576 // rbx - method
558 577
559 // On return (i.e. jump to entry_point) [ back to invocation of interpreter ] 578 // On return (i.e. jump to entry_point) [ back to invocation of interpreter ]
560 // rbx, - method 579 // rbx, - method
561 // rcx - rcvr (assuming there is one) 580 // rcx - rcvr (assuming there is one)
562 // top of stack return address of interpreter caller 581 // top of stack return address of interpreter caller
563 // rsp - sender_sp 582 // rsp - sender_sp
564 583
565 // C++ interpreter only 584 // C++ interpreter only
566 // rsi - previous interpreter state pointer 585 // rsi/r13 - previous interpreter state pointer
567 586
568 const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset()); 587 const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset());
569 588
570 // InterpreterRuntime::frequency_counter_overflow takes one argument 589 // InterpreterRuntime::frequency_counter_overflow takes one argument
571 // indicating if the counter overflow occurs at a backwards branch (non-NULL bcp). 590 // indicating if the counter overflow occurs at a backwards branch (non-NULL bcp).
572 // The call returns the address of the verified entry point for the method or NULL 591 // The call returns the address of the verified entry point for the method or NULL
573 // if the compilation did not complete (either went background or bailed out). 592 // if the compilation did not complete (either went background or bailed out).
574 __ movl(rax, (int)false); 593 __ movptr(rax, (int32_t)false);
575 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), rax); 594 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), rax);
576 595
577 // for c++ interpreter can rsi really be munged? 596 // for c++ interpreter can rsi really be munged?
578 __ leal(rsi, Address(rbp, -sizeof(BytecodeInterpreter))); // restore state 597 __ lea(state, Address(rbp, -sizeof(BytecodeInterpreter))); // restore state
579 __ movl(rbx, Address(rsi, byte_offset_of(BytecodeInterpreter, _method))); // restore method 598 __ movptr(rbx, Address(state, byte_offset_of(BytecodeInterpreter, _method))); // restore method
580 __ movl(rdi, Address(rsi, byte_offset_of(BytecodeInterpreter, _locals))); // get locals pointer 599 __ movptr(rdi, Address(state, byte_offset_of(BytecodeInterpreter, _locals))); // get locals pointer
581 600
582 // Preserve invariant that rsi/rdi contain bcp/locals of sender frame
583 // and jump to the interpreted entry.
584 __ jmp(*do_continue, relocInfo::none); 601 __ jmp(*do_continue, relocInfo::none);
585 602
586 } 603 }
587 604
588 void InterpreterGenerator::generate_stack_overflow_check(void) { 605 void InterpreterGenerator::generate_stack_overflow_check(void) {
595 // Asm interpreter 612 // Asm interpreter
596 // rdx: number of additional locals this frame needs (what we must check) 613 // rdx: number of additional locals this frame needs (what we must check)
597 // rbx,: methodOop 614 // rbx,: methodOop
598 615
599 // C++ Interpreter 616 // C++ Interpreter
600 // rsi: previous interpreter frame state object 617 // rsi/r13: previous interpreter frame state object
601 // rdi: &locals[0] 618 // rdi: &locals[0]
602 // rcx: # of locals 619 // rcx: # of locals
603 // rdx: number of additional locals this frame needs (what we must check) 620 // rdx: number of additional locals this frame needs (what we must check)
604 // rbx: methodOop 621 // rbx: methodOop
605 622
626 643
627 Label after_frame_check_pop; 644 Label after_frame_check_pop;
628 645
629 // save rsi == caller's bytecode ptr (c++ previous interp. state) 646 // save rsi == caller's bytecode ptr (c++ previous interp. state)
630 // QQQ problem here?? rsi overload???? 647 // QQQ problem here?? rsi overload????
631 __ pushl(rsi); 648 __ push(state);
632 649
633 const Register thread = rsi; 650 const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rsi);
634 651
635 __ get_thread(thread); 652 NOT_LP64(__ get_thread(thread));
636 653
637 const Address stack_base(thread, Thread::stack_base_offset()); 654 const Address stack_base(thread, Thread::stack_base_offset());
638 const Address stack_size(thread, Thread::stack_size_offset()); 655 const Address stack_size(thread, Thread::stack_size_offset());
639 656
640 // locals + overhead, in bytes 657 // locals + overhead, in bytes
641 const Address size_of_stack (rbx, methodOopDesc::max_stack_offset()); 658 const Address size_of_stack (rbx, methodOopDesc::max_stack_offset());
642 // Always give one monitor to allow us to start interp if sync method. 659 // Always give one monitor to allow us to start interp if sync method.
643 // Any additional monitors need a check when moving the expression stack 660 // Any additional monitors need a check when moving the expression stack
644 const one_monitor = frame::interpreter_frame_monitor_size() * wordSize; 661 const one_monitor = frame::interpreter_frame_monitor_size() * wordSize;
645 __ load_unsigned_word(rax, size_of_stack); // get size of expression stack in words 662 __ load_unsigned_word(rax, size_of_stack); // get size of expression stack in words
646 __ leal(rax, Address(noreg, rax, Interpreter::stackElementScale(), one_monitor)); 663 __ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), one_monitor));
647 __ leal(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size)); 664 __ lea(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size));
648 665
649 #ifdef ASSERT 666 #ifdef ASSERT
650 Label stack_base_okay, stack_size_okay; 667 Label stack_base_okay, stack_size_okay;
651 // verify that thread stack base is non-zero 668 // verify that thread stack base is non-zero
652 __ cmpl(stack_base, 0); 669 __ cmpptr(stack_base, (int32_t)0);
653 __ jcc(Assembler::notEqual, stack_base_okay); 670 __ jcc(Assembler::notEqual, stack_base_okay);
654 __ stop("stack base is zero"); 671 __ stop("stack base is zero");
655 __ bind(stack_base_okay); 672 __ bind(stack_base_okay);
656 // verify that thread stack size is non-zero 673 // verify that thread stack size is non-zero
657 __ cmpl(stack_size, 0); 674 __ cmpptr(stack_size, (int32_t)0);
658 __ jcc(Assembler::notEqual, stack_size_okay); 675 __ jcc(Assembler::notEqual, stack_size_okay);
659 __ stop("stack size is zero"); 676 __ stop("stack size is zero");
660 __ bind(stack_size_okay); 677 __ bind(stack_size_okay);
661 #endif 678 #endif
662 679
663 // Add stack base to locals and subtract stack size 680 // Add stack base to locals and subtract stack size
664 __ addl(rax, stack_base); 681 __ addptr(rax, stack_base);
665 __ subl(rax, stack_size); 682 __ subptr(rax, stack_size);
666 683
667 // We should have a magic number here for the size of the c++ interpreter frame. 684 // We should have a magic number here for the size of the c++ interpreter frame.
668 // We can't actually tell this ahead of time. The debug version size is around 3k 685 // We can't actually tell this ahead of time. The debug version size is around 3k
669 // product is 1k and fastdebug is 4k 686 // product is 1k and fastdebug is 4k
670 const int slop = 6 * K; 687 const int slop = 6 * K;
672 // Use the maximum number of pages we might bang. 689 // Use the maximum number of pages we might bang.
673 const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages : 690 const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages :
674 (StackRedPages+StackYellowPages); 691 (StackRedPages+StackYellowPages);
675 // Only need this if we are stack banging which is temporary while 692 // Only need this if we are stack banging which is temporary while
676 // we're debugging. 693 // we're debugging.
677 __ addl(rax, slop + 2*max_pages * page_size); 694 __ addptr(rax, slop + 2*max_pages * page_size);
678 695
679 // check against the current stack bottom 696 // check against the current stack bottom
680 __ cmpl(rsp, rax); 697 __ cmpptr(rsp, rax);
681 __ jcc(Assembler::above, after_frame_check_pop); 698 __ jcc(Assembler::above, after_frame_check_pop);
682 699
683 __ popl(rsi); // get saved bcp / (c++ prev state ). 700 __ pop(state); // get c++ prev state.
684 701
685 // throw exception return address becomes throwing pc 702 // throw exception return address becomes throwing pc
686 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError)); 703 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError));
687 704
688 // all done with frame size check 705 // all done with frame size check
689 __ bind(after_frame_check_pop); 706 __ bind(after_frame_check_pop);
690 __ popl(rsi); 707 __ pop(state);
691 708
692 __ bind(after_frame_check); 709 __ bind(after_frame_check);
693 } 710 }
694 711
695 // Find preallocated monitor and lock method (C++ interpreter) 712 // Find preallocated monitor and lock method (C++ interpreter)
696 // rbx - methodOop 713 // rbx - methodOop
697 // 714 //
698 void InterpreterGenerator::lock_method(void) { 715 void InterpreterGenerator::lock_method(void) {
699 // assumes state == rsi == pointer to current interpreterState 716 // assumes state == rsi/r13 == pointer to current interpreterState
700 // minimally destroys rax, rdx, rdi 717 // minimally destroys rax, rdx|c_rarg1, rdi
701 // 718 //
702 // synchronize method 719 // synchronize method
703 const Register state = rsi;
704 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; 720 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
705 const Address access_flags (rbx, methodOopDesc::access_flags_offset()); 721 const Address access_flags (rbx, methodOopDesc::access_flags_offset());
706 722
723 const Register monitor = NOT_LP64(rdx) LP64_ONLY(c_rarg1);
724
707 // find initial monitor i.e. monitors[-1] 725 // find initial monitor i.e. monitors[-1]
708 __ movl(rdx, STATE(_monitor_base)); // get monitor bottom limit 726 __ movptr(monitor, STATE(_monitor_base)); // get monitor bottom limit
709 __ subl(rdx, entry_size); // point to initial monitor 727 __ subptr(monitor, entry_size); // point to initial monitor
710 728
711 #ifdef ASSERT 729 #ifdef ASSERT
712 { Label L; 730 { Label L;
713 __ movl(rax, access_flags); 731 __ movl(rax, access_flags);
714 __ testl(rax, JVM_ACC_SYNCHRONIZED); 732 __ testl(rax, JVM_ACC_SYNCHRONIZED);
719 #endif // ASSERT 737 #endif // ASSERT
720 // get synchronization object 738 // get synchronization object
721 { Label done; 739 { Label done;
722 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); 740 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
723 __ movl(rax, access_flags); 741 __ movl(rax, access_flags);
724 __ movl(rdi, STATE(_locals)); // prepare to get receiver (assume common case) 742 __ movptr(rdi, STATE(_locals)); // prepare to get receiver (assume common case)
725 __ testl(rax, JVM_ACC_STATIC); 743 __ testl(rax, JVM_ACC_STATIC);
726 __ movl(rax, Address(rdi, 0)); // get receiver (assume this is frequent case) 744 __ movptr(rax, Address(rdi, 0)); // get receiver (assume this is frequent case)
727 __ jcc(Assembler::zero, done); 745 __ jcc(Assembler::zero, done);
728 __ movl(rax, Address(rbx, methodOopDesc::constants_offset())); 746 __ movptr(rax, Address(rbx, methodOopDesc::constants_offset()));
729 __ movl(rax, Address(rax, constantPoolOopDesc::pool_holder_offset_in_bytes())); 747 __ movptr(rax, Address(rax, constantPoolOopDesc::pool_holder_offset_in_bytes()));
730 __ movl(rax, Address(rax, mirror_offset)); 748 __ movptr(rax, Address(rax, mirror_offset));
731 __ bind(done); 749 __ bind(done);
732 } 750 }
733 #ifdef ASSERT 751 #ifdef ASSERT
734 { Label L; 752 { Label L;
735 __ cmpl(rax, Address(rdx, BasicObjectLock::obj_offset_in_bytes())); // correct object? 753 __ cmpptr(rax, Address(monitor, BasicObjectLock::obj_offset_in_bytes())); // correct object?
736 __ jcc(Assembler::equal, L); 754 __ jcc(Assembler::equal, L);
737 __ stop("wrong synchronization lobject"); 755 __ stop("wrong synchronization lobject");
738 __ bind(L); 756 __ bind(L);
739 } 757 }
740 #endif // ASSERT 758 #endif // ASSERT
741 // can destroy rax, rdx, rcx, and (via call_VM) rdi! 759 // can destroy rax, rdx|c_rarg1, rcx, and (via call_VM) rdi!
742 __ lock_object(rdx); 760 __ lock_object(monitor);
743 } 761 }
744 762
745 // Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry 763 // Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry
746 764
747 address InterpreterGenerator::generate_accessor_entry(void) { 765 address InterpreterGenerator::generate_accessor_entry(void) {
748 766
749 // rbx,: methodOop 767 // rbx: methodOop
750 // rcx: receiver (preserve for slow entry into asm interpreter) 768
751 769 // rsi/r13: senderSP must preserved for slow path, set SP to it on fast path
752 // rsi: senderSP must preserved for slow path, set SP to it on fast path
753 770
754 Label xreturn_path; 771 Label xreturn_path;
755 772
756 // do fastpath for resolved accessor methods 773 // do fastpath for resolved accessor methods
757 if (UseFastAccessorMethods) { 774 if (UseFastAccessorMethods) {
770 // Note: We can only use this code if the getfield has been resolved 787 // Note: We can only use this code if the getfield has been resolved
771 // and if we don't have a null-pointer exception => check for 788 // and if we don't have a null-pointer exception => check for
772 // these conditions first and use slow path if necessary. 789 // these conditions first and use slow path if necessary.
773 // rbx,: method 790 // rbx,: method
774 // rcx: receiver 791 // rcx: receiver
775 __ movl(rax, Address(rsp, wordSize)); 792 __ movptr(rax, Address(rsp, wordSize));
776 793
777 // check if local 0 != NULL and read field 794 // check if local 0 != NULL and read field
778 __ testl(rax, rax); 795 __ testptr(rax, rax);
779 __ jcc(Assembler::zero, slow_path); 796 __ jcc(Assembler::zero, slow_path);
780 797
781 __ movl(rdi, Address(rbx, methodOopDesc::constants_offset())); 798 __ movptr(rdi, Address(rbx, methodOopDesc::constants_offset()));
782 // read first instruction word and extract bytecode @ 1 and index @ 2 799 // read first instruction word and extract bytecode @ 1 and index @ 2
783 __ movl(rdx, Address(rbx, methodOopDesc::const_offset())); 800 __ movptr(rdx, Address(rbx, methodOopDesc::const_offset()));
784 __ movl(rdx, Address(rdx, constMethodOopDesc::codes_offset())); 801 __ movl(rdx, Address(rdx, constMethodOopDesc::codes_offset()));
785 // Shift codes right to get the index on the right. 802 // Shift codes right to get the index on the right.
786 // The bytecode fetched looks like <index><0xb4><0x2a> 803 // The bytecode fetched looks like <index><0xb4><0x2a>
787 __ shrl(rdx, 2*BitsPerByte); 804 __ shrl(rdx, 2*BitsPerByte);
788 __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); 805 __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size())));
789 __ movl(rdi, Address(rdi, constantPoolOopDesc::cache_offset_in_bytes())); 806 __ movptr(rdi, Address(rdi, constantPoolOopDesc::cache_offset_in_bytes()));
790 807
791 // rax,: local 0 808 // rax,: local 0
792 // rbx,: method 809 // rbx,: method
793 // rcx: receiver - do not destroy since it is needed for slow path! 810 // rcx: receiver - do not destroy since it is needed for slow path!
794 // rcx: scratch 811 // rcx: scratch
795 // rdx: constant pool cache index 812 // rdx: constant pool cache index
796 // rdi: constant pool cache 813 // rdi: constant pool cache
797 // rsi: sender sp 814 // rsi/r13: sender sp
798 815
799 // check if getfield has been resolved and read constant pool cache entry 816 // check if getfield has been resolved and read constant pool cache entry
800 // check the validity of the cache entry by testing whether _indices field 817 // check the validity of the cache entry by testing whether _indices field
801 // contains Bytecode::_getfield in b1 byte. 818 // contains Bytecode::_getfield in b1 byte.
802 assert(in_words(ConstantPoolCacheEntry::size()) == 4, "adjust shift below"); 819 assert(in_words(ConstantPoolCacheEntry::size()) == 4, "adjust shift below");
803 __ movl(rcx, 820 __ movl(rcx,
804 Address(rdi, 821 Address(rdi,
805 rdx, 822 rdx,
806 Address::times_4, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::indices_offset())); 823 Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::indices_offset()));
807 __ shrl(rcx, 2*BitsPerByte); 824 __ shrl(rcx, 2*BitsPerByte);
808 __ andl(rcx, 0xFF); 825 __ andl(rcx, 0xFF);
809 __ cmpl(rcx, Bytecodes::_getfield); 826 __ cmpl(rcx, Bytecodes::_getfield);
810 __ jcc(Assembler::notEqual, slow_path); 827 __ jcc(Assembler::notEqual, slow_path);
811 828
812 // Note: constant pool entry is not valid before bytecode is resolved 829 // Note: constant pool entry is not valid before bytecode is resolved
813 __ movl(rcx, 830 __ movptr(rcx,
814 Address(rdi, 831 Address(rdi,
815 rdx, 832 rdx,
816 Address::times_4, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset())); 833 Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset()));
817 __ movl(rdx, 834 __ movl(rdx,
818 Address(rdi, 835 Address(rdi,
819 rdx, 836 rdx,
820 Address::times_4, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::flags_offset())); 837 Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::flags_offset()));
821 838
822 Label notByte, notShort, notChar; 839 Label notByte, notShort, notChar;
823 const Address field_address (rax, rcx, Address::times_1); 840 const Address field_address (rax, rcx, Address::times_1);
824 841
825 // Need to differentiate between igetfield, agetfield, bgetfield etc. 842 // Need to differentiate between igetfield, agetfield, bgetfield etc.
826 // because they are different sizes. 843 // because they are different sizes.
827 // Use the type from the constant pool cache 844 // Use the type from the constant pool cache
828 __ shrl(rdx, ConstantPoolCacheEntry::tosBits); 845 __ shrl(rdx, ConstantPoolCacheEntry::tosBits);
829 // Make sure we don't need to mask rdx for tosBits after the above shift 846 // Make sure we don't need to mask rdx for tosBits after the above shift
830 ConstantPoolCacheEntry::verify_tosBits(); 847 ConstantPoolCacheEntry::verify_tosBits();
848 #ifdef _LP64
849 Label notObj;
850 __ cmpl(rdx, atos);
851 __ jcc(Assembler::notEqual, notObj);
852 // atos
853 __ movptr(rax, field_address);
854 __ jmp(xreturn_path);
855
856 __ bind(notObj);
857 #endif // _LP64
831 __ cmpl(rdx, btos); 858 __ cmpl(rdx, btos);
832 __ jcc(Assembler::notEqual, notByte); 859 __ jcc(Assembler::notEqual, notByte);
833 __ load_signed_byte(rax, field_address); 860 __ load_signed_byte(rax, field_address);
834 __ jmp(xreturn_path); 861 __ jmp(xreturn_path);
835 862
846 __ jmp(xreturn_path); 873 __ jmp(xreturn_path);
847 874
848 __ bind(notChar); 875 __ bind(notChar);
849 #ifdef ASSERT 876 #ifdef ASSERT
850 Label okay; 877 Label okay;
878 #ifndef _LP64
851 __ cmpl(rdx, atos); 879 __ cmpl(rdx, atos);
852 __ jcc(Assembler::equal, okay); 880 __ jcc(Assembler::equal, okay);
881 #endif // _LP64
853 __ cmpl(rdx, itos); 882 __ cmpl(rdx, itos);
854 __ jcc(Assembler::equal, okay); 883 __ jcc(Assembler::equal, okay);
855 __ stop("what type is this?"); 884 __ stop("what type is this?");
856 __ bind(okay); 885 __ bind(okay);
857 #endif // ASSERT 886 #endif // ASSERT
859 __ movl(rax, field_address); 888 __ movl(rax, field_address);
860 889
861 __ bind(xreturn_path); 890 __ bind(xreturn_path);
862 891
863 // _ireturn/_areturn 892 // _ireturn/_areturn
864 __ popl(rdi); // get return address 893 __ pop(rdi); // get return address
865 __ movl(rsp, rsi); // set sp to sender sp 894 __ mov(rsp, sender_sp_on_entry); // set sp to sender sp
866 __ jmp(rdi); 895 __ jmp(rdi);
867 896
868 // generate a vanilla interpreter entry as the slow path 897 // generate a vanilla interpreter entry as the slow path
869 __ bind(slow_path); 898 __ bind(slow_path);
870 // We will enter c++ interpreter looking like it was 899 // We will enter c++ interpreter looking like it was
892 // determine code generation flags 921 // determine code generation flags
893 bool inc_counter = UseCompiler || CountCompiledCalls; 922 bool inc_counter = UseCompiler || CountCompiledCalls;
894 923
895 // rbx: methodOop 924 // rbx: methodOop
896 // rcx: receiver (unused) 925 // rcx: receiver (unused)
897 // rsi: previous interpreter state (if called from C++ interpreter) must preserve 926 // rsi/r13: previous interpreter state (if called from C++ interpreter) must preserve
898 // in any case. If called via c1/c2/call_stub rsi is junk (to use) but harmless 927 // in any case. If called via c1/c2/call_stub rsi/r13 is junk (to use) but harmless
899 // to save/restore. 928 // to save/restore.
900 address entry_point = __ pc(); 929 address entry_point = __ pc();
901 930
902 const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset()); 931 const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset());
903 const Address size_of_locals (rbx, methodOopDesc::size_of_locals_offset()); 932 const Address size_of_locals (rbx, methodOopDesc::size_of_locals_offset());
904 const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset()); 933 const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset());
905 const Address access_flags (rbx, methodOopDesc::access_flags_offset()); 934 const Address access_flags (rbx, methodOopDesc::access_flags_offset());
906 935
907 // rsi == state/locals rdi == prevstate 936 // rsi/r13 == state/locals rdi == prevstate
908 const Register state = rsi;
909 const Register locals = rdi; 937 const Register locals = rdi;
910 938
911 // get parameter size (always needed) 939 // get parameter size (always needed)
912 __ load_unsigned_word(rcx, size_of_parameters); 940 __ load_unsigned_word(rcx, size_of_parameters);
913 941
914 // rbx: methodOop 942 // rbx: methodOop
915 // rcx: size of parameters 943 // rcx: size of parameters
916 __ popl(rax); // get return address 944 __ pop(rax); // get return address
917 // for natives the size of locals is zero 945 // for natives the size of locals is zero
918 946
919 // compute beginning of parameters /locals 947 // compute beginning of parameters /locals
920 __ leal(locals, Address(rsp, rcx, Address::times_4, -wordSize)); 948 __ lea(locals, Address(rsp, rcx, Address::times_ptr, -wordSize));
921 949
922 // initialize fixed part of activation frame 950 // initialize fixed part of activation frame
923 951
924 // Assumes rax = return address 952 // Assumes rax = return address
925 953
929 // destroys rax, rcx, rdx 957 // destroys rax, rcx, rdx
930 // OUT (state) -> new interpreterState 958 // OUT (state) -> new interpreterState
931 // OUT(rsp) -> bottom of methods expression stack 959 // OUT(rsp) -> bottom of methods expression stack
932 960
933 // save sender_sp 961 // save sender_sp
934 __ movl(rcx, rsi); 962 __ mov(rcx, sender_sp_on_entry);
935 // start with NULL previous state 963 // start with NULL previous state
936 __ movl(state, 0); 964 __ movptr(state, (int32_t)NULL_WORD);
937 generate_compute_interpreter_state(state, locals, rcx, true); 965 generate_compute_interpreter_state(state, locals, rcx, true);
938 966
939 #ifdef ASSERT 967 #ifdef ASSERT
940 { Label L; 968 { Label L;
941 __ movl(rax, STATE(_stack_base)); 969 __ movptr(rax, STATE(_stack_base));
942 __ cmpl(rax, rsp); 970 #ifdef _LP64
971 // duplicate the alignment rsp got after setting stack_base
972 __ subptr(rax, frame::arg_reg_save_area_bytes); // windows
973 __ andptr(rax, -16); // must be 16 byte boundry (see amd64 ABI)
974 #endif // _LP64
975 __ cmpptr(rax, rsp);
943 __ jcc(Assembler::equal, L); 976 __ jcc(Assembler::equal, L);
944 __ stop("broken stack frame setup in interpreter"); 977 __ stop("broken stack frame setup in interpreter");
945 __ bind(L); 978 __ bind(L);
946 } 979 }
947 #endif 980 #endif
948 981
949 if (inc_counter) __ movl(rcx, invocation_counter); // (pre-)fetch invocation count 982 if (inc_counter) __ movl(rcx, invocation_counter); // (pre-)fetch invocation count
950 983
951 __ movl(rax, STATE(_thread)); // get thread 984 const Register unlock_thread = LP64_ONLY(r15_thread) NOT_LP64(rax);
985 NOT_LP64(__ movptr(unlock_thread, STATE(_thread));) // get thread
952 // Since at this point in the method invocation the exception handler 986 // Since at this point in the method invocation the exception handler
953 // would try to exit the monitor of synchronized methods which hasn't 987 // would try to exit the monitor of synchronized methods which hasn't
954 // been entered yet, we set the thread local variable 988 // been entered yet, we set the thread local variable
955 // _do_not_unlock_if_synchronized to true. The remove_activation will 989 // _do_not_unlock_if_synchronized to true. The remove_activation will
956 // check this flag. 990 // check this flag.
957 991
958 const Address do_not_unlock_if_synchronized(rax, 992 const Address do_not_unlock_if_synchronized(unlock_thread,
959 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); 993 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
960 __ movbool(do_not_unlock_if_synchronized, true); 994 __ movbool(do_not_unlock_if_synchronized, true);
961 995
962 // make sure method is native & not abstract 996 // make sure method is native & not abstract
963 #ifdef ASSERT 997 #ifdef ASSERT
989 __ bind(continue_after_compile); 1023 __ bind(continue_after_compile);
990 1024
991 bang_stack_shadow_pages(true); 1025 bang_stack_shadow_pages(true);
992 1026
993 // reset the _do_not_unlock_if_synchronized flag 1027 // reset the _do_not_unlock_if_synchronized flag
994 __ movl(rax, STATE(_thread)); // get thread 1028 NOT_LP64(__ movl(rax, STATE(_thread));) // get thread
995 __ movbool(do_not_unlock_if_synchronized, false); 1029 __ movbool(do_not_unlock_if_synchronized, false);
996 1030
997 1031
998 // check for synchronized native methods 1032 // check for synchronized native methods
999 // 1033 //
1020 // jvmti support 1054 // jvmti support
1021 __ notify_method_entry(); 1055 __ notify_method_entry();
1022 1056
1023 // work registers 1057 // work registers
1024 const Register method = rbx; 1058 const Register method = rbx;
1025 const Register thread = rdi; 1059 const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rdi);
1026 const Register t = rcx; 1060 const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); // rcx|rscratch1
1027 1061
1028 // allocate space for parameters 1062 // allocate space for parameters
1029 __ movl(method, STATE(_method)); 1063 __ movptr(method, STATE(_method));
1030 __ verify_oop(method); 1064 __ verify_oop(method);
1031 __ load_unsigned_word(t, Address(method, methodOopDesc::size_of_parameters_offset())); 1065 __ load_unsigned_word(t, Address(method, methodOopDesc::size_of_parameters_offset()));
1032 __ shll(t, 2); 1066 __ shll(t, 2);
1033 __ addl(t, 2*wordSize); // allocate two more slots for JNIEnv and possible mirror 1067 #ifdef _LP64
1034 __ subl(rsp, t); 1068 __ subptr(rsp, t);
1035 __ andl(rsp, -(StackAlignmentInBytes)); // gcc needs 16 byte aligned stacks to do XMM intrinsics 1069 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
1070 __ andptr(rsp, -16); // must be 16 byte boundry (see amd64 ABI)
1071 #else
1072 __ addptr(t, 2*wordSize); // allocate two more slots for JNIEnv and possible mirror
1073 __ subptr(rsp, t);
1074 __ andptr(rsp, -(StackAlignmentInBytes)); // gcc needs 16 byte aligned stacks to do XMM intrinsics
1075 #endif // _LP64
1036 1076
1037 // get signature handler 1077 // get signature handler
1038 Label pending_exception_present; 1078 Label pending_exception_present;
1039 1079
1040 { Label L; 1080 { Label L;
1041 __ movl(t, Address(method, methodOopDesc::signature_handler_offset())); 1081 __ movptr(t, Address(method, methodOopDesc::signature_handler_offset()));
1042 __ testl(t, t); 1082 __ testptr(t, t);
1043 __ jcc(Assembler::notZero, L); 1083 __ jcc(Assembler::notZero, L);
1044 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method, false); 1084 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method, false);
1045 __ movl(method, STATE(_method)); 1085 __ movptr(method, STATE(_method));
1046 __ cmpl(Address(thread, Thread::pending_exception_offset()), NULL_WORD); 1086 __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1047 __ jcc(Assembler::notEqual, pending_exception_present); 1087 __ jcc(Assembler::notEqual, pending_exception_present);
1048 __ verify_oop(method); 1088 __ verify_oop(method);
1049 __ movl(t, Address(method, methodOopDesc::signature_handler_offset())); 1089 __ movptr(t, Address(method, methodOopDesc::signature_handler_offset()));
1050 __ bind(L); 1090 __ bind(L);
1051 } 1091 }
1052 #ifdef ASSERT 1092 #ifdef ASSERT
1053 { 1093 {
1054 Label L; 1094 Label L;
1055 __ pushl(t); 1095 __ push(t);
1056 __ get_thread(t); // get vm's javathread* 1096 __ get_thread(t); // get vm's javathread*
1057 __ cmpl(t, STATE(_thread)); 1097 __ cmpptr(t, STATE(_thread));
1058 __ jcc(Assembler::equal, L); 1098 __ jcc(Assembler::equal, L);
1059 __ int3(); 1099 __ int3();
1060 __ bind(L); 1100 __ bind(L);
1061 __ popl(t); 1101 __ pop(t);
1062 } 1102 }
1063 #endif // 1103 #endif //
1064 1104
1105 const Register from_ptr = InterpreterRuntime::SignatureHandlerGenerator::from();
1065 // call signature handler 1106 // call signature handler
1066 assert(InterpreterRuntime::SignatureHandlerGenerator::from() == rdi, "adjust this code");
1067 assert(InterpreterRuntime::SignatureHandlerGenerator::to () == rsp, "adjust this code"); 1107 assert(InterpreterRuntime::SignatureHandlerGenerator::to () == rsp, "adjust this code");
1068 assert(InterpreterRuntime::SignatureHandlerGenerator::temp() == t , "adjust this code"); 1108
1069 // The generated handlers do not touch RBX (the method oop). 1109 // The generated handlers do not touch RBX (the method oop).
1070 // However, large signatures cannot be cached and are generated 1110 // However, large signatures cannot be cached and are generated
1071 // each time here. The slow-path generator will blow RBX 1111 // each time here. The slow-path generator will blow RBX
1072 // sometime, so we must reload it after the call. 1112 // sometime, so we must reload it after the call.
1073 __ movl(rdi, STATE(_locals)); // get the from pointer 1113 __ movptr(from_ptr, STATE(_locals)); // get the from pointer
1074 __ call(t); 1114 __ call(t);
1075 __ movl(method, STATE(_method)); 1115 __ movptr(method, STATE(_method));
1076 __ verify_oop(method); 1116 __ verify_oop(method);
1077 1117
1078 // result handler is in rax 1118 // result handler is in rax
1079 // set result handler 1119 // set result handler
1080 __ movl(STATE(_result_handler), rax); 1120 __ movptr(STATE(_result_handler), rax);
1121
1122
1123 // get native function entry point
1124 { Label L;
1125 __ movptr(rax, Address(method, methodOopDesc::native_function_offset()));
1126 __ testptr(rax, rax);
1127 __ jcc(Assembler::notZero, L);
1128 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method);
1129 __ movptr(method, STATE(_method));
1130 __ verify_oop(method);
1131 __ movptr(rax, Address(method, methodOopDesc::native_function_offset()));
1132 __ bind(L);
1133 }
1081 1134
1082 // pass mirror handle if static call 1135 // pass mirror handle if static call
1083 { Label L; 1136 { Label L;
1084 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); 1137 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
1085 __ movl(t, Address(method, methodOopDesc::access_flags_offset())); 1138 __ movl(t, Address(method, methodOopDesc::access_flags_offset()));
1086 __ testl(t, JVM_ACC_STATIC); 1139 __ testl(t, JVM_ACC_STATIC);
1087 __ jcc(Assembler::zero, L); 1140 __ jcc(Assembler::zero, L);
1088 // get mirror 1141 // get mirror
1089 __ movl(t, Address(method, methodOopDesc:: constants_offset())); 1142 __ movptr(t, Address(method, methodOopDesc:: constants_offset()));
1090 __ movl(t, Address(t, constantPoolOopDesc::pool_holder_offset_in_bytes())); 1143 __ movptr(t, Address(t, constantPoolOopDesc::pool_holder_offset_in_bytes()));
1091 __ movl(t, Address(t, mirror_offset)); 1144 __ movptr(t, Address(t, mirror_offset));
1092 // copy mirror into activation object 1145 // copy mirror into activation object
1093 __ movl(STATE(_oop_temp), t); 1146 __ movptr(STATE(_oop_temp), t);
1094 // pass handle to mirror 1147 // pass handle to mirror
1095 __ leal(t, STATE(_oop_temp)); 1148 #ifdef _LP64
1096 __ movl(Address(rsp, wordSize), t); 1149 __ lea(c_rarg1, STATE(_oop_temp));
1150 #else
1151 __ lea(t, STATE(_oop_temp));
1152 __ movptr(Address(rsp, wordSize), t);
1153 #endif // _LP64
1097 __ bind(L); 1154 __ bind(L);
1098 } 1155 }
1099 #ifdef ASSERT 1156 #ifdef ASSERT
1100 { 1157 {
1101 Label L; 1158 Label L;
1102 __ pushl(t); 1159 __ push(t);
1103 __ get_thread(t); // get vm's javathread* 1160 __ get_thread(t); // get vm's javathread*
1104 __ cmpl(t, STATE(_thread)); 1161 __ cmpptr(t, STATE(_thread));
1105 __ jcc(Assembler::equal, L); 1162 __ jcc(Assembler::equal, L);
1106 __ int3(); 1163 __ int3();
1107 __ bind(L); 1164 __ bind(L);
1108 __ popl(t); 1165 __ pop(t);
1109 } 1166 }
1110 #endif // 1167 #endif //
1111 1168
1112 // get native function entry point
1113 { Label L;
1114 __ movl(rax, Address(method, methodOopDesc::native_function_offset()));
1115 __ testl(rax, rax);
1116 __ jcc(Assembler::notZero, L);
1117 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method);
1118 __ movl(method, STATE(_method));
1119 __ verify_oop(method);
1120 __ movl(rax, Address(method, methodOopDesc::native_function_offset()));
1121 __ bind(L);
1122 }
1123
1124 // pass JNIEnv 1169 // pass JNIEnv
1125 __ movl(thread, STATE(_thread)); // get thread 1170 #ifdef _LP64
1126 __ leal(t, Address(thread, JavaThread::jni_environment_offset())); 1171 __ lea(c_rarg0, Address(thread, JavaThread::jni_environment_offset()));
1127 __ movl(Address(rsp, 0), t); 1172 #else
1173 __ movptr(thread, STATE(_thread)); // get thread
1174 __ lea(t, Address(thread, JavaThread::jni_environment_offset()));
1175
1176 __ movptr(Address(rsp, 0), t);
1177 #endif // _LP64
1178
1128 #ifdef ASSERT 1179 #ifdef ASSERT
1129 { 1180 {
1130 Label L; 1181 Label L;
1131 __ pushl(t); 1182 __ push(t);
1132 __ get_thread(t); // get vm's javathread* 1183 __ get_thread(t); // get vm's javathread*
1133 __ cmpl(t, STATE(_thread)); 1184 __ cmpptr(t, STATE(_thread));
1134 __ jcc(Assembler::equal, L); 1185 __ jcc(Assembler::equal, L);
1135 __ int3(); 1186 __ int3();
1136 __ bind(L); 1187 __ bind(L);
1137 __ popl(t); 1188 __ pop(t);
1138 } 1189 }
1139 #endif // 1190 #endif //
1140 1191
1141 #ifdef ASSERT 1192 #ifdef ASSERT
1142 { Label L; 1193 { Label L;
1157 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native); 1208 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native);
1158 1209
1159 __ call(rax); 1210 __ call(rax);
1160 1211
1161 // result potentially in rdx:rax or ST0 1212 // result potentially in rdx:rax or ST0
1162 __ movl(method, STATE(_method)); 1213 __ movptr(method, STATE(_method));
1163 __ movl(thread, STATE(_thread)); // get thread 1214 NOT_LP64(__ movptr(thread, STATE(_thread));) // get thread
1164 1215
1165 // The potential result is in ST(0) & rdx:rax 1216 // The potential result is in ST(0) & rdx:rax
1166 // With C++ interpreter we leave any possible result in ST(0) until we are in result handler and then 1217 // With C++ interpreter we leave any possible result in ST(0) until we are in result handler and then
1167 // we do the appropriate stuff for returning the result. rdx:rax must always be saved because just about 1218 // we do the appropriate stuff for returning the result. rdx:rax must always be saved because just about
1168 // anything we do here will destroy it, st(0) is only saved if we re-enter the vm where it would 1219 // anything we do here will destroy it, st(0) is only saved if we re-enter the vm where it would
1169 // be destroyed. 1220 // be destroyed.
1170 // It is safe to do these pushes because state is _thread_in_native and return address will be found 1221 // It is safe to do these pushes because state is _thread_in_native and return address will be found
1171 // via _last_native_pc and not via _last_jave_sp 1222 // via _last_native_pc and not via _last_jave_sp
1172 1223
1173 // Must save the value of ST(0) since it could be destroyed before we get to result handler 1224 // Must save the value of ST(0)/xmm0 since it could be destroyed before we get to result handler
1174 { Label Lpush, Lskip; 1225 { Label Lpush, Lskip;
1175 ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT)); 1226 ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT));
1176 ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE)); 1227 ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE));
1177 __ cmpptr(STATE(_result_handler), float_handler.addr()); 1228 __ cmpptr(STATE(_result_handler), float_handler.addr());
1178 __ jcc(Assembler::equal, Lpush); 1229 __ jcc(Assembler::equal, Lpush);
1179 __ cmpptr(STATE(_result_handler), double_handler.addr()); 1230 __ cmpptr(STATE(_result_handler), double_handler.addr());
1180 __ jcc(Assembler::notEqual, Lskip); 1231 __ jcc(Assembler::notEqual, Lskip);
1181 __ bind(Lpush); 1232 __ bind(Lpush);
1182 __ push(dtos); 1233 __ subptr(rsp, 2*wordSize);
1234 if ( UseSSE < 2 ) {
1235 __ fstp_d(Address(rsp, 0));
1236 } else {
1237 __ movdbl(Address(rsp, 0), xmm0);
1238 }
1183 __ bind(Lskip); 1239 __ bind(Lskip);
1184 } 1240 }
1185 1241
1186 __ push(ltos); // save rax:rdx for potential use by result handler. 1242 // save rax:rdx for potential use by result handler.
1243 __ push(rax);
1244 #ifndef _LP64
1245 __ push(rdx);
1246 #endif // _LP64
1187 1247
1188 // Either restore the MXCSR register after returning from the JNI Call 1248 // Either restore the MXCSR register after returning from the JNI Call
1189 // or verify that it wasn't changed. 1249 // or verify that it wasn't changed.
1190 if (VM_Version::supports_sse()) { 1250 if (VM_Version::supports_sse()) {
1191 if (RestoreMXCSROnJNICalls) { 1251 if (RestoreMXCSROnJNICalls) {
1192 __ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); 1252 __ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std()));
1193 } 1253 }
1194 else if (CheckJNICalls ) { 1254 else if (CheckJNICalls ) {
1195 __ call(RuntimeAddress(StubRoutines::i486::verify_mxcsr_entry())); 1255 __ call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry()));
1196 } 1256 }
1197 } 1257 }
1198 1258
1259 #ifndef _LP64
1199 // Either restore the x87 floating pointer control word after returning 1260 // Either restore the x87 floating pointer control word after returning
1200 // from the JNI call or verify that it wasn't changed. 1261 // from the JNI call or verify that it wasn't changed.
1201 if (CheckJNICalls) { 1262 if (CheckJNICalls) {
1202 __ call(RuntimeAddress(StubRoutines::i486::verify_fpu_cntrl_wrd_entry())); 1263 __ call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry()));
1203 } 1264 }
1265 #endif // _LP64
1204 1266
1205 1267
1206 // change thread state 1268 // change thread state
1207 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans); 1269 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans);
1208 if(os::is_MP()) { 1270 if(os::is_MP()) {
1229 __ bind(L); 1291 __ bind(L);
1230 1292
1231 // Don't use call_VM as it will see a possible pending exception and forward it 1293 // Don't use call_VM as it will see a possible pending exception and forward it
1232 // and never return here preventing us from clearing _last_native_pc down below. 1294 // and never return here preventing us from clearing _last_native_pc down below.
1233 // Also can't use call_VM_leaf either as it will check to see if rsi & rdi are 1295 // Also can't use call_VM_leaf either as it will check to see if rsi & rdi are
1234 // preserved and correspond to the bcp/locals pointers. So we do a runtime call 1296 // preserved and correspond to the bcp/locals pointers.
1235 // by hand.
1236 // 1297 //
1237 __ pushl(thread); 1298
1238 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, 1299 ((MacroAssembler*)_masm)->call_VM_leaf(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
1239 JavaThread::check_special_condition_for_native_trans))); 1300 thread);
1240 __ increment(rsp, wordSize); 1301 __ increment(rsp, wordSize);
1241 1302
1242 __ movl(method, STATE(_method)); 1303 __ movptr(method, STATE(_method));
1243 __ verify_oop(method); 1304 __ verify_oop(method);
1244 __ movl(thread, STATE(_thread)); // get thread 1305 __ movptr(thread, STATE(_thread)); // get thread
1245 1306
1246 __ bind(Continue); 1307 __ bind(Continue);
1247 } 1308 }
1248 1309
1249 // change thread state 1310 // change thread state
1250 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java); 1311 __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
1251 1312
1252 __ reset_last_Java_frame(thread, true, true); 1313 __ reset_last_Java_frame(thread, true, true);
1253 1314
1254 // reset handle block 1315 // reset handle block
1255 __ movl(t, Address(thread, JavaThread::active_handles_offset())); 1316 __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
1256 __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD); 1317 __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
1257 1318
1258 // If result was an oop then unbox and save it in the frame 1319 // If result was an oop then unbox and save it in the frame
1259 { Label L; 1320 { Label L;
1260 Label no_oop, store_result; 1321 Label no_oop, store_result;
1261 ExternalAddress oop_handler(AbstractInterpreter::result_handler(T_OBJECT)); 1322 ExternalAddress oop_handler(AbstractInterpreter::result_handler(T_OBJECT));
1262 __ cmpptr(STATE(_result_handler), oop_handler.addr()); 1323 __ cmpptr(STATE(_result_handler), oop_handler.addr());
1263 __ jcc(Assembler::notEqual, no_oop); 1324 __ jcc(Assembler::notEqual, no_oop);
1264 __ pop(ltos); 1325 #ifndef _LP64
1265 __ testl(rax, rax); 1326 __ pop(rdx);
1327 #endif // _LP64
1328 __ pop(rax);
1329 __ testptr(rax, rax);
1266 __ jcc(Assembler::zero, store_result); 1330 __ jcc(Assembler::zero, store_result);
1267 // unbox 1331 // unbox
1268 __ movl(rax, Address(rax, 0)); 1332 __ movptr(rax, Address(rax, 0));
1269 __ bind(store_result); 1333 __ bind(store_result);
1270 __ movl(STATE(_oop_temp), rax); 1334 __ movptr(STATE(_oop_temp), rax);
1271 // keep stack depth as expected by pushing oop which will eventually be discarded 1335 // keep stack depth as expected by pushing oop which will eventually be discarded
1272 __ push(ltos); 1336 __ push(rax);
1337 #ifndef _LP64
1338 __ push(rdx);
1339 #endif // _LP64
1273 __ bind(no_oop); 1340 __ bind(no_oop);
1274 } 1341 }
1275 1342
1276 { 1343 {
1277 Label no_reguard; 1344 Label no_reguard;
1278 __ cmpl(Address(thread, JavaThread::stack_guard_state_offset()), JavaThread::stack_guard_yellow_disabled); 1345 __ cmpl(Address(thread, JavaThread::stack_guard_state_offset()), JavaThread::stack_guard_yellow_disabled);
1279 __ jcc(Assembler::notEqual, no_reguard); 1346 __ jcc(Assembler::notEqual, no_reguard);
1280 1347
1281 __ pushad(); 1348 __ pusha();
1282 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages))); 1349 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages)));
1283 __ popad(); 1350 __ popa();
1284 1351
1285 __ bind(no_reguard); 1352 __ bind(no_reguard);
1286 } 1353 }
1287 1354
1288 1355
1293 // and forward it before doing the unlocking and notifying jvmdi that method has exited. 1360 // and forward it before doing the unlocking and notifying jvmdi that method has exited.
1294 // This seems wrong need to investigate the spec. 1361 // This seems wrong need to investigate the spec.
1295 1362
1296 // handle exceptions (exception handling will handle unlocking!) 1363 // handle exceptions (exception handling will handle unlocking!)
1297 { Label L; 1364 { Label L;
1298 __ cmpl(Address(thread, Thread::pending_exception_offset()), NULL_WORD); 1365 __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1299 __ jcc(Assembler::zero, L); 1366 __ jcc(Assembler::zero, L);
1300 __ bind(pending_exception_present); 1367 __ bind(pending_exception_present);
1301 1368
1302 // There are potential results on the stack (rax/rdx, ST(0)) we ignore these and simply 1369 // There are potential results on the stack (rax/rdx, ST(0)) we ignore these and simply
1303 // return and let caller deal with exception. This skips the unlocking here which 1370 // return and let caller deal with exception. This skips the unlocking here which
1305 // Note: must preverve method in rbx 1372 // Note: must preverve method in rbx
1306 // 1373 //
1307 1374
1308 // remove activation 1375 // remove activation
1309 1376
1310 __ movl(t, STATE(_sender_sp)); 1377 __ movptr(t, STATE(_sender_sp));
1311 __ leave(); // remove frame anchor 1378 __ leave(); // remove frame anchor
1312 __ popl(rdi); // get return address 1379 __ pop(rdi); // get return address
1313 __ movl(state, STATE(_prev_link)); // get previous state for return 1380 __ movptr(state, STATE(_prev_link)); // get previous state for return
1314 __ movl(rsp, t); // set sp to sender sp 1381 __ mov(rsp, t); // set sp to sender sp
1315 __ pushl(rdi); // [ush throwing pc 1382 __ push(rdi); // push throwing pc
1316 // The skips unlocking!! This seems to be what asm interpreter does but seems 1383 // The skips unlocking!! This seems to be what asm interpreter does but seems
1317 // very wrong. Not clear if this violates the spec. 1384 // very wrong. Not clear if this violates the spec.
1318 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); 1385 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
1319 __ bind(L); 1386 __ bind(L);
1320 } 1387 }
1324 __ movl(t, Address(method, methodOopDesc::access_flags_offset())); 1391 __ movl(t, Address(method, methodOopDesc::access_flags_offset()));
1325 __ testl(t, JVM_ACC_SYNCHRONIZED); 1392 __ testl(t, JVM_ACC_SYNCHRONIZED);
1326 __ jcc(Assembler::zero, L); 1393 __ jcc(Assembler::zero, L);
1327 // the code below should be shared with interpreter macro assembler implementation 1394 // the code below should be shared with interpreter macro assembler implementation
1328 { Label unlock; 1395 { Label unlock;
1396 const Register monitor = NOT_LP64(rdx) LP64_ONLY(c_rarg1);
1329 // BasicObjectLock will be first in list, since this is a synchronized method. However, need 1397 // BasicObjectLock will be first in list, since this is a synchronized method. However, need
1330 // to check that the object has not been unlocked by an explicit monitorexit bytecode. 1398 // to check that the object has not been unlocked by an explicit monitorexit bytecode.
1331 __ movl(rdx, STATE(_monitor_base)); 1399 __ movptr(monitor, STATE(_monitor_base));
1332 __ subl(rdx, frame::interpreter_frame_monitor_size() * wordSize); // address of initial monitor 1400 __ subptr(monitor, frame::interpreter_frame_monitor_size() * wordSize); // address of initial monitor
1333 1401
1334 __ movl(t, Address(rdx, BasicObjectLock::obj_offset_in_bytes())); 1402 __ movptr(t, Address(monitor, BasicObjectLock::obj_offset_in_bytes()));
1335 __ testl(t, t); 1403 __ testptr(t, t);
1336 __ jcc(Assembler::notZero, unlock); 1404 __ jcc(Assembler::notZero, unlock);
1337 1405
1338 // Entry already unlocked, need to throw exception 1406 // Entry already unlocked, need to throw exception
1339 __ MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); 1407 __ MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
1340 __ should_not_reach_here(); 1408 __ should_not_reach_here();
1341 1409
1342 __ bind(unlock); 1410 __ bind(unlock);
1343 __ unlock_object(rdx); 1411 __ unlock_object(monitor);
1344 // unlock can blow rbx so restore it for path that needs it below 1412 // unlock can blow rbx so restore it for path that needs it below
1345 __ movl(method, STATE(_method)); 1413 __ movptr(method, STATE(_method));
1346 } 1414 }
1347 __ bind(L); 1415 __ bind(L);
1348 } 1416 }
1349 1417
1350 // jvmti support 1418 // jvmti support
1353 // too. If this happens before, method entry/exit notifications are 1421 // too. If this happens before, method entry/exit notifications are
1354 // not properly paired (was bug - gri 11/22/99). 1422 // not properly paired (was bug - gri 11/22/99).
1355 __ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI); 1423 __ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI);
1356 1424
1357 // restore potential result in rdx:rax, call result handler to restore potential result in ST0 & handle result 1425 // restore potential result in rdx:rax, call result handler to restore potential result in ST0 & handle result
1358 __ pop(ltos); // restore rax/rdx floating result if present still on stack 1426 #ifndef _LP64
1359 __ movl(t, STATE(_result_handler)); // get result handler 1427 __ pop(rdx);
1428 #endif // _LP64
1429 __ pop(rax);
1430 __ movptr(t, STATE(_result_handler)); // get result handler
1360 __ call(t); // call result handler to convert to tosca form 1431 __ call(t); // call result handler to convert to tosca form
1361 1432
1362 // remove activation 1433 // remove activation
1363 1434
1364 __ movl(t, STATE(_sender_sp)); 1435 __ movptr(t, STATE(_sender_sp));
1365 1436
1366 __ leave(); // remove frame anchor 1437 __ leave(); // remove frame anchor
1367 __ popl(rdi); // get return address 1438 __ pop(rdi); // get return address
1368 __ movl(state, STATE(_prev_link)); // get previous state for return (if c++ interpreter was caller) 1439 __ movptr(state, STATE(_prev_link)); // get previous state for return (if c++ interpreter was caller)
1369 __ movl(rsp, t); // set sp to sender sp 1440 __ mov(rsp, t); // set sp to sender sp
1370 __ jmp(rdi); 1441 __ jmp(rdi);
1371 1442
1372 // invocation counter overflow 1443 // invocation counter overflow
1373 if (inc_counter) { 1444 if (inc_counter) {
1374 // Handle overflow of counter and compile method 1445 // Handle overflow of counter and compile method
1380 } 1451 }
1381 1452
1382 // Generate entries that will put a result type index into rcx 1453 // Generate entries that will put a result type index into rcx
1383 void CppInterpreterGenerator::generate_deopt_handling() { 1454 void CppInterpreterGenerator::generate_deopt_handling() {
1384 1455
1385 const Register state = rsi;
1386 Label return_from_deopt_common; 1456 Label return_from_deopt_common;
1387 1457
1388 // Generate entries that will put a result type index into rcx 1458 // Generate entries that will put a result type index into rcx
1389 // deopt needs to jump to here to enter the interpreter (return a result) 1459 // deopt needs to jump to here to enter the interpreter (return a result)
1390 deopt_frame_manager_return_atos = __ pc(); 1460 deopt_frame_manager_return_atos = __ pc();
1447 // than say sparc (which needs a full size activation because 1517 // than say sparc (which needs a full size activation because
1448 // the windows are in the way. Really it could be short? QQQ 1518 // the windows are in the way. Really it could be short? QQQ
1449 // 1519 //
1450 __ bind(return_from_deopt_common); 1520 __ bind(return_from_deopt_common);
1451 1521
1452 __ leal(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); 1522 __ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter)));
1453 1523
1454 // setup rsp so we can push the "result" as needed. 1524 // setup rsp so we can push the "result" as needed.
1455 __ movl(rsp, STATE(_stack)); // trim stack (is prepushed) 1525 __ movptr(rsp, STATE(_stack)); // trim stack (is prepushed)
1456 __ addl(rsp, wordSize); // undo prepush 1526 __ addptr(rsp, wordSize); // undo prepush
1457 1527
1458 ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack); 1528 ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack);
1459 // Address index(noreg, rcx, Address::times_4); 1529 // Address index(noreg, rcx, Address::times_ptr);
1460 __ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_4))); 1530 __ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_ptr)));
1461 // __ movl(rcx, Address(noreg, rcx, Address::times_4, int(AbstractInterpreter::_tosca_to_stack))); 1531 // __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack)));
1462 __ call(rcx); // call result converter 1532 __ call(rcx); // call result converter
1463 1533
1464 __ movl(STATE(_msg), (int)BytecodeInterpreter::deopt_resume); 1534 __ movl(STATE(_msg), (int)BytecodeInterpreter::deopt_resume);
1465 __ leal(rsp, Address(rsp, -wordSize)); // prepush stack (result if any already present) 1535 __ lea(rsp, Address(rsp, -wordSize)); // prepush stack (result if any already present)
1466 __ movl(STATE(_stack), rsp); // inform interpreter of new stack depth (parameters removed, 1536 __ movptr(STATE(_stack), rsp); // inform interpreter of new stack depth (parameters removed,
1467 // result if any on stack already ) 1537 // result if any on stack already )
1468 __ movl(rsp, STATE(_stack_limit)); // restore expression stack to full depth 1538 __ movptr(rsp, STATE(_stack_limit)); // restore expression stack to full depth
1469 } 1539 }
1470 1540
1471 // Generate the code to handle a more_monitors message from the c++ interpreter 1541 // Generate the code to handle a more_monitors message from the c++ interpreter
1472 void CppInterpreterGenerator::generate_more_monitors() { 1542 void CppInterpreterGenerator::generate_more_monitors() {
1473 1543
1474 const Register state = rsi;
1475 1544
1476 Label entry, loop; 1545 Label entry, loop;
1477 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; 1546 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
1478 // 1. compute new pointers // rsp: old expression stack top 1547 // 1. compute new pointers // rsp: old expression stack top
1479 __ movl(rdx, STATE(_stack_base)); // rdx: old expression stack bottom 1548 __ movptr(rdx, STATE(_stack_base)); // rdx: old expression stack bottom
1480 __ subl(rsp, entry_size); // move expression stack top limit 1549 __ subptr(rsp, entry_size); // move expression stack top limit
1481 __ subl(STATE(_stack), entry_size); // update interpreter stack top 1550 __ subptr(STATE(_stack), entry_size); // update interpreter stack top
1482 __ movl(STATE(_stack_limit), rsp); // inform interpreter 1551 __ subptr(STATE(_stack_limit), entry_size); // inform interpreter
1483 __ subl(rdx, entry_size); // move expression stack bottom 1552 __ subptr(rdx, entry_size); // move expression stack bottom
1484 __ movl(STATE(_stack_base), rdx); // inform interpreter 1553 __ movptr(STATE(_stack_base), rdx); // inform interpreter
1485 __ movl(rcx, STATE(_stack)); // set start value for copy loop 1554 __ movptr(rcx, STATE(_stack)); // set start value for copy loop
1486 __ jmp(entry); 1555 __ jmp(entry);
1487 // 2. move expression stack contents 1556 // 2. move expression stack contents
1488 __ bind(loop); 1557 __ bind(loop);
1489 __ movl(rbx, Address(rcx, entry_size)); // load expression stack word from old location 1558 __ movptr(rbx, Address(rcx, entry_size)); // load expression stack word from old location
1490 __ movl(Address(rcx, 0), rbx); // and store it at new location 1559 __ movptr(Address(rcx, 0), rbx); // and store it at new location
1491 __ addl(rcx, wordSize); // advance to next word 1560 __ addptr(rcx, wordSize); // advance to next word
1492 __ bind(entry); 1561 __ bind(entry);
1493 __ cmpl(rcx, rdx); // check if bottom reached 1562 __ cmpptr(rcx, rdx); // check if bottom reached
1494 __ jcc(Assembler::notEqual, loop); // if not at bottom then copy next word 1563 __ jcc(Assembler::notEqual, loop); // if not at bottom then copy next word
1495 // now zero the slot so we can find it. 1564 // now zero the slot so we can find it.
1496 __ movl(Address(rdx, BasicObjectLock::obj_offset_in_bytes()), (int) NULL); 1565 __ movptr(Address(rdx, BasicObjectLock::obj_offset_in_bytes()), (int32_t) NULL_WORD);
1497 __ movl(STATE(_msg), (int)BytecodeInterpreter::got_monitors); 1566 __ movl(STATE(_msg), (int)BytecodeInterpreter::got_monitors);
1498 } 1567 }
1499 1568
1500 1569
1501 // Initial entry to C++ interpreter from the call_stub. 1570 // Initial entry to C++ interpreter from the call_stub.
1515 // 1584 //
1516 // Arguments: 1585 // Arguments:
1517 // 1586 //
1518 // rbx: methodOop 1587 // rbx: methodOop
1519 // rcx: receiver - unused (retrieved from stack as needed) 1588 // rcx: receiver - unused (retrieved from stack as needed)
1520 // rsi: previous frame manager state (NULL from the call_stub/c1/c2) 1589 // rsi/r13: previous frame manager state (NULL from the call_stub/c1/c2)
1521 // 1590 //
1522 // 1591 //
1523 // Stack layout at entry 1592 // Stack layout at entry
1524 // 1593 //
1525 // [ return address ] <--- rsp 1594 // [ return address ] <--- rsp
1537 static address interpreter_frame_manager = NULL; 1606 static address interpreter_frame_manager = NULL;
1538 1607
1539 address InterpreterGenerator::generate_normal_entry(bool synchronized) { 1608 address InterpreterGenerator::generate_normal_entry(bool synchronized) {
1540 1609
1541 // rbx: methodOop 1610 // rbx: methodOop
1542 // rsi: sender sp 1611 // rsi/r13: sender sp
1543 1612
1544 // Because we redispatch "recursive" interpreter entries thru this same entry point 1613 // Because we redispatch "recursive" interpreter entries thru this same entry point
1545 // the "input" register usage is a little strange and not what you expect coming 1614 // the "input" register usage is a little strange and not what you expect coming
1546 // from the call_stub. From the call stub rsi/rdi (current/previous) interpreter 1615 // from the call_stub. From the call stub rsi/rdi (current/previous) interpreter
1547 // state are NULL but on "recursive" dispatches they are what you'd expect. 1616 // state are NULL but on "recursive" dispatches they are what you'd expect.
1560 // Fast accessor methods share this entry point. 1629 // Fast accessor methods share this entry point.
1561 // This works because frame manager is in the same codelet 1630 // This works because frame manager is in the same codelet
1562 if (UseFastAccessorMethods && !synchronized) __ bind(fast_accessor_slow_entry_path); 1631 if (UseFastAccessorMethods && !synchronized) __ bind(fast_accessor_slow_entry_path);
1563 1632
1564 Label dispatch_entry_2; 1633 Label dispatch_entry_2;
1565 __ movl(rcx, rsi); 1634 __ movptr(rcx, sender_sp_on_entry);
1566 __ movl(rsi, 0); // no current activation 1635 __ movptr(state, (int32_t)NULL_WORD); // no current activation
1567 1636
1568 __ jmp(dispatch_entry_2); 1637 __ jmp(dispatch_entry_2);
1569 1638
1570 const Register state = rsi; // current activation object, valid on entry
1571 const Register locals = rdi; 1639 const Register locals = rdi;
1572 1640
1573 Label re_dispatch; 1641 Label re_dispatch;
1574 1642
1575 __ bind(re_dispatch); 1643 __ bind(re_dispatch);
1576 1644
1577 // save sender sp (doesn't include return address 1645 // save sender sp (doesn't include return address
1578 __ leal(rcx, Address(rsp, wordSize)); 1646 __ lea(rcx, Address(rsp, wordSize));
1579 1647
1580 __ bind(dispatch_entry_2); 1648 __ bind(dispatch_entry_2);
1581 1649
1582 // save sender sp 1650 // save sender sp
1583 __ pushl(rcx); 1651 __ push(rcx);
1584 1652
1585 const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset()); 1653 const Address size_of_parameters(rbx, methodOopDesc::size_of_parameters_offset());
1586 const Address size_of_locals (rbx, methodOopDesc::size_of_locals_offset()); 1654 const Address size_of_locals (rbx, methodOopDesc::size_of_locals_offset());
1587 const Address access_flags (rbx, methodOopDesc::access_flags_offset()); 1655 const Address access_flags (rbx, methodOopDesc::access_flags_offset());
1588 1656
1595 1663
1596 // rbx: methodOop 1664 // rbx: methodOop
1597 // rcx: size of parameters 1665 // rcx: size of parameters
1598 __ load_unsigned_word(rdx, size_of_locals); // get size of locals in words 1666 __ load_unsigned_word(rdx, size_of_locals); // get size of locals in words
1599 1667
1600 __ subl(rdx, rcx); // rdx = no. of additional locals 1668 __ subptr(rdx, rcx); // rdx = no. of additional locals
1601 1669
1602 // see if we've got enough room on the stack for locals plus overhead. 1670 // see if we've got enough room on the stack for locals plus overhead.
1603 generate_stack_overflow_check(); // C++ 1671 generate_stack_overflow_check(); // C++
1604 1672
1605 // c++ interpreter does not use stack banging or any implicit exceptions 1673 // c++ interpreter does not use stack banging or any implicit exceptions
1607 bang_stack_shadow_pages(false); 1675 bang_stack_shadow_pages(false);
1608 1676
1609 1677
1610 1678
1611 // compute beginning of parameters (rdi) 1679 // compute beginning of parameters (rdi)
1612 __ leal(locals, Address(rsp, rcx, Address::times_4, wordSize)); 1680 __ lea(locals, Address(rsp, rcx, Address::times_ptr, wordSize));
1613 1681
1614 // save sender's sp 1682 // save sender's sp
1615 // __ movl(rcx, rsp); 1683 // __ movl(rcx, rsp);
1616 1684
1617 // get sender's sp 1685 // get sender's sp
1618 __ popl(rcx); 1686 __ pop(rcx);
1619 1687
1620 // get return address 1688 // get return address
1621 __ popl(rax); 1689 __ pop(rax);
1622 1690
1623 // rdx - # of additional locals 1691 // rdx - # of additional locals
1624 // allocate space for locals 1692 // allocate space for locals
1625 // explicitly initialize locals 1693 // explicitly initialize locals
1626 { 1694 {
1627 Label exit, loop; 1695 Label exit, loop;
1628 __ testl(rdx, rdx); 1696 __ testl(rdx, rdx); // (32bit ok)
1629 __ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0 1697 __ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0
1630 __ bind(loop); 1698 __ bind(loop);
1631 __ pushl((int)NULL); // initialize local variables 1699 __ push((int32_t)NULL_WORD); // initialize local variables
1632 __ decrement(rdx); // until everything initialized 1700 __ decrement(rdx); // until everything initialized
1633 __ jcc(Assembler::greater, loop); 1701 __ jcc(Assembler::greater, loop);
1634 __ bind(exit); 1702 __ bind(exit);
1635 } 1703 }
1636 1704
1662 Label call_interpreter_2; 1730 Label call_interpreter_2;
1663 1731
1664 __ bind(call_interpreter_2); 1732 __ bind(call_interpreter_2);
1665 1733
1666 { 1734 {
1667 const Register thread = rcx; 1735 const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread);
1668 1736
1669 __ pushl(state); // push arg to interpreter 1737 #ifdef _LP64
1670 __ movl(thread, STATE(_thread)); 1738 __ mov(c_rarg0, state);
1739 #else
1740 __ push(state); // push arg to interpreter
1741 __ movptr(thread, STATE(_thread));
1742 #endif // _LP64
1671 1743
1672 // We can setup the frame anchor with everything we want at this point 1744 // We can setup the frame anchor with everything we want at this point
1673 // as we are thread_in_Java and no safepoints can occur until we go to 1745 // as we are thread_in_Java and no safepoints can occur until we go to
1674 // vm mode. We do have to clear flags on return from vm but that is it 1746 // vm mode. We do have to clear flags on return from vm but that is it
1675 // 1747 //
1676 __ movl(Address(thread, JavaThread::last_Java_fp_offset()), rbp); 1748 __ movptr(Address(thread, JavaThread::last_Java_fp_offset()), rbp);
1677 __ movl(Address(thread, JavaThread::last_Java_sp_offset()), rsp); 1749 __ movptr(Address(thread, JavaThread::last_Java_sp_offset()), rsp);
1678 1750
1679 // Call the interpreter 1751 // Call the interpreter
1680 1752
1681 RuntimeAddress normal(CAST_FROM_FN_PTR(address, BytecodeInterpreter::run)); 1753 RuntimeAddress normal(CAST_FROM_FN_PTR(address, BytecodeInterpreter::run));
1682 RuntimeAddress checking(CAST_FROM_FN_PTR(address, BytecodeInterpreter::runWithChecks)); 1754 RuntimeAddress checking(CAST_FROM_FN_PTR(address, BytecodeInterpreter::runWithChecks));
1683 1755
1684 __ call(JvmtiExport::can_post_interpreter_events() ? checking : normal); 1756 __ call(JvmtiExport::can_post_interpreter_events() ? checking : normal);
1685 __ popl(rax); // discard parameter to run 1757 NOT_LP64(__ pop(rax);) // discard parameter to run
1686 // 1758 //
1687 // state is preserved since it is callee saved 1759 // state is preserved since it is callee saved
1688 // 1760 //
1689 1761
1690 // reset_last_Java_frame 1762 // reset_last_Java_frame
1691 1763
1692 __ movl(thread, STATE(_thread)); 1764 NOT_LP64(__ movl(thread, STATE(_thread));)
1693 __ reset_last_Java_frame(thread, true, true); 1765 __ reset_last_Java_frame(thread, true, true);
1694 } 1766 }
1695 1767
1696 // examine msg from interpreter to determine next action 1768 // examine msg from interpreter to determine next action
1697 1769
1701 Label return_from_interpreted_method; 1773 Label return_from_interpreted_method;
1702 Label throw_exception; 1774 Label throw_exception;
1703 Label bad_msg; 1775 Label bad_msg;
1704 Label do_OSR; 1776 Label do_OSR;
1705 1777
1706 __ cmpl(rdx, (int)BytecodeInterpreter::call_method); 1778 __ cmpl(rdx, (int32_t)BytecodeInterpreter::call_method);
1707 __ jcc(Assembler::equal, call_method); 1779 __ jcc(Assembler::equal, call_method);
1708 __ cmpl(rdx, (int)BytecodeInterpreter::return_from_method); 1780 __ cmpl(rdx, (int32_t)BytecodeInterpreter::return_from_method);
1709 __ jcc(Assembler::equal, return_from_interpreted_method); 1781 __ jcc(Assembler::equal, return_from_interpreted_method);
1710 __ cmpl(rdx, (int)BytecodeInterpreter::do_osr); 1782 __ cmpl(rdx, (int32_t)BytecodeInterpreter::do_osr);
1711 __ jcc(Assembler::equal, do_OSR); 1783 __ jcc(Assembler::equal, do_OSR);
1712 __ cmpl(rdx, (int)BytecodeInterpreter::throwing_exception); 1784 __ cmpl(rdx, (int32_t)BytecodeInterpreter::throwing_exception);
1713 __ jcc(Assembler::equal, throw_exception); 1785 __ jcc(Assembler::equal, throw_exception);
1714 __ cmpl(rdx, (int)BytecodeInterpreter::more_monitors); 1786 __ cmpl(rdx, (int32_t)BytecodeInterpreter::more_monitors);
1715 __ jcc(Assembler::notEqual, bad_msg); 1787 __ jcc(Assembler::notEqual, bad_msg);
1716 1788
1717 // Allocate more monitor space, shuffle expression stack.... 1789 // Allocate more monitor space, shuffle expression stack....
1718 1790
1719 generate_more_monitors(); 1791 generate_more_monitors();
1722 1794
1723 // uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode) 1795 // uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode)
1724 unctrap_frame_manager_entry = __ pc(); 1796 unctrap_frame_manager_entry = __ pc();
1725 // 1797 //
1726 // Load the registers we need. 1798 // Load the registers we need.
1727 __ leal(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); 1799 __ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter)));
1728 __ movl(rsp, STATE(_stack_limit)); // restore expression stack to full depth 1800 __ movptr(rsp, STATE(_stack_limit)); // restore expression stack to full depth
1729 __ jmp(call_interpreter_2); 1801 __ jmp(call_interpreter_2);
1730 1802
1731 1803
1732 1804
1733 //============================================================================= 1805 //=============================================================================
1755 1827
1756 Label return_with_exception; 1828 Label return_with_exception;
1757 Label unwind_and_forward; 1829 Label unwind_and_forward;
1758 1830
1759 // restore state pointer. 1831 // restore state pointer.
1760 __ leal(state, Address(rbp, -sizeof(BytecodeInterpreter))); 1832 __ lea(state, Address(rbp, -sizeof(BytecodeInterpreter)));
1761 1833
1762 __ movl(rbx, STATE(_method)); // get method 1834 __ movptr(rbx, STATE(_method)); // get method
1835 #ifdef _LP64
1836 __ movptr(Address(r15_thread, Thread::pending_exception_offset()), rax);
1837 #else
1763 __ movl(rcx, STATE(_thread)); // get thread 1838 __ movl(rcx, STATE(_thread)); // get thread
1764 1839
1765 // Store exception with interpreter will expect it 1840 // Store exception with interpreter will expect it
1766 __ movl(Address(rcx, Thread::pending_exception_offset()), rax); 1841 __ movptr(Address(rcx, Thread::pending_exception_offset()), rax);
1842 #endif // _LP64
1767 1843
1768 // is current frame vanilla or native? 1844 // is current frame vanilla or native?
1769 1845
1770 __ movl(rdx, access_flags); 1846 __ movl(rdx, access_flags);
1771 __ testl(rdx, JVM_ACC_NATIVE); 1847 __ testl(rdx, JVM_ACC_NATIVE);
1777 1853
1778 __ bind(unwind_and_forward); 1854 __ bind(unwind_and_forward);
1779 1855
1780 // unwind rbp, return stack to unextended value and re-push return address 1856 // unwind rbp, return stack to unextended value and re-push return address
1781 1857
1782 __ movl(rcx, STATE(_sender_sp)); 1858 __ movptr(rcx, STATE(_sender_sp));
1783 __ leave(); 1859 __ leave();
1784 __ popl(rdx); 1860 __ pop(rdx);
1785 __ movl(rsp, rcx); 1861 __ mov(rsp, rcx);
1786 __ pushl(rdx); 1862 __ push(rdx);
1787 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); 1863 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
1788 1864
1789 // Return point from a call which returns a result in the native abi 1865 // Return point from a call which returns a result in the native abi
1790 // (c1/c2/jni-native). This result must be processed onto the java 1866 // (c1/c2/jni-native). This result must be processed onto the java
1791 // expression stack. 1867 // expression stack.
1799 1875
1800 address compiled_entry = __ pc(); 1876 address compiled_entry = __ pc();
1801 1877
1802 // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases 1878 // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases
1803 if (UseSSE < 2) { 1879 if (UseSSE < 2) {
1804 __ leal(state, Address(rbp, -sizeof(BytecodeInterpreter))); 1880 __ lea(state, Address(rbp, -sizeof(BytecodeInterpreter)));
1805 __ movl(rbx, STATE(_result._to_call._callee)); // get method just executed 1881 __ movptr(rbx, STATE(_result._to_call._callee)); // get method just executed
1806 __ movl(rcx, Address(rbx, methodOopDesc::result_index_offset())); 1882 __ movl(rcx, Address(rbx, methodOopDesc::result_index_offset()));
1807 __ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_FLOAT)); // Result stub address array index 1883 __ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_FLOAT)); // Result stub address array index
1808 __ jcc(Assembler::equal, do_float); 1884 __ jcc(Assembler::equal, do_float);
1809 __ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_DOUBLE)); // Result stub address array index 1885 __ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_DOUBLE)); // Result stub address array index
1810 __ jcc(Assembler::equal, do_double); 1886 __ jcc(Assembler::equal, do_double);
1830 } else { 1906 } else {
1831 __ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled"); 1907 __ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled");
1832 __ jmp(done_conv); 1908 __ jmp(done_conv);
1833 } 1909 }
1834 1910
1911 #if 0
1835 // emit a sentinel we can test for when converting an interpreter 1912 // emit a sentinel we can test for when converting an interpreter
1836 // entry point to a compiled entry point. 1913 // entry point to a compiled entry point.
1837 __ a_long(Interpreter::return_sentinel); 1914 __ a_long(Interpreter::return_sentinel);
1838 __ a_long((int)compiled_entry); 1915 __ a_long((int)compiled_entry);
1916 #endif
1839 1917
1840 // Return point to interpreter from compiled/native method 1918 // Return point to interpreter from compiled/native method
1841 1919
1842 InternalAddress return_from_native_method(__ pc()); 1920 InternalAddress return_from_native_method(__ pc());
1843 1921
1846 1924
1847 // Result if any is in tosca. The java expression stack is in the state that the 1925 // Result if any is in tosca. The java expression stack is in the state that the
1848 // calling convention left it (i.e. params may or may not be present) 1926 // calling convention left it (i.e. params may or may not be present)
1849 // Copy the result from tosca and place it on java expression stack. 1927 // Copy the result from tosca and place it on java expression stack.
1850 1928
1851 // Restore rsi as compiled code may not preserve it 1929 // Restore rsi/r13 as compiled code may not preserve it
1852 1930
1853 __ leal(state, Address(rbp, -sizeof(BytecodeInterpreter))); 1931 __ lea(state, Address(rbp, -sizeof(BytecodeInterpreter)));
1854 1932
1855 // restore stack to what we had when we left (in case i2c extended it) 1933 // restore stack to what we had when we left (in case i2c extended it)
1856 1934
1857 __ movl(rsp, STATE(_stack)); 1935 __ movptr(rsp, STATE(_stack));
1858 __ leal(rsp, Address(rsp, wordSize)); 1936 __ lea(rsp, Address(rsp, wordSize));
1859 1937
1860 // If there is a pending exception then we don't really have a result to process 1938 // If there is a pending exception then we don't really have a result to process
1861 1939
1862 __ movl(rcx, STATE(_thread)); // get thread 1940 #ifdef _LP64
1863 __ cmpl(Address(rcx, Thread::pending_exception_offset()), (int)NULL); 1941 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1942 #else
1943 __ movptr(rcx, STATE(_thread)); // get thread
1944 __ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1945 #endif / __LP64
1864 __ jcc(Assembler::notZero, return_with_exception); 1946 __ jcc(Assembler::notZero, return_with_exception);
1865 1947
1866 // get method just executed 1948 // get method just executed
1867 __ movl(rbx, STATE(_result._to_call._callee)); 1949 __ movptr(rbx, STATE(_result._to_call._callee));
1868 1950
1869 // callee left args on top of expression stack, remove them 1951 // callee left args on top of expression stack, remove them
1870 __ load_unsigned_word(rcx, Address(rbx, methodOopDesc::size_of_parameters_offset())); 1952 __ load_unsigned_word(rcx, Address(rbx, methodOopDesc::size_of_parameters_offset()));
1871 __ leal(rsp, Address(rsp, rcx, Address::times_4)); 1953 __ lea(rsp, Address(rsp, rcx, Address::times_ptr));
1872 1954
1873 __ movl(rcx, Address(rbx, methodOopDesc::result_index_offset())); 1955 __ movl(rcx, Address(rbx, methodOopDesc::result_index_offset()));
1874 ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack); 1956 ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack);
1875 // Address index(noreg, rax, Address::times_4); 1957 // Address index(noreg, rax, Address::times_ptr);
1876 __ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_4))); 1958 __ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_ptr)));
1877 // __ movl(rcx, Address(noreg, rcx, Address::times_4, int(AbstractInterpreter::_tosca_to_stack))); 1959 // __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack)));
1878 __ call(rcx); // call result converter 1960 __ call(rcx); // call result converter
1879 __ jmp(resume_interpreter); 1961 __ jmp(resume_interpreter);
1880 1962
1881 // An exception is being caught on return to a vanilla interpreter frame. 1963 // An exception is being caught on return to a vanilla interpreter frame.
1882 // Empty the stack and resume interpreter 1964 // Empty the stack and resume interpreter
1883 1965
1884 __ bind(return_with_exception); 1966 __ bind(return_with_exception);
1885 1967
1886 // Exception present, empty stack 1968 // Exception present, empty stack
1887 __ movl(rsp, STATE(_stack_base)); 1969 __ movptr(rsp, STATE(_stack_base));
1888 __ jmp(resume_interpreter); 1970 __ jmp(resume_interpreter);
1889 1971
1890 // Return from interpreted method we return result appropriate to the caller (i.e. "recursive" 1972 // Return from interpreted method we return result appropriate to the caller (i.e. "recursive"
1891 // interpreter call, or native) and unwind this interpreter activation. 1973 // interpreter call, or native) and unwind this interpreter activation.
1892 // All monitors should be unlocked. 1974 // All monitors should be unlocked.
1893 1975
1894 __ bind(return_from_interpreted_method); 1976 __ bind(return_from_interpreted_method);
1895 1977
1896 Label return_to_initial_caller; 1978 Label return_to_initial_caller;
1897 1979
1898 __ movl(rbx, STATE(_method)); // get method just executed 1980 __ movptr(rbx, STATE(_method)); // get method just executed
1899 __ cmpl(STATE(_prev_link), (int)NULL); // returning from "recursive" interpreter call? 1981 __ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD); // returning from "recursive" interpreter call?
1900 __ movl(rax, Address(rbx, methodOopDesc::result_index_offset())); // get result type index 1982 __ movl(rax, Address(rbx, methodOopDesc::result_index_offset())); // get result type index
1901 __ jcc(Assembler::equal, return_to_initial_caller); // back to native code (call_stub/c1/c2) 1983 __ jcc(Assembler::equal, return_to_initial_caller); // back to native code (call_stub/c1/c2)
1902 1984
1903 // Copy result to callers java stack 1985 // Copy result to callers java stack
1904 ExternalAddress stack_to_stack((address)CppInterpreter::_stack_to_stack); 1986 ExternalAddress stack_to_stack((address)CppInterpreter::_stack_to_stack);
1905 // Address index(noreg, rax, Address::times_4); 1987 // Address index(noreg, rax, Address::times_ptr);
1906 1988
1907 __ movptr(rax, ArrayAddress(stack_to_stack, Address(noreg, rax, Address::times_4))); 1989 __ movptr(rax, ArrayAddress(stack_to_stack, Address(noreg, rax, Address::times_ptr)));
1908 // __ movl(rax, Address(noreg, rax, Address::times_4, int(AbstractInterpreter::_stack_to_stack))); 1990 // __ movl(rax, Address(noreg, rax, Address::times_ptr, int(AbstractInterpreter::_stack_to_stack)));
1909 __ call(rax); // call result converter 1991 __ call(rax); // call result converter
1910 1992
1911 Label unwind_recursive_activation; 1993 Label unwind_recursive_activation;
1912 __ bind(unwind_recursive_activation); 1994 __ bind(unwind_recursive_activation);
1913 1995
1914 // returning to interpreter method from "recursive" interpreter call 1996 // returning to interpreter method from "recursive" interpreter call
1915 // result converter left rax pointing to top of the java stack for method we are returning 1997 // result converter left rax pointing to top of the java stack for method we are returning
1916 // to. Now all we must do is unwind the state from the completed call 1998 // to. Now all we must do is unwind the state from the completed call
1917 1999
1918 __ movl(state, STATE(_prev_link)); // unwind state 2000 __ movptr(state, STATE(_prev_link)); // unwind state
1919 __ leave(); // pop the frame 2001 __ leave(); // pop the frame
1920 __ movl(rsp, rax); // unwind stack to remove args 2002 __ mov(rsp, rax); // unwind stack to remove args
1921 2003
1922 // Resume the interpreter. The current frame contains the current interpreter 2004 // Resume the interpreter. The current frame contains the current interpreter
1923 // state object. 2005 // state object.
1924 // 2006 //
1925 2007
1926 __ bind(resume_interpreter); 2008 __ bind(resume_interpreter);
1927 2009
1928 // state == interpreterState object for method we are resuming 2010 // state == interpreterState object for method we are resuming
1929 2011
1930 __ movl(STATE(_msg), (int)BytecodeInterpreter::method_resume); 2012 __ movl(STATE(_msg), (int)BytecodeInterpreter::method_resume);
1931 __ leal(rsp, Address(rsp, -wordSize)); // prepush stack (result if any already present) 2013 __ lea(rsp, Address(rsp, -wordSize)); // prepush stack (result if any already present)
1932 __ movl(STATE(_stack), rsp); // inform interpreter of new stack depth (parameters removed, 2014 __ movptr(STATE(_stack), rsp); // inform interpreter of new stack depth (parameters removed,
1933 // result if any on stack already ) 2015 // result if any on stack already )
1934 __ movl(rsp, STATE(_stack_limit)); // restore expression stack to full depth 2016 __ movptr(rsp, STATE(_stack_limit)); // restore expression stack to full depth
1935 __ jmp(call_interpreter_2); // No need to bang 2017 __ jmp(call_interpreter_2); // No need to bang
1936 2018
1937 // interpreter returning to native code (call_stub/c1/c2) 2019 // interpreter returning to native code (call_stub/c1/c2)
1938 // convert result and unwind initial activation 2020 // convert result and unwind initial activation
1939 // rax - result index 2021 // rax - result index
1940 2022
1941 __ bind(return_to_initial_caller); 2023 __ bind(return_to_initial_caller);
1942 ExternalAddress stack_to_native((address)CppInterpreter::_stack_to_native_abi); 2024 ExternalAddress stack_to_native((address)CppInterpreter::_stack_to_native_abi);
1943 // Address index(noreg, rax, Address::times_4); 2025 // Address index(noreg, rax, Address::times_ptr);
1944 2026
1945 __ movptr(rax, ArrayAddress(stack_to_native, Address(noreg, rax, Address::times_4))); 2027 __ movptr(rax, ArrayAddress(stack_to_native, Address(noreg, rax, Address::times_ptr)));
1946 __ call(rax); // call result converter 2028 __ call(rax); // call result converter
1947 2029
1948 Label unwind_initial_activation; 2030 Label unwind_initial_activation;
1949 __ bind(unwind_initial_activation); 2031 __ bind(unwind_initial_activation);
1950 2032
1962 2044
1963 */ 2045 */
1964 2046
1965 // return restoring the stack to the original sender_sp value 2047 // return restoring the stack to the original sender_sp value
1966 2048
1967 __ movl(rcx, STATE(_sender_sp)); 2049 __ movptr(rcx, STATE(_sender_sp));
1968 __ leave(); 2050 __ leave();
1969 __ popl(rdi); // get return address 2051 __ pop(rdi); // get return address
1970 // set stack to sender's sp 2052 // set stack to sender's sp
1971 __ movl(rsp, rcx); 2053 __ mov(rsp, rcx);
1972 __ jmp(rdi); // return to call_stub 2054 __ jmp(rdi); // return to call_stub
1973 2055
1974 // OSR request, adjust return address to make current frame into adapter frame 2056 // OSR request, adjust return address to make current frame into adapter frame
1975 // and enter OSR nmethod 2057 // and enter OSR nmethod
1976 2058
1980 2062
1981 // We are going to pop this frame. Is there another interpreter frame underneath 2063 // We are going to pop this frame. Is there another interpreter frame underneath
1982 // it or is it callstub/compiled? 2064 // it or is it callstub/compiled?
1983 2065
1984 // Move buffer to the expected parameter location 2066 // Move buffer to the expected parameter location
1985 __ movl(rcx, STATE(_result._osr._osr_buf)); 2067 __ movptr(rcx, STATE(_result._osr._osr_buf));
1986 2068
1987 __ movl(rax, STATE(_result._osr._osr_entry)); 2069 __ movptr(rax, STATE(_result._osr._osr_entry));
1988 2070
1989 __ cmpl(STATE(_prev_link), (int)NULL); // returning from "recursive" interpreter call? 2071 __ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD); // returning from "recursive" interpreter call?
1990 __ jcc(Assembler::equal, remove_initial_frame); // back to native code (call_stub/c1/c2) 2072 __ jcc(Assembler::equal, remove_initial_frame); // back to native code (call_stub/c1/c2)
1991 2073
1992 // __ movl(state, STATE(_prev_link)); // unwind state 2074 __ movptr(sender_sp_on_entry, STATE(_sender_sp)); // get sender's sp in expected register
1993 __ movl(rsi, STATE(_sender_sp)); // get sender's sp in expected register
1994 __ leave(); // pop the frame 2075 __ leave(); // pop the frame
1995 __ movl(rsp, rsi); // trim any stack expansion 2076 __ mov(rsp, sender_sp_on_entry); // trim any stack expansion
1996 2077
1997 2078
1998 // We know we are calling compiled so push specialized return 2079 // We know we are calling compiled so push specialized return
1999 // method uses specialized entry, push a return so we look like call stub setup 2080 // method uses specialized entry, push a return so we look like call stub setup
2000 // this path will handle fact that result is returned in registers and not 2081 // this path will handle fact that result is returned in registers and not
2004 2085
2005 __ jmp(rax); 2086 __ jmp(rax);
2006 2087
2007 __ bind(remove_initial_frame); 2088 __ bind(remove_initial_frame);
2008 2089
2009 __ movl(rdx, STATE(_sender_sp)); 2090 __ movptr(rdx, STATE(_sender_sp));
2010 __ leave(); 2091 __ leave();
2011 // get real return 2092 // get real return
2012 __ popl(rsi); 2093 __ pop(rsi);
2013 // set stack to sender's sp 2094 // set stack to sender's sp
2014 __ movl(rsp, rdx); 2095 __ mov(rsp, rdx);
2015 // repush real return 2096 // repush real return
2016 __ pushl(rsi); 2097 __ push(rsi);
2017 // Enter OSR nmethod 2098 // Enter OSR nmethod
2018 __ jmp(rax); 2099 __ jmp(rax);
2019 2100
2020 2101
2021 2102
2026 __ bind(call_method); 2107 __ bind(call_method);
2027 2108
2028 // stack points to next free location and not top element on expression stack 2109 // stack points to next free location and not top element on expression stack
2029 // method expects sp to be pointing to topmost element 2110 // method expects sp to be pointing to topmost element
2030 2111
2031 __ movl(rsp, STATE(_stack)); // pop args to c++ interpreter, set sp to java stack top 2112 __ movptr(rsp, STATE(_stack)); // pop args to c++ interpreter, set sp to java stack top
2032 __ leal(rsp, Address(rsp, wordSize)); 2113 __ lea(rsp, Address(rsp, wordSize));
2033 2114
2034 __ movl(rbx, STATE(_result._to_call._callee)); // get method to execute 2115 __ movptr(rbx, STATE(_result._to_call._callee)); // get method to execute
2035 2116
2036 // don't need a return address if reinvoking interpreter 2117 // don't need a return address if reinvoking interpreter
2037 2118
2038 // Make it look like call_stub calling conventions 2119 // Make it look like call_stub calling conventions
2039 2120
2045 2126
2046 InternalAddress entry(entry_point); 2127 InternalAddress entry(entry_point);
2047 __ cmpptr(STATE(_result._to_call._callee_entry_point), entry.addr()); // returning to interpreter? 2128 __ cmpptr(STATE(_result._to_call._callee_entry_point), entry.addr()); // returning to interpreter?
2048 __ jcc(Assembler::equal, re_dispatch); // yes 2129 __ jcc(Assembler::equal, re_dispatch); // yes
2049 2130
2050 __ popl(rax); // pop dummy address 2131 __ pop(rax); // pop dummy address
2051 2132
2052 2133
2053 // get specialized entry 2134 // get specialized entry
2054 __ movl(rax, STATE(_result._to_call._callee_entry_point)); 2135 __ movptr(rax, STATE(_result._to_call._callee_entry_point));
2055 // set sender SP 2136 // set sender SP
2056 __ movl(rsi, rsp); 2137 __ mov(sender_sp_on_entry, rsp);
2057 2138
2058 // method uses specialized entry, push a return so we look like call stub setup 2139 // method uses specialized entry, push a return so we look like call stub setup
2059 // this path will handle fact that result is returned in registers and not 2140 // this path will handle fact that result is returned in registers and not
2060 // on the java stack. 2141 // on the java stack.
2061 2142
2071 // We handle result (if any) differently based on return to interpreter or call_stub 2152 // We handle result (if any) differently based on return to interpreter or call_stub
2072 2153
2073 Label unwind_initial_with_pending_exception; 2154 Label unwind_initial_with_pending_exception;
2074 2155
2075 __ bind(throw_exception); 2156 __ bind(throw_exception);
2076 __ cmpl(STATE(_prev_link), (int)NULL); // returning from recursive interpreter call? 2157 __ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD); // returning from recursive interpreter call?
2077 __ jcc(Assembler::equal, unwind_initial_with_pending_exception); // no, back to native code (call_stub/c1/c2) 2158 __ jcc(Assembler::equal, unwind_initial_with_pending_exception); // no, back to native code (call_stub/c1/c2)
2078 __ movl(rax, STATE(_locals)); // pop parameters get new stack value 2159 __ movptr(rax, STATE(_locals)); // pop parameters get new stack value
2079 __ addl(rax, wordSize); // account for prepush before we return 2160 __ addptr(rax, wordSize); // account for prepush before we return
2080 __ jmp(unwind_recursive_activation); 2161 __ jmp(unwind_recursive_activation);
2081 2162
2082 __ bind(unwind_initial_with_pending_exception); 2163 __ bind(unwind_initial_with_pending_exception);
2083 2164
2084 // We will unwind the current (initial) interpreter frame and forward 2165 // We will unwind the current (initial) interpreter frame and forward