Index: src/crankshaft/x87/lithium-codegen-x87.cc |
diff --git a/src/crankshaft/x87/lithium-codegen-x87.cc b/src/crankshaft/x87/lithium-codegen-x87.cc |
index 0edaaa4ce11d26952dfa7e3059a60ff589544e18..d542143cc835738db18d09c9515d709c8f8cf2d1 100644 |
--- a/src/crankshaft/x87/lithium-codegen-x87.cc |
+++ b/src/crankshaft/x87/lithium-codegen-x87.cc |
@@ -4672,34 +4672,18 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
__ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); |
if (instr->truncating()) { |
- Label no_heap_number, check_bools, check_false; |
- |
- // Heap number map check. |
+ Label truncate; |
+ Label::Distance truncate_distance = |
+ DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
__ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
factory()->heap_number_map()); |
- __ j(not_equal, &no_heap_number, Label::kNear); |
+ __ j(equal, &truncate, truncate_distance); |
+ __ push(input_reg); |
+ __ CmpObjectType(input_reg, ODDBALL_TYPE, input_reg); |
+ __ pop(input_reg); |
+ DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotANumberOrOddball); |
+ __ bind(&truncate); |
__ TruncateHeapNumberToI(input_reg, input_reg); |
- __ jmp(done); |
- |
- __ bind(&no_heap_number); |
- // Check for Oddballs. Undefined/False is converted to zero and True to one |
- // for truncating conversions. |
- __ cmp(input_reg, factory()->undefined_value()); |
- __ j(not_equal, &check_bools, Label::kNear); |
- __ Move(input_reg, Immediate(0)); |
- __ jmp(done); |
- |
- __ bind(&check_bools); |
- __ cmp(input_reg, factory()->true_value()); |
- __ j(not_equal, &check_false, Label::kNear); |
- __ Move(input_reg, Immediate(1)); |
- __ jmp(done); |
- |
- __ bind(&check_false); |
- __ cmp(input_reg, factory()->false_value()); |
- DeoptimizeIf(not_equal, instr, |
- DeoptimizeReason::kNotAHeapNumberUndefinedBoolean); |
- __ Move(input_reg, Immediate(0)); |
} else { |
// TODO(olivf) Converting a number on the fpu is actually quite slow. We |
// should first try a fast conversion and then bailout to this slow case. |