Bug 1385278 - Move StoreDenseElement to CacheIR from Ion. r=jandem
authorTom Schuster <evilpies@gmail.com>
Wed, 30 Aug 2017 00:46:47 +0200
changeset 377663 35a1fe8f201b8d8a18d1af4929c8bf0de0acee1f
parent 377662 b823779242ed24d12daa86e1de3c0052d0a285ce
child 377664 2f39c03124665364d7465c7b9873a6e5c3c1f2b9
push id32413
push userarchaeopteryx@coole-files.de
push dateWed, 30 Aug 2017 09:05:33 +0000
treeherdermozilla-central@ab2d700fda2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1385278
milestone57.0a1
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
Bug 1385278 - Move StoreDenseElement to CacheIR from Ion. r=jandem
js/src/jit/IonCacheIRCompiler.cpp
js/src/jit/IonCaches.cpp
js/src/jit/IonCaches.h
--- a/js/src/jit/IonCacheIRCompiler.cpp
+++ b/js/src/jit/IonCacheIRCompiler.cpp
@@ -1664,16 +1664,70 @@ IonCacheIRCompiler::emitStoreTypedObject
     // Compute the address being written to.
     LoadTypedThingData(masm, layout, obj, scratch1);
     Address dest(scratch1, offset);
 
     StoreToTypedArray(cx_, masm, type, val, dest, scratch2, failure->label());
     return true;
 }
 
