Refactor lithium CheckSmi instruction into two separate instructions CheckSmi and CheckNonSmi.

There is no need to store the branch condition separately in the LIR.

Review URL: http://codereview.chromium.org/6673082

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7206 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0584aa3e
......@@ -1667,7 +1667,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, eq));
return AssignEnvironment(new LCheckNonSmi(value));
}
......@@ -1688,7 +1688,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, ne));
return AssignEnvironment(new LCheckSmi(value));
}
......
......@@ -69,6 +69,7 @@ class LCodeGen;
V(CallStub) \
V(CheckFunction) \
V(CheckInstanceType) \
V(CheckNonSmi) \
V(CheckMap) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
......@@ -1718,20 +1719,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
LCheckSmi(LOperand* value, Condition condition)
: condition_(condition) {
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
}
Condition condition() const { return condition_; }
DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
};
virtual void CompileToNative(LCodeGen* generator);
virtual const char* Mnemonic() const {
return (condition_ == eq) ? "check-non-smi" : "check-smi";
class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckNonSmi(LOperand* value) {
inputs_[0] = value;
}
private:
Condition condition_;
DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
};
......
......@@ -3525,9 +3525,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister());
__ tst(ToRegister(input), Operand(kSmiTagMask));
DeoptimizeIf(instr->condition(), instr->environment());
DeoptimizeIf(ne, instr->environment());
}
void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
LOperand* input = instr->InputAt(0);
__ tst(ToRegister(input), Operand(kSmiTagMask));
DeoptimizeIf(eq, instr->environment());
}
......
......@@ -3497,9 +3497,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister());
__ test(ToRegister(input), Immediate(kSmiTagMask));
DeoptimizeIf(instr->condition(), instr->environment());
DeoptimizeIf(not_zero, instr->environment());
}
void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
LOperand* input = instr->InputAt(0);
__ test(ToRegister(input), Immediate(kSmiTagMask));
DeoptimizeIf(zero, instr->environment());
}
......
......@@ -1683,7 +1683,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, zero));
return AssignEnvironment(new LCheckNonSmi(value));
}
......@@ -1704,7 +1704,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, not_zero));
return AssignEnvironment(new LCheckSmi(value));
}
......
......@@ -70,6 +70,7 @@ class LCodeGen;
V(CheckFunction) \
V(CheckInstanceType) \
V(CheckMap) \
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
V(ClassOfTest) \
......@@ -1792,20 +1793,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
LCheckSmi(LOperand* value, Condition condition)
: condition_(condition) {
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
}
Condition condition() const { return condition_; }
DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
};
virtual void CompileToNative(LCodeGen* generator);
virtual const char* Mnemonic() const {
return (condition_ == zero) ? "check-non-smi" : "check-smi";
class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckNonSmi(LOperand* value) {
inputs_[0] = value;
}
private:
Condition condition_;
DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
};
......
......@@ -3297,11 +3297,14 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister());
Condition cc = masm()->CheckSmi(ToRegister(input));
if (instr->condition() != equal) {
cc = NegateCondition(cc);
}
DeoptimizeIf(NegateCondition(cc), instr->environment());
}
void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
LOperand* input = instr->InputAt(0);
Condition cc = masm()->CheckSmi(ToRegister(input));
DeoptimizeIf(cc, instr->environment());
}
......
......@@ -1658,7 +1658,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, zero));
return AssignEnvironment(new LCheckNonSmi(value));
}
......@@ -1678,7 +1678,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, not_zero));
return AssignEnvironment(new LCheckSmi(value));
}
......
......@@ -70,6 +70,7 @@ class LCodeGen;
V(CheckFunction) \
V(CheckInstanceType) \
V(CheckMap) \
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
V(ClassOfTest) \
......@@ -1707,20 +1708,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
LCheckSmi(LOperand* value, Condition condition)
: condition_(condition) {
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
}
Condition condition() const { return condition_; }
DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
};
virtual void CompileToNative(LCodeGen* generator);
virtual const char* Mnemonic() const {
return (condition_ == zero) ? "check-non-smi" : "check-smi";
class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckNonSmi(LOperand* value) {
inputs_[0] = value;
}
private:
Condition condition_;
DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment