Loading js/src/jit/CodeGenerator.cpp +32 −78 Original line number Diff line number Diff line Loading @@ -9727,26 +9727,11 @@ void CodeGenerator::visitIsNullOrLikeUndefinedV(LIsNullOrLikeUndefinedV* lir) { Register output = ToRegister(lir->output()); if (op == JSOp::Eq || op == JSOp::Ne) { MOZ_ASSERT( lir->mir()->lhs()->type() != MIRType::Object || lir->mir()->operandMightEmulateUndefined(), "Operands which can't emulate undefined should have been folded"); OutOfLineTestObjectWithLabels* ool = nullptr; Maybe<Label> label1, label2; Label* nullOrLikeUndefined; Label* notNullOrLikeUndefined; if (lir->mir()->operandMightEmulateUndefined()) { ool = new (alloc()) OutOfLineTestObjectWithLabels(); auto* ool = new (alloc()) OutOfLineTestObjectWithLabels(); addOutOfLineCode(ool, lir->mir()); nullOrLikeUndefined = ool->label1(); notNullOrLikeUndefined = ool->label2(); } else { label1.emplace(); label2.emplace(); nullOrLikeUndefined = label1.ptr(); notNullOrLikeUndefined = label2.ptr(); } Label* nullOrLikeUndefined = ool->label1(); Label* notNullOrLikeUndefined = ool->label2(); { ScratchTagScope tag(masm, value); Loading @@ -9760,12 +9745,10 @@ void CodeGenerator::visitIsNullOrLikeUndefinedV(LIsNullOrLikeUndefinedV* lir) { masm.branchTestUndefined(Assembler::Equal, tag, nullOrLikeUndefined); } if (ool) { // Check whether it's a truthy object or a falsy object that emulates // undefined. masm.branchTestObject(Assembler::NotEqual, tag, notNullOrLikeUndefined); ScratchTagScopeRelease _(&tag); } Register objreg = masm.extractObject(value, ToTempUnboxRegister(lir->tempToUnbox())); Loading @@ -9773,8 +9756,6 @@ void CodeGenerator::visitIsNullOrLikeUndefinedV(LIsNullOrLikeUndefinedV* lir) { notNullOrLikeUndefined, ToRegister(lir->temp()), ool); // fall through } } Label done; Loading Loading @@ -9825,24 +9806,16 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV( op = JSOp::Eq; } MOZ_ASSERT( lir->cmpMir()->lhs()->type() != MIRType::Object || lir->cmpMir()->operandMightEmulateUndefined(), "Operands which can't emulate undefined should have been folded"); OutOfLineTestObject* ool = nullptr; if (lir->cmpMir()->operandMightEmulateUndefined()) { ool = new (alloc()) OutOfLineTestObject(); auto* ool = new (alloc()) OutOfLineTestObject(); addOutOfLineCode(ool, lir->cmpMir()); } Label* ifTrueLabel = getJumpLabelForBranch(ifTrue); Label* ifFalseLabel = getJumpLabelForBranch(ifFalse); { ScratchTagScope tag(masm, value); masm.splitTagForTest(value, tag); Label* ifTrueLabel = getJumpLabelForBranch(ifTrue); Label* ifFalseLabel = getJumpLabelForBranch(ifFalse); MDefinition* input = lir->cmpMir()->lhs(); if (input->mightBeType(MIRType::Null)) { masm.branchTestNull(Assembler::Equal, tag, ifTrueLabel); Loading @@ -9851,10 +9824,8 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV( masm.branchTestUndefined(Assembler::Equal, tag, ifTrueLabel); } if (ool) { masm.branchTestObject(Assembler::NotEqual, tag, ifFalseLabel); ScratchTagScopeRelease _(&tag); } // Objects that emulate undefined are loosely equal to null/undefined. Register objreg = Loading @@ -9862,12 +9833,8 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV( Register scratch = ToRegister(lir->temp()); testObjectEmulatesUndefined(objreg, ifTrueLabel, ifFalseLabel, scratch, ool); } else { masm.jump(ifFalseLabel); } return; } } MOZ_ASSERT(op == JSOp::StrictEq || op == JSOp::StrictNe); Loading @@ -9891,18 +9858,11 @@ void CodeGenerator::visitIsNullOrLikeUndefinedT(LIsNullOrLikeUndefinedT* lir) { lhsType == MIRType::ObjectOrNull || op == JSOp::Eq || op == JSOp::Ne, "Strict equality should have been folded"); MOZ_ASSERT(lhsType == MIRType::ObjectOrNull || lir->mir()->operandMightEmulateUndefined(), "If the object couldn't emulate undefined, this should have been " "folded."); Register objreg = ToRegister(lir->input()); Register output = ToRegister(lir->output()); if ((op == JSOp::Eq || op == JSOp::Ne) && lir->mir()->operandMightEmulateUndefined()) { OutOfLineTestObjectWithLabels* ool = new (alloc()) OutOfLineTestObjectWithLabels(); if (op == JSOp::Eq || op == JSOp::Ne) { auto* ool = new (alloc()) OutOfLineTestObjectWithLabels(); addOutOfLineCode(ool, lir->mir()); Label* emulatesUndefined = ool->label1(); Loading Loading @@ -9954,11 +9914,6 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchT( lhsType == MIRType::ObjectOrNull || op == JSOp::Eq || op == JSOp::Ne, "Strict equality should have been folded"); MOZ_ASSERT(lhsType == MIRType::ObjectOrNull || lir->cmpMir()->operandMightEmulateUndefined(), "If the object couldn't emulate undefined, this should have been " "folded."); MBasicBlock* ifTrue; MBasicBlock* ifFalse; Loading @@ -9973,9 +9928,8 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchT( Register input = ToRegister(lir->getOperand(0)); if ((op == JSOp::Eq || op == JSOp::Ne) && lir->cmpMir()->operandMightEmulateUndefined()) { OutOfLineTestObject* ool = new (alloc()) OutOfLineTestObject(); if (op == JSOp::Eq || op == JSOp::Ne) { auto* ool = new (alloc()) OutOfLineTestObject(); addOutOfLineCode(ool, lir->cmpMir()); Label* ifTrueLabel = getJumpLabelForBranch(ifTrue); Loading js/src/jit/Lowering.cpp +6 −38 Original line number Diff line number Diff line Loading @@ -723,33 +723,14 @@ void LIRGenerator::visitTest(MTest* test) { comp->compareType() == MCompare::Compare_Undefined) { if (left->type() == MIRType::Object || left->type() == MIRType::ObjectOrNull) { MOZ_ASSERT(left->type() == MIRType::ObjectOrNull || comp->operandMightEmulateUndefined(), "MCompare::tryFold should handle the " "never-emulates-undefined case"); LDefinition tmp = comp->operandMightEmulateUndefined() ? temp() : LDefinition::BogusTemp(); LIsNullOrLikeUndefinedAndBranchT* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchT( comp, useRegister(left), ifTrue, ifFalse, tmp); auto* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchT( comp, useRegister(left), ifTrue, ifFalse, temp()); add(lir, test); return; } LDefinition tmp, tmpToUnbox; if (comp->operandMightEmulateUndefined()) { tmp = temp(); tmpToUnbox = tempToUnbox(); } else { tmp = LDefinition::BogusTemp(); tmpToUnbox = LDefinition::BogusTemp(); } LIsNullOrLikeUndefinedAndBranchV* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchV( comp, ifTrue, ifFalse, useBox(left), tmp, tmpToUnbox); auto* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchV( comp, ifTrue, ifFalse, useBox(left), temp(), tempToUnbox()); add(lir, test); return; } Loading Loading @@ -999,25 +980,12 @@ void LIRGenerator::visitCompare(MCompare* comp) { comp->compareType() == MCompare::Compare_Undefined) { if (left->type() == MIRType::Object || left->type() == MIRType::ObjectOrNull) { MOZ_ASSERT(left->type() == MIRType::ObjectOrNull || comp->operandMightEmulateUndefined(), "MCompare::tryFold should have folded this away"); define(new (alloc()) LIsNullOrLikeUndefinedT(useRegister(left)), comp); return; } LDefinition tmp, tmpToUnbox; if (comp->operandMightEmulateUndefined()) { tmp = temp(); tmpToUnbox = tempToUnbox(); } else { tmp = LDefinition::BogusTemp(); tmpToUnbox = LDefinition::BogusTemp(); } LIsNullOrLikeUndefinedV* lir = new (alloc()) LIsNullOrLikeUndefinedV(useBox(left), tmp, tmpToUnbox); auto* lir = new (alloc()) LIsNullOrLikeUndefinedV(useBox(left), temp(), tempToUnbox()); define(lir, comp); return; } Loading js/src/jit/MIR.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -3767,8 +3767,7 @@ bool MCompare::tryFold(bool* result) { } if (!lhs()->mightBeType(MIRType::Null) && !lhs()->mightBeType(MIRType::Undefined) && !(lhs()->mightBeType(MIRType::Object) && operandMightEmulateUndefined())) { !lhs()->mightBeType(MIRType::Object)) { *result = (op == JSOp::Ne); return true; } Loading js/src/jit/MIR.h +0 −6 Original line number Diff line number Diff line Loading @@ -2916,7 +2916,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { private: CompareType compareType_; JSOp jsop_; bool operandMightEmulateUndefined_; bool operandsAreNeverNaN_; // When a floating-point comparison is converted to an integer comparison Loading @@ -2928,7 +2927,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { : MBinaryInstruction(classOpcode, left, right), compareType_(Compare_Unknown), jsop_(jsop), operandMightEmulateUndefined_(true), operandsAreNeverNaN_(false), truncateOperands_(false) { setResultType(MIRType::Boolean); Loading @@ -2944,7 +2942,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { compareType == Compare_Float32 || compareType == Compare_RefOrNull); compareType_ = compareType; operandMightEmulateUndefined_ = false; setResultType(MIRType::Int32); } Loading @@ -2970,9 +2967,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { MIRType inputType(); JSOp jsop() const { return jsop_; } bool operandMightEmulateUndefined() const { return operandMightEmulateUndefined_; } bool operandsAreNeverNaN() const { return operandsAreNeverNaN_; } AliasSet getAliasSet() const override { // Strict equality is never effectful. Loading Loading
js/src/jit/CodeGenerator.cpp +32 −78 Original line number Diff line number Diff line Loading @@ -9727,26 +9727,11 @@ void CodeGenerator::visitIsNullOrLikeUndefinedV(LIsNullOrLikeUndefinedV* lir) { Register output = ToRegister(lir->output()); if (op == JSOp::Eq || op == JSOp::Ne) { MOZ_ASSERT( lir->mir()->lhs()->type() != MIRType::Object || lir->mir()->operandMightEmulateUndefined(), "Operands which can't emulate undefined should have been folded"); OutOfLineTestObjectWithLabels* ool = nullptr; Maybe<Label> label1, label2; Label* nullOrLikeUndefined; Label* notNullOrLikeUndefined; if (lir->mir()->operandMightEmulateUndefined()) { ool = new (alloc()) OutOfLineTestObjectWithLabels(); auto* ool = new (alloc()) OutOfLineTestObjectWithLabels(); addOutOfLineCode(ool, lir->mir()); nullOrLikeUndefined = ool->label1(); notNullOrLikeUndefined = ool->label2(); } else { label1.emplace(); label2.emplace(); nullOrLikeUndefined = label1.ptr(); notNullOrLikeUndefined = label2.ptr(); } Label* nullOrLikeUndefined = ool->label1(); Label* notNullOrLikeUndefined = ool->label2(); { ScratchTagScope tag(masm, value); Loading @@ -9760,12 +9745,10 @@ void CodeGenerator::visitIsNullOrLikeUndefinedV(LIsNullOrLikeUndefinedV* lir) { masm.branchTestUndefined(Assembler::Equal, tag, nullOrLikeUndefined); } if (ool) { // Check whether it's a truthy object or a falsy object that emulates // undefined. masm.branchTestObject(Assembler::NotEqual, tag, notNullOrLikeUndefined); ScratchTagScopeRelease _(&tag); } Register objreg = masm.extractObject(value, ToTempUnboxRegister(lir->tempToUnbox())); Loading @@ -9773,8 +9756,6 @@ void CodeGenerator::visitIsNullOrLikeUndefinedV(LIsNullOrLikeUndefinedV* lir) { notNullOrLikeUndefined, ToRegister(lir->temp()), ool); // fall through } } Label done; Loading Loading @@ -9825,24 +9806,16 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV( op = JSOp::Eq; } MOZ_ASSERT( lir->cmpMir()->lhs()->type() != MIRType::Object || lir->cmpMir()->operandMightEmulateUndefined(), "Operands which can't emulate undefined should have been folded"); OutOfLineTestObject* ool = nullptr; if (lir->cmpMir()->operandMightEmulateUndefined()) { ool = new (alloc()) OutOfLineTestObject(); auto* ool = new (alloc()) OutOfLineTestObject(); addOutOfLineCode(ool, lir->cmpMir()); } Label* ifTrueLabel = getJumpLabelForBranch(ifTrue); Label* ifFalseLabel = getJumpLabelForBranch(ifFalse); { ScratchTagScope tag(masm, value); masm.splitTagForTest(value, tag); Label* ifTrueLabel = getJumpLabelForBranch(ifTrue); Label* ifFalseLabel = getJumpLabelForBranch(ifFalse); MDefinition* input = lir->cmpMir()->lhs(); if (input->mightBeType(MIRType::Null)) { masm.branchTestNull(Assembler::Equal, tag, ifTrueLabel); Loading @@ -9851,10 +9824,8 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV( masm.branchTestUndefined(Assembler::Equal, tag, ifTrueLabel); } if (ool) { masm.branchTestObject(Assembler::NotEqual, tag, ifFalseLabel); ScratchTagScopeRelease _(&tag); } // Objects that emulate undefined are loosely equal to null/undefined. Register objreg = Loading @@ -9862,12 +9833,8 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV( Register scratch = ToRegister(lir->temp()); testObjectEmulatesUndefined(objreg, ifTrueLabel, ifFalseLabel, scratch, ool); } else { masm.jump(ifFalseLabel); } return; } } MOZ_ASSERT(op == JSOp::StrictEq || op == JSOp::StrictNe); Loading @@ -9891,18 +9858,11 @@ void CodeGenerator::visitIsNullOrLikeUndefinedT(LIsNullOrLikeUndefinedT* lir) { lhsType == MIRType::ObjectOrNull || op == JSOp::Eq || op == JSOp::Ne, "Strict equality should have been folded"); MOZ_ASSERT(lhsType == MIRType::ObjectOrNull || lir->mir()->operandMightEmulateUndefined(), "If the object couldn't emulate undefined, this should have been " "folded."); Register objreg = ToRegister(lir->input()); Register output = ToRegister(lir->output()); if ((op == JSOp::Eq || op == JSOp::Ne) && lir->mir()->operandMightEmulateUndefined()) { OutOfLineTestObjectWithLabels* ool = new (alloc()) OutOfLineTestObjectWithLabels(); if (op == JSOp::Eq || op == JSOp::Ne) { auto* ool = new (alloc()) OutOfLineTestObjectWithLabels(); addOutOfLineCode(ool, lir->mir()); Label* emulatesUndefined = ool->label1(); Loading Loading @@ -9954,11 +9914,6 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchT( lhsType == MIRType::ObjectOrNull || op == JSOp::Eq || op == JSOp::Ne, "Strict equality should have been folded"); MOZ_ASSERT(lhsType == MIRType::ObjectOrNull || lir->cmpMir()->operandMightEmulateUndefined(), "If the object couldn't emulate undefined, this should have been " "folded."); MBasicBlock* ifTrue; MBasicBlock* ifFalse; Loading @@ -9973,9 +9928,8 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchT( Register input = ToRegister(lir->getOperand(0)); if ((op == JSOp::Eq || op == JSOp::Ne) && lir->cmpMir()->operandMightEmulateUndefined()) { OutOfLineTestObject* ool = new (alloc()) OutOfLineTestObject(); if (op == JSOp::Eq || op == JSOp::Ne) { auto* ool = new (alloc()) OutOfLineTestObject(); addOutOfLineCode(ool, lir->cmpMir()); Label* ifTrueLabel = getJumpLabelForBranch(ifTrue); Loading
js/src/jit/Lowering.cpp +6 −38 Original line number Diff line number Diff line Loading @@ -723,33 +723,14 @@ void LIRGenerator::visitTest(MTest* test) { comp->compareType() == MCompare::Compare_Undefined) { if (left->type() == MIRType::Object || left->type() == MIRType::ObjectOrNull) { MOZ_ASSERT(left->type() == MIRType::ObjectOrNull || comp->operandMightEmulateUndefined(), "MCompare::tryFold should handle the " "never-emulates-undefined case"); LDefinition tmp = comp->operandMightEmulateUndefined() ? temp() : LDefinition::BogusTemp(); LIsNullOrLikeUndefinedAndBranchT* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchT( comp, useRegister(left), ifTrue, ifFalse, tmp); auto* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchT( comp, useRegister(left), ifTrue, ifFalse, temp()); add(lir, test); return; } LDefinition tmp, tmpToUnbox; if (comp->operandMightEmulateUndefined()) { tmp = temp(); tmpToUnbox = tempToUnbox(); } else { tmp = LDefinition::BogusTemp(); tmpToUnbox = LDefinition::BogusTemp(); } LIsNullOrLikeUndefinedAndBranchV* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchV( comp, ifTrue, ifFalse, useBox(left), tmp, tmpToUnbox); auto* lir = new (alloc()) LIsNullOrLikeUndefinedAndBranchV( comp, ifTrue, ifFalse, useBox(left), temp(), tempToUnbox()); add(lir, test); return; } Loading Loading @@ -999,25 +980,12 @@ void LIRGenerator::visitCompare(MCompare* comp) { comp->compareType() == MCompare::Compare_Undefined) { if (left->type() == MIRType::Object || left->type() == MIRType::ObjectOrNull) { MOZ_ASSERT(left->type() == MIRType::ObjectOrNull || comp->operandMightEmulateUndefined(), "MCompare::tryFold should have folded this away"); define(new (alloc()) LIsNullOrLikeUndefinedT(useRegister(left)), comp); return; } LDefinition tmp, tmpToUnbox; if (comp->operandMightEmulateUndefined()) { tmp = temp(); tmpToUnbox = tempToUnbox(); } else { tmp = LDefinition::BogusTemp(); tmpToUnbox = LDefinition::BogusTemp(); } LIsNullOrLikeUndefinedV* lir = new (alloc()) LIsNullOrLikeUndefinedV(useBox(left), tmp, tmpToUnbox); auto* lir = new (alloc()) LIsNullOrLikeUndefinedV(useBox(left), temp(), tempToUnbox()); define(lir, comp); return; } Loading
js/src/jit/MIR.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -3767,8 +3767,7 @@ bool MCompare::tryFold(bool* result) { } if (!lhs()->mightBeType(MIRType::Null) && !lhs()->mightBeType(MIRType::Undefined) && !(lhs()->mightBeType(MIRType::Object) && operandMightEmulateUndefined())) { !lhs()->mightBeType(MIRType::Object)) { *result = (op == JSOp::Ne); return true; } Loading
js/src/jit/MIR.h +0 −6 Original line number Diff line number Diff line Loading @@ -2916,7 +2916,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { private: CompareType compareType_; JSOp jsop_; bool operandMightEmulateUndefined_; bool operandsAreNeverNaN_; // When a floating-point comparison is converted to an integer comparison Loading @@ -2928,7 +2927,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { : MBinaryInstruction(classOpcode, left, right), compareType_(Compare_Unknown), jsop_(jsop), operandMightEmulateUndefined_(true), operandsAreNeverNaN_(false), truncateOperands_(false) { setResultType(MIRType::Boolean); Loading @@ -2944,7 +2942,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { compareType == Compare_Float32 || compareType == Compare_RefOrNull); compareType_ = compareType; operandMightEmulateUndefined_ = false; setResultType(MIRType::Int32); } Loading @@ -2970,9 +2967,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data { MIRType inputType(); JSOp jsop() const { return jsop_; } bool operandMightEmulateUndefined() const { return operandMightEmulateUndefined_; } bool operandsAreNeverNaN() const { return operandsAreNeverNaN_; } AliasSet getAliasSet() const override { // Strict equality is never effectful. Loading