hotspot/src/cpu/x86/vm/x86_32.ad
changeset 4566 b363f6ef4068
parent 3908 24b55ad4c228
child 4757 1fe15ef4fc8a
equal deleted inserted replaced
4565:cbb3fed38514 4566:b363f6ef4068
   266 static jlong *float_signmask_pool  = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
   266 static jlong *float_signmask_pool  = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
   267 static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
   267 static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
   268 static jlong *float_signflip_pool  = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
   268 static jlong *float_signflip_pool  = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
   269 static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000));
   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 // !!!!! Special hack to get all type of calls to specify the byte offset
   282 // !!!!! Special hack to get all type of calls to specify the byte offset
   272 //       from the start of the call to the point where the return address
   283 //       from the start of the call to the point where the return address
   273 //       will point.
   284 //       will point.
   274 int MachCallStaticJavaNode::ret_addr_offset() {
   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 int MachCallDynamicJavaNode::ret_addr_offset() {
   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 static int sizeof_FFree_Float_Stack_All = -1;
   296 static int sizeof_FFree_Float_Stack_All = -1;
   283 
   297 
   284 int MachCallRuntimeNode::ret_addr_offset() {
   298 int MachCallRuntimeNode::ret_addr_offset() {
   285   assert(sizeof_FFree_Float_Stack_All != -1, "must have been emitted already");
   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 // Indicate if the safepoint node needs the polling page as an input.
   303 // Indicate if the safepoint node needs the polling page as an input.
   290 // Since x86 does have absolute addressing, it doesn't.
   304 // Since x86 does have absolute addressing, it doesn't.
   291 bool SafePointNode::needs_polling_address_input() {
   305 bool SafePointNode::needs_polling_address_input() {
   297 //
   311 //
   298 
   312 
   299 // The address of the call instruction needs to be 4-byte aligned to
   313 // The address of the call instruction needs to be 4-byte aligned to
   300 // ensure that it does not span a cache line so that it can be patched.
   314 // ensure that it does not span a cache line so that it can be patched.
   301 int CallStaticJavaDirectNode::compute_padding(int current_offset) const {
   315 int CallStaticJavaDirectNode::compute_padding(int current_offset) const {
   302   if (Compile::current()->in_24_bit_fp_mode())
   316   current_offset += pre_call_FPU_size();  // skip fldcw, if any
   303     current_offset += 6;    // skip fldcw in pre_call_FPU, if any
       
   304   current_offset += 1;      // skip call opcode byte
   317   current_offset += 1;      // skip call opcode byte
   305   return round_to(current_offset, alignment_required()) - current_offset;
   318   return round_to(current_offset, alignment_required()) - current_offset;
   306 }
   319 }
   307 
   320 
   308 // The address of the call instruction needs to be 4-byte aligned to
   321 // The address of the call instruction needs to be 4-byte aligned to
   309 // ensure that it does not span a cache line so that it can be patched.
   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
       
   326   current_offset += 1;      // skip call opcode byte
       
   327   return round_to(current_offset, alignment_required()) - current_offset;
       
   328 }
       
   329 
       
   330 // The address of the call instruction needs to be 4-byte aligned to
       
   331 // ensure that it does not span a cache line so that it can be patched.
   310 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const {
   332 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const {
   311   if (Compile::current()->in_24_bit_fp_mode())
   333   current_offset += pre_call_FPU_size();  // skip fldcw, if any
   312     current_offset += 6;    // skip fldcw in pre_call_FPU, if any
       
   313   current_offset += 5;      // skip MOV instruction
   334   current_offset += 5;      // skip MOV instruction
   314   current_offset += 1;      // skip call opcode byte
   335   current_offset += 1;      // skip call opcode byte
   315   return round_to(current_offset, alignment_required()) - current_offset;
   336   return round_to(current_offset, alignment_required()) - current_offset;
   316 }
   337 }
   317 
   338 
  1458 RegMask Matcher::modL_proj_mask() {
  1479 RegMask Matcher::modL_proj_mask() {
  1459   ShouldNotReachHere();
  1480   ShouldNotReachHere();
  1460   return RegMask();
  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 //----------ENCODING BLOCK-----------------------------------------------------
  1490 //----------ENCODING BLOCK-----------------------------------------------------
  1466 // This block specifies the encoding classes used by the compiler to output
  1491 // This block specifies the encoding classes used by the compiler to output
  1467 // byte streams.  Encoding classes generate functions which are called by
  1492 // byte streams.  Encoding classes generate functions which are called by
  1770   %}
  1795   %}
  1771 
  1796 
  1772 
  1797 
  1773   enc_class pre_call_FPU %{
  1798   enc_class pre_call_FPU %{
  1774     // If method sets FPU control word restore it here
  1799     // If method sets FPU control word restore it here
       
  1800     debug_only(int off0 = cbuf.code_size());
  1775     if( Compile::current()->in_24_bit_fp_mode() ) {
  1801     if( Compile::current()->in_24_bit_fp_mode() ) {
  1776       MacroAssembler masm(&cbuf);
  1802       MacroAssembler masm(&cbuf);
  1777       masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
  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   enc_class post_call_FPU %{
  1809   enc_class post_call_FPU %{
  1782     // If method sets FPU control word do it here also
  1810     // If method sets FPU control word do it here also
  1783     if( Compile::current()->in_24_bit_fp_mode() ) {
  1811     if( Compile::current()->in_24_bit_fp_mode() ) {
  1784       MacroAssembler masm(&cbuf);
  1812       MacroAssembler masm(&cbuf);
  1785       masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
  1813       masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
  1786     }
  1814     }
       
  1815   %}
       
  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);
  1787   %}
  1830   %}
  1788 
  1831 
  1789   enc_class Java_Static_Call (method meth) %{    // JAVA STATIC CALL
  1832   enc_class Java_Static_Call (method meth) %{    // JAVA STATIC CALL
  1790     // CALL to fixup routine.  Fixup routine uses ScopeDesc info to determine
  1833     // CALL to fixup routine.  Fixup routine uses ScopeDesc info to determine
  1791     // who we intended to call.
  1834     // who we intended to call.
 13404 // Call Java Static Instruction
 13447 // Call Java Static Instruction
 13405 // Note: If this code changes, the corresponding ret_addr_offset() and
 13448 // Note: If this code changes, the corresponding ret_addr_offset() and
 13406 //       compute_padding() functions will have to be adjusted.
 13449 //       compute_padding() functions will have to be adjusted.
 13407 instruct CallStaticJavaDirect(method meth) %{
 13450 instruct CallStaticJavaDirect(method meth) %{
 13408   match(CallStaticJava);
 13451   match(CallStaticJava);
       
 13452   predicate(! ((CallStaticJavaNode*)n)->is_method_handle_invoke());
 13409   effect(USE meth);
 13453   effect(USE meth);
 13410 
 13454 
 13411   ins_cost(300);
 13455   ins_cost(300);
 13412   format %{ "CALL,static " %}
 13456   format %{ "CALL,static " %}
 13413   opcode(0xE8); /* E8 cd */
 13457   opcode(0xE8); /* E8 cd */
 13414   ins_encode( pre_call_FPU,
 13458   ins_encode( pre_call_FPU,
 13415               Java_Static_Call( meth ),
 13459               Java_Static_Call( meth ),
       
 13460               call_epilog,
       
 13461               post_call_FPU );
       
 13462   ins_pipe( pipe_slow );
       
 13463   ins_pc_relative(1);
       
 13464   ins_alignment(4);
       
 13465 %}
       
 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,
 13416               call_epilog,
 13484               call_epilog,
 13417               post_call_FPU );
 13485               post_call_FPU );
 13418   ins_pipe( pipe_slow );
 13486   ins_pipe( pipe_slow );
 13419   ins_pc_relative(1);
 13487   ins_pc_relative(1);
 13420   ins_alignment(4);
 13488   ins_alignment(4);