Index: src/x64/codegen-x64.cc |
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc |
index 473fead53d7dc146c40b887f07dc1295f947e28b..b25d74afc46249c8581b804449a5394579410a27 100644 |
--- a/src/x64/codegen-x64.cc |
+++ b/src/x64/codegen-x64.cc |
@@ -5739,48 +5739,55 @@ void CodeGenerator::Comparison(AstNode* node, |
// by reconstituting them on the non-fall-through path. |
JumpTarget is_smi; |
- Condition left_is_smi = masm_->CheckSmi(left_side.reg()); |
- is_smi.Branch(left_is_smi); |
- |
- bool is_loop_condition = (node->AsExpression() != NULL) && |
- node->AsExpression()->is_loop_condition(); |
- if (!is_loop_condition && right_val->IsSmi()) { |
- // Right side is a constant smi and left side has been checked |
- // not to be a smi. |
- JumpTarget not_number; |
- __ Cmp(FieldOperand(left_reg, HeapObject::kMapOffset), |
- Factory::heap_number_map()); |
- not_number.Branch(not_equal, &left_side); |
- __ movsd(xmm1, |
- FieldOperand(left_reg, HeapNumber::kValueOffset)); |
- int value = Smi::cast(*right_val)->value(); |
- if (value == 0) { |
- __ xorpd(xmm0, xmm0); |
- } else { |
- Result temp = allocator()->Allocate(); |
- __ movl(temp.reg(), Immediate(value)); |
- __ cvtlsi2sd(xmm0, temp.reg()); |
- temp.Unuse(); |
+ if (left_side.is_smi()) { |
+ if (FLAG_debug_code) { |
+ __ AbortIfNotSmi(left_side.reg(), "Non-smi value inferred as smi."); |
+ } |
+ } else { |
+ Condition left_is_smi = masm_->CheckSmi(left_side.reg()); |
+ is_smi.Branch(left_is_smi); |
+ |
+ bool is_loop_condition = (node->AsExpression() != NULL) && |
+ node->AsExpression()->is_loop_condition(); |
+ if (!is_loop_condition && right_val->IsSmi()) { |
+ // Right side is a constant smi and left side has been checked |
+ // not to be a smi. |
+ JumpTarget not_number; |
+ __ Cmp(FieldOperand(left_reg, HeapObject::kMapOffset), |
+ Factory::heap_number_map()); |
+ not_number.Branch(not_equal, &left_side); |
+ __ movsd(xmm1, |
+ FieldOperand(left_reg, HeapNumber::kValueOffset)); |
+ int value = Smi::cast(*right_val)->value(); |
+ if (value == 0) { |
+ __ xorpd(xmm0, xmm0); |
+ } else { |
+ Result temp = allocator()->Allocate(); |
+ __ movl(temp.reg(), Immediate(value)); |
+ __ cvtlsi2sd(xmm0, temp.reg()); |
+ temp.Unuse(); |
+ } |
+ __ ucomisd(xmm1, xmm0); |
+ // Jump to builtin for NaN. |
+ not_number.Branch(parity_even, &left_side); |
+ left_side.Unuse(); |
+ dest->true_target()->Branch(DoubleCondition(cc)); |
+ dest->false_target()->Jump(); |
+ not_number.Bind(&left_side); |
} |
- __ ucomisd(xmm1, xmm0); |
- // Jump to builtin for NaN. |
- not_number.Branch(parity_even, &left_side); |
- left_side.Unuse(); |
- dest->true_target()->Branch(DoubleCondition(cc)); |
+ |
+ // Setup and call the compare stub. |
+ CompareStub stub(cc, strict, kCantBothBeNaN); |
+ Result result = frame_->CallStub(&stub, &left_side, &right_side); |
+ result.ToRegister(); |
+ __ testq(result.reg(), result.reg()); |
+ result.Unuse(); |
+ dest->true_target()->Branch(cc); |
dest->false_target()->Jump(); |
- not_number.Bind(&left_side); |
- } |
- // Setup and call the compare stub. |
- CompareStub stub(cc, strict, kCantBothBeNaN); |
- Result result = frame_->CallStub(&stub, &left_side, &right_side); |
- result.ToRegister(); |
- __ testq(result.reg(), result.reg()); |
- result.Unuse(); |
- dest->true_target()->Branch(cc); |
- dest->false_target()->Jump(); |
+ is_smi.Bind(); |
+ } |
- is_smi.Bind(); |
left_side = Result(left_reg); |
right_side = Result(right_val); |
// Test smi equality and comparison by signed int comparison. |
@@ -5952,7 +5959,7 @@ void CodeGenerator::Comparison(AstNode* node, |
// If the first character is the same then the long string sorts after |
// the short one. |
__ SmiCompare(FieldOperand(left_side.reg(), String::kLengthOffset), |
- Smi::FromInt(1)); |
+ Smi::FromInt(1)); |
__ bind(&characters_were_different); |
} |
temp2.Unuse(); |