diff --git a/js/src/jit-test/tests/ion/bug1146410.js b/js/src/jit-test/tests/ion/bug1146410.js new file mode 100644 index 000000000000..fd7caafda804 --- /dev/null +++ b/js/src/jit-test/tests/ion/bug1146410.js @@ -0,0 +1,9 @@ +// |jit-test| error: TypeError +function foo() { + var ws = new WeakSet(); + ws.add({}); + for (var i = 0; i < 10; i++) + ws.add(WeakSet + ""); +} +foo(); +delete Math diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 1865ded0eb3b..960f9374fdf9 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -3659,15 +3659,16 @@ IonBuilder::improveTypesAtTest(MDefinition *ins, bool trueBranch, MTest *test) case MDefinition::Op_Not: return improveTypesAtTest(ins->toNot()->getOperand(0), !trueBranch, test); case MDefinition::Op_IsObject: { - TemporaryTypeSet *oldType = ins->getOperand(0)->resultTypeSet(); + MDefinition *subject = ins->getOperand(0); + TemporaryTypeSet *oldType = subject->resultTypeSet(); // Create temporary typeset equal to the type if there is no resultTypeSet. TemporaryTypeSet tmp; if (!oldType) { - if (ins->type() == MIRType_Value) + if (subject->type() == MIRType_Value) return true; oldType = &tmp; - tmp.addType(TypeSet::PrimitiveType(ValueTypeFromMIRType(ins->type())), alloc_->lifoAlloc()); + tmp.addType(TypeSet::PrimitiveType(ValueTypeFromMIRType(subject->type())), alloc_->lifoAlloc()); } if (oldType->unknown()) @@ -3682,7 +3683,7 @@ IonBuilder::improveTypesAtTest(MDefinition *ins, bool trueBranch, MTest *test) if (!type) return false; - return replaceTypeSet(ins->getOperand(0), type, test); + return replaceTypeSet(subject, type, test); } case MDefinition::Op_Phi: { bool branchIsAnd = true;