diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 7dc2de55c1b9..700e68670016 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -12110,7 +12110,7 @@ AbortReasonOr IonBuilder::jsop_globalthis() { AbortReasonOr IonBuilder::jsop_typeof() { MDefinition* input = current->pop(); - MTypeOf* ins = MTypeOf::New(alloc(), input, input->type()); + MTypeOf* ins = MTypeOf::New(alloc(), input); ins->cacheInputMaybeCallableOrEmulatesUndefined(constraints()); diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 3729f300aea7..754817030443 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -3540,13 +3540,13 @@ MDefinition* MBitNot::foldsTo(TempAllocator& alloc) { } MDefinition* MTypeOf::foldsTo(TempAllocator& alloc) { - // Note: we can't use input->type() here, type analysis has - // boxed the input. - MOZ_ASSERT(input()->type() == MIRType::Value); + if (!input()->isBox()) { + return this; + } + MDefinition* unboxed = input()->toBox()->input(); JSType type; - - switch (inputType()) { + switch (unboxed->type()) { case MIRType::Double: case MIRType::Float32: case MIRType::Int32: diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 8b8d1d058492..21c592e63a6a 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -4482,12 +4482,10 @@ class MBitNot : public MUnaryInstruction, public BitwisePolicy::Data { }; class MTypeOf : public MUnaryInstruction, public BoxInputsPolicy::Data { - MIRType inputType_; bool inputMaybeCallableOrEmulatesUndefined_; - MTypeOf(MDefinition* def, MIRType inputType) + explicit MTypeOf(MDefinition* def) : MUnaryInstruction(classOpcode, def), - inputType_(inputType), inputMaybeCallableOrEmulatesUndefined_(true) { setResultType(MIRType::String); setMovable(); @@ -4497,8 +4495,6 @@ class MTypeOf : public MUnaryInstruction, public BoxInputsPolicy::Data { INSTRUCTION_HEADER(TypeOf) TRIVIAL_NEW_WRAPPERS - MIRType inputType() const { return inputType_; } - MDefinition* foldsTo(TempAllocator& alloc) override; void cacheInputMaybeCallableOrEmulatesUndefined( CompilerConstraintList* constraints); @@ -4516,9 +4512,6 @@ class MTypeOf : public MUnaryInstruction, public BoxInputsPolicy::Data { if (!ins->isTypeOf()) { return false; } - if (inputType() != ins->toTypeOf()->inputType()) { - return false; - } if (inputMaybeCallableOrEmulatesUndefined() != ins->toTypeOf()->inputMaybeCallableOrEmulatesUndefined()) { return false; diff --git a/js/src/jit/WarpBuilder.cpp b/js/src/jit/WarpBuilder.cpp index efefbbef1dd6..853ca281f284 100644 --- a/js/src/jit/WarpBuilder.cpp +++ b/js/src/jit/WarpBuilder.cpp @@ -1525,9 +1525,8 @@ bool WarpBuilder::build_ToPropertyKey(BytecodeLocation loc) { } bool WarpBuilder::build_Typeof(BytecodeLocation) { - // TODO: remove MTypeOf::inputType_ and unbox in foldsTo instead. MDefinition* input = current->pop(); - MTypeOf* ins = MTypeOf::New(alloc(), input, MIRType::Value); + MTypeOf* ins = MTypeOf::New(alloc(), input); current->add(ins); current->push(ins); return true;