Bug 1341087 - Implement symbol equality comparison in SharedIC. r=h4writer
authorTom Schuster <evilpies@gmail.com>
Tue, 21 Feb 2017 14:24:10 +0100
changeset 343977 1de8a2485e15aed6455d399680dc18846b65e4e1
parent 343976 f0e0d480f660c02bdd40c3d26a635a51fe03de75
child 343978 bb77e8d293e031b08825e588fe4cea11ff094a2e
push id87237
push userevilpies@gmail.com
push dateTue, 21 Feb 2017 13:24:28 +0000
treeherdermozilla-inbound@1de8a2485e15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1341087
milestone54.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 1341087 - Implement symbol equality comparison in SharedIC. r=h4writer
js/src/jit/MacroAssembler.h
js/src/jit/SharedIC.cpp
js/src/jit/SharedIC.h
js/src/jit/SharedICList.h
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -1598,20 +1598,16 @@ class MacroAssembler : public MacroAssem
             mov(JSReturnReg, dest.valueReg());
 #else
 #error "Bad architecture"
 #endif
     }
 
     inline void storeCallResultValue(TypedOrValueRegister dest);
 
-    template <typename T>
-    Register extractString(const T& source, Register scratch) {
-        return extractObject(source, scratch);
-    }
     using MacroAssemblerSpecific::store32;
     void store32(const RegisterOrInt32Constant& key, const Address& dest) {
         if (key.isRegister())
             store32(key.reg(), dest);
         else
             store32(Imm32(key.constant()), dest);
     }
 
@@ -1693,21 +1689,24 @@ class MacroAssembler : public MacroAssem
     // in the property.
     template <typename T>
     void storeUnboxedProperty(T address, JSValueType type,
                               const ConstantOrRegister& value, Label* failure);
 
     void checkUnboxedArrayCapacity(Register obj, const RegisterOrInt32Constant& index,
                                    Register temp, Label* failure);
 
