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:23:59 -0400
changeset 267228 5086a9614080d5acd7861a5413713202583cbf9b
parent 267227 a9933a4e10148b727ba51f64841461e630a4b568
child 267229 76ef277068e7c69cec7898bf5cb0e1edf6b77da6
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, abillings
bugs1149119
milestone39.0a2
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
@@ -9566,16 +9566,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
@@ -1537,24 +1537,21 @@ IonBuilder::inlineConstantStringSplit(Ca
 
     if (!key.maybeTypes()->hasType(TypeSet::StringType()))
         return InliningStatus_NotInlined;
 
     uint32_t initLength = templateObject->as<ArrayObject>().length();
     if (templateObject->getDenseInitializedLength() != initLength)
         return InliningStatus_NotInlined;
 
-    JSContext* cx = GetJitContext()->cx;
     Vector<MConstant*, 0, SystemAllocPolicy> arrayValues;
     for (uint32_t i = 0; i < initLength; i++) {
-        JSAtom* str = js::AtomizeString(cx, templateObject->getDenseElement(i).toString());
-        if (!str)
-            return InliningStatus_Error;
-
-        MConstant* value = MConstant::New(alloc(), StringValue(str), 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();