diff --git a/doc/IR.md b/doc/IR.md index e031f0c083a..5b0541452eb 100644 --- a/doc/IR.md +++ b/doc/IR.md @@ -557,16 +557,6 @@ Arguments | This instruction takes one parameter, which is the register that con Semantics | This instruction is a terminator instruction that will transition the control to the CatchInst that covers this instruction with closest scope. Effects | May read and write memory. -### CheckHasInstanceInst - -CheckHasInstanceInst | _ ---- | --- | -Description | Check whether an object has a particular instance. -Example | %0 = CheckHasInstanceInst %check_result, %left, %right, %onTrue, %onFalse -Arguments | This instruction takes 5 parameters: %check_result will be a write-only stack register and holds the check result, %left and %right are the operands of instanceof, and %onTrue and %onFalse are the jump targets in case of check returns true/false. -Semantics | This instruction is generated as part of instanceof operator. It checks whether %right could possibly have %left as an instance, and returns the check result. If the checked object is invalid to have the target instance, it will throw an exception. It the check returns false, it jumps to the %jump_label. -Effects | May read or write memory. - ### TryStartInst TryStartInst | _ diff --git a/include/hermes/IR/IRBuilder.h b/include/hermes/IR/IRBuilder.h index 33fb85f91cc..06f2910e631 100644 --- a/include/hermes/IR/IRBuilder.h +++ b/include/hermes/IR/IRBuilder.h @@ -302,13 +302,6 @@ class IRBuilder { ThrowInst *createThrowInst(Value *thrownValue); - CheckHasInstanceInst *createCheckHasInstanceInst( - AllocStackInst *result, - Value *left, - Value *right, - BasicBlock *onTrue, - BasicBlock *onFalse); - TryStartInst *createTryStartInst( BasicBlock *tryBodyBlock, BasicBlock *catchTargetBlock); diff --git a/include/hermes/IR/Instrs.def b/include/hermes/IR/Instrs.def index 2ea7b7a2de3..f687876340b 100644 --- a/include/hermes/IR/Instrs.def +++ b/include/hermes/IR/Instrs.def @@ -177,7 +177,6 @@ TERMINATOR(SwitchInst, TerminatorInst) TERMINATOR(CondBranchInst, TerminatorInst) TERMINATOR(GetPNamesInst, TerminatorInst) TERMINATOR(GetNextPNameInst, TerminatorInst) -TERMINATOR(CheckHasInstanceInst, TerminatorInst) TERMINATOR(TryStartInst, TerminatorInst) BEGIN_TERMINATOR(CompareBranchInst, TerminatorInst) diff --git a/include/hermes/IR/Instrs.h b/include/hermes/IR/Instrs.h index 6cf7194df66..357cc0bdec0 100644 --- a/include/hermes/IR/Instrs.h +++ b/include/hermes/IR/Instrs.h @@ -2319,83 +2319,6 @@ class GetNextPNameInst : public TerminatorInst { } }; -class CheckHasInstanceInst : public TerminatorInst { - CheckHasInstanceInst(const CheckHasInstanceInst &) = delete; - void operator=(const CheckHasInstanceInst &) = delete; - - public: - enum { ResultIdx, LeftIdx, RightIdx, OnTrueIdx, OnFalseIdx }; - - explicit CheckHasInstanceInst( - AllocStackInst *result, - Value *left, - Value *right, - BasicBlock *onTrue, - BasicBlock *onFalse) - : TerminatorInst(ValueKind::CheckHasInstanceInstKind) { - pushOperand(result); - pushOperand(left); - pushOperand(right); - pushOperand(onTrue); - pushOperand(onFalse); - } - explicit CheckHasInstanceInst( - const CheckHasInstanceInst *src, - llvh::ArrayRef operands) - : TerminatorInst(src, operands) {} - - static bool hasOutput() { - return false; - } - - SideEffectKind getSideEffect() { - return SideEffectKind::None; - } - - WordBitSet<> getChangedOperandsImpl() { - return {}; - } - - static bool classof(const Value *V) { - ValueKind kind = V->getKind(); - return kind == ValueKind::CheckHasInstanceInstKind; - } - - AllocStackInst *getResult() const { - return cast(getOperand(ResultIdx)); - } - Value *getLeft() const { - return getOperand(LeftIdx); - } - Value *getRight() const { - return getOperand(RightIdx); - } - BasicBlock *getOnTrueDest() const { - return cast(getOperand(OnTrueIdx)); - } - BasicBlock *getOnFalseDest() const { - return cast(getOperand(OnFalseIdx)); - } - - unsigned getNumSuccessors() const { - return 2; - } - BasicBlock *getSuccessor(unsigned idx) const { - if (idx == 0) - return getOnTrueDest(); - if (idx == 1) - return getOnFalseDest(); - llvm_unreachable("CheckHasInstanceInst only have 2 successors!"); - } - void setSuccessor(unsigned idx, BasicBlock *B) { - if (idx == 0) - return setOperand(B, OnTrueIdx); - if (idx == 1) - return setOperand(B, OnFalseIdx); - llvm_unreachable("CheckHasInstanceInst only have 2 successors!"); - } -}; - class TryStartInst : public TerminatorInst { TryStartInst(const TryStartInst &) = delete; void operator=(const TryStartInst &) = delete; diff --git a/lib/BCGen/HBC/ISel.cpp b/lib/BCGen/HBC/ISel.cpp index 73a187910d1..5a28a21a12f 100644 --- a/lib/BCGen/HBC/ISel.cpp +++ b/lib/BCGen/HBC/ISel.cpp @@ -1167,11 +1167,6 @@ void HBCISel::generateGetNextPNameInst( registerLongJump(loc, onSomeBlock); } } -void HBCISel::generateCheckHasInstanceInst( - CheckHasInstanceInst *Inst, - BasicBlock *next) { - llvm_unreachable("This instruction is not in use in HBC."); -} void HBCISel::generateTryStartInst(TryStartInst *Inst, BasicBlock *next) { // TryStartInst is the same as BranchInst in bytecode gen. BasicBlock *destination = Inst->getTryBody(); diff --git a/lib/BCGen/SH/SH.cpp b/lib/BCGen/SH/SH.cpp index 3ccd9808dbe..2a9211565c1 100644 --- a/lib/BCGen/SH/SH.cpp +++ b/lib/BCGen/SH/SH.cpp @@ -1256,9 +1256,6 @@ class InstrGen { generateBasicBlockLabel(inst.getOnSomeDest(), os_, bbMap_); os_ << ";\n"; } - void generateCheckHasInstanceInst(CheckHasInstanceInst &inst) { - hermes_fatal("This instruction is not in use in HBC."); - } void generateTryStartInst(TryStartInst &inst) { // TODO(T132354002): Properly understand the nesting of try blocks so we can // reuse SHJmpBufs. diff --git a/lib/IR/IRBuilder.cpp b/lib/IR/IRBuilder.cpp index 1190b93d84a..60016d22c5b 100644 --- a/lib/IR/IRBuilder.cpp +++ b/lib/IR/IRBuilder.cpp @@ -281,17 +281,6 @@ ThrowInst *IRBuilder::createThrowInst(Value *thrownValue) { return TI; } -CheckHasInstanceInst *IRBuilder::createCheckHasInstanceInst( - AllocStackInst *result, - Value *left, - Value *right, - BasicBlock *onTrue, - BasicBlock *onFalse) { - auto *TI = new CheckHasInstanceInst(result, left, right, onTrue, onFalse); - insert(TI); - return TI; -} - TryStartInst *IRBuilder::createTryStartInst( BasicBlock *tryBodyBlock, BasicBlock *catchTargetBlock) { diff --git a/lib/IR/IRVerifier.cpp b/lib/IR/IRVerifier.cpp index 11b0fabb338..8e25b049504 100644 --- a/lib/IR/IRVerifier.cpp +++ b/lib/IR/IRVerifier.cpp @@ -262,7 +262,6 @@ void Verifier::beforeVisitInstruction(const Instruction &Inst) { Assert( llvh::isa(Inst) || llvh::isa(Inst) || llvh::isa(Inst) || llvh::isa(Inst) || - llvh::isa(Inst) || llvh::isa(Inst) || llvh::isa(Inst) || llvh::isa(Inst) || @@ -730,13 +729,6 @@ void Verifier::visitSwitchImmInst(const hermes::SwitchImmInst &Inst) { } } -void Verifier::visitCheckHasInstanceInst(const CheckHasInstanceInst &Inst) { - Assert(isTerminator(&Inst), "CheckHasInstanceInst must be a terminator"); - Assert( - Inst.getNumSuccessors() == 2, - "CheckHasInstanceInst should have 2 successors"); -} - void Verifier::visitDebuggerInst(DebuggerInst const &Inst) { // Nothing to verify at this point. } diff --git a/lib/Optimizer/Scalar/TypeInference.cpp b/lib/Optimizer/Scalar/TypeInference.cpp index 14ceb1a0c68..50eb53d0bee 100644 --- a/lib/Optimizer/Scalar/TypeInference.cpp +++ b/lib/Optimizer/Scalar/TypeInference.cpp @@ -866,9 +866,6 @@ class TypeInferenceImpl { Type inferGetNextPNameInst(GetNextPNameInst *inst) { return Type::createNoType(); } - Type inferCheckHasInstanceInst(CheckHasInstanceInst *inst) { - return Type::createNoType(); - } Type inferTryStartInst(TryStartInst *inst) { return Type::createNoType(); }