diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index 03fbd221912..c5a4dabe1a1 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -3060,6 +3060,16 @@ IonBuilder::addTypeBarrier(uint32_t i, CallInfo &callinfo, types::StackTypeSet * if (needsBarrier) { MTypeBarrier *barrier = MTypeBarrier::New(ins, cloneTypeSet(calleeObs), Bailout_Normal); current->add(barrier); + + // Non-matching types are boxed such as the MIRType does not conflict + // with the inferred type. + if (callerObs->getKnownTypeTag() != calleeObs->getKnownTypeTag() && + ins->type() != MIRType_Value) + { + MBox *box = MBox::New(ins); + current->add(box); + ins = box; + } } if (i == 0) diff --git a/js/src/jit-test/tests/ion/bug851067.js b/js/src/jit-test/tests/ion/bug851067.js new file mode 100644 index 00000000000..79f3b1b1efc --- /dev/null +++ b/js/src/jit-test/tests/ion/bug851067.js @@ -0,0 +1,6 @@ +function toPrinted(value) { + value = String(value); +} +String = Array; +toPrinted(123); +evaluate('toPrinted("foo");');