OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/crankshaft/x87/lithium-codegen-x87.h" | 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 4654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4665 | 4665 |
4666 | 4666 |
4667 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { | 4667 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
4668 Register input_reg = ToRegister(instr->value()); | 4668 Register input_reg = ToRegister(instr->value()); |
4669 | 4669 |
4670 // The input was optimistically untagged; revert it. | 4670 // The input was optimistically untagged; revert it. |
4671 STATIC_ASSERT(kSmiTagSize == 1); | 4671 STATIC_ASSERT(kSmiTagSize == 1); |
4672 __ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); | 4672 __ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); |
4673 | 4673 |
4674 if (instr->truncating()) { | 4674 if (instr->truncating()) { |
4675 Label no_heap_number, check_bools, check_false; | 4675 Label truncate; |
4676 | 4676 Label::Distance truncate_distance = |
4677 // Heap number map check. | 4677 DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
4678 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 4678 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
4679 factory()->heap_number_map()); | 4679 factory()->heap_number_map()); |
4680 __ j(not_equal, &no_heap_number, Label::kNear); | 4680 __ j(equal, &truncate, truncate_distance); |
| 4681 __ push(input_reg); |
| 4682 __ CmpObjectType(input_reg, ODDBALL_TYPE, input_reg); |
| 4683 __ pop(input_reg); |
| 4684 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotANumberOrOddball); |
| 4685 __ bind(&truncate); |
4681 __ TruncateHeapNumberToI(input_reg, input_reg); | 4686 __ TruncateHeapNumberToI(input_reg, input_reg); |
4682 __ jmp(done); | |
4683 | |
4684 __ bind(&no_heap_number); | |
4685 // Check for Oddballs. Undefined/False is converted to zero and True to one | |
4686 // for truncating conversions. | |
4687 __ cmp(input_reg, factory()->undefined_value()); | |
4688 __ j(not_equal, &check_bools, Label::kNear); | |
4689 __ Move(input_reg, Immediate(0)); | |
4690 __ jmp(done); | |
4691 | |
4692 __ bind(&check_bools); | |
4693 __ cmp(input_reg, factory()->true_value()); | |
4694 __ j(not_equal, &check_false, Label::kNear); | |
4695 __ Move(input_reg, Immediate(1)); | |
4696 __ jmp(done); | |
4697 | |
4698 __ bind(&check_false); | |
4699 __ cmp(input_reg, factory()->false_value()); | |
4700 DeoptimizeIf(not_equal, instr, | |
4701 DeoptimizeReason::kNotAHeapNumberUndefinedBoolean); | |
4702 __ Move(input_reg, Immediate(0)); | |
4703 } else { | 4687 } else { |
4704 // TODO(olivf) Converting a number on the fpu is actually quite slow. We | 4688 // TODO(olivf) Converting a number on the fpu is actually quite slow. We |
4705 // should first try a fast conversion and then bailout to this slow case. | 4689 // should first try a fast conversion and then bailout to this slow case. |
4706 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 4690 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
4707 isolate()->factory()->heap_number_map()); | 4691 isolate()->factory()->heap_number_map()); |
4708 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotAHeapNumber); | 4692 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotAHeapNumber); |
4709 | 4693 |
4710 __ sub(esp, Immediate(kPointerSize)); | 4694 __ sub(esp, Immediate(kPointerSize)); |
4711 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4695 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4712 | 4696 |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5657 __ bind(deferred->exit()); | 5641 __ bind(deferred->exit()); |
5658 __ bind(&done); | 5642 __ bind(&done); |
5659 } | 5643 } |
5660 | 5644 |
5661 #undef __ | 5645 #undef __ |
5662 | 5646 |
5663 } // namespace internal | 5647 } // namespace internal |
5664 } // namespace v8 | 5648 } // namespace v8 |
5665 | 5649 |
5666 #endif // V8_TARGET_ARCH_X87 | 5650 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |