MIPS: Support Smi in CompareIDAndBranch

Port r14842 (1c8d7430)

BUG=

Review URL: https://codereview.chromium.org/15917012

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14863 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
palfia@homejinni.com 2013-05-28 21:36:03 +00:00
parent cbdf760ef8
commit 041257e549
2 changed files with 20 additions and 7 deletions

View File

@ -2047,11 +2047,23 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
Operand cmp_right = Operand(0); Operand cmp_right = Operand(0);
if (right->IsConstantOperand()) { if (right->IsConstantOperand()) {
cmp_left = ToRegister(left); int32_t value = ToInteger32(LConstantOperand::cast(right));
cmp_right = Operand(ToInteger32(LConstantOperand::cast(right))); if (instr->hydrogen_value()->representation().IsSmi()) {
cmp_left = ToRegister(left);
cmp_right = Operand(Smi::FromInt(value));
} else {
cmp_left = ToRegister(left);
cmp_right = Operand(value);
}
} else if (left->IsConstantOperand()) { } else if (left->IsConstantOperand()) {
cmp_left = ToRegister(right); int32_t value = ToInteger32(LConstantOperand::cast(left));
cmp_right = Operand(ToInteger32(LConstantOperand::cast(left))); if (instr->hydrogen_value()->representation().IsSmi()) {
cmp_left = ToRegister(right);
cmp_right = Operand(Smi::FromInt(value));
} else {
cmp_left = ToRegister(right);
cmp_right = Operand(value);
}
// We transposed the operands. Reverse the condition. // We transposed the operands. Reverse the condition.
cond = ReverseCondition(cond); cond = ReverseCondition(cond);
} else { } else {

View File

@ -1554,9 +1554,10 @@ LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
LInstruction* LChunkBuilder::DoCompareIDAndBranch( LInstruction* LChunkBuilder::DoCompareIDAndBranch(
HCompareIDAndBranch* instr) { HCompareIDAndBranch* instr) {
Representation r = instr->representation(); Representation r = instr->representation();
if (r.IsInteger32()) { if (r.IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().IsInteger32()); ASSERT(instr->left()->representation().IsSmiOrInteger32());
ASSERT(instr->right()->representation().IsInteger32()); ASSERT(instr->left()->representation().Equals(
instr->right()->representation()));
LOperand* left = UseRegisterOrConstantAtStart(instr->left()); LOperand* left = UseRegisterOrConstantAtStart(instr->left());
LOperand* right = UseRegisterOrConstantAtStart(instr->right()); LOperand* right = UseRegisterOrConstantAtStart(instr->right());
return new(zone()) LCmpIDAndBranch(left, right); return new(zone()) LCmpIDAndBranch(left, right);