comparison src/cpu/x86/vm/x86_64.ad @ 23050:e8260b6328fb

8068945: Use RBP register as proper frame pointer in JIT compiled code on x86 Summary: Introduce the PreserveFramePointer flag to control if RBP is used as the frame pointer or as a general purpose register. Reviewed-by: kvn, roland, dlong, enevill, shade
author zmajo
date Fri, 29 May 2015 10:58:45 +0200
parents 0bf37f737702
children dd9cc155639c faef2a237329
comparison
equal deleted inserted replaced
23049:a1642365d69f 23050:e8260b6328fb
164 // 2) reg_class compiler_method_oop_reg ( /* as def'd in frame section */ ) 164 // 2) reg_class compiler_method_oop_reg ( /* as def'd in frame section */ )
165 // 2) reg_class interpreter_method_oop_reg ( /* as def'd in frame section */ ) 165 // 2) reg_class interpreter_method_oop_reg ( /* as def'd in frame section */ )
166 // 3) reg_class stack_slots( /* one chunk of stack-based "registers" */ ) 166 // 3) reg_class stack_slots( /* one chunk of stack-based "registers" */ )
167 // 167 //
168 168
169 // Class for all pointer registers (including RSP) 169 // Empty register class.
170 reg_class any_reg(RAX, RAX_H, 170 reg_class no_reg();
171 RDX, RDX_H, 171
172 RBP, RBP_H, 172 // Class for all pointer registers (including RSP and RBP)
173 RDI, RDI_H, 173 reg_class any_reg_with_rbp(RAX, RAX_H,
174 RSI, RSI_H, 174 RDX, RDX_H,
175 RCX, RCX_H, 175 RBP, RBP_H,
176 RBX, RBX_H, 176 RDI, RDI_H,
177 RSP, RSP_H, 177 RSI, RSI_H,
178 R8, R8_H, 178 RCX, RCX_H,
179 R9, R9_H, 179 RBX, RBX_H,
180 R10, R10_H, 180 RSP, RSP_H,
181 R11, R11_H, 181 R8, R8_H,
182 R12, R12_H, 182 R9, R9_H,
183 R13, R13_H, 183 R10, R10_H,
184 R14, R14_H, 184 R11, R11_H,
185 R15, R15_H); 185 R12, R12_H,
186 186 R13, R13_H,
187 // Class for all pointer registers except RSP 187 R14, R14_H,
188 reg_class ptr_reg(RAX, RAX_H, 188 R15, R15_H);
189 RDX, RDX_H, 189
190 RBP, RBP_H, 190 // Class for all pointer registers (including RSP, but excluding RBP)
191 RDI, RDI_H, 191 reg_class any_reg_no_rbp(RAX, RAX_H,
192 RSI, RSI_H, 192 RDX, RDX_H,
193 RCX, RCX_H, 193 RDI, RDI_H,
194 RBX, RBX_H, 194 RSI, RSI_H,
195 R8, R8_H, 195 RCX, RCX_H,
196 R9, R9_H, 196 RBX, RBX_H,
197 R10, R10_H, 197 RSP, RSP_H,
198 R11, R11_H, 198 R8, R8_H,
199 R13, R13_H, 199 R9, R9_H,
200 R14, R14_H); 200 R10, R10_H,
201 201 R11, R11_H,
202 // Class for all pointer registers except RAX and RSP 202 R12, R12_H,
203 reg_class ptr_no_rax_reg(RDX, RDX_H, 203 R13, R13_H,
204 RBP, RBP_H, 204 R14, R14_H,
205 R15, R15_H);
206
207 // Dynamic register class that selects at runtime between register classes
208 // any_reg_no_rbp and any_reg_with_rbp (depending on the value of the flag PreserveFramePointer).
209 // Equivalent to: return PreserveFramePointer ? any_reg_no_rbp : any_reg_with_rbp;
210 reg_class_dynamic any_reg(any_reg_no_rbp, any_reg_with_rbp, %{ PreserveFramePointer %});
211
212 // Class for all pointer registers (excluding RSP)
213 reg_class ptr_reg_with_rbp(RAX, RAX_H,
214 RDX, RDX_H,
215 RBP, RBP_H,
216 RDI, RDI_H,
217 RSI, RSI_H,
218 RCX, RCX_H,
219 RBX, RBX_H,
220 R8, R8_H,
221 R9, R9_H,
222 R10, R10_H,
223 R11, R11_H,
224 R13, R13_H,
225 R14, R14_H);
226
227 // Class for all pointer registers (excluding RSP and RBP)
228 reg_class ptr_reg_no_rbp(RAX, RAX_H,
229 RDX, RDX_H,
205 RDI, RDI_H, 230 RDI, RDI_H,
206 RSI, RSI_H, 231 RSI, RSI_H,
207 RCX, RCX_H, 232 RCX, RCX_H,
208 RBX, RBX_H, 233 RBX, RBX_H,
209 R8, R8_H, 234 R8, R8_H,
211 R10, R10_H, 236 R10, R10_H,
212 R11, R11_H, 237 R11, R11_H,
213 R13, R13_H, 238 R13, R13_H,
214 R14, R14_H); 239 R14, R14_H);
215 240
216 reg_class ptr_no_rbp_reg(RDX, RDX_H, 241 // Dynamic register class that selects between ptr_reg_no_rbp and ptr_reg_with_rbp.
217 RAX, RAX_H, 242 reg_class_dynamic ptr_reg(ptr_reg_no_rbp, ptr_reg_with_rbp, %{ PreserveFramePointer %});
218 RDI, RDI_H, 243
219 RSI, RSI_H, 244 // Class for all pointer registers (excluding RAX and RSP)
220 RCX, RCX_H, 245 reg_class ptr_no_rax_reg_with_rbp(RDX, RDX_H,
221 RBX, RBX_H, 246 RBP, RBP_H,
222 R8, R8_H, 247 RDI, RDI_H,
223 R9, R9_H, 248 RSI, RSI_H,
224 R10, R10_H, 249 RCX, RCX_H,
225 R11, R11_H, 250 RBX, RBX_H,
226 R13, R13_H, 251 R8, R8_H,
227 R14, R14_H); 252 R9, R9_H,
228 253 R10, R10_H,
229 // Class for all pointer registers except RAX, RBX and RSP 254 R11, R11_H,
230 reg_class ptr_no_rax_rbx_reg(RDX, RDX_H, 255 R13, R13_H,
231 RBP, RBP_H, 256 R14, R14_H);
232 RDI, RDI_H, 257
233 RSI, RSI_H, 258 // Class for all pointer registers (excluding RAX, RSP, and RBP)
234 RCX, RCX_H, 259 reg_class ptr_no_rax_reg_no_rbp(RDX, RDX_H,
235 R8, R8_H, 260 RDI, RDI_H,
236 R9, R9_H, 261 RSI, RSI_H,
237 R10, R10_H, 262 RCX, RCX_H,
238 R11, R11_H, 263 RBX, RBX_H,
239 R13, R13_H, 264 R8, R8_H,
240 R14, R14_H); 265 R9, R9_H,
266 R10, R10_H,
267 R11, R11_H,
268 R13, R13_H,
269 R14, R14_H);
270
271 // Dynamic register class that selects between ptr_no_rax_reg_no_rbp and ptr_no_rax_reg_with_rbp.
272 reg_class_dynamic ptr_no_rax_reg(ptr_no_rax_reg_no_rbp, ptr_no_rax_reg_with_rbp, %{ PreserveFramePointer %});
273
274 // Class for all pointer registers (excluding RAX, RBX, and RSP)
275 reg_class ptr_no_rax_rbx_reg_with_rbp(RDX, RDX_H,
276 RBP, RBP_H,
277 RDI, RDI_H,
278 RSI, RSI_H,
279 RCX, RCX_H,
280 R8, R8_H,
281 R9, R9_H,
282 R10, R10_H,
283 R11, R11_H,
284 R13, R13_H,
285 R14, R14_H);
286
287 // Class for all pointer registers (excluding RAX, RBX, RSP, and RBP)
288 reg_class ptr_no_rax_rbx_reg_no_rbp(RDX, RDX_H,
289 RDI, RDI_H,
290 RSI, RSI_H,
291 RCX, RCX_H,
292 R8, R8_H,
293 R9, R9_H,
294 R10, R10_H,
295 R11, R11_H,
296 R13, R13_H,
297 R14, R14_H);
298
299 // Dynamic register class that selects between ptr_no_rax_rbx_reg_no_rbp and ptr_no_rax_rbx_reg_with_rbp.
300 reg_class_dynamic ptr_no_rax_rbx_reg(ptr_no_rax_rbx_reg_no_rbp, ptr_no_rax_rbx_reg_with_rbp, %{ PreserveFramePointer %});
241 301
242 // Singleton class for RAX pointer register 302 // Singleton class for RAX pointer register
243 reg_class ptr_rax_reg(RAX, RAX_H); 303 reg_class ptr_rax_reg(RAX, RAX_H);
244 304
245 // Singleton class for RBX pointer register 305 // Singleton class for RBX pointer register
249 reg_class ptr_rsi_reg(RSI, RSI_H); 309 reg_class ptr_rsi_reg(RSI, RSI_H);
250 310
251 // Singleton class for RDI pointer register 311 // Singleton class for RDI pointer register
252 reg_class ptr_rdi_reg(RDI, RDI_H); 312 reg_class ptr_rdi_reg(RDI, RDI_H);
253 313
254 // Singleton class for RBP pointer register
255 reg_class ptr_rbp_reg(RBP, RBP_H);
256
257 // Singleton class for stack pointer 314 // Singleton class for stack pointer
258 reg_class ptr_rsp_reg(RSP, RSP_H); 315 reg_class ptr_rsp_reg(RSP, RSP_H);
259 316
260 // Singleton class for TLS pointer 317 // Singleton class for TLS pointer
261 reg_class ptr_r15_reg(R15, R15_H); 318 reg_class ptr_r15_reg(R15, R15_H);
262 319
263 // Class for all long registers (except RSP) 320 // Class for all long registers (excluding RSP)
264 reg_class long_reg(RAX, RAX_H, 321 reg_class long_reg_with_rbp(RAX, RAX_H,
265 RDX, RDX_H, 322 RDX, RDX_H,
266 RBP, RBP_H, 323 RBP, RBP_H,
267 RDI, RDI_H, 324 RDI, RDI_H,
268 RSI, RSI_H, 325 RSI, RSI_H,
269 RCX, RCX_H, 326 RCX, RCX_H,
270 RBX, RBX_H, 327 RBX, RBX_H,
271 R8, R8_H, 328 R8, R8_H,
272 R9, R9_H, 329 R9, R9_H,
273 R10, R10_H, 330 R10, R10_H,
274 R11, R11_H, 331 R11, R11_H,
275 R13, R13_H, 332 R13, R13_H,
276 R14, R14_H); 333 R14, R14_H);
277 334
278 // Class for all long registers except RAX, RDX (and RSP) 335 // Class for all long registers (excluding RSP and RBP)
279 reg_class long_no_rax_rdx_reg(RBP, RBP_H, 336 reg_class long_reg_no_rbp(RAX, RAX_H,
280 RDI, RDI_H,
281 RSI, RSI_H,
282 RCX, RCX_H,
283 RBX, RBX_H,
284 R8, R8_H,
285 R9, R9_H,
286 R10, R10_H,
287 R11, R11_H,
288 R13, R13_H,
289 R14, R14_H);
290
291 // Class for all long registers except RCX (and RSP)
292 reg_class long_no_rcx_reg(RBP, RBP_H,
293 RDI, RDI_H,
294 RSI, RSI_H,
295 RAX, RAX_H,
296 RDX, RDX_H,
297 RBX, RBX_H,
298 R8, R8_H,
299 R9, R9_H,
300 R10, R10_H,
301 R11, R11_H,
302 R13, R13_H,
303 R14, R14_H);
304
305 // Class for all long registers except RAX (and RSP)
306 reg_class long_no_rax_reg(RBP, RBP_H,
307 RDX, RDX_H, 337 RDX, RDX_H,
308 RDI, RDI_H, 338 RDI, RDI_H,
309 RSI, RSI_H, 339 RSI, RSI_H,
310 RCX, RCX_H, 340 RCX, RCX_H,
311 RBX, RBX_H, 341 RBX, RBX_H,
314 R10, R10_H, 344 R10, R10_H,
315 R11, R11_H, 345 R11, R11_H,
316 R13, R13_H, 346 R13, R13_H,
317 R14, R14_H); 347 R14, R14_H);
318 348
349 // Dynamic register class that selects between long_reg_no_rbp and long_reg_with_rbp.
350 reg_class_dynamic long_reg(long_reg_no_rbp, long_reg_with_rbp, %{ PreserveFramePointer %});
351
352 // Class for all long registers (excluding RAX, RDX and RSP)
353 reg_class long_no_rax_rdx_reg_with_rbp(RBP, RBP_H,
354 RDI, RDI_H,
355 RSI, RSI_H,
356 RCX, RCX_H,
357 RBX, RBX_H,
358 R8, R8_H,
359 R9, R9_H,
360 R10, R10_H,
361 R11, R11_H,
362 R13, R13_H,
363 R14, R14_H);
364
365 // Class for all long registers (excluding RAX, RDX, RSP, and RBP)
366 reg_class long_no_rax_rdx_reg_no_rbp(RDI, RDI_H,
367 RSI, RSI_H,
368 RCX, RCX_H,
369 RBX, RBX_H,
370 R8, R8_H,
371 R9, R9_H,
372 R10, R10_H,
373 R11, R11_H,
374 R13, R13_H,
375 R14, R14_H);
376
377 // Dynamic register class that selects between long_no_rax_rdx_reg_no_rbp and long_no_rax_rdx_reg_with_rbp.
378 reg_class_dynamic long_no_rax_rdx_reg(long_no_rax_rdx_reg_no_rbp, long_no_rax_rdx_reg_with_rbp, %{ PreserveFramePointer %});
379
380 // Class for all long registers (excluding RCX and RSP)
381 reg_class long_no_rcx_reg_with_rbp(RBP, RBP_H,
382 RDI, RDI_H,
383 RSI, RSI_H,
384 RAX, RAX_H,
385 RDX, RDX_H,
386 RBX, RBX_H,
387 R8, R8_H,
388 R9, R9_H,
389 R10, R10_H,
390 R11, R11_H,
391 R13, R13_H,
392 R14, R14_H);
393
394 // Class for all long registers (excluding RCX, RSP, and RBP)
395 reg_class long_no_rcx_reg_no_rbp(RDI, RDI_H,
396 RSI, RSI_H,
397 RAX, RAX_H,
398 RDX, RDX_H,
399 RBX, RBX_H,
400 R8, R8_H,
401 R9, R9_H,
402 R10, R10_H,
403 R11, R11_H,
404 R13, R13_H,
405 R14, R14_H);
406
407 // Dynamic register class that selects between long_no_rcx_reg_no_rbp and long_no_rcx_reg_with_rbp.
408 reg_class_dynamic long_no_rcx_reg(long_no_rcx_reg_no_rbp, long_no_rcx_reg_with_rbp, %{ PreserveFramePointer %});
409
319 // Singleton class for RAX long register 410 // Singleton class for RAX long register
320 reg_class long_rax_reg(RAX, RAX_H); 411 reg_class long_rax_reg(RAX, RAX_H);
321 412
322 // Singleton class for RCX long register 413 // Singleton class for RCX long register
323 reg_class long_rcx_reg(RCX, RCX_H); 414 reg_class long_rcx_reg(RCX, RCX_H);
324 415
325 // Singleton class for RDX long register 416 // Singleton class for RDX long register
326 reg_class long_rdx_reg(RDX, RDX_H); 417 reg_class long_rdx_reg(RDX, RDX_H);
327 418
328 // Class for all int registers (except RSP) 419 // Class for all int registers (excluding RSP)
329 reg_class int_reg(RAX, 420 reg_class int_reg_with_rbp(RAX,
330 RDX, 421 RDX,
331 RBP, 422 RBP,
332 RDI, 423 RDI,
333 RSI, 424 RSI,
334 RCX, 425 RCX,
335 RBX, 426 RBX,
336 R8, 427 R8,
337 R9, 428 R9,
338 R10, 429 R10,
339 R11, 430 R11,
340 R13, 431 R13,
341 R14); 432 R14);
342 433
343 // Class for all int registers except RCX (and RSP) 434 // Class for all int registers (excluding RSP and RBP)
344 reg_class int_no_rcx_reg(RAX, 435 reg_class int_reg_no_rbp(RAX,
345 RDX, 436 RDX,
346 RBP,
347 RDI, 437 RDI,
348 RSI, 438 RSI,
439 RCX,
349 RBX, 440 RBX,
350 R8, 441 R8,
351 R9, 442 R9,
352 R10, 443 R10,
353 R11, 444 R11,
354 R13, 445 R13,
355 R14); 446 R14);
356 447
357 // Class for all int registers except RAX, RDX (and RSP) 448 // Dynamic register class that selects between int_reg_no_rbp and int_reg_with_rbp.
358 reg_class int_no_rax_rdx_reg(RBP, 449 reg_class_dynamic int_reg(int_reg_no_rbp, int_reg_with_rbp, %{ PreserveFramePointer %});
359 RDI, 450
360 RSI, 451 // Class for all int registers (excluding RCX and RSP)
361 RCX, 452 reg_class int_no_rcx_reg_with_rbp(RAX,
362 RBX, 453 RDX,
363 R8, 454 RBP,
364 R9, 455 RDI,
365 R10, 456 RSI,
366 R11, 457 RBX,
367 R13, 458 R8,
368 R14); 459 R9,
460 R10,
461 R11,
462 R13,
463 R14);
464
465 // Class for all int registers (excluding RCX, RSP, and RBP)
466 reg_class int_no_rcx_reg_no_rbp(RAX,
467 RDX,
468 RDI,
469 RSI,
470 RBX,
471 R8,
472 R9,
473 R10,
474 R11,
475 R13,
476 R14);
477
478 // Dynamic register class that selects between int_no_rcx_reg_no_rbp and int_no_rcx_reg_with_rbp.
479 reg_class_dynamic int_no_rcx_reg(int_no_rcx_reg_no_rbp, int_no_rcx_reg_with_rbp, %{ PreserveFramePointer %});
480
481 // Class for all int registers (excluding RAX, RDX, and RSP)
482 reg_class int_no_rax_rdx_reg_with_rbp(RBP,
483 RDI,
484 RSI,
485 RCX,
486 RBX,
487 R8,
488 R9,
489 R10,
490 R11,
491 R13,
492 R14);
493
494 // Class for all int registers (excluding RAX, RDX, RSP, and RBP)
495 reg_class int_no_rax_rdx_reg_no_rbp(RDI,
496 RSI,
497 RCX,
498 RBX,
499 R8,
500 R9,
501 R10,
502 R11,
503 R13,
504 R14);
505
506 // Dynamic register class that selects between int_no_rax_rdx_reg_no_rbp and int_no_rax_rdx_reg_with_rbp.
507 reg_class_dynamic int_no_rax_rdx_reg(int_no_rax_rdx_reg_no_rbp, int_no_rax_rdx_reg_with_rbp, %{ PreserveFramePointer %});
369 508
370 // Singleton class for RAX int register 509 // Singleton class for RAX int register
371 reg_class int_rax_reg(RAX); 510 reg_class int_rax_reg(RAX);
372 511
373 // Singleton class for RBX int register 512 // Singleton class for RBX int register
394 #define RELOC_IMM64 Assembler::imm_operand 533 #define RELOC_IMM64 Assembler::imm_operand
395 #define RELOC_DISP32 Assembler::disp32_operand 534 #define RELOC_DISP32 Assembler::disp32_operand
396 535
397 #define __ _masm. 536 #define __ _masm.
398 537
399 static int preserve_SP_size() {
400 return 3; // rex.w, op, rm(reg/reg)
401 }
402 static int clear_avx_size() { 538 static int clear_avx_size() {
403 return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper 539 return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper
404 } 540 }
405 541
406 // !!!!! Special hack to get all types of calls to specify the byte offset 542 // !!!!! Special hack to get all types of calls to specify the byte offset
407 // from the start of the call to the point where the return address 543 // from the start of the call to the point where the return address
408 // will point. 544 // will point.
409 int MachCallStaticJavaNode::ret_addr_offset() 545 int MachCallStaticJavaNode::ret_addr_offset()
410 { 546 {
411 int offset = 5; // 5 bytes from start of call to where return address points 547 int offset = 5; // 5 bytes from start of call to where return address points
412 offset += clear_avx_size(); 548 offset += clear_avx_size();
413 if (_method_handle_invoke)
414 offset += preserve_SP_size();
415 return offset; 549 return offset;
416 } 550 }
417 551
418 int MachCallDynamicJavaNode::ret_addr_offset() 552 int MachCallDynamicJavaNode::ret_addr_offset()
419 { 553 {
441 575
442 // The address of the call instruction needs to be 4-byte aligned to 576 // The address of the call instruction needs to be 4-byte aligned to
443 // ensure that it does not span a cache line so that it can be patched. 577 // ensure that it does not span a cache line so that it can be patched.
444 int CallStaticJavaDirectNode::compute_padding(int current_offset) const 578 int CallStaticJavaDirectNode::compute_padding(int current_offset) const
445 { 579 {
446 current_offset += clear_avx_size(); // skip vzeroupper
447 current_offset += 1; // skip call opcode byte
448 return round_to(current_offset, alignment_required()) - current_offset;
449 }
450
451 // The address of the call instruction needs to be 4-byte aligned to
452 // ensure that it does not span a cache line so that it can be patched.
453 int CallStaticJavaHandleNode::compute_padding(int current_offset) const
454 {
455 current_offset += preserve_SP_size(); // skip mov rbp, rsp
456 current_offset += clear_avx_size(); // skip vzeroupper 580 current_offset += clear_avx_size(); // skip vzeroupper
457 current_offset += 1; // skip call opcode byte 581 current_offset += 1; // skip call opcode byte
458 return round_to(current_offset, alignment_required()) - current_offset; 582 return round_to(current_offset, alignment_required()) - current_offset;
459 } 583 }
460 584
722 if (C->need_stack_bang(bangsize)) { 846 if (C->need_stack_bang(bangsize)) {
723 framesize -= wordSize; 847 framesize -= wordSize;
724 st->print("# stack bang (%d bytes)", bangsize); 848 st->print("# stack bang (%d bytes)", bangsize);
725 st->print("\n\t"); 849 st->print("\n\t");
726 st->print("pushq rbp\t# Save rbp"); 850 st->print("pushq rbp\t# Save rbp");
851 if (PreserveFramePointer) {
852 st->print("\n\t");
853 st->print("movq rbp, rsp\t# Save the caller's SP into rbp");
854 }
727 if (framesize) { 855 if (framesize) {
728 st->print("\n\t"); 856 st->print("\n\t");
729 st->print("subq rsp, #%d\t# Create frame",framesize); 857 st->print("subq rsp, #%d\t# Create frame",framesize);
730 } 858 }
731 } else { 859 } else {
732 st->print("subq rsp, #%d\t# Create frame",framesize); 860 st->print("subq rsp, #%d\t# Create frame",framesize);
733 st->print("\n\t"); 861 st->print("\n\t");
734 framesize -= wordSize; 862 framesize -= wordSize;
735 st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize); 863 st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize);
864 if (PreserveFramePointer) {
865 st->print("\n\t");
866 st->print("movq rbp, [rsp + #%d]\t# Save the caller's SP into rbp", (framesize + wordSize));
867 }
736 } 868 }
737 869
738 if (VerifyStackAtCalls) { 870 if (VerifyStackAtCalls) {
739 st->print("\n\t"); 871 st->print("\n\t");
740 framesize -= wordSize; 872 framesize -= wordSize;
1596 // Register for MODL projection of divmodL 1728 // Register for MODL projection of divmodL
1597 RegMask Matcher::modL_proj_mask() { 1729 RegMask Matcher::modL_proj_mask() {
1598 return LONG_RDX_REG_mask(); 1730 return LONG_RDX_REG_mask();
1599 } 1731 }
1600 1732
1733 // Register for saving SP into on method handle invokes. Not used on x86_64.
1601 const RegMask Matcher::method_handle_invoke_SP_save_mask() { 1734 const RegMask Matcher::method_handle_invoke_SP_save_mask() {
1602 return PTR_RBP_REG_mask(); 1735 return NO_REG_mask();
1603 } 1736 }
1604 1737
1605 %} 1738 %}
1606 1739
1607 //----------ENCODING BLOCK----------------------------------------------------- 1740 //----------ENCODING BLOCK-----------------------------------------------------
3200 %} 3333 %}
3201 3334
3202 // Pointer Register 3335 // Pointer Register
3203 operand any_RegP() 3336 operand any_RegP()
3204 %{ 3337 %{
3205 constraint(ALLOC_IN_RC(any_reg)); 3338 constraint(ALLOC_IN_RC(any_reg));
3206 match(RegP); 3339 match(RegP);
3207 match(rax_RegP); 3340 match(rax_RegP);
3208 match(rbx_RegP); 3341 match(rbx_RegP);
3209 match(rdi_RegP); 3342 match(rdi_RegP);
3210 match(rsi_RegP); 3343 match(rsi_RegP);
3222 match(RegP); 3355 match(RegP);
3223 match(rax_RegP); 3356 match(rax_RegP);
3224 match(rbx_RegP); 3357 match(rbx_RegP);
3225 match(rdi_RegP); 3358 match(rdi_RegP);
3226 match(rsi_RegP); 3359 match(rsi_RegP);
3227 match(rbp_RegP); 3360 match(rbp_RegP); // See Q&A below about
3228 match(r15_RegP); // See Q&A below about r15_RegP. 3361 match(r15_RegP); // r15_RegP and rbp_RegP.
3229 3362
3230 format %{ %} 3363 format %{ %}
3231 interface(REG_INTER); 3364 interface(REG_INTER);
3232 %} 3365 %}
3233 3366
3239 interface(REG_INTER); 3372 interface(REG_INTER);
3240 %} 3373 %}
3241 3374
3242 // Question: Why is r15_RegP (the read-only TLS register) a match for rRegP? 3375 // Question: Why is r15_RegP (the read-only TLS register) a match for rRegP?
3243 // Answer: Operand match rules govern the DFA as it processes instruction inputs. 3376 // Answer: Operand match rules govern the DFA as it processes instruction inputs.
3244 // It's fine for an instruction input which expects rRegP to match a r15_RegP. 3377 // It's fine for an instruction input that expects rRegP to match a r15_RegP.
3245 // The output of an instruction is controlled by the allocator, which respects 3378 // The output of an instruction is controlled by the allocator, which respects
3246 // register class masks, not match rules. Unless an instruction mentions 3379 // register class masks, not match rules. Unless an instruction mentions
3247 // r15_RegP or any_RegP explicitly as its output, r15 will not be considered 3380 // r15_RegP or any_RegP explicitly as its output, r15 will not be considered
3248 // by the allocator as an input. 3381 // by the allocator as an input.
3382 // The same logic applies to rbp_RegP being a match for rRegP: If PreserveFramePointer==true,
3383 // the RBP is used as a proper frame pointer and is not included in ptr_reg. As a
3384 // result, RBP is not included in the output of the instruction either.
3249 3385
3250 operand no_rax_RegP() 3386 operand no_rax_RegP()
3251 %{ 3387 %{
3252 constraint(ALLOC_IN_RC(ptr_no_rax_reg)); 3388 constraint(ALLOC_IN_RC(ptr_no_rax_reg));
3253 match(RegP); 3389 match(RegP);
3257 3393
3258 format %{ %} 3394 format %{ %}
3259 interface(REG_INTER); 3395 interface(REG_INTER);
3260 %} 3396 %}
3261 3397
3398 // This operand is not allowed to use RBP even if
3399 // RBP is not used to hold the frame pointer.
3262 operand no_rbp_RegP() 3400 operand no_rbp_RegP()
3263 %{ 3401 %{
3264 constraint(ALLOC_IN_RC(ptr_no_rbp_reg)); 3402 constraint(ALLOC_IN_RC(ptr_reg_no_rbp));
3265 match(RegP); 3403 match(RegP);
3266 match(rbx_RegP); 3404 match(rbx_RegP);
3267 match(rsi_RegP); 3405 match(rsi_RegP);
3268 match(rdi_RegP); 3406 match(rdi_RegP);
3269 3407
3329 3467
3330 // Used in rep stosq 3468 // Used in rep stosq
3331 operand rdi_RegP() 3469 operand rdi_RegP()
3332 %{ 3470 %{
3333 constraint(ALLOC_IN_RC(ptr_rdi_reg)); 3471 constraint(ALLOC_IN_RC(ptr_rdi_reg));
3334 match(RegP);
3335 match(rRegP);
3336
3337 format %{ %}
3338 interface(REG_INTER);
3339 %}
3340
3341 operand rbp_RegP()
3342 %{
3343 constraint(ALLOC_IN_RC(ptr_rbp_reg));
3344 match(RegP); 3472 match(RegP);
3345 match(rRegP); 3473 match(rRegP);
3346 3474
3347 format %{ %} 3475 format %{ %}
3348 interface(REG_INTER); 3476 interface(REG_INTER);
11412 // Call Java Static Instruction 11540 // Call Java Static Instruction
11413 // Note: If this code changes, the corresponding ret_addr_offset() and 11541 // Note: If this code changes, the corresponding ret_addr_offset() and
11414 // compute_padding() functions will have to be adjusted. 11542 // compute_padding() functions will have to be adjusted.
11415 instruct CallStaticJavaDirect(method meth) %{ 11543 instruct CallStaticJavaDirect(method meth) %{
11416 match(CallStaticJava); 11544 match(CallStaticJava);
11417 predicate(!((CallStaticJavaNode*) n)->is_method_handle_invoke());
11418 effect(USE meth); 11545 effect(USE meth);
11419 11546
11420 ins_cost(300); 11547 ins_cost(300);
11421 format %{ "call,static " %} 11548 format %{ "call,static " %}
11422 opcode(0xE8); /* E8 cd */ 11549 opcode(0xE8); /* E8 cd */
11423 ins_encode(clear_avx, Java_Static_Call(meth), call_epilog); 11550 ins_encode(clear_avx, Java_Static_Call(meth), call_epilog);
11424 ins_pipe(pipe_slow);
11425 ins_alignment(4);
11426 %}
11427
11428 // Call Java Static Instruction (method handle version)
11429 // Note: If this code changes, the corresponding ret_addr_offset() and
11430 // compute_padding() functions will have to be adjusted.
11431 instruct CallStaticJavaHandle(method meth, rbp_RegP rbp_mh_SP_save) %{
11432 match(CallStaticJava);
11433 predicate(((CallStaticJavaNode*) n)->is_method_handle_invoke());
11434 effect(USE meth);
11435 // RBP is saved by all callees (for interpreter stack correction).
11436 // We use it here for a similar purpose, in {preserve,restore}_SP.
11437
11438 ins_cost(300);
11439 format %{ "call,static/MethodHandle " %}
11440 opcode(0xE8); /* E8 cd */
11441 ins_encode(clear_avx, preserve_SP,
11442 Java_Static_Call(meth),
11443 restore_SP,
11444 call_epilog);
11445 ins_pipe(pipe_slow); 11551 ins_pipe(pipe_slow);
11446 ins_alignment(4); 11552 ins_alignment(4);
11447 %} 11553 %}
11448 11554
11449 // Call Java Dynamic Instruction 11555 // Call Java Dynamic Instruction