src/cpu/x86/vm/x86_64.ad

changeset 1572
97125851f396
parent 1424
148e5441d916
child 1709
2883969d09e7
equal deleted inserted replaced
1571:4b84186a8248 1572:97125851f396
549 #define RELOC_IMM64 Assembler::imm_operand 549 #define RELOC_IMM64 Assembler::imm_operand
550 #define RELOC_DISP32 Assembler::disp32_operand 550 #define RELOC_DISP32 Assembler::disp32_operand
551 551
552 #define __ _masm. 552 #define __ _masm.
553 553
554 static int preserve_SP_size() {
555 return LP64_ONLY(1 +) 2; // [rex,] op, rm(reg/reg)
556 }
557
554 // !!!!! Special hack to get all types of calls to specify the byte offset 558 // !!!!! 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 559 // from the start of the call to the point where the return address
556 // will point. 560 // will point.
557 int MachCallStaticJavaNode::ret_addr_offset() 561 int MachCallStaticJavaNode::ret_addr_offset()
558 { 562 {
559 return 5; // 5 bytes from start of call to where return address points 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;
560 } 567 }
561 568
562 int MachCallDynamicJavaNode::ret_addr_offset() 569 int MachCallDynamicJavaNode::ret_addr_offset()
563 { 570 {
564 return 15; // 15 bytes from start of call to where return address points 571 return 15; // 15 bytes from start of call to where return address points
581 588
582 // The address of the call instruction needs to be 4-byte aligned to 589 // 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. 590 // ensure that it does not span a cache line so that it can be patched.
584 int CallStaticJavaDirectNode::compute_padding(int current_offset) const 591 int CallStaticJavaDirectNode::compute_padding(int current_offset) const
585 { 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
586 current_offset += 1; // skip call opcode byte 602 current_offset += 1; // skip call opcode byte
587 return round_to(current_offset, alignment_required()) - current_offset; 603 return round_to(current_offset, alignment_required()) - current_offset;
588 } 604 }
589 605
590 // The address of the call instruction needs to be 4-byte aligned to 606 // The address of the call instruction needs to be 4-byte aligned to
2111 // Register for MODL projection of divmodL 2127 // Register for MODL projection of divmodL
2112 RegMask Matcher::modL_proj_mask() { 2128 RegMask Matcher::modL_proj_mask() {
2113 return LONG_RDX_REG_mask; 2129 return LONG_RDX_REG_mask;
2114 } 2130 }
2115 2131
2132 const RegMask Matcher::method_handle_invoke_SP_save_mask() {
2133 return PTR_RBP_REG_mask;
2134 }
2135
2116 static Address build_address(int b, int i, int s, int d) { 2136 static Address build_address(int b, int i, int s, int d) {
2117 Register index = as_Register(i); 2137 Register index = as_Register(i);
2118 Address::ScaleFactor scale = (Address::ScaleFactor)s; 2138 Address::ScaleFactor scale = (Address::ScaleFactor)s;
2119 if (index == rsp) { 2139 if (index == rsp) {
2120 index = noreg; 2140 index = noreg;
2604 // CALL directly to the runtime 2624 // CALL directly to the runtime
2605 emit_d32_reloc(cbuf, 2625 emit_d32_reloc(cbuf,
2606 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4), 2626 (int) ($meth$$method - ((intptr_t) cbuf.code_end()) - 4),
2607 runtime_call_Relocation::spec(), 2627 runtime_call_Relocation::spec(),
2608 RELOC_DISP32); 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);
2609 %} 2644 %}
2610 2645
2611 enc_class Java_Static_Call(method meth) 2646 enc_class Java_Static_Call(method meth)
2612 %{ 2647 %{
2613 // JAVA STATIC CALL 2648 // JAVA STATIC CALL
12524 // ============================================================================ 12559 // ============================================================================
12525 // Procedure Call/Return Instructions 12560 // Procedure Call/Return Instructions
12526 // Call Java Static Instruction 12561 // Call Java Static Instruction
12527 // Note: If this code changes, the corresponding ret_addr_offset() and 12562 // Note: If this code changes, the corresponding ret_addr_offset() and
12528 // compute_padding() functions will have to be adjusted. 12563 // compute_padding() functions will have to be adjusted.
12529 instruct CallStaticJavaDirect(method meth) 12564 instruct CallStaticJavaDirect(method meth) %{
12530 %{
12531 match(CallStaticJava); 12565 match(CallStaticJava);
12566 predicate(!((CallStaticJavaNode*) n)->is_method_handle_invoke());
12532 effect(USE meth); 12567 effect(USE meth);
12533 12568
12534 ins_cost(300); 12569 ins_cost(300);
12535 format %{ "call,static " %} 12570 format %{ "call,static " %}
12536 opcode(0xE8); /* E8 cd */ 12571 opcode(0xE8); /* E8 cd */
12537 ins_encode(Java_Static_Call(meth), call_epilog); 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);
12538 ins_pipe(pipe_slow); 12595 ins_pipe(pipe_slow);
12539 ins_pc_relative(1); 12596 ins_pc_relative(1);
12540 ins_alignment(4); 12597 ins_alignment(4);
12541 %} 12598 %}
12542 12599

mercurial