+static void
+EmitStoreDenseElement(MacroAssembler& masm, const ConstantOrRegister& value,
+                      Register elements, BaseObjectElementIndex target)
+{
+    // If the ObjectElements::CONVERT_DOUBLE_ELEMENTS flag is set, int32 values
+    // have to be converted to double first. If the value is not int32, it can
+    // always be stored directly.
+
+    Address elementsFlags(elements, ObjectElements::offsetOfFlags());
+    if (value.constant()) {
+        Value v = value.value();
+        Label done;
+        if (v.isInt32()) {
+            Label dontConvert;
+            masm.branchTest32(Assembler::Zero, elementsFlags,
+                              Imm32(ObjectElements::CONVERT_DOUBLE_ELEMENTS),
+                              &dontConvert);
+            masm.storeValue(DoubleValue(v.toInt32()), target);
+            masm.jump(&done);
+            masm.bind(&dontConvert);
+        }
+        masm.storeValue(v, target);
+        masm.bind(&done);
+        return;
+    }
+
+    TypedOrValueRegister reg = value.reg();
+    if (reg.hasTyped() && reg.type() != MIRType::Int32) {
+        masm.storeTypedOrValue(reg, target);
+        return;
+    }
+
+    Label convert, storeValue, done;
+    masm.branchTest32(Assembler::NonZero, elementsFlags,
+                      Imm32(ObjectElements::CONVERT_DOUBLE_ELEMENTS),
+                      &convert);
+    masm.bind(&storeValue);
+    masm.storeTypedOrValue(reg, target);
+    masm.jump(&done);
+
+    masm.bind(&convert);
+    if (reg.hasValue()) {
+        masm.branchTestInt32(Assembler::NotEqual, reg.valueReg(), &storeValue);
+        masm.int32ValueToDouble(reg.valueReg(), ScratchDoubleReg);
+        masm.storeDouble(ScratchDoubleReg, target);
+    } else {
+        MOZ_ASSERT(reg.type() == MIRType::Int32);
+        masm.convertInt32ToDouble(reg.typedReg().gpr(), ScratchDoubleReg);
+        masm.storeDouble(ScratchDoubleReg, target);
+    }
+
+    masm.bind(&done);
+}
+
 bool
 IonCacheIRCompiler::emitStoreDenseElement()
 {
     Register obj = allocator.useRegister(masm, reader.objOperandId());
     Register index = allocator.useRegister(masm, reader.int32OperandId());
     ConstantOrRegister val = allocator.useConstantOrRegister(masm, reader.valOperandId());
 
     AutoScratchRegister scratch(allocator, masm);
@@ -1691,17 +1745,17 @@ IonCacheIRCompiler::emitStoreDenseElemen
     Address initLength(scratch, ObjectElements::offsetOfInitializedLength());
     masm.branch32(Assembler::BelowOrEqual, initLength, index, failure->label());
 
     // Hole check.
     BaseObjectElementIndex element(scratch, index);
     masm.branchTestMagic(Assembler::Equal, element, failure->label());
 
     EmitPreBarrier(masm, element, MIRType::Value);
-    EmitIonStoreDenseElement(masm, val, scratch, element);
+    EmitStoreDenseElement(masm, val, scratch, element);
     if (needsPostBarrier())
         emitPostBarrierElement(obj, val, scratch, index);
     return true;
 }
 
 bool
 IonCacheIRCompiler::emitStoreDenseElementHole()
 {
@@ -1777,17 +1831,17 @@ IonCacheIRCompiler::emitStoreDenseElemen
     // Skip EmitPreBarrier as the memory is uninitialized.
     masm.jump(&doStore);
 
     masm.bind(&inBounds);
 
     EmitPreBarrier(masm, element, MIRType::Value);
 
     masm.bind(&doStore);
-    EmitIonStoreDenseElement(masm, val, scratch, element);
+    EmitStoreDenseElement(masm, val, scratch, element);
     if (needsPostBarrier())
         emitPostBarrierElement(obj, val, scratch, index);
     return true;
 }
 
 bool
 IonCacheIRCompiler::emitArrayPush()
 {
--- a/js/src/jit/IonCaches.cpp
+++ b/js/src/jit/IonCaches.cpp
@@ -95,62 +95,8 @@ jit::GetReturnAddressToIonCode(JSContext
 
     void* returnAddr = frame.returnAddress();
 #ifdef DEBUG
     ++frame;
     MOZ_ASSERT(frame.isIonJS());
 #endif
     return returnAddr;
 }
-
-void
-jit::EmitIonStoreDenseElement(MacroAssembler& masm, const ConstantOrRegister& value,
-                              Register elements, BaseObjectElementIndex target)
-{
-    // If the ObjectElements::CONVERT_DOUBLE_ELEMENTS flag is set, int32 values
-    // have to be converted to double first. If the value is not int32, it can
-    // always be stored directly.
-
-    Address elementsFlags(elements, ObjectElements::offsetOfFlags());
-    if (value.constant()) {
-        Value v = value.value();
-        Label done;
-        if (v.isInt32()) {
-            Label dontConvert;
-            masm.branchTest32(Assembler::Zero, elementsFlags,
-                              Imm32(ObjectElements::CONVERT_DOUBLE_ELEMENTS),
-                              &dontConvert);
-            masm.storeValue(DoubleValue(v.toInt32()), target);
-            masm.jump(&done);
-            masm.bind(&dontConvert);
-        }
-        masm.storeValue(v, target);
-        masm.bind(&done);
-        return;
-    }
-
-    TypedOrValueRegister reg = value.reg();
-    if (reg.hasTyped() && reg.type() != MIRType::Int32) {
-        masm.storeTypedOrValue(reg, target);
-        return;
-    }
-
-    Label convert, storeValue, done;
-    masm.branchTest32(Assembler::NonZero, elementsFlags,
-                      Imm32(ObjectElements::CONVERT_DOUBLE_ELEMENTS),
-                      &convert);
-    masm.bind(&storeValue);
-    masm.storeTypedOrValue(reg, target);
-    masm.jump(&done);
-
-    masm.bind(&convert);
-    if (reg.hasValue()) {
-        masm.branchTestInt32(Assembler::NotEqual, reg.valueReg(), &storeValue);
-        masm.int32ValueToDouble(reg.valueReg(), ScratchDoubleReg);
-        masm.storeDouble(ScratchDoubleReg, target);
-    } else {
-        MOZ_ASSERT(reg.type() == MIRType::Int32);
-        masm.convertInt32ToDouble(reg.typedReg().gpr(), ScratchDoubleReg);
-        masm.storeDouble(ScratchDoubleReg, target);
-    }
-
-    masm.bind(&done);
-}
--- a/js/src/jit/IonCaches.h
+++ b/js/src/jit/IonCaches.h
@@ -23,15 +23,12 @@
 
 #include "vm/TypedArrayObject.h"
 
 namespace js {
 namespace jit {
 
 void* GetReturnAddressToIonCode(JSContext* cx);
 
-void EmitIonStoreDenseElement(MacroAssembler& masm, const ConstantOrRegister& value,
-                              Register elements, BaseObjectElementIndex target);
-
 } // namespace jit
 } // namespace js
 
 #endif /* jit_IonCaches_h */