Print this page
rev 1025 : imported patch indy.compiler.patch

Split Close
Expand all
Collapse all
          --- old/src/cpu/x86/vm/x86_32.ad
          +++ new/src/cpu/x86/vm/x86_32.ad
↓ open down ↓ 260 lines elided ↑ open up ↑
 261  261  
 262  262  // Buffer for 128-bits masks used by SSE instructions.
 263  263  static jlong fp_signmask_pool[(4+1)*2]; // 4*128bits(data) + 128bits(alignment)
 264  264  
 265  265  // Static initialization during VM startup.
 266  266  static jlong *float_signmask_pool  = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
 267  267  static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
 268  268  static jlong *float_signflip_pool  = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
 269  269  static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000));
 270  270  
      271 +// Offset hacking within calls.
      272 +static int pre_call_FPU_size() {
      273 +  if (Compile::current()->in_24_bit_fp_mode())
      274 +    return 6; // fldcw
      275 +  return 0;
      276 +}
      277 +
      278 +static int preserve_SP_size() {
      279 +  return LP64_ONLY(1 +) 2;  // [rex,] op, rm(reg/reg)
      280 +}
      281 +
 271  282  // !!!!! Special hack to get all type of calls to specify the byte offset
 272  283  //       from the start of the call to the point where the return address
 273  284  //       will point.
 274  285  int MachCallStaticJavaNode::ret_addr_offset() {
 275      -  return 5 + (Compile::current()->in_24_bit_fp_mode() ? 6 : 0);  // 5 bytes from start of call to where return address points
      286 +  int offset = 5 + pre_call_FPU_size();  // 5 bytes from start of call to where return address points
      287 +  if (_method_handle_invoke)
      288 +    offset += preserve_SP_size();
      289 +  return offset;
 276  290  }
 277  291  
 278  292  int MachCallDynamicJavaNode::ret_addr_offset() {
 279      -  return 10 + (Compile::current()->in_24_bit_fp_mode() ? 6 : 0);  // 10 bytes from start of call to where return address points
      293 +  return 10 + pre_call_FPU_size();  // 10 bytes from start of call to where return address points
 280  294  }
 281  295  
 282  296  static int sizeof_FFree_Float_Stack_All = -1;
 283  297  
 284  298  int MachCallRuntimeNode::ret_addr_offset() {
 285  299    assert(sizeof_FFree_Float_Stack_All != -1, "must have been emitted already");
 286      -  return sizeof_FFree_Float_Stack_All + 5 + (Compile::current()->in_24_bit_fp_mode() ? 6 : 0);
      300 +  return sizeof_FFree_Float_Stack_All + 5 + pre_call_FPU_size();
 287  301  }
 288  302  
 289  303  // Indicate if the safepoint node needs the polling page as an input.
 290  304  // Since x86 does have absolute addressing, it doesn't.
 291  305  bool SafePointNode::needs_polling_address_input() {
 292  306    return false;
 293  307  }
 294  308  
 295  309  //
 296  310  // Compute padding required for nodes which need alignment
 297  311  //
 298  312  
 299  313  // The address of the call instruction needs to be 4-byte aligned to
 300  314  // ensure that it does not span a cache line so that it can be patched.
 301  315  int CallStaticJavaDirectNode::compute_padding(int current_offset) const {
 302      -  if (Compile::current()->in_24_bit_fp_mode())
 303      -    current_offset += 6;    // skip fldcw in pre_call_FPU, if any
      316 +  current_offset += pre_call_FPU_size();  // skip fldcw, if any
      317 +  current_offset += 1;      // skip call opcode byte
      318 +  return round_to(current_offset, alignment_required()) - current_offset;
      319 +}
      320 +
      321 +// The address of the call instruction needs to be 4-byte aligned to
      322 +// ensure that it does not span a cache line so that it can be patched.
      323 +int CallStaticJavaHandleNode::compute_padding(int current_offset) const {
      324 +  current_offset += pre_call_FPU_size();  // skip fldcw, if any
      325 +  current_offset += preserve_SP_size();   // skip mov rbp, rsp
 304  326    current_offset += 1;      // skip call opcode byte
 305  327    return round_to(current_offset, alignment_required()) - current_offset;
 306  328  }
 307  329  
 308  330  // The address of the call instruction needs to be 4-byte aligned to
 309  331  // ensure that it does not span a cache line so that it can be patched.
 310  332  int CallDynamicJavaDirectNode::compute_padding(int current_offset) const {
 311      -  if (Compile::current()->in_24_bit_fp_mode())
 312      -    current_offset += 6;    // skip fldcw in pre_call_FPU, if any
      333 +  current_offset += pre_call_FPU_size();  // skip fldcw, if any
 313  334    current_offset += 5;      // skip MOV instruction
 314  335    current_offset += 1;      // skip call opcode byte
 315  336    return round_to(current_offset, alignment_required()) - current_offset;
 316  337  }
 317  338  
 318  339  #ifndef PRODUCT
 319  340  void MachBreakpointNode::format( PhaseRegAlloc *, outputStream* st ) const {
 320  341    st->print("INT3");
 321  342  }
 322  343  #endif
