404 R15, R15_H,
405 R16, R16_H,
406 R17, R17_H,
407 R18, R18_H,
408 R19, R19_H,
409 R20, R20_H,
410 R21, R21_H,
411 R22, R22_H,
412 R23, R23_H,
413 R24, R24_H,
414 R25, R25_H,
415 R26, R26_H,
416 R27, R27_H,
417 R28, R28_H,
418 R29, R29_H,
419 R30, R30_H,
420 R31, R31_H
421 );
422
423 // Class for all non-special integer registers
424 reg_class no_special_reg32(
425 R0,
426 R1,
427 R2,
428 R3,
429 R4,
430 R5,
431 R6,
432 R7,
433 R10,
434 R11,
435 R12, // rmethod
436 R13,
437 R14,
438 R15,
439 R16,
440 R17,
441 R18,
442 R19,
443 R20,
444 R21,
445 R22,
446 R23,
447 R24,
448 R25,
449 R26
450 /* R27, */ // heapbase
451 /* R28, */ // thread
452 R29, // fp
453 /* R30, */ // lr
454 /* R31 */ // sp
455 );
456
457 // Class for all non-special long integer registers
458 reg_class no_special_reg(
459 R0, R0_H,
460 R1, R1_H,
461 R2, R2_H,
462 R3, R3_H,
463 R4, R4_H,
464 R5, R5_H,
465 R6, R6_H,
466 R7, R7_H,
467 R10, R10_H,
468 R11, R11_H,
469 R12, R12_H, // rmethod
470 R13, R13_H,
471 R14, R14_H,
472 R15, R15_H,
473 R16, R16_H,
474 R17, R17_H,
475 R18, R18_H,
476 R19, R19_H,
477 R20, R20_H,
478 R21, R21_H,
479 R22, R22_H,
480 R23, R23_H,
481 R24, R24_H,
482 R25, R25_H,
483 R26, R26_H,
484 /* R27, R27_H, */ // heapbase
485 /* R28, R28_H, */ // thread
486 R29, R29_H, // fp
487 /* R30, R30_H, */ // lr
488 /* R31, R31_H */ // sp
489 );
490
491 // Class for 64 bit register r0
492 reg_class r0_reg(
493 R0, R0_H
494 );
495
496 // Class for 64 bit register r1
497 reg_class r1_reg(
498 R1, R1_H
499 );
500
501 // Class for 64 bit register r2
502 reg_class r2_reg(
503 R2, R2_H
504 );
505
506 // Class for 64 bit register r3
507 reg_class r3_reg(
508 R3, R3_H
509 );
510
1623
1624 #define __ _masm.
1625
1626 // advance declarations for helper functions to convert register
1627 // indices to register objects
1628
1629 // the ad file has to provide implementations of certain methods
1630 // expected by the generic code
1631 //
1632 // REQUIRED FUNCTIONALITY
1633
1634 //=============================================================================
1635
1636 // !!!!! Special hack to get all types of calls to specify the byte offset
1637 // from the start of the call to the point where the return address
1638 // will point.
1639
1640 int MachCallStaticJavaNode::ret_addr_offset()
1641 {
1642 // call should be a simple bl
1643 // unless this is a method handle invoke in which case it is
1644 // mov(rfp, sp), bl, mov(sp, rfp)
1645 int off = 4;
1646 if (_method_handle_invoke) {
1647 off += 4;
1648 }
1649 return off;
1650 }
1651
1652 int MachCallDynamicJavaNode::ret_addr_offset()
1653 {
1654 return 16; // movz, movk, movk, bl
1655 }
1656
1657 int MachCallRuntimeNode::ret_addr_offset() {
1658 // for generated stubs the call will be
1659 // far_call(addr)
1660 // for real runtime callouts it will be six instructions
1661 // see aarch64_enc_java_to_runtime
1662 // adr(rscratch2, retaddr)
1663 // lea(rscratch1, RuntimeAddress(addr)
1664 // stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize)))
1665 // blrt rscratch1
1666 CodeBlob *cb = CodeCache::find_blob(_entry_point);
1667 if (cb) {
1668 return MacroAssembler::far_branch_size();
1739
1740 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const {
1741 return 0;
1742 }
1743
1744 #ifndef PRODUCT
1745 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
1746 st->print("-- \t// MachConstantBaseNode (empty encoding)");
1747 }
1748 #endif
1749
1750 #ifndef PRODUCT
1751 void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
1752 Compile* C = ra_->C;
1753
1754 int framesize = C->frame_slots() << LogBytesPerInt;
1755
1756 if (C->need_stack_bang(framesize))
1757 st->print("# stack bang size=%d\n\t", framesize);
1758
1759 if (framesize == 0) {
1760 // Is this even possible?
1761 st->print("stp lr, rfp, [sp, #%d]!", -(2 * wordSize));
1762 } else if (framesize < ((1 << 9) + 2 * wordSize)) {
1763 st->print("sub sp, sp, #%d\n\t", framesize);
1764 st->print("stp rfp, lr, [sp, #%d]", framesize - 2 * wordSize);
1765 } else {
1766 st->print("stp lr, rfp, [sp, #%d]!\n\t", -(2 * wordSize));
1767 st->print("mov rscratch1, #%d\n\t", framesize - 2 * wordSize);
1768 st->print("sub sp, sp, rscratch1");
1769 }
1770 }
1771 #endif
1772
1773 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
1774 Compile* C = ra_->C;
1775 MacroAssembler _masm(&cbuf);
1776
1777 // n.b. frame size includes space for return pc and rfp
1778 const long framesize = C->frame_size_in_bytes();
1779 assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");
1780
1781 // insert a nop at the start of the prolog so we can patch in a
1782 // branch if we need to invalidate the method later
1783 __ nop();
1784
1785 int bangsize = C->bang_size_in_bytes();
1786 if (C->need_stack_bang(bangsize) && UseStackBanging)
3503
3504 enc_class aarch64_enc_java_static_call(method meth) %{
3505 MacroAssembler _masm(&cbuf);
3506
3507 address addr = (address)$meth$$method;
3508 if (!_method) {
3509 // A call to a runtime wrapper, e.g. new, new_typeArray_Java, uncommon_trap.
3510 __ trampoline_call(Address(addr, relocInfo::runtime_call_type), &cbuf);
3511 } else if (_optimized_virtual) {
3512 __ trampoline_call(Address(addr, relocInfo::opt_virtual_call_type), &cbuf);
3513 } else {
3514 __ trampoline_call(Address(addr, relocInfo::static_call_type), &cbuf);
3515 }
3516
3517 if (_method) {
3518 // Emit stub for static call
3519 CompiledStaticCall::emit_to_interp_stub(cbuf);
3520 }
3521 %}
3522
3523 enc_class aarch64_enc_java_handle_call(method meth) %{
3524 MacroAssembler _masm(&cbuf);
3525 relocInfo::relocType reloc;
3526
3527 // RFP is preserved across all calls, even compiled calls.
3528 // Use it to preserve SP.
3529 __ mov(rfp, sp);
3530
3531 const int start_offset = __ offset();
3532 address addr = (address)$meth$$method;
3533 if (!_method) {
3534 // A call to a runtime wrapper, e.g. new, new_typeArray_Java, uncommon_trap.
3535 __ trampoline_call(Address(addr, relocInfo::runtime_call_type), &cbuf);
3536 } else if (_optimized_virtual) {
3537 __ trampoline_call(Address(addr, relocInfo::opt_virtual_call_type), &cbuf);
3538 } else {
3539 __ trampoline_call(Address(addr, relocInfo::static_call_type), &cbuf);
3540 }
3541
3542 if (_method) {
3543 // Emit stub for static call
3544 CompiledStaticCall::emit_to_interp_stub(cbuf);
3545 }
3546
3547 // now restore sp
3548 __ mov(sp, rfp);
3549 %}
3550
3551 enc_class aarch64_enc_java_dynamic_call(method meth) %{
3552 MacroAssembler _masm(&cbuf);
3553 __ ic_call((address)$meth$$method);
3554 %}
3555
3556 enc_class aarch64_enc_call_epilog() %{
3557 MacroAssembler _masm(&cbuf);
3558 if (VerifyStackAtCalls) {
3559 // Check that stack depth is unchanged: find majik cookie on stack
3560 __ call_Unimplemented();
3561 }
3562 %}
3563
3564 enc_class aarch64_enc_java_to_runtime(method meth) %{
3565 MacroAssembler _masm(&cbuf);
3566
3567 // some calls to generated routines (arraycopy code) are scheduled
3568 // by C2 as runtime calls. if so we can call them using a br (they
3569 // will be in a reachable segment) otherwise we have to use a blrt
3570 // which loads the absolute address into a register.
12547 "ldrw zr, [$poll]\t# Safepoint: poll for GC"
12548 %}
12549 ins_encode %{
12550 __ read_polling_page(as_Register($poll$$reg), relocInfo::poll_type);
12551 %}
12552 ins_pipe(pipe_serial); // ins_pipe(iload_reg_mem);
12553 %}
12554
12555
12556 // ============================================================================
12557 // Procedure Call/Return Instructions
12558
12559 // Call Java Static Instruction
12560
12561 instruct CallStaticJavaDirect(method meth)
12562 %{
12563 match(CallStaticJava);
12564
12565 effect(USE meth);
12566
12567 predicate(!((CallStaticJavaNode*)n)->is_method_handle_invoke());
12568
12569 ins_cost(CALL_COST);
12570
12571 format %{ "call,static $meth \t// ==> " %}
12572
12573 ins_encode( aarch64_enc_java_static_call(meth),
12574 aarch64_enc_call_epilog );
12575
12576 ins_pipe(pipe_class_call);
12577 %}
12578
12579 // TO HERE
12580
12581 // Call Java Static Instruction (method handle version)
12582
12583 instruct CallStaticJavaDirectHandle(method meth, iRegP_FP reg_mh_save)
12584 %{
12585 match(CallStaticJava);
12586
12587 effect(USE meth);
12588
12589 predicate(((CallStaticJavaNode*)n)->is_method_handle_invoke());
12590
12591 ins_cost(CALL_COST);
12592
12593 format %{ "call,static $meth \t// (methodhandle) ==> " %}
12594
12595 ins_encode( aarch64_enc_java_handle_call(meth),
12596 aarch64_enc_call_epilog );
12597
12598 ins_pipe(pipe_class_call);
12599 %}
12600
12601 // Call Java Dynamic Instruction
12602 instruct CallDynamicJavaDirect(method meth)
12603 %{
12604 match(CallDynamicJava);
12605
12606 effect(USE meth);
12607
12608 ins_cost(CALL_COST);
12609
12610 format %{ "CALL,dynamic $meth \t// ==> " %}
12611
12612 ins_encode( aarch64_enc_java_dynamic_call(meth),
12613 aarch64_enc_call_epilog );
12614
12615 ins_pipe(pipe_class_call);
12616 %}
12617
12618 // Call Runtime Instruction
12619
|
404 R15, R15_H,
405 R16, R16_H,
406 R17, R17_H,
407 R18, R18_H,
408 R19, R19_H,
409 R20, R20_H,
410 R21, R21_H,
411 R22, R22_H,
412 R23, R23_H,
413 R24, R24_H,
414 R25, R25_H,
415 R26, R26_H,
416 R27, R27_H,
417 R28, R28_H,
418 R29, R29_H,
419 R30, R30_H,
420 R31, R31_H
421 );
422
423 // Class for all non-special integer registers
424 reg_class no_special_reg32_no_fp(
425 R0,
426 R1,
427 R2,
428 R3,
429 R4,
430 R5,
431 R6,
432 R7,
433 R10,
434 R11,
435 R12, // rmethod
436 R13,
437 R14,
438 R15,
439 R16,
440 R17,
441 R18,
442 R19,
443 R20,
444 R21,
445 R22,
446 R23,
447 R24,
448 R25,
449 R26
450 /* R27, */ // heapbase
451 /* R28, */ // thread
452 /* R29, */ // fp
453 /* R30, */ // lr
454 /* R31 */ // sp
455 );
456
457 reg_class no_special_reg32_with_fp(
458 R0,
459 R1,
460 R2,
461 R3,
462 R4,
463 R5,
464 R6,
465 R7,
466 R10,
467 R11,
468 R12, // rmethod
469 R13,
470 R14,
471 R15,
472 R16,
473 R17,
474 R18,
475 R19,
476 R20,
477 R21,
478 R22,
479 R23,
480 R24,
481 R25,
482 R26
483 /* R27, */ // heapbase
484 /* R28, */ // thread
485 R29, // fp
486 /* R30, */ // lr
487 /* R31 */ // sp
488 );
489
490 reg_class_dynamic no_special_reg32(no_special_reg32_no_fp, no_special_reg32_with_fp, %{ PreserveFramePointer %});
491
492 // Class for all non-special long integer registers
493 reg_class no_special_reg_no_fp(
494 R0, R0_H,
495 R1, R1_H,
496 R2, R2_H,
497 R3, R3_H,
498 R4, R4_H,
499 R5, R5_H,
500 R6, R6_H,
501 R7, R7_H,
502 R10, R10_H,
503 R11, R11_H,
504 R12, R12_H, // rmethod
505 R13, R13_H,
506 R14, R14_H,
507 R15, R15_H,
508 R16, R16_H,
509 R17, R17_H,
510 R18, R18_H,
511 R19, R19_H,
512 R20, R20_H,
513 R21, R21_H,
514 R22, R22_H,
515 R23, R23_H,
516 R24, R24_H,
517 R25, R25_H,
518 R26, R26_H,
519 /* R27, R27_H, */ // heapbase
520 /* R28, R28_H, */ // thread
521 /* R29, R29_H, */ // fp
522 /* R30, R30_H, */ // lr
523 /* R31, R31_H */ // sp
524 );
525
526 reg_class no_special_reg_with_fp(
527 R0, R0_H,
528 R1, R1_H,
529 R2, R2_H,
530 R3, R3_H,
531 R4, R4_H,
532 R5, R5_H,
533 R6, R6_H,
534 R7, R7_H,
535 R10, R10_H,
536 R11, R11_H,
537 R12, R12_H, // rmethod
538 R13, R13_H,
539 R14, R14_H,
540 R15, R15_H,
541 R16, R16_H,
542 R17, R17_H,
543 R18, R18_H,
544 R19, R19_H,
545 R20, R20_H,
546 R21, R21_H,
547 R22, R22_H,
548 R23, R23_H,
549 R24, R24_H,
550 R25, R25_H,
551 R26, R26_H,
552 /* R27, R27_H, */ // heapbase
553 /* R28, R28_H, */ // thread
554 R29, R29_H, // fp
555 /* R30, R30_H, */ // lr
556 /* R31, R31_H */ // sp
557 );
558
559 reg_class_dynamic no_special_reg(no_special_reg_no_fp, no_special_reg_with_fp, %{ PreserveFramePointer %});
560
561 // Class for 64 bit register r0
562 reg_class r0_reg(
563 R0, R0_H
564 );
565
566 // Class for 64 bit register r1
567 reg_class r1_reg(
568 R1, R1_H
569 );
570
571 // Class for 64 bit register r2
572 reg_class r2_reg(
573 R2, R2_H
574 );
575
576 // Class for 64 bit register r3
577 reg_class r3_reg(
578 R3, R3_H
579 );
580
1693
1694 #define __ _masm.
1695
1696 // advance declarations for helper functions to convert register
1697 // indices to register objects
1698
1699 // the ad file has to provide implementations of certain methods
1700 // expected by the generic code
1701 //
1702 // REQUIRED FUNCTIONALITY
1703
1704 //=============================================================================
1705
1706 // !!!!! Special hack to get all types of calls to specify the byte offset
1707 // from the start of the call to the point where the return address
1708 // will point.
1709
1710 int MachCallStaticJavaNode::ret_addr_offset()
1711 {
1712 // call should be a simple bl
1713 int off = 4;
1714 return off;
1715 }
1716
1717 int MachCallDynamicJavaNode::ret_addr_offset()
1718 {
1719 return 16; // movz, movk, movk, bl
1720 }
1721
1722 int MachCallRuntimeNode::ret_addr_offset() {
1723 // for generated stubs the call will be
1724 // far_call(addr)
1725 // for real runtime callouts it will be six instructions
1726 // see aarch64_enc_java_to_runtime
1727 // adr(rscratch2, retaddr)
1728 // lea(rscratch1, RuntimeAddress(addr)
1729 // stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize)))
1730 // blrt rscratch1
1731 CodeBlob *cb = CodeCache::find_blob(_entry_point);
1732 if (cb) {
1733 return MacroAssembler::far_branch_size();
1804
1805 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const {
1806 return 0;
1807 }
1808
1809 #ifndef PRODUCT
1810 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
1811 st->print("-- \t// MachConstantBaseNode (empty encoding)");
1812 }
1813 #endif
1814
1815 #ifndef PRODUCT
1816 void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
1817 Compile* C = ra_->C;
1818
1819 int framesize = C->frame_slots() << LogBytesPerInt;
1820
1821 if (C->need_stack_bang(framesize))
1822 st->print("# stack bang size=%d\n\t", framesize);
1823
1824 if (framesize < ((1 << 9) + 2 * wordSize)) {
1825 st->print("sub sp, sp, #%d\n\t", framesize);
1826 st->print("stp rfp, lr, [sp, #%d]", framesize - 2 * wordSize);
1827 if (PreserveFramePointer) st->print("\n\tadd rfp, sp, #%d", framesize - 2 * wordSize);
1828 } else {
1829 st->print("stp lr, rfp, [sp, #%d]!\n\t", -(2 * wordSize));
1830 if (PreserveFramePointer) st->print("mov rfp, sp\n\t");
1831 st->print("mov rscratch1, #%d\n\t", framesize - 2 * wordSize);
1832 st->print("sub sp, sp, rscratch1");
1833 }
1834 }
1835 #endif
1836
1837 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
1838 Compile* C = ra_->C;
1839 MacroAssembler _masm(&cbuf);
1840
1841 // n.b. frame size includes space for return pc and rfp
1842 const long framesize = C->frame_size_in_bytes();
1843 assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");
1844
1845 // insert a nop at the start of the prolog so we can patch in a
1846 // branch if we need to invalidate the method later
1847 __ nop();
1848
1849 int bangsize = C->bang_size_in_bytes();
1850 if (C->need_stack_bang(bangsize) && UseStackBanging)
3567
3568 enc_class aarch64_enc_java_static_call(method meth) %{
3569 MacroAssembler _masm(&cbuf);
3570
3571 address addr = (address)$meth$$method;
3572 if (!_method) {
3573 // A call to a runtime wrapper, e.g. new, new_typeArray_Java, uncommon_trap.
3574 __ trampoline_call(Address(addr, relocInfo::runtime_call_type), &cbuf);
3575 } else if (_optimized_virtual) {
3576 __ trampoline_call(Address(addr, relocInfo::opt_virtual_call_type), &cbuf);
3577 } else {
3578 __ trampoline_call(Address(addr, relocInfo::static_call_type), &cbuf);
3579 }
3580
3581 if (_method) {
3582 // Emit stub for static call
3583 CompiledStaticCall::emit_to_interp_stub(cbuf);
3584 }
3585 %}
3586
3587 enc_class aarch64_enc_java_dynamic_call(method meth) %{
3588 MacroAssembler _masm(&cbuf);
3589 __ ic_call((address)$meth$$method);
3590 %}
3591
3592 enc_class aarch64_enc_call_epilog() %{
3593 MacroAssembler _masm(&cbuf);
3594 if (VerifyStackAtCalls) {
3595 // Check that stack depth is unchanged: find majik cookie on stack
3596 __ call_Unimplemented();
3597 }
3598 %}
3599
3600 enc_class aarch64_enc_java_to_runtime(method meth) %{
3601 MacroAssembler _masm(&cbuf);
3602
3603 // some calls to generated routines (arraycopy code) are scheduled
3604 // by C2 as runtime calls. if so we can call them using a br (they
3605 // will be in a reachable segment) otherwise we have to use a blrt
3606 // which loads the absolute address into a register.
12583 "ldrw zr, [$poll]\t# Safepoint: poll for GC"
12584 %}
12585 ins_encode %{
12586 __ read_polling_page(as_Register($poll$$reg), relocInfo::poll_type);
12587 %}
12588 ins_pipe(pipe_serial); // ins_pipe(iload_reg_mem);
12589 %}
12590
12591
12592 // ============================================================================
12593 // Procedure Call/Return Instructions
12594
12595 // Call Java Static Instruction
12596
12597 instruct CallStaticJavaDirect(method meth)
12598 %{
12599 match(CallStaticJava);
12600
12601 effect(USE meth);
12602
12603 ins_cost(CALL_COST);
12604
12605 format %{ "call,static $meth \t// ==> " %}
12606
12607 ins_encode( aarch64_enc_java_static_call(meth),
12608 aarch64_enc_call_epilog );
12609
12610 ins_pipe(pipe_class_call);
12611 %}
12612
12613 // TO HERE
12614
12615 // Call Java Dynamic Instruction
12616 instruct CallDynamicJavaDirect(method meth)
12617 %{
12618 match(CallDynamicJava);
12619
12620 effect(USE meth);
12621
12622 ins_cost(CALL_COST);
12623
12624 format %{ "CALL,dynamic $meth \t// ==> " %}
12625
12626 ins_encode( aarch64_enc_java_dynamic_call(meth),
12627 aarch64_enc_call_epilog );
12628
12629 ins_pipe(pipe_class_call);
12630 %}
12631
12632 // Call Runtime Instruction
12633
|