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
This commit is contained in:
fschneider@chromium.org 2011-03-16 16:28:06 +00:00
parent 0584aa3e32
commit a20ee85139
9 changed files with 59 additions and 38 deletions

View File

@ -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));
}

View File

@ -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")
};

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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));
}

View File

@ -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")
};

View File

@ -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());
}

View File

@ -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));
}

View File

@ -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")
};