↓ open down ↓ 1130 lines elided ↑ open up ↑
1453 1474    ShouldNotReachHere();
1454 1475    return RegMask();
1455 1476  }
1456 1477  
1457 1478  // Register for MODL projection of divmodL
1458 1479  RegMask Matcher::modL_proj_mask() {
1459 1480    ShouldNotReachHere();
1460 1481    return RegMask();
1461 1482  }
1462 1483  
     1484 +const RegMask Matcher::method_handle_invoke_SP_save_mask() {
     1485 +  return EBP_REG_mask;
     1486 +}
     1487 +
1463 1488  %}
1464 1489  
1465 1490  //----------ENCODING BLOCK-----------------------------------------------------
1466 1491  // This block specifies the encoding classes used by the compiler to output
1467 1492  // byte streams.  Encoding classes generate functions which are called by
1468 1493  // Machine Instruction Nodes in order to generate the bit encoding of the
1469 1494  // instruction.  Operands specify their base encoding interface with the
1470 1495  // interface keyword.  There are currently supported four interfaces,
1471 1496  // REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER.  REG_INTER causes an
1472 1497  // operand to generate a function which returns its register number when
↓ open down ↓ 292 lines elided ↑ open up ↑
1765 1790          __ fstp_d(Address(rsp, 0));
1766 1791          __ movdbl(xmm0, Address(rsp, 0));
1767 1792          __ lea(rsp, Address(rsp,  8));
1768 1793        }
1769 1794      }
1770 1795    %}
1771 1796  
1772 1797  
1773 1798    enc_class pre_call_FPU %{
1774 1799      // If method sets FPU control word restore it here
     1800 +    debug_only(int off0 = cbuf.code_size());
1775 1801      if( Compile::current()->in_24_bit_fp_mode() ) {
1776 1802        MacroAssembler masm(&cbuf);
1777 1803        masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
1778 1804      }
     1805 +    debug_only(int off1 = cbuf.code_size());
     1806 +    assert(off1 - off0 == pre_call_FPU_size(), "correct size prediction");
1779 1807    %}
1780 1808  
1781 1809    enc_class post_call_FPU %{
1782 1810      // If method sets FPU control word do it here also
1783 1811      if( Compile::current()->in_24_bit_fp_mode() ) {
1784 1812        MacroAssembler masm(&cbuf);
1785 1813        masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
1786 1814      }
1787 1815    %}
1788 1816  
     1817 +  enc_class preserve_SP %{
     1818 +    debug_only(int off0 = cbuf.code_size());
     1819 +    MacroAssembler _masm(&cbuf);
     1820 +    // RBP is preserved across all calls, even compiled calls.
     1821 +    // Use it to preserve RSP in places where the callee might change the SP.
     1822 +    __ movptr(rbp, rsp);
     1823 +    debug_only(int off1 = cbuf.code_size());
     1824 +    assert(off1 - off0 == preserve_SP_size(), "correct size prediction");
     1825 +  %}
     1826 +
     1827 +  enc_class restore_SP %{
     1828 +    MacroAssembler _masm(&cbuf);
     1829 +    __ movptr(rsp, rbp);
     1830 +  %}
     1831 +
