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 4783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4794 } | 4794 } |
4795 | 4795 |
4796 | 4796 |
4797 void LCodeGen::EmitNumberUntagD(Register input_reg, | 4797 void LCodeGen::EmitNumberUntagD(Register input_reg, |
4798 DoubleRegister result_reg, | 4798 DoubleRegister result_reg, |
4799 bool can_convert_undefined_to_nan, | 4799 bool can_convert_undefined_to_nan, |
4800 bool deoptimize_on_minus_zero, | 4800 bool deoptimize_on_minus_zero, |
4801 LEnvironment* env, | 4801 LEnvironment* env, |
4802 NumberUntagDMode mode) { | 4802 NumberUntagDMode mode) { |
4803 Register scratch = scratch0(); | 4803 Register scratch = scratch0(); |
4804 | 4804 Label convert, load_smi, done; |
4805 Label load_smi, heap_number, done; | |
4806 | |
4807 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { | 4805 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
4808 // Smi check. | 4806 // Smi check. |
4809 __ UntagAndJumpIfSmi(scratch, input_reg, &load_smi); | 4807 __ UntagAndJumpIfSmi(scratch, input_reg, &load_smi); |
4810 | |
4811 // Heap number map check. | 4808 // Heap number map check. |
4812 __ lw(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 4809 __ lw(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); |
4813 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | 4810 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
4814 if (!can_convert_undefined_to_nan) { | 4811 if (can_convert_undefined_to_nan) { |
| 4812 __ Branch(&convert, ne, scratch, Operand(at)); |
| 4813 } else { |
4815 DeoptimizeIf(ne, env, scratch, Operand(at)); | 4814 DeoptimizeIf(ne, env, scratch, Operand(at)); |
4816 } else { | |
4817 Label heap_number, convert; | |
4818 __ Branch(&heap_number, eq, scratch, Operand(at)); | |
4819 | |
4820 // Convert undefined (and hole) to NaN. | |
4821 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | |
4822 DeoptimizeIf(ne, env, input_reg, Operand(at)); | |
4823 | |
4824 __ bind(&convert); | |
4825 __ LoadRoot(at, Heap::kNanValueRootIndex); | |
4826 __ ldc1(result_reg, FieldMemOperand(at, HeapNumber::kValueOffset)); | |
4827 __ Branch(&done); | |
4828 | |
4829 __ bind(&heap_number); | |
4830 } | 4815 } |
4831 // Heap number to double register conversion. | 4816 // Load heap number. |
4832 __ ldc1(result_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); | 4817 __ ldc1(result_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); |
4833 if (deoptimize_on_minus_zero) { | 4818 if (deoptimize_on_minus_zero) { |
4834 __ mfc1(at, result_reg.low()); | 4819 __ mfc1(at, result_reg.low()); |
4835 __ Branch(&done, ne, at, Operand(zero_reg)); | 4820 __ Branch(&done, ne, at, Operand(zero_reg)); |
4836 __ mfc1(scratch, result_reg.high()); | 4821 __ mfc1(scratch, result_reg.high()); |
4837 DeoptimizeIf(eq, env, scratch, Operand(HeapNumber::kSignMask)); | 4822 DeoptimizeIf(eq, env, scratch, Operand(HeapNumber::kSignMask)); |
4838 } | 4823 } |
4839 __ Branch(&done); | 4824 __ Branch(&done); |
| 4825 if (can_convert_undefined_to_nan) { |
| 4826 __ bind(&convert); |
| 4827 // Convert undefined (and hole) to NaN. |
| 4828 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
| 4829 DeoptimizeIf(ne, env, input_reg, Operand(at)); |
| 4830 __ LoadRoot(scratch, Heap::kNanValueRootIndex); |
| 4831 __ ldc1(result_reg, FieldMemOperand(scratch, HeapNumber::kValueOffset)); |
| 4832 __ Branch(&done); |
| 4833 } |
4840 } else { | 4834 } else { |
4841 __ SmiUntag(scratch, input_reg); | 4835 __ SmiUntag(scratch, input_reg); |
4842 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); | 4836 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); |
4843 } | 4837 } |
4844 | |
4845 // Smi to double register conversion | 4838 // Smi to double register conversion |
4846 __ bind(&load_smi); | 4839 __ bind(&load_smi); |
4847 // scratch: untagged value of input_reg | 4840 // scratch: untagged value of input_reg |
4848 __ mtc1(scratch, result_reg); | 4841 __ mtc1(scratch, result_reg); |
4849 __ cvt_d_w(result_reg, result_reg); | 4842 __ cvt_d_w(result_reg, result_reg); |
4850 __ bind(&done); | 4843 __ bind(&done); |
4851 } | 4844 } |
4852 | 4845 |
4853 | 4846 |
4854 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 4847 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5780 __ Subu(scratch, result, scratch); | 5773 __ Subu(scratch, result, scratch); |
5781 __ lw(result, FieldMemOperand(scratch, | 5774 __ lw(result, FieldMemOperand(scratch, |
5782 FixedArray::kHeaderSize - kPointerSize)); | 5775 FixedArray::kHeaderSize - kPointerSize)); |
5783 __ bind(&done); | 5776 __ bind(&done); |
5784 } | 5777 } |
5785 | 5778 |
5786 | 5779 |
5787 #undef __ | 5780 #undef __ |
5788 | 5781 |
5789 } } // namespace v8::internal | 5782 } } // namespace v8::internal |
OLD | NEW |