diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index cf1a5f12bffd..d98e58b1e68f 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -12678,14 +12678,16 @@ void CodeGenerator::visitHasClass(LHasClass* ins) { void CodeGenerator::visitGuardToClass(LGuardToClass* ins) { Register lhs = ToRegister(ins->lhs()); - Register output = ToRegister(ins->output()); Register temp = ToRegister(ins->temp()); + // branchTestObjClass may zero the object register on speculative paths + // (we should have a defineReuseInput allocation in this case). + Register spectreRegToZero = lhs; + Label notEqual; masm.branchTestObjClass(Assembler::NotEqual, lhs, ins->mir()->getClass(), - temp, output, ¬Equal); - masm.mov(lhs, output); + temp, spectreRegToZero, ¬Equal); // Can't return null-return here, so bail. bailoutFrom(¬Equal, ins->snapshot()); diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index 008aa3c1a9b2..ad3fd9a979fa 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -4208,9 +4208,9 @@ void LIRGenerator::visitGuardToClass(MGuardToClass* ins) { MOZ_ASSERT(ins->object()->type() == MIRType::Object); MOZ_ASSERT(ins->type() == MIRType::Object); LGuardToClass* lir = - new (alloc()) LGuardToClass(useRegister(ins->object()), temp()); + new (alloc()) LGuardToClass(useRegisterAtStart(ins->object()), temp()); assignSnapshot(lir, Bailout_TypeBarrierO); - define(lir, ins); + defineReuseInput(lir, ins, 0); } void LIRGenerator::visitObjectClassToString(MObjectClassToString* ins) {