Bug 469012 - crashing LirBufWriter::insLinkToFar, r=danderson.
authorGraydon Hoare <graydon@mozilla.com>
Fri, 19 Dec 2008 16:20:51 -0800
changeset 23104 a86e8c84e2ee0b9b6ed0beb17370cecf0d689911
parent 23103 173464ec399c3b5193a9996365c409fb636545e4
child 23105 c22e5761de557e3d48e18c2167f6302fc070ac99
push id4346
push userrsayre@mozilla.com
push dateFri, 26 Dec 2008 01:26:36 +0000
treeherdermozilla-central@8eb5a5b83a93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdanderson
bugs469012
milestone1.9.2a1pre
Bug 469012 - crashing LirBufWriter::insLinkToFar, r=danderson.
js/src/nanojit/LIR.cpp
--- a/js/src/nanojit/LIR.cpp
+++ b/js/src/nanojit/LIR.cpp
@@ -149,32 +149,32 @@ namespace nanojit
 	}
 
 	void LirBufWriter::ensureRoom(uint32_t count)
 	{
 		LInsp before = _buf->next();
 		LInsp after = before+count+LIR_FAR_SLOTS;
 		if (!samepage(before,after+LirBuffer::LIR_BUF_THRESHOLD))
 		{
+			if (!_buf->_thresholdPage)
+			{
+				// LIR_BUF_THRESHOLD away from a new page but pre-alloc it, setting noMem for early OOM detection
+				_buf->_thresholdPage = _buf->pageAlloc();
+				NanoAssert(_buf->_thresholdPage || _buf->_noMem);
+			}
 			// transition to the next page?
 			if (!samepage(before,after))
 			{
 				NanoAssert(_buf->_thresholdPage);
 				_buf->_unused = &_buf->_thresholdPage->lir[0];	
 				_buf->_thresholdPage = 0;  // pageAlloc() stored it in _pages already			
 
 				// link LIR stream back to prior instruction (careful insLink relies on _unused...)
 				insLinkTo(LIR_skip, before-1);
 			}
-			else if (!_buf->_thresholdPage)
-			{
-				// LIR_BUF_THRESHOLD away from a new page but pre-alloc it, setting noMem for early OOM detection
-				_buf->_thresholdPage = _buf->pageAlloc();
-				NanoAssert(_buf->_thresholdPage || _buf->_noMem);
-			}
 		}
 	}
 
 	LInsp LirBufWriter::insLinkTo(LOpcode op, LInsp to)
 	{
 		LInsp l = _buf->next();
 		NanoAssert(samepage(l,l+LIR_FAR_SLOTS)); // must have called ensureRoom()
         if (can24bReach(l,to))