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) { ...@@ -1667,7 +1667,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); 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) { ...@@ -1688,7 +1688,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, ne)); return AssignEnvironment(new LCheckSmi(value));
} }
......
...@@ -69,6 +69,7 @@ class LCodeGen; ...@@ -69,6 +69,7 @@ class LCodeGen;
V(CallStub) \ V(CallStub) \
V(CheckFunction) \ V(CheckFunction) \
V(CheckInstanceType) \ V(CheckInstanceType) \
V(CheckNonSmi) \
V(CheckMap) \ V(CheckMap) \
V(CheckPrototypeMaps) \ V(CheckPrototypeMaps) \
V(CheckSmi) \ V(CheckSmi) \
...@@ -1718,20 +1719,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> { ...@@ -1718,20 +1719,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> { class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public: public:
LCheckSmi(LOperand* value, Condition condition) explicit LCheckSmi(LOperand* value) {
: condition_(condition) {
inputs_[0] = 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 { class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
return (condition_ == eq) ? "check-non-smi" : "check-smi"; public:
explicit LCheckNonSmi(LOperand* value) {
inputs_[0] = value;
} }
private: DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Condition condition_;
}; };
......
...@@ -3525,9 +3525,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { ...@@ -3525,9 +3525,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->InputAt(0); LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister());
__ tst(ToRegister(input), Operand(kSmiTagMask)); __ 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) { ...@@ -3497,9 +3497,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->InputAt(0); LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister());
__ test(ToRegister(input), Immediate(kSmiTagMask)); __ 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) { ...@@ -1683,7 +1683,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); 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) { ...@@ -1704,7 +1704,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, not_zero)); return AssignEnvironment(new LCheckSmi(value));
} }
......
...@@ -70,6 +70,7 @@ class LCodeGen; ...@@ -70,6 +70,7 @@ class LCodeGen;
V(CheckFunction) \ V(CheckFunction) \
V(CheckInstanceType) \ V(CheckInstanceType) \
V(CheckMap) \ V(CheckMap) \
V(CheckNonSmi) \
V(CheckPrototypeMaps) \ V(CheckPrototypeMaps) \
V(CheckSmi) \ V(CheckSmi) \
V(ClassOfTest) \ V(ClassOfTest) \
...@@ -1792,20 +1793,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> { ...@@ -1792,20 +1793,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> { class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public: public:
LCheckSmi(LOperand* value, Condition condition) explicit LCheckSmi(LOperand* value) {
: condition_(condition) {
inputs_[0] = 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 { class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
return (condition_ == zero) ? "check-non-smi" : "check-smi"; public:
explicit LCheckNonSmi(LOperand* value) {
inputs_[0] = value;
} }
private: DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Condition condition_;
}; };
......
...@@ -3297,11 +3297,14 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { ...@@ -3297,11 +3297,14 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
void LCodeGen::DoCheckSmi(LCheckSmi* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->InputAt(0); LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister());
Condition cc = masm()->CheckSmi(ToRegister(input)); Condition cc = masm()->CheckSmi(ToRegister(input));
if (instr->condition() != equal) { DeoptimizeIf(NegateCondition(cc), instr->environment());
cc = NegateCondition(cc); }
}
void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
LOperand* input = instr->InputAt(0);
Condition cc = masm()->CheckSmi(ToRegister(input));
DeoptimizeIf(cc, instr->environment()); DeoptimizeIf(cc, instr->environment());
} }
......
...@@ -1658,7 +1658,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1658,7 +1658,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); 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) { ...@@ -1678,7 +1678,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new LCheckSmi(value, not_zero)); return AssignEnvironment(new LCheckSmi(value));
} }
......
...@@ -70,6 +70,7 @@ class LCodeGen; ...@@ -70,6 +70,7 @@ class LCodeGen;
V(CheckFunction) \ V(CheckFunction) \
V(CheckInstanceType) \ V(CheckInstanceType) \
V(CheckMap) \ V(CheckMap) \
V(CheckNonSmi) \
V(CheckPrototypeMaps) \ V(CheckPrototypeMaps) \
V(CheckSmi) \ V(CheckSmi) \
V(ClassOfTest) \ V(ClassOfTest) \
...@@ -1707,20 +1708,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> { ...@@ -1707,20 +1708,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> { class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public: public:
LCheckSmi(LOperand* value, Condition condition) explicit LCheckSmi(LOperand* value) {
: condition_(condition) {
inputs_[0] = 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 { class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
return (condition_ == zero) ? "check-non-smi" : "check-smi"; public:
explicit LCheckNonSmi(LOperand* value) {
inputs_[0] = value;
} }
private: DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Condition condition_;
}; };
......
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