hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp
changeset 29070 b0a5fc9c59c8
parent 28719 5a9aedf87213
child 29325 0e86e64c66e5
equal deleted inserted replaced
29069:938c1c97ad3b 29070:b0a5fc9c59c8
  1716   if (EmitSync & 1) {
  1716   if (EmitSync & 1) {
  1717       // set box->dhw = markOopDesc::unused_mark()
  1717       // set box->dhw = markOopDesc::unused_mark()
  1718       // Force all sync thru slow-path: slow_enter() and slow_exit()
  1718       // Force all sync thru slow-path: slow_enter() and slow_exit()
  1719       movptr (Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
  1719       movptr (Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
  1720       cmpptr (rsp, (int32_t)NULL_WORD);
  1720       cmpptr (rsp, (int32_t)NULL_WORD);
  1721   } else
       
  1722   if (EmitSync & 2) {
       
  1723       Label DONE_LABEL ;
       
  1724       if (UseBiasedLocking) {
       
  1725          // Note: tmpReg maps to the swap_reg argument and scrReg to the tmp_reg argument.
       
  1726          biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, counters);
       
  1727       }
       
  1728 
       
  1729       movptr(tmpReg, Address(objReg, 0));           // fetch markword
       
  1730       orptr (tmpReg, 0x1);
       
  1731       movptr(Address(boxReg, 0), tmpReg);           // Anticipate successful CAS
       
  1732       if (os::is_MP()) {
       
  1733         lock();
       
  1734       }
       
  1735       cmpxchgptr(boxReg, Address(objReg, 0));       // Updates tmpReg
       
  1736       jccb(Assembler::equal, DONE_LABEL);
       
  1737       // Recursive locking
       
  1738       subptr(tmpReg, rsp);
       
  1739       andptr(tmpReg, (int32_t) (NOT_LP64(0xFFFFF003) LP64_ONLY(7 - os::vm_page_size())) );
       
  1740       movptr(Address(boxReg, 0), tmpReg);
       
  1741       bind(DONE_LABEL);
       
  1742   } else {
  1721   } else {
  1743     // Possible cases that we'll encounter in fast_lock
  1722     // Possible cases that we'll encounter in fast_lock
  1744     // ------------------------------------------------
  1723     // ------------------------------------------------
  1745     // * Inflated
  1724     // * Inflated
  1746     //    -- unlocked
  1725     //    -- unlocked
  1921        //   Invariant: m->_recursions should already be 0, so we don't need to explicitly set it.
  1900        //   Invariant: m->_recursions should already be 0, so we don't need to explicitly set it.
  1922        // Intentional fall-through into DONE_LABEL ...
  1901        // Intentional fall-through into DONE_LABEL ...
  1923     }
  1902     }
  1924 #else // _LP64
  1903 #else // _LP64
  1925     // It's inflated
  1904     // It's inflated
  1926 
  1905     movq(scrReg, tmpReg);
  1927     // TODO: someday avoid the ST-before-CAS penalty by
  1906     xorq(tmpReg, tmpReg);
  1928     // relocating (deferring) the following ST.
  1907 
  1929     // We should also think about trying a CAS without having
       
  1930     // fetched _owner.  If the CAS is successful we may
       
  1931     // avoid an RTO->RTS upgrade on the $line.
       
  1932 
       
  1933     // Without cast to int32_t a movptr will destroy r10 which is typically obj
       
  1934     movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
       
  1935 
       
  1936     movptr (boxReg, tmpReg);
       
  1937     movptr(tmpReg, Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
       
  1938     testptr(tmpReg, tmpReg);
       
  1939     jccb   (Assembler::notZero, DONE_LABEL);
       
  1940 
       
  1941     // It's inflated and appears unlocked
       
  1942     if (os::is_MP()) {
  1908     if (os::is_MP()) {
  1943       lock();
  1909       lock();
  1944     }
  1910     }
  1945     cmpxchgptr(r15_thread, Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
  1911     cmpxchgptr(r15_thread, Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
       
  1912     // Unconditionally set box->_displaced_header = markOopDesc::unused_mark().
       
  1913     // Without cast to int32_t movptr will destroy r10 which is typically obj.
       
  1914     movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
  1946     // Intentional fall-through into DONE_LABEL ...
  1915     // Intentional fall-through into DONE_LABEL ...
       
  1916     // Propagate ICC.ZF from CAS above into DONE_LABEL.
  1947 #endif // _LP64
  1917 #endif // _LP64
  1948 
       
  1949 #if INCLUDE_RTM_OPT
  1918 #if INCLUDE_RTM_OPT
  1950     } // use_rtm()
  1919     } // use_rtm()
  1951 #endif
  1920 #endif
  1952     // DONE_LABEL is a hot target - we'd really like to place it at the
  1921     // DONE_LABEL is a hot target - we'd really like to place it at the
  1953     // start of cache line by padding with NOPs.
  1922     // start of cache line by padding with NOPs.