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 4560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4571 | 4571 |
4572 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); | 4572 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); |
4573 __ Branch(deferred->entry(), hi, reg, Operand(Smi::kMaxValue)); | 4573 __ Branch(deferred->entry(), hi, reg, Operand(Smi::kMaxValue)); |
4574 __ SmiTag(reg, reg); | 4574 __ SmiTag(reg, reg); |
4575 __ bind(deferred->exit()); | 4575 __ bind(deferred->exit()); |
4576 } | 4576 } |
4577 | 4577 |
4578 | 4578 |
4579 // Convert unsigned integer with specified number of leading zeroes in binary | 4579 // Convert unsigned integer with specified number of leading zeroes in binary |
4580 // representation to IEEE 754 double. | 4580 // representation to IEEE 754 double. |
4581 // Integer to convert is passed in register hiword. | 4581 // Integer to convert is passed in register src. |
4582 // Resulting double is returned in registers hiword:loword. | 4582 // Resulting double is returned in registers hiword:loword. |
4583 // This functions does not work correctly for 0. | 4583 // This functions does not work correctly for 0. |
4584 static void GenerateUInt2Double(MacroAssembler* masm, | 4584 static void GenerateUInt2Double(MacroAssembler* masm, |
| 4585 Register src, |
4585 Register hiword, | 4586 Register hiword, |
4586 Register loword, | 4587 Register loword, |
4587 Register scratch, | 4588 Register scratch, |
4588 int leading_zeroes) { | 4589 int leading_zeroes) { |
4589 const int meaningful_bits = kBitsPerInt - leading_zeroes - 1; | 4590 const int meaningful_bits = kBitsPerInt - leading_zeroes - 1; |
4590 const int biased_exponent = HeapNumber::kExponentBias + meaningful_bits; | 4591 const int biased_exponent = HeapNumber::kExponentBias + meaningful_bits; |
4591 | 4592 |
4592 const int mantissa_shift_for_hi_word = | 4593 const int mantissa_shift_for_hi_word = |
4593 meaningful_bits - HeapNumber::kMantissaBitsInTopWord; | 4594 meaningful_bits - HeapNumber::kMantissaBitsInTopWord; |
4594 const int mantissa_shift_for_lo_word = | 4595 const int mantissa_shift_for_lo_word = |
4595 kBitsPerInt - mantissa_shift_for_hi_word; | 4596 kBitsPerInt - mantissa_shift_for_hi_word; |
4596 masm->li(scratch, Operand(biased_exponent << HeapNumber::kExponentShift)); | 4597 masm->li(scratch, Operand(biased_exponent << HeapNumber::kExponentShift)); |
4597 if (mantissa_shift_for_hi_word > 0) { | 4598 if (mantissa_shift_for_hi_word > 0) { |
4598 masm->sll(loword, hiword, mantissa_shift_for_lo_word); | 4599 masm->sll(loword, src, mantissa_shift_for_lo_word); |
4599 masm->srl(hiword, hiword, mantissa_shift_for_hi_word); | 4600 masm->srl(hiword, src, mantissa_shift_for_hi_word); |
4600 masm->Or(hiword, scratch, hiword); | 4601 masm->Or(hiword, scratch, hiword); |
4601 } else { | 4602 } else { |
4602 masm->mov(loword, zero_reg); | 4603 masm->mov(loword, zero_reg); |
4603 masm->sll(hiword, hiword, mantissa_shift_for_hi_word); | 4604 masm->sll(hiword, src, mantissa_shift_for_hi_word); |
4604 masm->Or(hiword, scratch, hiword); | 4605 masm->Or(hiword, scratch, hiword); |
4605 } | 4606 } |
4606 | 4607 |
4607 // If least significant bit of biased exponent was not 1 it was corrupted | 4608 // If least significant bit of biased exponent was not 1 it was corrupted |
4608 // by most significant bit of mantissa so we should fix that. | 4609 // by most significant bit of mantissa so we should fix that. |
4609 if (!(biased_exponent & 1)) { | 4610 if (!(biased_exponent & 1)) { |
4610 masm->li(scratch, 1 << HeapNumber::kExponentShift); | 4611 masm->li(scratch, 1 << HeapNumber::kExponentShift); |
4611 masm->nor(scratch, scratch, scratch); | 4612 masm->nor(scratch, scratch, scratch); |
4612 masm->and_(hiword, hiword, scratch); | 4613 masm->and_(hiword, hiword, scratch); |
4613 } | 4614 } |
(...skipping 30 matching lines...) Expand all Loading... |
4644 FloatingPointHelper::ConvertIntToDouble(masm(), src, dest, f0, | 4645 FloatingPointHelper::ConvertIntToDouble(masm(), src, dest, f0, |
4645 sfpd_lo, sfpd_hi, | 4646 sfpd_lo, sfpd_hi, |
4646 scratch0(), f2); | 4647 scratch0(), f2); |
4647 } | 4648 } |
4648 } else { | 4649 } else { |
4649 if (CpuFeatures::IsSupported(FPU)) { | 4650 if (CpuFeatures::IsSupported(FPU)) { |
4650 CpuFeatureScope scope(masm(), FPU); | 4651 CpuFeatureScope scope(masm(), FPU); |
4651 __ mtc1(src, dbl_scratch); | 4652 __ mtc1(src, dbl_scratch); |
4652 __ Cvt_d_uw(dbl_scratch, dbl_scratch, f22); | 4653 __ Cvt_d_uw(dbl_scratch, dbl_scratch, f22); |
4653 } else { | 4654 } else { |
4654 Label no_leading_zero, done; | 4655 Label no_leading_zero, convert_done; |
4655 __ And(at, src, Operand(0x80000000)); | 4656 __ And(at, src, Operand(0x80000000)); |
4656 __ Branch(&no_leading_zero, ne, at, Operand(zero_reg)); | 4657 __ Branch(&no_leading_zero, ne, at, Operand(zero_reg)); |
4657 | 4658 |
4658 // Integer has one leading zeros. | 4659 // Integer has one leading zeros. |
4659 GenerateUInt2Double(masm(), sfpd_hi, sfpd_lo, t0, 1); | 4660 GenerateUInt2Double(masm(), src, sfpd_hi, sfpd_lo, t0, 1); |
4660 __ Branch(&done); | 4661 __ Branch(&convert_done); |
4661 | 4662 |
4662 __ bind(&no_leading_zero); | 4663 __ bind(&no_leading_zero); |
4663 GenerateUInt2Double(masm(), sfpd_hi, sfpd_lo, t0, 0); | 4664 GenerateUInt2Double(masm(), src, sfpd_hi, sfpd_lo, t0, 0); |
4664 __ Branch(&done); | 4665 __ bind(&convert_done); |
4665 } | 4666 } |
4666 } | 4667 } |
4667 | 4668 |
4668 if (FLAG_inline_new) { | 4669 if (FLAG_inline_new) { |
4669 __ LoadRoot(scratch0(), Heap::kHeapNumberMapRootIndex); | 4670 __ LoadRoot(scratch0(), Heap::kHeapNumberMapRootIndex); |
4670 __ AllocateHeapNumber(t1, a3, t0, scratch0(), &slow, DONT_TAG_RESULT); | 4671 __ AllocateHeapNumber(t1, a3, t0, scratch0(), &slow, DONT_TAG_RESULT); |
4671 __ Move(dst, t1); | 4672 __ Move(dst, t1); |
4672 __ Branch(&done); | 4673 __ Branch(&done); |
4673 } | 4674 } |
4674 | 4675 |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6106 __ Subu(scratch, result, scratch); | 6107 __ Subu(scratch, result, scratch); |
6107 __ lw(result, FieldMemOperand(scratch, | 6108 __ lw(result, FieldMemOperand(scratch, |
6108 FixedArray::kHeaderSize - kPointerSize)); | 6109 FixedArray::kHeaderSize - kPointerSize)); |
6109 __ bind(&done); | 6110 __ bind(&done); |
6110 } | 6111 } |
6111 | 6112 |
6112 | 6113 |
6113 #undef __ | 6114 #undef __ |
6114 | 6115 |
6115 } } // namespace v8::internal | 6116 } } // namespace v8::internal |
OLD | NEW |