Backed out changeset 6031f4ce0f9c (bug 1141865)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 03 Jun 2015 12:42:16 +0200
changeset 246984 a837cfd8ee1e05edfcd186e1fe3a14f1c25d0bd8
parent 246983 8b7268073cd82c258a45f5fb98aaec0bc055a20c
child 246985 28087e3f22f8740104eb345379ae2980381d5bd7
push id28848
push userryanvm@gmail.com
push dateWed, 03 Jun 2015 20:00:13 +0000
treeherdermozilla-central@0920f2325a6d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1141865
milestone41.0a1
backs out6031f4ce0f9cf2896abf1e51155b99f9d8bf3142
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
Backed out changeset 6031f4ce0f9c (bug 1141865)
js/src/builtin/Eval.cpp
js/src/builtin/Eval.h
js/src/jit/CodeGenerator.cpp
js/src/jit/CodeGenerator.h
js/src/jit/LIR-Common.h
js/src/jit/LOpcodes.h
js/src/jit/Lowering.cpp
js/src/jit/MIR.h
js/src/jit/TypePolicy.cpp
--- a/js/src/builtin/Eval.cpp
+++ b/js/src/builtin/Eval.cpp
@@ -461,16 +461,32 @@ js::DirectEvalStringFromIon(JSContext* c
         nthisValue = ObjectValue(*obj);
     }
 
     return ExecuteKernel(cx, esg.script(), *scopeobj, nthisValue, ExecuteType(DIRECT_EVAL),
                          NullFramePtr() /* evalInFrame */, vp.address());
 }
 
 bool
+js::DirectEvalValueFromIon(JSContext* cx,
+                           HandleObject scopeobj, HandleScript callerScript,
+                           HandleValue thisValue, HandleValue evalArg,
+                           jsbytecode* pc, MutableHandleValue vp)
+{
+    // Act as identity on non-strings per ES5 15.1.2.1 step 1.
+    if (!evalArg.isString()) {
+        vp.set(evalArg);
+        return true;
+    }
+
+    RootedString string(cx, evalArg.toString());
+    return DirectEvalStringFromIon(cx, scopeobj, callerScript, thisValue, string, pc, vp);
+}
+
+bool
 js::IndirectEval(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     Rooted<GlobalObject*> global(cx, &args.callee().global());
     return EvalKernel(cx, args, INDIRECT_EVAL, NullFramePtr(), global, nullptr);
 }
 
 bool
--- a/js/src/builtin/Eval.h
+++ b/js/src/builtin/Eval.h
@@ -27,15 +27,20 @@ extern bool
 DirectEval(JSContext* cx, const CallArgs& args);
 
 // Performs a direct eval called from Ion code.
 extern bool
 DirectEvalStringFromIon(JSContext* cx,
                         HandleObject scopeObj, HandleScript callerScript,
                         HandleValue thisValue, HandleString str,
                         jsbytecode * pc, MutableHandleValue vp);
+extern bool
+DirectEvalValueFromIon(JSContext* cx,
+                       HandleObject scopeObj, HandleScript callerScript,
+                       HandleValue thisValue, HandleValue evalArg,
+                       jsbytecode * pc, MutableHandleValue vp);
 
 // True iff fun is a built-in eval function.
 extern bool
 IsAnyBuiltinEval(JSFunction* fun);
 
 }  // namespace js
 #endif /* builtin_Eval_h */
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -3485,30 +3485,48 @@ CodeGenerator::visitFilterArgumentsOrEva
     masm.bind(&done);
 }
 
 typedef bool (*DirectEvalSFn)(JSContext*, HandleObject, HandleScript, HandleValue, HandleString,
                               jsbytecode*, MutableHandleValue);
 static const VMFunction DirectEvalStringInfo = FunctionInfo<DirectEvalSFn>(DirectEvalStringFromIon);
 
 void
-CodeGenerator::visitCallDirectEval(LCallDirectEval* lir)
+CodeGenerator::visitCallDirectEvalS(LCallDirectEvalS* lir)
 {
     Register scopeChain = ToRegister(lir->getScopeChain());
     Register string = ToRegister(lir->getString());
 
     pushArg(ImmPtr(lir->mir()->pc()));
     pushArg(string);
-    pushArg(ToValue(lir, LCallDirectEval::ThisValue));
+    pushArg(ToValue(lir, LCallDirectEvalS::ThisValue));
     pushArg(ImmGCPtr(gen->info().script()));
     pushArg(scopeChain);
 
     callVM(DirectEvalStringInfo, lir);
 }
 
