Bug 1149119 - Use Atoms in the template object hold by Baseline. r=jandem, a=abillings
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Fri, 24 Apr 2015 16:25:41 -0400
changeset 260268 7298f6e3943e
parent 260267 38ff61772a2e
child 260269 0e69c76cbbe2
push id732
push userryanvm@gmail.com
push date2015-04-24 20:26 +0000
treeherdermozilla-release@0e69c76cbbe2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, abillings
bugs1149119
milestone38.0
Bug 1149119 - Use Atoms in the template object hold by Baseline. r=jandem, a=abillings
js/src/jit/BaselineIC.cpp
js/src/jit/MCallOptimize.cpp
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -9485,16 +9485,27 @@ TryAttachStringSplit(JSContext* cx, ICCa
     RootedString argString(cx, args[0].toString());
     RootedArrayObject obj(cx, &res.toObject().as<ArrayObject>());
     RootedValue arr(cx);
 
     // Copy the array before storing in stub.
     if (!CopyArray(cx, obj, &arr))
         return false;
 
+    // Atomize all elements of the array.
+    RootedArrayObject arrObj(cx, &arr.toObject().as<ArrayObject>());
+    uint32_t initLength = arrObj->length();
+    for (uint32_t i = 0; i < initLength; i++) {
+        JSAtom* str = js::AtomizeString(cx, arrObj->getDenseElement(i).toString());
+        if (!str)
+            return false;
+
+        arrObj->setDenseElement(i, StringValue(str));
+    }
+
     ICCall_StringSplit::Compiler compiler(cx, stub->fallbackMonitorStub()->firstMonitorStub(),
                                           script->pcToOffset(pc), thisString, argString,
                                           arr);
     ICStub* newStub = compiler.getStub(compiler.getStubSpace(script));
     if (!newStub)
         return false;
 
     stub->addNewStub(newStub);
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -1415,17 +1415,19 @@ IonBuilder::inlineConstantStringSplit(Ca
         return InliningStatus_NotInlined;
 
     uint32_t initLength = templateObject->as<ArrayObject>().length();
     if (templateObject->getDenseInitializedLength() != initLength)
         return InliningStatus_NotInlined;
 
     Vector<MConstant*, 0, SystemAllocPolicy> arrayValues;
     for (uint32_t i = 0; i < initLength; i++) {
-        MConstant* value = MConstant::New(alloc(), templateObject->getDenseElement(i), constraints());
+        Value str = templateObject->getDenseElement(i);
+        MOZ_ASSERT(str.toString()->isAtom());
+        MConstant* value = MConstant::New(alloc(), str, constraints());
         if (!TypeSetIncludes(key.maybeTypes(), value->type(), value->resultTypeSet()))
             return InliningStatus_NotInlined;
 
         if (!arrayValues.append(value))
             return InliningStatus_Error;
     }
     callInfo.setImplicitlyUsedUnchecked();