Bug 1119081 - Fix Ion string concat stub to create non-fat inline strings if possible. r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 09 Jan 2015 21:18:18 +0100
changeset 223114 75b65a499a576e54fd9175e5203d96887b08c1e7
parent 223113 a5f042eed356bf543b579f1985657bc14472585a
child 223115 9c5d2d742c546526989c455ebb7022b19dcfda46
push id10769
push usercbook@mozilla.com
push dateMon, 12 Jan 2015 14:15:52 +0000
treeherderfx-team@0e9765732906 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1119081
milestone37.0a1
Bug 1119081 - Fix Ion string concat stub to create non-fat inline strings if possible. r=bhackett
js/src/jit/CodeGenerator.cpp
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -5381,24 +5381,41 @@ ConcatFatInlineString(MacroAssembler &ma
                       Label *failure, Label *failurePopTemps, bool isTwoByte)
 {
     // State: result length in temp2.
 
     // Ensure both strings are linear.
     masm.branchIfRope(lhs, failure);
     masm.branchIfRope(rhs, failure);
 
-    // Allocate a JSFatInlineString.
-    masm.newGCFatInlineString(output, temp1, failure);
-
-    // Store length and flags.
-    uint32_t flags = JSString::INIT_FAT_INLINE_FLAGS;
-    if (!isTwoByte)
-        flags |= JSString::LATIN1_CHARS_BIT;
-    masm.store32(Imm32(flags), Address(output, JSString::offsetOfFlags()));
+    // Allocate a JSInlineString or JSFatInlineString.
+    size_t maxLengthInline = isTwoByte
+                             ? JSInlineString::MAX_LENGTH_TWO_BYTE
+                             : JSInlineString::MAX_LENGTH_LATIN1;
+    Label isFat, allocDone;
+    masm.branch32(Assembler::Above, temp2, Imm32(maxLengthInline), &isFat);
+    {
+        uint32_t flags = JSString::INIT_INLINE_FLAGS;
+        if (!isTwoByte)
+            flags |= JSString::LATIN1_CHARS_BIT;
+        masm.newGCString(output, temp1, failure);
+        masm.store32(Imm32(flags), Address(output, JSString::offsetOfFlags()));
+        masm.jump(&allocDone);
+    }
+    masm.bind(&isFat);
+    {
+        uint32_t flags = JSString::INIT_FAT_INLINE_FLAGS;
+        if (!isTwoByte)
+            flags |= JSString::LATIN1_CHARS_BIT;
+        masm.newGCFatInlineString(output, temp1, failure);
+        masm.store32(Imm32(flags), Address(output, JSString::offsetOfFlags()));
+    }
+    masm.bind(&allocDone);
+
+    // Store length.
     masm.store32(temp2, Address(output, JSString::offsetOfLength()));
 
     // Load chars pointer in temp2.
     masm.computeEffectiveAddress(Address(output, JSInlineString::offsetOfInlineStorage()), temp2);
 
     {
         // Copy lhs chars. Note that this advances temp2 to point to the next
         // char. This also clobbers the lhs register.