Backout 51e4e9fcde24 (bug 1105895) for causing some Octane and Dromaeo regressions.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 08 Jan 2015 14:19:36 -0800
changeset 222841 7877a00d7025405b31b2f0df73e8a1067bda5923
parent 222840 06402d84ac3d38c86214129c533911a520165e58
child 222842 15f5148fe5892f1267f298ea6a09d8a6f64dc647
push id10731
push usercbook@mozilla.com
push dateFri, 09 Jan 2015 14:51:37 +0000
treeherderfx-team@e6756043d930 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1105895
milestone37.0a1
backs out51e4e9fcde248895ce6713cdb52cb7e2713f9425
Backout 51e4e9fcde24 (bug 1105895) for causing some Octane and Dromaeo regressions.
js/src/vm/String.cpp
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -480,44 +480,42 @@ js::ConcatStrings(ThreadSafeContext *cx,
     if (!JSString::validateLength(cx, wholeLength))
         return nullptr;
 
     bool isLatin1 = left->hasLatin1Chars() && right->hasLatin1Chars();
     bool canUseFatInline = isLatin1
                            ? JSFatInlineString::latin1LengthFits(wholeLength)
                            : JSFatInlineString::twoByteLengthFits(wholeLength);
     if (canUseFatInline && cx->isJSContext()) {
-        Latin1Char *latin1Buf;
-        char16_t *twoByteBuf;
-        JSInlineString *str = isLatin1
-            ? AllocateFatInlineString<allowGC>(cx, wholeLength, &latin1Buf)
-            : AllocateFatInlineString<allowGC>(cx, wholeLength, &twoByteBuf);
+        JSFatInlineString *str = NewGCFatInlineString<allowGC>(cx);
         if (!str)
             return nullptr;
 
         AutoCheckCannotGC nogc;
         ScopedThreadSafeStringInspector leftInspector(left);
         ScopedThreadSafeStringInspector rightInspector(right);
         if (!leftInspector.ensureChars(cx, nogc) || !rightInspector.ensureChars(cx, nogc))
             return nullptr;
 
         if (isLatin1) {
-            PodCopy(latin1Buf, leftInspector.latin1Chars(), leftLen);
-            PodCopy(latin1Buf + leftLen, rightInspector.latin1Chars(), rightLen);
-            latin1Buf[wholeLength] = 0;
+            Latin1Char *buf = str->initLatin1(wholeLength);
+            PodCopy(buf, leftInspector.latin1Chars(), leftLen);
+            PodCopy(buf + leftLen, rightInspector.latin1Chars(), rightLen);
+            buf[wholeLength] = 0;
         } else {
+            char16_t *buf = str->initTwoByte(wholeLength);
             if (leftInspector.hasTwoByteChars())
-                PodCopy(twoByteBuf, leftInspector.twoByteChars(), leftLen);
+                PodCopy(buf, leftInspector.twoByteChars(), leftLen);
             else
-                CopyAndInflateChars(twoByteBuf, leftInspector.latin1Chars(), leftLen);
+                CopyAndInflateChars(buf, leftInspector.latin1Chars(), leftLen);
             if (rightInspector.hasTwoByteChars())
-                PodCopy(twoByteBuf + leftLen, rightInspector.twoByteChars(), rightLen);
+                PodCopy(buf + leftLen, rightInspector.twoByteChars(), rightLen);
             else
-                CopyAndInflateChars(twoByteBuf + leftLen, rightInspector.latin1Chars(), rightLen);
-            twoByteBuf[wholeLength] = 0;
+                CopyAndInflateChars(buf + leftLen, rightInspector.latin1Chars(), rightLen);
+            buf[wholeLength] = 0;
         }
 
         return str;
     }
 
     return JSRope::new_<allowGC>(cx, left, right, wholeLength);
 }