+typedef bool (*DirectEvalVFn)(JSContext*, HandleObject, HandleScript, HandleValue, HandleValue,
+                              jsbytecode*, MutableHandleValue);
+static const VMFunction DirectEvalValueInfo = FunctionInfo<DirectEvalVFn>(DirectEvalValueFromIon);
+
+void
+CodeGenerator::visitCallDirectEvalV(LCallDirectEvalV* lir)
+{
+    Register scopeChain = ToRegister(lir->getScopeChain());
+
+    pushArg(ImmPtr(lir->mir()->pc()));
+    pushArg(ToValue(lir, LCallDirectEvalV::Argument));
+    pushArg(ToValue(lir, LCallDirectEvalV::ThisValue));
+    pushArg(ImmGCPtr(gen->info().script()));
+    pushArg(scopeChain);
+
+    callVM(DirectEvalValueInfo, lir);
+}
+
 void
 CodeGenerator::generateArgumentsChecks(bool bailout)
 {
     // Registers safe for use before generatePrologue().
     static const uint32_t EntryTempMask = Registers::TempMask & ~(1 << OsrFrameReg.code());
 
     // This function can be used the normal way to check the argument types,
     // before entering the function and bailout when arguments don't match.
--- a/js/src/jit/CodeGenerator.h
+++ b/js/src/jit/CodeGenerator.h
@@ -143,17 +143,18 @@ class CodeGenerator : public CodeGenerat
     void emitPopArguments(LApplyArgsGeneric* apply, Register extraStackSize);
     void visitApplyArgsGeneric(LApplyArgsGeneric* apply);
     void visitBail(LBail* lir);
     void visitUnreachable(LUnreachable* unreachable);
     void visitEncodeSnapshot(LEncodeSnapshot* lir);
     void visitGetDynamicName(LGetDynamicName* lir);
     void visitFilterArgumentsOrEvalS(LFilterArgumentsOrEvalS* lir);
     void visitFilterArgumentsOrEvalV(LFilterArgumentsOrEvalV* lir);
-    void visitCallDirectEval(LCallDirectEval* lir);
+    void visitCallDirectEvalS(LCallDirectEvalS* lir);
+    void visitCallDirectEvalV(LCallDirectEvalV* lir);
     void visitDoubleToInt32(LDoubleToInt32* lir);
     void visitFloat32ToInt32(LFloat32ToInt32* lir);
     void visitNewArrayCallVM(LNewArray* lir);
     void visitNewArray(LNewArray* lir);
     void visitOutOfLineNewArray(OutOfLineNewArray* ool);
     void visitNewArrayCopyOnWrite(LNewArrayCopyOnWrite* lir);
     void visitNewArrayDynamicLength(LNewArrayDynamicLength* lir);
     void visitNewObjectVMCall(LNewObject* lir);
--- a/js/src/jit/LIR-Common.h
+++ b/js/src/jit/LIR-Common.h
@@ -1922,22 +1922,22 @@ class LFilterArgumentsOrEvalV : public L
     const LDefinition* temp2() {
         return getTemp(1);
     }
     const LDefinition* temp3() {
         return getTemp(2);
     }
 };
 