1789 1832    enc_class Java_Static_Call (method meth) %{    // JAVA STATIC CALL
1790 1833      // CALL to fixup routine.  Fixup routine uses ScopeDesc info to determine
1791 1834      // who we intended to call.
1792 1835      cbuf.set_inst_mark();
1793 1836      $$$emit8$primary;
1794 1837      if ( !_method ) {
1795 1838        emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
1796 1839                       runtime_call_Relocation::spec(), RELOC_IMM32 );
1797 1840      } else if(_optimized_virtual) {
1798 1841        emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
↓ open down ↓ 11600 lines elided ↑ open up ↑
13399 13442  %}
13400 13443  
13401 13444  
13402 13445  // ============================================================================
13403 13446  // Procedure Call/Return Instructions
13404 13447  // Call Java Static Instruction
13405 13448  // Note: If this code changes, the corresponding ret_addr_offset() and
13406 13449  //       compute_padding() functions will have to be adjusted.
13407 13450  instruct CallStaticJavaDirect(method meth) %{
13408 13451    match(CallStaticJava);
     13452 +  predicate(! ((CallStaticJavaNode*)n)->is_method_handle_invoke());
13409 13453    effect(USE meth);
13410 13454  
13411 13455    ins_cost(300);
13412 13456    format %{ "CALL,static " %}
13413 13457    opcode(0xE8); /* E8 cd */
13414 13458    ins_encode( pre_call_FPU,
13415 13459                Java_Static_Call( meth ),
13416 13460                call_epilog,
13417 13461                post_call_FPU );
13418 13462    ins_pipe( pipe_slow );
13419 13463    ins_pc_relative(1);
13420 13464    ins_alignment(4);
13421 13465  %}
13422 13466  
     13467 +// Call Java Static Instruction (method handle version)
     13468 +// Note: If this code changes, the corresponding ret_addr_offset() and
     13469 +//       compute_padding() functions will have to be adjusted.
     13470 +instruct CallStaticJavaHandle(method meth, eBPRegP ebp) %{
     13471 +  match(CallStaticJava);
     13472 +  predicate(((CallStaticJavaNode*)n)->is_method_handle_invoke());
     13473 +  effect(USE meth);
     13474 +  // EBP is saved by all callees (for interpreter stack correction).
     13475 +  // We use it here for a similar purpose, in {preserve,restore}_SP.
     13476 +
     13477 +  ins_cost(300);
     13478 +  format %{ "CALL,static/MethodHandle " %}
     13479 +  opcode(0xE8); /* E8 cd */
     13480 +  ins_encode( pre_call_FPU,
     13481 +              preserve_SP,
     13482 +              Java_Static_Call( meth ),
     13483 +              restore_SP,
     13484 +              call_epilog,
     13485 +              post_call_FPU );
     13486 +  ins_pipe( pipe_slow );
     13487 +  ins_pc_relative(1);
     13488 +  ins_alignment(4);
     13489 +%}
     13490 +
13423 13491  // Call Java Dynamic Instruction
13424 13492  // Note: If this code changes, the corresponding ret_addr_offset() and
13425 13493  //       compute_padding() functions will have to be adjusted.
13426 13494  instruct CallDynamicJavaDirect(method meth) %{
13427 13495    match(CallDynamicJava);
13428 13496    effect(USE meth);
13429 13497  
13430 13498    ins_cost(300);
13431 13499    format %{ "MOV    EAX,(oop)-1\n\t"
13432 13500              "CALL,dynamic" %}
↓ open down ↓ 267 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX