src/share/vm/opto/macro.cpp

Print this page
rev 2571 : [mq]: membar3


1799   #endif
1800 
1801   Node* mem  = alock->in(TypeFunc::Memory);
1802   Node* ctrl = alock->in(TypeFunc::Control);
1803 
1804   extract_call_projections(alock);
1805   // There are 2 projections from the lock.  The lock node will
1806   // be deleted when its last use is subsumed below.
1807   assert(alock->outcnt() == 2 &&
1808          _fallthroughproj != NULL &&
1809          _memproj_fallthrough != NULL,
1810          "Unexpected projections from Lock/Unlock");
1811 
1812   Node* fallthroughproj = _fallthroughproj;
1813   Node* memproj_fallthrough = _memproj_fallthrough;
1814 
1815   // The memory projection from a lock/unlock is RawMem
1816   // The input to a Lock is merged memory, so extract its RawMem input
1817   // (unless the MergeMem has been optimized away.)
1818   if (alock->is_Lock()) {
1819     // Seach for MemBarAcquire node and delete it also.
1820     MemBarNode* membar = fallthroughproj->unique_ctrl_out()->as_MemBar();
1821     assert(membar != NULL && membar->Opcode() == Op_MemBarAcquire, "");
1822     Node* ctrlproj = membar->proj_out(TypeFunc::Control);
1823     Node* memproj = membar->proj_out(TypeFunc::Memory);
1824     _igvn.replace_node(ctrlproj, fallthroughproj);
1825     _igvn.replace_node(memproj, memproj_fallthrough);
1826 
1827     // Delete FastLock node also if this Lock node is unique user
1828     // (a loop peeling may clone a Lock node).
1829     Node* flock = alock->as_Lock()->fastlock_node();
1830     if (flock->outcnt() == 1) {
1831       assert(flock->unique_out() == alock, "sanity");
1832       _igvn.replace_node(flock, top());
1833     }
1834   }
1835 
1836   // Seach for MemBarRelease node and delete it also.
1837   if (alock->is_Unlock() && ctrl != NULL && ctrl->is_Proj() &&
1838       ctrl->in(0)->is_MemBar()) {
1839     MemBarNode* membar = ctrl->in(0)->as_MemBar();
1840     assert(membar->Opcode() == Op_MemBarRelease &&
1841            mem->is_Proj() && membar == mem->in(0), "");
1842     _igvn.replace_node(fallthroughproj, ctrl);
1843     _igvn.replace_node(memproj_fallthrough, mem);
1844     fallthroughproj = ctrl;
1845     memproj_fallthrough = mem;
1846     ctrl = membar->in(TypeFunc::Control);
1847     mem  = membar->in(TypeFunc::Memory);
1848   }
1849 
1850   _igvn.replace_node(fallthroughproj, ctrl);
1851   _igvn.replace_node(memproj_fallthrough, mem);
1852   return true;
1853 }
1854 
1855 
1856 //------------------------------expand_lock_node----------------------
1857 void PhaseMacroExpand::expand_lock_node(LockNode *lock) {
1858 
1859   Node* ctrl = lock->in(TypeFunc::Control);
1860   Node* mem = lock->in(TypeFunc::Memory);




1799   #endif
1800 
1801   Node* mem  = alock->in(TypeFunc::Memory);
1802   Node* ctrl = alock->in(TypeFunc::Control);
1803 
1804   extract_call_projections(alock);
1805   // There are 2 projections from the lock.  The lock node will
1806   // be deleted when its last use is subsumed below.
1807   assert(alock->outcnt() == 2 &&
1808          _fallthroughproj != NULL &&
1809          _memproj_fallthrough != NULL,
1810          "Unexpected projections from Lock/Unlock");
1811 
1812   Node* fallthroughproj = _fallthroughproj;
1813   Node* memproj_fallthrough = _memproj_fallthrough;
1814 
1815   // The memory projection from a lock/unlock is RawMem
1816   // The input to a Lock is merged memory, so extract its RawMem input
1817   // (unless the MergeMem has been optimized away.)
1818   if (alock->is_Lock()) {
1819     // Seach for MemBarAcquireLock node and delete it also.
1820     MemBarNode* membar = fallthroughproj->unique_ctrl_out()->as_MemBar();
1821     assert(membar != NULL && membar->Opcode() == Op_MemBarAcquireLock, "");
1822     Node* ctrlproj = membar->proj_out(TypeFunc::Control);
1823     Node* memproj = membar->proj_out(TypeFunc::Memory);
1824     _igvn.replace_node(ctrlproj, fallthroughproj);
1825     _igvn.replace_node(memproj, memproj_fallthrough);
1826 
1827     // Delete FastLock node also if this Lock node is unique user
1828     // (a loop peeling may clone a Lock node).
1829     Node* flock = alock->as_Lock()->fastlock_node();
1830     if (flock->outcnt() == 1) {
1831       assert(flock->unique_out() == alock, "sanity");
1832       _igvn.replace_node(flock, top());
1833     }
1834   }
1835 
1836   // Seach for MemBarReleaseLock node and delete it also.
1837   if (alock->is_Unlock() && ctrl != NULL && ctrl->is_Proj() &&
1838       ctrl->in(0)->is_MemBar()) {
1839     MemBarNode* membar = ctrl->in(0)->as_MemBar();
1840     assert(membar->Opcode() == Op_MemBarReleaseLock &&
1841            mem->is_Proj() && membar == mem->in(0), "");
1842     _igvn.replace_node(fallthroughproj, ctrl);
1843     _igvn.replace_node(memproj_fallthrough, mem);
1844     fallthroughproj = ctrl;
1845     memproj_fallthrough = mem;
1846     ctrl = membar->in(TypeFunc::Control);
1847     mem  = membar->in(TypeFunc::Memory);
1848   }
1849 
1850   _igvn.replace_node(fallthroughproj, ctrl);
1851   _igvn.replace_node(memproj_fallthrough, mem);
1852   return true;
1853 }
1854 
1855 
1856 //------------------------------expand_lock_node----------------------
1857 void PhaseMacroExpand::expand_lock_node(LockNode *lock) {
1858 
1859   Node* ctrl = lock->in(TypeFunc::Control);
1860   Node* mem = lock->in(TypeFunc::Memory);