Backed out changesets 01de929d4b85 and b9c5750d818a (bug 943519) for suspicion of causing B2G mochitest-2 failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 16 Dec 2013 13:41:15 -0500
changeset 160662 b2c07abf977a7d1d71a454eaa1b218af9a6ca2fa
parent 160661 b38e6bb55fc6ef31015fe6e82058ea05b9da145f
child 160663 3df0585a23a1622bf21bce5a2e9f9adc8ce2ccb6
child 160710 8aa46cd4c63c17147e0227325b40eb450b463b3d
push id37666
push userryanvm@gmail.com
push dateMon, 16 Dec 2013 18:41:16 +0000
treeherdermozilla-inbound@b2c07abf977a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs943519
milestone29.0a1
backs out01de929d4b858b78f85ff666239041eeedfa9afe
b9c5750d818a3f3497eee00124c3c9be71c4014b
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changesets 01de929d4b85 and b9c5750d818a (bug 943519) for suspicion of causing B2G mochitest-2 failures. CLOSED TREE
content/base/src/nsGenericDOMDataNode.cpp
content/base/src/nsTextFragment.cpp
content/base/src/nsTextFragment.h
parser/html/nsHtml5TreeOpExecutor.cpp
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -308,23 +308,21 @@ nsGenericDOMDataNode::SetTextInternal(ui
 
   if (NodeType() == nsIDOMNode::TEXT_NODE) {
     SetDirectionFromChangedTextNode(this, aOffset, aBuffer, aLength, aNotify);
   }
 
   if (aOffset == 0 && endOffset == textLength) {
     // Replacing whole text or old text was empty.  Don't bother to check for
     // bidi in this string if the document already has bidi enabled.
-    bool ok = mText.SetTo(aBuffer, aLength, !document || !document->GetBidiEnabled());
-    NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
+    mText.SetTo(aBuffer, aLength, !document || !document->GetBidiEnabled());
   }
   else if (aOffset == textLength) {
     // Appending to existing
-    bool ok = mText.Append(aBuffer, aLength, !document || !document->GetBidiEnabled());
-    NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
+    mText.Append(aBuffer, aLength, !document || !document->GetBidiEnabled());
   }
   else {
     // Merging old and new
 
     // Allocate new buffer
     int32_t newLength = textLength - aCount + aLength;
     PRUnichar* to = new PRUnichar[newLength];
     NS_ENSURE_TRUE(to, NS_ERROR_OUT_OF_MEMORY);
@@ -335,21 +333,20 @@ nsGenericDOMDataNode::SetTextInternal(ui
     }
     if (aLength) {
       memcpy(to + aOffset, aBuffer, aLength * sizeof(PRUnichar));
     }
     if (endOffset != textLength) {
       mText.CopyTo(to + aOffset + aLength, endOffset, textLength - endOffset);
     }
 
-    bool ok = mText.SetTo(to, newLength, !document || !document->GetBidiEnabled());
+    // XXX Add OOM checking to this
+    mText.SetTo(to, newLength, !document || !document->GetBidiEnabled());
 
     delete [] to;
-
-    NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
   }
 
   UnsetFlags(NS_CACHED_TEXT_IS_ONLY_WHITESPACE);
 
   if (document && mText.IsBidi()) {
     // If we found bidi characters in mText.SetTo() above, indicate that the
     // document contains bidi characters.
     document->SetBidiEnabled();
--- a/content/base/src/nsTextFragment.cpp
+++ b/content/base/src/nsTextFragment.cpp
@@ -79,17 +79,17 @@ nsTextFragment::~nsTextFragment()
   ReleaseText();
   MOZ_COUNT_DTOR(nsTextFragment);
 }
 
 void
 nsTextFragment::ReleaseText()
 {
   if (mState.mLength && m1b && mState.mInHeap) {
-    moz_free(m2b); // m1b == m2b as far as moz_free is concerned
+    nsMemory::Free(m2b); // m1b == m2b as far as nsMemory is concerned
   }
 
   m1b = nullptr;
   mState.mIsBidi = false;
 
   // Set mState.mIs2b, mState.mInHeap, and mState.mLength = 0 with mAllBits;
   mAllBits = 0;
 }
@@ -99,30 +99,19 @@ nsTextFragment::operator=(const nsTextFr
 {
   ReleaseText();
 
   if (aOther.mState.mLength) {
     if (!aOther.mState.mInHeap) {
       m1b = aOther.m1b; // This will work even if aOther is using m2b
     }
     else {
-      size_t m2bSize = aOther.mState.mLength *
-        (aOther.mState.mIs2b ? sizeof(PRUnichar) : sizeof(char));
-
-      m2b = static_cast<PRUnichar*>(moz_malloc(m2bSize));
-      if (m2b) {
-        memcpy(m2b, aOther.m2b, m2bSize);
-      } else {
-        // allocate a buffer for a single REPLACEMENT CHARACTER
-        m2b = static_cast<PRUnichar*>(moz_xmalloc(sizeof(PRUnichar)));
-        m2b[0] = 0xFFFD; // REPLACEMENT CHARACTER
-        mState.mIs2b = true;
-        mState.mInHeap = true;
-        mState.mLength = 1;
-      }
+      m2b = static_cast<PRUnichar*>
+                       (nsMemory::Clone(aOther.m2b, aOther.mState.mLength *
+                                    (aOther.mState.mIs2b ? sizeof(PRUnichar) : sizeof(char))));
     }
 
     if (m1b) {
       mAllBits = aOther.mAllBits;
     }
   }
 
   return *this;
@@ -185,33 +174,33 @@ FirstNon8Bit(const PRUnichar *str, const
   if (mozilla::supports_sse2()) {
     return mozilla::SSE2::FirstNon8Bit(str, end);
   }
 #endif
 
   return FirstNon8BitUnvectorized(str, end);
 }
 
-bool
+void
 nsTextFragment::SetTo(const PRUnichar* aBuffer, int32_t aLength, bool aUpdateBidi)
 {
   ReleaseText();
 
   if (aLength == 0) {
-    return true;
+    return;
   }
   
   PRUnichar firstChar = *aBuffer;
   if (aLength == 1 && firstChar < 256) {
     m1b = sSingleCharSharedString + firstChar;
     mState.mInHeap = false;
     mState.mIs2b = false;
     mState.mLength = 1;
 
-    return true;
+    return;
   }
 
   const PRUnichar *ucp = aBuffer;
   const PRUnichar *uend = aBuffer + aLength;
 
   // Check if we can use a shared string
   if (aLength <= 1 + TEXTFRAG_WHITE_AFTER_NEWLINE + TEXTFRAG_MAX_NEWLINES &&
      (firstChar == ' ' || firstChar == '\n' || firstChar == '\t')) {
@@ -240,56 +229,53 @@ nsTextFragment::SetTo(const PRUnichar* a
       if (firstChar != ' ') {
         ++m1b;
       }
 
       mState.mInHeap = false;
       mState.mIs2b = false;
       mState.mLength = aLength;
 
-      return true;        
+      return;        
     }
   }
 
   // See if we need to store the data in ucs2 or not
   int32_t first16bit = FirstNon8Bit(ucp, uend);
 
   if (first16bit != -1) { // aBuffer contains no non-8bit character
     // Use ucs2 storage because we have to
-    size_t m2bSize = aLength * sizeof(PRUnichar);
-    m2b = (PRUnichar *)moz_malloc(m2bSize);
+    m2b = (PRUnichar *)nsMemory::Clone(aBuffer,
+                                       aLength * sizeof(PRUnichar));
     if (!m2b) {
-      return false;
+      return;
     }
-    memcpy(m2b, aBuffer, m2bSize);
 
     mState.mIs2b = true;
     if (aUpdateBidi) {
       UpdateBidiFlag(aBuffer + first16bit, aLength - first16bit);
     }
 
   } else {
     // Use 1 byte storage because we can
-    char* buff = (char *)moz_malloc(aLength * sizeof(char));
+    char* buff = (char *)nsMemory::Alloc(aLength * sizeof(char));
     if (!buff) {
-      return false;
+      return;
     }
 
     // Copy data
     LossyConvertEncoding16to8 converter(buff);
     copy_string(aBuffer, aBuffer+aLength, converter);
     m1b = buff;
     mState.mIs2b = false;
   }
 
   // Setup our fields
   mState.mInHeap = true;
   mState.mLength = aLength;
-
-  return true;
 }
 
 void
 nsTextFragment::CopyTo(PRUnichar *aDest, int32_t aOffset, int32_t aCount)
 {
   NS_ASSERTION(aOffset >= 0, "Bad offset passed to nsTextFragment::CopyTo()!");
   NS_ASSERTION(aCount >= 0, "Bad count passed to nsTextFragment::CopyTo()!");
 
@@ -308,106 +294,107 @@ nsTextFragment::CopyTo(PRUnichar *aDest,
       const char *cp = m1b + aOffset;
       const char *end = cp + aCount;
       LossyConvertEncoding8to16 converter(aDest);
       copy_string(cp, end, converter);
     }
   }
 }
 
-bool
+void
 nsTextFragment::Append(const PRUnichar* aBuffer, uint32_t aLength, bool aUpdateBidi)
 {
   // This is a common case because some callsites create a textnode
   // with a value by creating the node and then calling AppendData.
   if (mState.mLength == 0) {
-    return SetTo(aBuffer, aLength, aUpdateBidi);
+    SetTo(aBuffer, aLength, aUpdateBidi);
+
+    return;
   }
 
   // Should we optimize for aData.Length() == 0?
 
   if (mState.mIs2b) {
     // Already a 2-byte string so the result will be too
-    PRUnichar* buff = (PRUnichar*)moz_realloc(m2b, (mState.mLength + aLength) * sizeof(PRUnichar));
+    PRUnichar* buff = (PRUnichar*)nsMemory::Realloc(m2b, (mState.mLength + aLength) * sizeof(PRUnichar));
     if (!buff) {
-      return false;
+      return;
     }
 
     memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(PRUnichar));
     mState.mLength += aLength;
     m2b = buff;
 
     if (aUpdateBidi) {
       UpdateBidiFlag(aBuffer, aLength);
     }
 
-    return true;
+    return;
   }
 
   // Current string is a 1-byte string, check if the new data fits in one byte too.
   int32_t first16bit = FirstNon8Bit(aBuffer, aBuffer + aLength);
 
   if (first16bit != -1) { // aBuffer contains no non-8bit character
     // The old data was 1-byte, but the new is not so we have to expand it
     // all to 2-byte
-    PRUnichar* buff = (PRUnichar*)moz_malloc((mState.mLength + aLength) *
+    PRUnichar* buff = (PRUnichar*)nsMemory::Alloc((mState.mLength + aLength) *
                                                   sizeof(PRUnichar));
     if (!buff) {
-      return false;
+      return;
     }
 
     // Copy data into buff
     LossyConvertEncoding8to16 converter(buff);
     copy_string(m1b, m1b+mState.mLength, converter);
 
     memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(PRUnichar));
     mState.mLength += aLength;
     mState.mIs2b = true;
 
     if (mState.mInHeap) {
-      moz_free(m2b);
+      nsMemory::Free(m2b);
     }
     m2b = buff;
 
     mState.mInHeap = true;
 
     if (aUpdateBidi) {
       UpdateBidiFlag(aBuffer + first16bit, aLength - first16bit);
     }
 
-    return true;
+    return;
   }
 
   // The new and the old data is all 1-byte
   char* buff;
   if (mState.mInHeap) {
-    buff = (char*)moz_realloc(const_cast<char*>(m1b),
+    buff = (char*)nsMemory::Realloc(const_cast<char*>(m1b),
                                     (mState.mLength + aLength) * sizeof(char));
     if (!buff) {
-      return false;
+      return;
     }
   }
   else {
-    buff = (char*)moz_malloc((mState.mLength + aLength) * sizeof(char));
+    buff = (char*)nsMemory::Alloc((mState.mLength + aLength) * sizeof(char));
     if (!buff) {
-      return false;
+      return;
     }
 
     memcpy(buff, m1b, mState.mLength);
     mState.mInHeap = true;
   }
 
   // Copy aBuffer into buff.
   LossyConvertEncoding16to8 converter(buff + mState.mLength);
   copy_string(aBuffer, aBuffer + aLength, converter);
 
   m1b = buff;
   mState.mLength += aLength;
 
-  return true;
 }
 
 /* virtual */ size_t
 nsTextFragment::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
 {
   if (Is2b()) {
     return aMallocSizeOf(m2b);
   }
--- a/content/base/src/nsTextFragment.h
+++ b/content/base/src/nsTextFragment.h
@@ -48,17 +48,17 @@ public:
     MOZ_COUNT_CTOR(nsTextFragment);
     NS_ASSERTION(sizeof(FragmentBits) == 4, "Bad field packing!");
   }
 
   ~nsTextFragment();
 
   /**
    * Change the contents of this fragment to be a copy of the
-   * the argument fragment, or to "" if unable to allocate enough memory.
+   * the argument fragment.
    */
   nsTextFragment& operator=(const nsTextFragment& aOther);
 
   /**
    * Return true if this fragment is represented by PRUnichar data
    */
   bool Is2b() const
   {
@@ -107,24 +107,24 @@ public:
     return n < (1 << 29) && mState.mLength + n < (1 << 29);
   }
 
   /**
    * Change the contents of this fragment to be a copy of the given
    * buffer. If aUpdateBidi is true, contents of the fragment will be scanned,
    * and mState.mIsBidi will be turned on if it includes any Bidi characters.
    */
-  bool SetTo(const PRUnichar* aBuffer, int32_t aLength, bool aUpdateBidi);
+  void SetTo(const PRUnichar* aBuffer, int32_t aLength, bool aUpdateBidi);
 
   /**
    * Append aData to the end of this fragment. If aUpdateBidi is true, contents
    * of the fragment will be scanned, and mState.mIsBidi will be turned on if
    * it includes any Bidi characters.
    */
-  bool Append(const PRUnichar* aBuffer, uint32_t aLength, bool aUpdateBidi);
+  void Append(const PRUnichar* aBuffer, uint32_t aLength, bool aUpdateBidi);
 
   /**
    * Append the contents of this string fragment to aString
    */
   void AppendTo(nsAString& aString) const {
     if (mState.mIs2b) {
       aString.Append(m2b, mState.mLength);
     } else {
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -515,21 +515,17 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
     const nsHtml5TreeOperation* last = first + numberOfOpsToFlush - 1;
     for (nsHtml5TreeOperation* iter = const_cast<nsHtml5TreeOperation*>(first);;) {
       if (MOZ_UNLIKELY(!mParser)) {
         // The previous tree op caused a call to nsIParser::Terminate().
         break;
       }
       NS_ASSERTION(mFlushState == eInDocUpdate, 
         "Tried to perform tree op outside update batch.");
-      nsresult rv = iter->Perform(this, &scriptElement);
-      if (NS_FAILED(rv)) {
-        MarkAsBroken(rv);
-        break;
-      }
+      iter->Perform(this, &scriptElement);
 
       // Be sure not to check the deadline if the last op was just performed.
       if (MOZ_UNLIKELY(iter == last)) {
         break;
       } else if (MOZ_UNLIKELY(nsContentSink::DidProcessATokenImpl() == 
                  NS_ERROR_HTMLPARSER_INTERRUPTED)) {
         mOpQueue.RemoveElementsAt(0, (iter - first) + 1);
         
@@ -621,21 +617,17 @@ nsHtml5TreeOpExecutor::FlushDocumentWrit
        iter < end;
        ++iter) {
     if (MOZ_UNLIKELY(!mParser)) {
       // The previous tree op caused a call to nsIParser::Terminate().
       break;
     }
     NS_ASSERTION(mFlushState == eInDocUpdate, 
       "Tried to perform tree op outside update batch.");
-    nsresult rv = iter->Perform(this, &scriptElement);
-    if (NS_FAILED(rv)) {
-      MarkAsBroken(rv);
-      break;
-    }
+    iter->Perform(this, &scriptElement);
   }
 
   mOpQueue.Clear();
   
   EndDocUpdate();
 
   mFlushState = eNotFlushing;