-class LCallDirectEval : public LCallInstructionHelper<BOX_PIECES, 2 + BOX_PIECES, 0>
-{
-  public:
-    LIR_HEADER(CallDirectEval)
-
-    LCallDirectEval(const LAllocation& scopeChain, const LAllocation& string)
+class LCallDirectEvalS : public LCallInstructionHelper<BOX_PIECES, 2 + BOX_PIECES, 0>
+{
+  public:
+    LIR_HEADER(CallDirectEvalS)
+
+    LCallDirectEvalS(const LAllocation& scopeChain, const LAllocation& string)
     {
         setOperand(0, scopeChain);
         setOperand(1, string);
     }
 
     static const size_t ThisValue = 2;
 
     MCallDirectEval* mir() const {
@@ -1947,16 +1947,38 @@ class LCallDirectEval : public LCallInst
     const LAllocation* getScopeChain() {
         return getOperand(0);
     }
     const LAllocation* getString() {
         return getOperand(1);
     }
 };
 
+class LCallDirectEvalV : public LCallInstructionHelper<BOX_PIECES, 1 + (2 * BOX_PIECES), 0>
+{
+  public:
+    LIR_HEADER(CallDirectEvalV)
+
+    explicit LCallDirectEvalV(const LAllocation& scopeChain)
+    {
+        setOperand(0, scopeChain);
+    }
+
+    static const size_t Argument = 1;
+    static const size_t ThisValue = 1 + BOX_PIECES;
+
+    MCallDirectEval* mir() const {
+        return mir_->toCallDirectEval();
+    }
+
+    const LAllocation* getScopeChain() {
+        return getOperand(0);
+    }
+};
+
 // Takes in either an integer or boolean input and tests it for truthiness.
 class LTestIAndBranch : public LControlInstructionHelper<2, 1, 0>
 {
   public:
     LIR_HEADER(TestIAndBranch)
 
     LTestIAndBranch(const LAllocation& in, MBasicBlock* ifTrue, MBasicBlock* ifFalse)
     {
--- a/js/src/jit/LOpcodes.h
+++ b/js/src/jit/LOpcodes.h
@@ -71,17 +71,18 @@
     _(CallNative)                   \
     _(ApplyArgsGeneric)             \
     _(Bail)                         \
     _(Unreachable)                  \
     _(EncodeSnapshot)               \
     _(GetDynamicName)               \
     _(FilterArgumentsOrEvalS)       \
     _(FilterArgumentsOrEvalV)       \
-    _(CallDirectEval)               \
+    _(CallDirectEvalS)              \
+    _(CallDirectEvalV)              \
     _(StackArgT)                    \
     _(StackArgV)                    \
     _(CreateThis)                   \
     _(CreateThisWithProto)          \
     _(CreateThisWithTemplate)       \
     _(CreateArgumentsObject)        \
     _(GetArgumentsObjectArg)        \
     _(SetArgumentsObjectArg)        \
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -601,23 +601,34 @@ LIRGenerator::visitFilterArgumentsOrEval
 
 void
 LIRGenerator::visitCallDirectEval(MCallDirectEval* ins)
 {
     MDefinition* scopeChain = ins->getScopeChain();
     MOZ_ASSERT(scopeChain->type() == MIRType_Object);
 
     MDefinition* string = ins->getString();
-    MOZ_ASSERT(string->type() == MIRType_String);
+    MOZ_ASSERT(string->type() == MIRType_String || string->type() == MIRType_Value);
 
     MDefinition* thisValue = ins->getThisValue();
 
-    LInstruction* lir = new(alloc()) LCallDirectEval(useRegisterAtStart(scopeChain),
-                                                     useRegisterAtStart(string));
-    useBoxAtStart(lir, LCallDirectEval::ThisValue, thisValue);
+
+    LInstruction* lir;
+    if (string->type() == MIRType_String) {
+        lir = new(alloc()) LCallDirectEvalS(useRegisterAtStart(scopeChain),
+                                            useRegisterAtStart(string));
+    } else {
+        lir = new(alloc()) LCallDirectEvalV(useRegisterAtStart(scopeChain));
+        useBoxAtStart(lir, LCallDirectEvalV::Argument, string);
+    }
+
+    if (string->type() == MIRType_String)
+        useBoxAtStart(lir, LCallDirectEvalS::ThisValue, thisValue);
+    else
+        useBoxAtStart(lir, LCallDirectEvalV::ThisValue, thisValue);
 
     defineReturn(lir, ins);
     assignSafepoint(lir, ins);
 }
 
 static JSOp
 ReorderComparison(JSOp op, MDefinition** lhsp, MDefinition** rhsp)
 {
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -4066,17 +4066,17 @@ class MFilterArgumentsOrEval
     bool possiblyCalls() const override {
         return true;
     }
 };
 
 class MCallDirectEval
   : public MAryInstruction<3>,
     public Mix3Policy<ObjectPolicy<0>,
-                      StringPolicy<1>,
+                      BoxExceptPolicy<1, MIRType_String>,
                       BoxPolicy<2> >::Data
 {
   protected:
     MCallDirectEval(MDefinition* scopeChain, MDefinition* string, MDefinition* thisValue,
                     jsbytecode* pc)
         : pc_(pc)
     {
         initOperand(0, scopeChain);
--- a/js/src/jit/TypePolicy.cpp
+++ b/js/src/jit/TypePolicy.cpp
@@ -1138,17 +1138,17 @@ FilterTypeSetPolicy::adjustInputs(TempAl
     _(BoxPolicy<0>)                                                     \
     _(ConvertToInt32Policy<0>)                                          \
     _(ConvertToStringPolicy<0>)                                         \
     _(ConvertToStringPolicy<2>)                                         \
     _(DoublePolicy<0>)                                                  \
     _(FloatingPointPolicy<0>)                                           \
     _(IntPolicy<0>)                                                     \
     _(IntPolicy<1>)                                                     \
-    _(Mix3Policy<ObjectPolicy<0>, StringPolicy<1>, BoxPolicy<2> >) \
+    _(Mix3Policy<ObjectPolicy<0>, BoxExceptPolicy<1, MIRType_String>, BoxPolicy<2> >) \
     _(Mix3Policy<ObjectPolicy<0>, BoxPolicy<1>, BoxPolicy<2> >)         \
     _(Mix3Policy<ObjectPolicy<0>, BoxPolicy<1>, ObjectPolicy<2> >)      \
     _(Mix3Policy<ObjectPolicy<0>, IntPolicy<1>, BoxPolicy<2> >)         \
     _(Mix3Policy<ObjectPolicy<0>, IntPolicy<1>, IntPolicy<2> >)         \
     _(Mix3Policy<ObjectPolicy<0>, ObjectPolicy<1>, IntPolicy<2> >)      \
     _(Mix3Policy<StringPolicy<0>, IntPolicy<1>, IntPolicy<2>>)          \
     _(Mix3Policy<StringPolicy<0>, ObjectPolicy<1>, StringPolicy<2> >)   \
     _(Mix3Policy<StringPolicy<0>, StringPolicy<1>, StringPolicy<2> >)   \