-    Register extractString(const Address& address, Register scratch) {
-        return extractObject(address, scratch);
+    template <typename T>
+    Register extractString(const T& source, Register scratch) {
+        return extractObject(source, scratch);
     }
-    Register extractString(const ValueOperand& value, Register scratch) {
-        return extractObject(value, scratch);
+
+    template <typename T>
+    Register extractSymbol(const T& source, Register scratch) {
+        return extractObject(source, scratch);
     }
 
     void debugAssertIsObject(const ValueOperand& val);
 
     using MacroAssemblerSpecific::extractTag;
     Register extractTag(const TypedOrValueRegister& reg, Register scratch) {
         if (reg.hasValue())
             return extractTag(reg.valueReg(), scratch);
--- a/js/src/jit/SharedIC.cpp
+++ b/js/src/jit/SharedIC.cpp
@@ -1529,16 +1529,27 @@ DoCompareFallback(JSContext* cx, void* p
             ICStub* stringStub = compiler.getStub(compiler.getStubSpace(info.outerScript(cx)));
             if (!stringStub)
                 return false;
 
             stub->addNewStub(stringStub);
             return true;
         }
 
+        if (lhs.isSymbol() && rhs.isSymbol() && !stub->hasStub(ICStub::Compare_Symbol)) {
+            JitSpew(JitSpew_BaselineIC, "  Generating %s(Symbol, Symbol) stub", CodeName[op]);
+            ICCompare_Symbol::Compiler compiler(cx, op, engine);
+            ICStub* symbolStub = compiler.getStub(compiler.getStubSpace(info.outerScript(cx)));
+            if (!symbolStub)
+                return false;
+
+            stub->addNewStub(symbolStub);
+            return true;
+        }
+
         if (lhs.isObject() && rhs.isObject()) {
             MOZ_ASSERT(!stub->hasStub(ICStub::Compare_Object));
             JitSpew(JitSpew_BaselineIC, "  Generating %s(Object, Object) stub", CodeName[op]);
             ICCompare_Object::Compiler compiler(cx, op, engine);
             ICStub* objectStub = compiler.getStub(compiler.getStubSpace(info.outerScript(cx)));
             if (!objectStub)
                 return false;
 
@@ -1620,16 +1631,48 @@ ICCompare_String::Compiler::generateStub
     EmitReturnFromIC(masm);
 
     masm.bind(&failure);
     EmitStubGuardFailure(masm);
     return true;
 }
 
 //
+// Compare_Symbol
+//
+
+bool
+ICCompare_Symbol::Compiler::generateStubCode(MacroAssembler& masm)
+{
+    Label failure;
+    masm.branchTestSymbol(Assembler::NotEqual, R0, &failure);
+    masm.branchTestSymbol(Assembler::NotEqual, R1, &failure);
+
+    MOZ_ASSERT(IsEqualityOp(op));
+
+    Register left = masm.extractSymbol(R0, ExtractTemp0);
+    Register right = masm.extractSymbol(R1, ExtractTemp1);
+
+    Label ifTrue;
+    masm.branchPtr(JSOpToCondition(op, /* signed = */true), left, right, &ifTrue);
+
+    masm.moveValue(BooleanValue(false), R0);
+    EmitReturnFromIC(masm);
+
+    masm.bind(&ifTrue);
+    masm.moveValue(BooleanValue(true), R0);
+    EmitReturnFromIC(masm);
+
+    // Failure case - jump to next stub
+    masm.bind(&failure);
+    EmitStubGuardFailure(masm);
+    return true;
+}
+
+//
 // Compare_Boolean
 //
 
 bool
 ICCompare_Boolean::Compiler::generateStubCode(MacroAssembler& masm)
 {
     Label failure;
     masm.branchTestBoolean(Assembler::NotEqual, R0, &failure);
--- a/js/src/jit/SharedIC.h
+++ b/js/src/jit/SharedIC.h
@@ -2118,16 +2118,40 @@ class ICCompare_String : public ICStub
         {}
 
         ICStub* getStub(ICStubSpace* space) {
             return newStub<ICCompare_String>(space, getStubCode());
         }
     };
 };
 
+class ICCompare_Symbol : public ICStub
+{
+    friend class ICStubSpace;
+
+    explicit ICCompare_Symbol(JitCode* stubCode)
+      : ICStub(ICStub::Compare_Symbol, stubCode)
+    {}
+
+  public:
+    class Compiler : public ICMultiStubCompiler {
+      protected:
+        MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+
+      public:
+        Compiler(JSContext* cx, JSOp op, Engine engine)
+          : ICMultiStubCompiler(cx, ICStub::Compare_Symbol, op, engine)
+        {}
+
+        ICStub* getStub(ICStubSpace* space) {
+            return newStub<ICCompare_Symbol>(space, getStubCode());
+        }
+    };
+};
+
 class ICCompare_Boolean : public ICStub
 {
     friend class ICStubSpace;
 
     explicit ICCompare_Boolean(JitCode* stubCode)
       : ICStub(ICStub::Compare_Boolean, stubCode)
     {}
 
--- a/js/src/jit/SharedICList.h
+++ b/js/src/jit/SharedICList.h
@@ -24,16 +24,17 @@ namespace jit {
     _(UnaryArith_Int32)                          \
     _(UnaryArith_Double)                         \
                                                  \
     _(Compare_Fallback)                          \
     _(Compare_Int32)                             \
     _(Compare_Double)                            \
     _(Compare_NumberWithUndefined)               \
     _(Compare_String)                            \
+    _(Compare_Symbol)                            \
     _(Compare_Boolean)                           \
     _(Compare_Object)                            \
     _(Compare_ObjectWithUndefined)               \
     _(Compare_Int32WithBoolean)                  \
                                                  \
     _(GetProp_Fallback)                          \
     _(GetProp_Generic)                           \
                                                  \