OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3692 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 3692 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
3693 if (instr->needs_check()) { | 3693 if (instr->needs_check()) { |
3694 __ test(ToRegister(input), Immediate(kSmiTagMask)); | 3694 __ test(ToRegister(input), Immediate(kSmiTagMask)); |
3695 DeoptimizeIf(not_zero, instr->environment()); | 3695 DeoptimizeIf(not_zero, instr->environment()); |
3696 } | 3696 } |
3697 __ SmiUntag(ToRegister(input)); | 3697 __ SmiUntag(ToRegister(input)); |
3698 } | 3698 } |
3699 | 3699 |
3700 | 3700 |
3701 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3701 void LCodeGen::EmitNumberUntagD(Register input_reg, |
| 3702 Register temp_reg, |
3702 XMMRegister result_reg, | 3703 XMMRegister result_reg, |
3703 bool deoptimize_on_undefined, | 3704 bool deoptimize_on_undefined, |
| 3705 bool deoptimize_on_minus_zero, |
3704 LEnvironment* env) { | 3706 LEnvironment* env) { |
3705 Label load_smi, done; | 3707 Label load_smi, done; |
3706 | 3708 |
3707 // Smi check. | 3709 // Smi check. |
3708 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 3710 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
3709 | 3711 |
3710 // Heap number map check. | 3712 // Heap number map check. |
3711 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 3713 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
3712 factory()->heap_number_map()); | 3714 factory()->heap_number_map()); |
3713 if (deoptimize_on_undefined) { | 3715 if (deoptimize_on_undefined) { |
3714 DeoptimizeIf(not_equal, env); | 3716 DeoptimizeIf(not_equal, env); |
3715 } else { | 3717 } else { |
3716 Label heap_number; | 3718 Label heap_number; |
3717 __ j(equal, &heap_number, Label::kNear); | 3719 __ j(equal, &heap_number, Label::kNear); |
3718 | 3720 |
3719 __ cmp(input_reg, factory()->undefined_value()); | 3721 __ cmp(input_reg, factory()->undefined_value()); |
3720 DeoptimizeIf(not_equal, env); | 3722 DeoptimizeIf(not_equal, env); |
3721 | 3723 |
3722 // Convert undefined to NaN. | 3724 // Convert undefined to NaN. |
3723 ExternalReference nan = | 3725 ExternalReference nan = |
3724 ExternalReference::address_of_canonical_non_hole_nan(); | 3726 ExternalReference::address_of_canonical_non_hole_nan(); |
3725 __ movdbl(result_reg, Operand::StaticVariable(nan)); | 3727 __ movdbl(result_reg, Operand::StaticVariable(nan)); |
3726 __ jmp(&done, Label::kNear); | 3728 __ jmp(&done, Label::kNear); |
3727 | 3729 |
3728 __ bind(&heap_number); | 3730 __ bind(&heap_number); |
3729 } | 3731 } |
3730 // Heap number to XMM conversion. | 3732 // Heap number to XMM conversion. |
3731 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 3733 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 3734 if (deoptimize_on_minus_zero) { |
| 3735 XMMRegister xmm_scratch = xmm0; |
| 3736 __ xorps(xmm_scratch, xmm_scratch); |
| 3737 __ ucomisd(result_reg, xmm_scratch); |
| 3738 __ j(not_zero, &done, Label::kNear); |
| 3739 __ movmskpd(temp_reg, result_reg); |
| 3740 __ test_b(temp_reg, 1); |
| 3741 DeoptimizeIf(not_zero, env); |
| 3742 } |
3732 __ jmp(&done, Label::kNear); | 3743 __ jmp(&done, Label::kNear); |
3733 | 3744 |
3734 // Smi to XMM conversion | 3745 // Smi to XMM conversion |
3735 __ bind(&load_smi); | 3746 __ bind(&load_smi); |
3736 __ SmiUntag(input_reg); // Untag smi before converting to float. | 3747 __ SmiUntag(input_reg); // Untag smi before converting to float. |
3737 __ cvtsi2sd(result_reg, Operand(input_reg)); | 3748 __ cvtsi2sd(result_reg, Operand(input_reg)); |
3738 __ SmiTag(input_reg); // Retag smi. | 3749 __ SmiTag(input_reg); // Retag smi. |
3739 __ bind(&done); | 3750 __ bind(&done); |
3740 } | 3751 } |
3741 | 3752 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3844 // Smi to int32 conversion | 3855 // Smi to int32 conversion |
3845 __ SmiUntag(input_reg); // Untag smi. | 3856 __ SmiUntag(input_reg); // Untag smi. |
3846 | 3857 |
3847 __ bind(deferred->exit()); | 3858 __ bind(deferred->exit()); |
3848 } | 3859 } |
3849 | 3860 |
3850 | 3861 |
3851 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3862 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
3852 LOperand* input = instr->InputAt(0); | 3863 LOperand* input = instr->InputAt(0); |
3853 ASSERT(input->IsRegister()); | 3864 ASSERT(input->IsRegister()); |
| 3865 LOperand* temp = instr->TempAt(0); |
| 3866 ASSERT(temp == NULL || temp->IsRegister()); |
3854 LOperand* result = instr->result(); | 3867 LOperand* result = instr->result(); |
3855 ASSERT(result->IsDoubleRegister()); | 3868 ASSERT(result->IsDoubleRegister()); |
3856 | 3869 |
3857 Register input_reg = ToRegister(input); | 3870 Register input_reg = ToRegister(input); |
3858 XMMRegister result_reg = ToDoubleRegister(result); | 3871 XMMRegister result_reg = ToDoubleRegister(result); |
3859 | 3872 |
3860 EmitNumberUntagD(input_reg, result_reg, | 3873 bool deoptimize_on_minus_zero = |
| 3874 instr->hydrogen()->deoptimize_on_minus_zero(); |
| 3875 Register temp_reg = deoptimize_on_minus_zero ? ToRegister(temp) : no_reg; |
| 3876 |
| 3877 EmitNumberUntagD(input_reg, |
| 3878 temp_reg, |
| 3879 result_reg, |
3861 instr->hydrogen()->deoptimize_on_undefined(), | 3880 instr->hydrogen()->deoptimize_on_undefined(), |
| 3881 deoptimize_on_minus_zero, |
3862 instr->environment()); | 3882 instr->environment()); |
3863 } | 3883 } |
3864 | 3884 |
3865 | 3885 |
3866 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 3886 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
3867 LOperand* input = instr->InputAt(0); | 3887 LOperand* input = instr->InputAt(0); |
3868 ASSERT(input->IsDoubleRegister()); | 3888 ASSERT(input->IsDoubleRegister()); |
3869 LOperand* result = instr->result(); | 3889 LOperand* result = instr->result(); |
3870 ASSERT(result->IsRegister()); | 3890 ASSERT(result->IsRegister()); |
3871 | 3891 |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4642 this, pointers, Safepoint::kLazyDeopt); | 4662 this, pointers, Safepoint::kLazyDeopt); |
4643 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4663 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4644 } | 4664 } |
4645 | 4665 |
4646 | 4666 |
4647 #undef __ | 4667 #undef __ |
4648 | 4668 |
4649 } } // namespace v8::internal | 4669 } } // namespace v8::internal |
4650 | 4670 |
4651 #endif // V8_TARGET_ARCH_IA32 | 4671 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |