534 XMM8, XMM8_H,
535 XMM9, XMM9_H,
536 XMM10, XMM10_H,
537 XMM11, XMM11_H,
538 XMM12, XMM12_H,
539 XMM13, XMM13_H,
540 XMM14, XMM14_H,
541 XMM15, XMM15_H);
542 %}
543
544
545 //----------SOURCE BLOCK-------------------------------------------------------
546 // This is a block of C++ code which provides values, functions, and
547 // definitions necessary in the rest of the architecture description
548 source %{
549 #define RELOC_IMM64 Assembler::imm_operand
550 #define RELOC_DISP32 Assembler::disp32_operand
551
552 #define __ _masm.
553
554 // !!!!! Special hack to get all types of calls to specify the byte offset
555 // from the start of the call to the point where the return address
556 // will point.
557 int MachCallStaticJavaNode::ret_addr_offset()
558 {
559 return 5; // 5 bytes from start of call to where return address points
560 }
561
562 int MachCallDynamicJavaNode::ret_addr_offset()
563 {
564 return 15; // 15 bytes from start of call to where return address points
565 }
566
567 // In os_cpu .ad file
568 // int MachCallRuntimeNode::ret_addr_offset()
569
570 // Indicate if the safepoint node needs the polling page as an input.
571 // Since amd64 does not have absolute addressing but RIP-relative
572 // addressing and the polling page is within 2G, it doesn't.
573 bool SafePointNode::needs_polling_address_input()
574 {
575 return false;
576 }
577
578 //
579 // Compute padding required for nodes which need alignment
580 //
581
582 // The address of the call instruction needs to be 4-byte aligned to
583 // ensure that it does not span a cache line so that it can be patched.
584 int CallStaticJavaDirectNode::compute_padding(int current_offset) const
585 {
586 current_offset += 1; // skip call opcode byte
587 return round_to(current_offset, alignment_required()) - current_offset;
588 }
589
590 // The address of the call instruction needs to be 4-byte aligned to
591 // ensure that it does not span a cache line so that it can be patched.
592 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const
593 {
594 current_offset += 11; // skip movq instruction + call opcode byte
595 return round_to(current_offset, alignment_required()) - current_offset;
596 }
597
598 #ifndef PRODUCT
599 void MachBreakpointNode::format(PhaseRegAlloc*, outputStream* st) const
600 {
601 st->print("INT3");
602 }
603 #endif
604
605 // EMIT_RM()
606 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3)
607 {
608 unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3);
609 *(cbuf.code_end()) = c;
610 cbuf.set_code_end(cbuf.code_end() + 1);
611 }
2096 // Register for DIVI projection of divmodI
2097 RegMask Matcher::divI_proj_mask() {
2098 return INT_RAX_REG_mask;
2099 }
2100
2101 // Register for MODI projection of divmodI
2102 RegMask Matcher::modI_proj_mask() {
2103 return INT_RDX_REG_mask;
2104 }
2105
2106 // Register for DIVL projection of divmodL
2107 RegMask Matcher::divL_proj_mask() {
2108 return LONG_RAX_REG_mask;
2109 }
2110
2111 // Register for MODL projection of divmodL
2112 RegMask Matcher::modL_proj_mask() {
2113 return LONG_RDX_REG_mask;
2114 }
2115
2116 static Address build_address(int b, int i, int s, int d) {
2117 Register index = as_Register(i);
2118 Address::ScaleFactor scale = (Address::ScaleFactor)s;
2119 if (index == rsp) {
2120 index = noreg;
2121 scale = Address::no_scale;
2122 }
2123 Address addr(as_Register(b), index, scale, d);
2124 return addr;
2125 }
2126
2127 %}
2128
2129 //----------ENCODING BLOCK-----------------------------------------------------
2130 // This block specifies the encoding classes used by the compiler to
2131 // output byte streams. Encoding classes are parameterized macros
2132 // used by Machine Instruction Nodes in order to generate the bit
2133 // encoding of the instruction. Operands specify their base encoding
2134 // interface with the interface keyword. There are currently
2135 // supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
2591 /*set_cond_codes:*/ true);
2592 if ($primary) {
2593 __ xorptr(Rrdi, Rrdi);
2594 }
2595 __ bind(miss);
2596 %}
2597
2598 enc_class Java_To_Interpreter(method meth)
2599 %{
2600 // CALL Java_To_Interpreter
2601 // This is the instruction starting address for relocation info.
2602 cbuf.set_inst_mark();
2603 $$$emit8$primary;
2604 // CALL directly to the runtime
2605 emit_d32_reloc(cbuf,
2606 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2607 runtime_call_Relocation::spec(),
2608 RELOC_DISP32);
2609 %}
2610
2611 enc_class Java_Static_Call(method meth)
2612 %{
2613 // JAVA STATIC CALL
2614 // CALL to fixup routine. Fixup routine uses ScopeDesc info to
2615 // determine who we intended to call.
2616 cbuf.set_inst_mark();
2617 $$$emit8$primary;
2618
2619 if (!_method) {
2620 emit_d32_reloc(cbuf,
2621 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2622 runtime_call_Relocation::spec(),
2623 RELOC_DISP32);
2624 } else if (_optimized_virtual) {
2625 emit_d32_reloc(cbuf,
2626 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2627 opt_virtual_call_Relocation::spec(),
2628 RELOC_DISP32);
2629 } else {
2630 emit_d32_reloc(cbuf,
12509 // ============================================================================
12510 // Safepoint Instructions
12511 instruct safePoint_poll(rFlagsReg cr)
12512 %{
12513 match(SafePoint);
12514 effect(KILL cr);
12515
12516 format %{ "testl rax, [rip + #offset_to_poll_page]\t"
12517 "# Safepoint: poll for GC" %}
12518 size(6); // Opcode + ModRM + Disp32 == 6 bytes
12519 ins_cost(125);
12520 ins_encode(enc_safepoint_poll);
12521 ins_pipe(ialu_reg_mem);
12522 %}
12523
12524 // ============================================================================
12525 // Procedure Call/Return Instructions
12526 // Call Java Static Instruction
12527 // Note: If this code changes, the corresponding ret_addr_offset() and
12528 // compute_padding() functions will have to be adjusted.
12529 instruct CallStaticJavaDirect(method meth)
12530 %{
12531 match(CallStaticJava);
12532 effect(USE meth);
12533
12534 ins_cost(300);
12535 format %{ "call,static " %}
12536 opcode(0xE8); /* E8 cd */
12537 ins_encode(Java_Static_Call(meth), call_epilog);
12538 ins_pipe(pipe_slow);
12539 ins_pc_relative(1);
12540 ins_alignment(4);
12541 %}
12542
12543 // Call Java Dynamic Instruction
12544 // Note: If this code changes, the corresponding ret_addr_offset() and
12545 // compute_padding() functions will have to be adjusted.
12546 instruct CallDynamicJavaDirect(method meth)
12547 %{
12548 match(CallDynamicJava);
12549 effect(USE meth);
12550
12551 ins_cost(300);
12552 format %{ "movq rax, #Universe::non_oop_word()\n\t"
12553 "call,dynamic " %}
12554 opcode(0xE8); /* E8 cd */
12555 ins_encode(Java_Dynamic_Call(meth), call_epilog);
12556 ins_pipe(pipe_slow);
12557 ins_pc_relative(1);
12558 ins_alignment(4);
12559 %}
12560
12561 // Call Runtime Instruction
12562 instruct CallRuntimeDirect(method meth)
|
534 XMM8, XMM8_H,
535 XMM9, XMM9_H,
536 XMM10, XMM10_H,
537 XMM11, XMM11_H,
538 XMM12, XMM12_H,
539 XMM13, XMM13_H,
540 XMM14, XMM14_H,
541 XMM15, XMM15_H);
542 %}
543
544
545 //----------SOURCE BLOCK-------------------------------------------------------
546 // This is a block of C++ code which provides values, functions, and
547 // definitions necessary in the rest of the architecture description
548 source %{
549 #define RELOC_IMM64 Assembler::imm_operand
550 #define RELOC_DISP32 Assembler::disp32_operand
551
552 #define __ _masm.
553
554 static int preserve_SP_size() {
555 return LP64_ONLY(1 +) 2; // [rex,] op, rm(reg/reg)
556 }
557
558 // !!!!! Special hack to get all types of calls to specify the byte offset
559 // from the start of the call to the point where the return address
560 // will point.
561 int MachCallStaticJavaNode::ret_addr_offset()
562 {
563 int offset = 5; // 5 bytes from start of call to where return address points
564 if (_method_handle_invoke)
565 offset += preserve_SP_size();
566 return offset;
567 }
568
569 int MachCallDynamicJavaNode::ret_addr_offset()
570 {
571 return 15; // 15 bytes from start of call to where return address points
572 }
573
574 // In os_cpu .ad file
575 // int MachCallRuntimeNode::ret_addr_offset()
576
577 // Indicate if the safepoint node needs the polling page as an input.
578 // Since amd64 does not have absolute addressing but RIP-relative
579 // addressing and the polling page is within 2G, it doesn't.
580 bool SafePointNode::needs_polling_address_input()
581 {
582 return false;
583 }
584
585 //
586 // Compute padding required for nodes which need alignment
587 //
588
589 // The address of the call instruction needs to be 4-byte aligned to
590 // ensure that it does not span a cache line so that it can be patched.
591 int CallStaticJavaDirectNode::compute_padding(int current_offset) const
592 {
593 current_offset += 1; // skip call opcode byte
594 return round_to(current_offset, alignment_required()) - current_offset;
595 }
596
597 // The address of the call instruction needs to be 4-byte aligned to
598 // ensure that it does not span a cache line so that it can be patched.
599 int CallStaticJavaHandleNode::compute_padding(int current_offset) const
600 {
601 current_offset += preserve_SP_size(); // skip mov rbp, rsp
602 current_offset += 1; // skip call opcode byte
603 return round_to(current_offset, alignment_required()) - current_offset;
604 }
605
606 // The address of the call instruction needs to be 4-byte aligned to
607 // ensure that it does not span a cache line so that it can be patched.
608 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const
609 {
610 current_offset += 11; // skip movq instruction + call opcode byte
611 return round_to(current_offset, alignment_required()) - current_offset;
612 }
613
614 #ifndef PRODUCT
615 void MachBreakpointNode::format(PhaseRegAlloc*, outputStream* st) const
616 {
617 st->print("INT3");
618 }
619 #endif
620
621 // EMIT_RM()
622 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3)
623 {
624 unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3);
625 *(cbuf.code_end()) = c;
626 cbuf.set_code_end(cbuf.code_end() + 1);
627 }
2112 // Register for DIVI projection of divmodI
2113 RegMask Matcher::divI_proj_mask() {
2114 return INT_RAX_REG_mask;
2115 }
2116
2117 // Register for MODI projection of divmodI
2118 RegMask Matcher::modI_proj_mask() {
2119 return INT_RDX_REG_mask;
2120 }
2121
2122 // Register for DIVL projection of divmodL
2123 RegMask Matcher::divL_proj_mask() {
2124 return LONG_RAX_REG_mask;
2125 }
2126
2127 // Register for MODL projection of divmodL
2128 RegMask Matcher::modL_proj_mask() {
2129 return LONG_RDX_REG_mask;
2130 }
2131
2132 const RegMask Matcher::method_handle_invoke_SP_save_mask() {
2133 return PTR_RBP_REG_mask;
2134 }
2135
2136 static Address build_address(int b, int i, int s, int d) {
2137 Register index = as_Register(i);
2138 Address::ScaleFactor scale = (Address::ScaleFactor)s;
2139 if (index == rsp) {
2140 index = noreg;
2141 scale = Address::no_scale;
2142 }
2143 Address addr(as_Register(b), index, scale, d);
2144 return addr;
2145 }
2146
2147 %}
2148
2149 //----------ENCODING BLOCK-----------------------------------------------------
2150 // This block specifies the encoding classes used by the compiler to
2151 // output byte streams. Encoding classes are parameterized macros
2152 // used by Machine Instruction Nodes in order to generate the bit
2153 // encoding of the instruction. Operands specify their base encoding
2154 // interface with the interface keyword. There are currently
2155 // supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
2611 /*set_cond_codes:*/ true);
2612 if ($primary) {
2613 __ xorptr(Rrdi, Rrdi);
2614 }
2615 __ bind(miss);
2616 %}
2617
2618 enc_class Java_To_Interpreter(method meth)
2619 %{
2620 // CALL Java_To_Interpreter
2621 // This is the instruction starting address for relocation info.
2622 cbuf.set_inst_mark();
2623 $$$emit8$primary;
2624 // CALL directly to the runtime
2625 emit_d32_reloc(cbuf,
2626 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2627 runtime_call_Relocation::spec(),
2628 RELOC_DISP32);
2629 %}
2630
2631 enc_class preserve_SP %{
2632 debug_only(int off0 = cbuf.code_size());
2633 MacroAssembler _masm(&cbuf);
2634 // RBP is preserved across all calls, even compiled calls.
2635 // Use it to preserve RSP in places where the callee might change the SP.
2636 __ movptr(rbp, rsp);
2637 debug_only(int off1 = cbuf.code_size());
2638 assert(off1 - off0 == preserve_SP_size(), "correct size prediction");
2639 %}
2640
2641 enc_class restore_SP %{
2642 MacroAssembler _masm(&cbuf);
2643 __ movptr(rsp, rbp);
2644 %}
2645
2646 enc_class Java_Static_Call(method meth)
2647 %{
2648 // JAVA STATIC CALL
2649 // CALL to fixup routine. Fixup routine uses ScopeDesc info to
2650 // determine who we intended to call.
2651 cbuf.set_inst_mark();
2652 $$$emit8$primary;
2653
2654 if (!_method) {
2655 emit_d32_reloc(cbuf,
2656 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2657 runtime_call_Relocation::spec(),
2658 RELOC_DISP32);
2659 } else if (_optimized_virtual) {
2660 emit_d32_reloc(cbuf,
2661 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2662 opt_virtual_call_Relocation::spec(),
2663 RELOC_DISP32);
2664 } else {
2665 emit_d32_reloc(cbuf,
12544 // ============================================================================
12545 // Safepoint Instructions
12546 instruct safePoint_poll(rFlagsReg cr)
12547 %{
12548 match(SafePoint);
12549 effect(KILL cr);
12550
12551 format %{ "testl rax, [rip + #offset_to_poll_page]\t"
12552 "# Safepoint: poll for GC" %}
12553 size(6); // Opcode + ModRM + Disp32 == 6 bytes
12554 ins_cost(125);
12555 ins_encode(enc_safepoint_poll);
12556 ins_pipe(ialu_reg_mem);
12557 %}
12558
12559 // ============================================================================
12560 // Procedure Call/Return Instructions
12561 // Call Java Static Instruction
12562 // Note: If this code changes, the corresponding ret_addr_offset() and
12563 // compute_padding() functions will have to be adjusted.
12564 instruct CallStaticJavaDirect(method meth) %{
12565 match(CallStaticJava);
12566 predicate(!((CallStaticJavaNode*) n)->is_method_handle_invoke());
12567 effect(USE meth);
12568
12569 ins_cost(300);
12570 format %{ "call,static " %}
12571 opcode(0xE8); /* E8 cd */
12572 ins_encode(Java_Static_Call(meth), call_epilog);
12573 ins_pipe(pipe_slow);
12574 ins_pc_relative(1);
12575 ins_alignment(4);
12576 %}
12577
12578 // Call Java Static Instruction (method handle version)
12579 // Note: If this code changes, the corresponding ret_addr_offset() and
12580 // compute_padding() functions will have to be adjusted.
12581 instruct CallStaticJavaHandle(method meth, rbp_RegP rbp) %{
12582 match(CallStaticJava);
12583 predicate(((CallStaticJavaNode*) n)->is_method_handle_invoke());
12584 effect(USE meth);
12585 // RBP is saved by all callees (for interpreter stack correction).
12586 // We use it here for a similar purpose, in {preserve,restore}_SP.
12587
12588 ins_cost(300);
12589 format %{ "call,static/MethodHandle " %}
12590 opcode(0xE8); /* E8 cd */
12591 ins_encode(preserve_SP,
12592 Java_Static_Call(meth),
12593 restore_SP,
12594 call_epilog);
12595 ins_pipe(pipe_slow);
12596 ins_pc_relative(1);
12597 ins_alignment(4);
12598 %}
12599
12600 // Call Java Dynamic Instruction
12601 // Note: If this code changes, the corresponding ret_addr_offset() and
12602 // compute_padding() functions will have to be adjusted.
12603 instruct CallDynamicJavaDirect(method meth)
12604 %{
12605 match(CallDynamicJava);
12606 effect(USE meth);
12607
12608 ins_cost(300);
12609 format %{ "movq rax, #Universe::non_oop_word()\n\t"
12610 "call,dynamic " %}
12611 opcode(0xE8); /* E8 cd */
12612 ins_encode(Java_Dynamic_Call(meth), call_epilog);
12613 ins_pipe(pipe_slow);
12614 ins_pc_relative(1);
12615 ins_alignment(4);
12616 %}
12617
12618 // Call Runtime Instruction
12619 instruct CallRuntimeDirect(method meth)
|