OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 __ tst(value, Operand(kSmiTagMask)); | 1772 __ tst(value, Operand(kSmiTagMask)); |
1773 __ Ret(eq); | 1773 __ Ret(eq); |
1774 // Update write barrier for the elements array address. | 1774 // Update write barrier for the elements array address. |
1775 __ sub(r4, r5, Operand(elements)); | 1775 __ sub(r4, r5, Operand(elements)); |
1776 __ RecordWrite(elements, Operand(r4), r5, r6); | 1776 __ RecordWrite(elements, Operand(r4), r5, r6); |
1777 | 1777 |
1778 __ Ret(); | 1778 __ Ret(); |
1779 } | 1779 } |
1780 | 1780 |
1781 | 1781 |
1782 // Convert int passed in register ival to IEE 754 single precision | 1782 // Convert and store int passed in register ival to IEEE 754 single precision |
1783 // floating point value and store it into register fval. | 1783 // floating point value at memory location (dst + 4 * wordoffset) |
1784 // If VFP3 is available use it for conversion. | 1784 // If VFP3 is available use it for conversion. |
1785 static void ConvertIntToFloat(MacroAssembler* masm, | 1785 static void StoreIntAsFloat(MacroAssembler* masm, |
1786 Register ival, | 1786 Register dst, |
1787 Register fval, | 1787 Register wordoffset, |
1788 Register scratch1, | 1788 Register ival, |
1789 Register scratch2) { | 1789 Register fval, |
| 1790 Register scratch1, |
| 1791 Register scratch2) { |
1790 if (CpuFeatures::IsSupported(VFP3)) { | 1792 if (CpuFeatures::IsSupported(VFP3)) { |
1791 CpuFeatures::Scope scope(VFP3); | 1793 CpuFeatures::Scope scope(VFP3); |
1792 __ vmov(s0, ival); | 1794 __ vmov(s0, ival); |
| 1795 __ add(scratch1, dst, Operand(wordoffset, LSL, 2)); |
1793 __ vcvt_f32_s32(s0, s0); | 1796 __ vcvt_f32_s32(s0, s0); |
1794 __ vmov(fval, s0); | 1797 __ vstr(s0, scratch1, 0); |
1795 } else { | 1798 } else { |
1796 Label not_special, done; | 1799 Label not_special, done; |
1797 // Move sign bit from source to destination. This works because the sign | 1800 // Move sign bit from source to destination. This works because the sign |
1798 // bit in the exponent word of the double has the same position and polarity | 1801 // bit in the exponent word of the double has the same position and polarity |
1799 // as the 2's complement sign bit in a Smi. | 1802 // as the 2's complement sign bit in a Smi. |
1800 ASSERT(kBinary32SignMask == 0x80000000u); | 1803 ASSERT(kBinary32SignMask == 0x80000000u); |
1801 | 1804 |
1802 __ and_(fval, ival, Operand(kBinary32SignMask), SetCC); | 1805 __ and_(fval, ival, Operand(kBinary32SignMask), SetCC); |
1803 // Negate value if it is negative. | 1806 // Negate value if it is negative. |
1804 __ rsb(ival, ival, Operand(0), LeaveCC, ne); | 1807 __ rsb(ival, ival, Operand(0), LeaveCC, ne); |
(...skipping 29 matching lines...) Expand all Loading... |
1834 // Shift up the source chopping the top bit off. | 1837 // Shift up the source chopping the top bit off. |
1835 __ add(zeros, zeros, Operand(1)); | 1838 __ add(zeros, zeros, Operand(1)); |
1836 // This wouldn't work for 1 and -1 as the shift would be 32 which means 0. | 1839 // This wouldn't work for 1 and -1 as the shift would be 32 which means 0. |
1837 __ mov(ival, Operand(ival, LSL, zeros)); | 1840 __ mov(ival, Operand(ival, LSL, zeros)); |
1838 // And the top (top 20 bits). | 1841 // And the top (top 20 bits). |
1839 __ orr(fval, | 1842 __ orr(fval, |
1840 fval, | 1843 fval, |
1841 Operand(ival, LSR, kBitsPerInt - kBinary32MantissaBits)); | 1844 Operand(ival, LSR, kBitsPerInt - kBinary32MantissaBits)); |
1842 | 1845 |
1843 __ bind(&done); | 1846 __ bind(&done); |
| 1847 __ str(fval, MemOperand(dst, wordoffset, LSL, 2)); |
1844 } | 1848 } |
1845 } | 1849 } |
1846 | 1850 |
1847 | 1851 |
1848 static bool IsElementTypeSigned(ExternalArrayType array_type) { | 1852 static bool IsElementTypeSigned(ExternalArrayType array_type) { |
1849 switch (array_type) { | 1853 switch (array_type) { |
1850 case kExternalByteArray: | 1854 case kExternalByteArray: |
1851 case kExternalShortArray: | 1855 case kExternalShortArray: |
1852 case kExternalIntArray: | 1856 case kExternalIntArray: |
1853 return true; | 1857 return true; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 break; | 1932 break; |
1929 case kExternalShortArray: | 1933 case kExternalShortArray: |
1930 case kExternalUnsignedShortArray: | 1934 case kExternalUnsignedShortArray: |
1931 __ strh(r5, MemOperand(r3, r4, LSL, 1)); | 1935 __ strh(r5, MemOperand(r3, r4, LSL, 1)); |
1932 break; | 1936 break; |
1933 case kExternalIntArray: | 1937 case kExternalIntArray: |
1934 case kExternalUnsignedIntArray: | 1938 case kExternalUnsignedIntArray: |
1935 __ str(r5, MemOperand(r3, r4, LSL, 2)); | 1939 __ str(r5, MemOperand(r3, r4, LSL, 2)); |
1936 break; | 1940 break; |
1937 case kExternalFloatArray: | 1941 case kExternalFloatArray: |
1938 // Need to perform int-to-float conversion. | 1942 // Perform int-to-float conversion and store to memory. |
1939 ConvertIntToFloat(masm, r5, r6, r7, r9); | 1943 StoreIntAsFloat(masm, r3, r4, r5, r6, r7, r9); |
1940 __ str(r6, MemOperand(r3, r4, LSL, 2)); | |
1941 break; | 1944 break; |
1942 default: | 1945 default: |
1943 UNREACHABLE(); | 1946 UNREACHABLE(); |
1944 break; | 1947 break; |
1945 } | 1948 } |
1946 | 1949 |
1947 // Entry registers are intact, r0 holds the value which is the return value. | 1950 // Entry registers are intact, r0 holds the value which is the return value. |
1948 __ Ret(); | 1951 __ Ret(); |
1949 | 1952 |
1950 | 1953 |
(...skipping 13 matching lines...) Expand all Loading... |
1964 // reproducible behavior, convert these to zero. | 1967 // reproducible behavior, convert these to zero. |
1965 if (CpuFeatures::IsSupported(VFP3)) { | 1968 if (CpuFeatures::IsSupported(VFP3)) { |
1966 CpuFeatures::Scope scope(VFP3); | 1969 CpuFeatures::Scope scope(VFP3); |
1967 | 1970 |
1968 | 1971 |
1969 if (array_type == kExternalFloatArray) { | 1972 if (array_type == kExternalFloatArray) { |
1970 // vldr requires offset to be a multiple of 4 so we can not | 1973 // vldr requires offset to be a multiple of 4 so we can not |
1971 // include -kHeapObjectTag into it. | 1974 // include -kHeapObjectTag into it. |
1972 __ sub(r5, r0, Operand(kHeapObjectTag)); | 1975 __ sub(r5, r0, Operand(kHeapObjectTag)); |
1973 __ vldr(d0, r5, HeapNumber::kValueOffset); | 1976 __ vldr(d0, r5, HeapNumber::kValueOffset); |
| 1977 __ add(r5, r3, Operand(r4, LSL, 2)); |
1974 __ vcvt_f32_f64(s0, d0); | 1978 __ vcvt_f32_f64(s0, d0); |
1975 __ vmov(r5, s0); | 1979 __ vstr(s0, r5, 0); |
1976 __ str(r5, MemOperand(r3, r4, LSL, 2)); | |
1977 } else { | 1980 } else { |
1978 // Need to perform float-to-int conversion. | 1981 // Need to perform float-to-int conversion. |
1979 // Test for NaN or infinity (both give zero). | 1982 // Test for NaN or infinity (both give zero). |
1980 __ ldr(r6, FieldMemOperand(r5, HeapNumber::kExponentOffset)); | 1983 __ ldr(r6, FieldMemOperand(r5, HeapNumber::kExponentOffset)); |
1981 | 1984 |
1982 // Hoisted load. vldr requires offset to be a multiple of 4 so we can not | 1985 // Hoisted load. vldr requires offset to be a multiple of 4 so we can not |
1983 // include -kHeapObjectTag into it. | 1986 // include -kHeapObjectTag into it. |
1984 __ sub(r5, r0, Operand(kHeapObjectTag)); | 1987 __ sub(r5, r0, Operand(kHeapObjectTag)); |
1985 __ vldr(d0, r5, HeapNumber::kValueOffset); | 1988 __ vldr(d0, r5, HeapNumber::kValueOffset); |
1986 | 1989 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 GenerateMiss(masm); | 2259 GenerateMiss(masm); |
2257 } | 2260 } |
2258 | 2261 |
2259 | 2262 |
2260 #undef __ | 2263 #undef __ |
2261 | 2264 |
2262 | 2265 |
2263 } } // namespace v8::internal | 2266 } } // namespace v8::internal |
2264 | 2267 |
2265 #endif // V8_TARGET_ARCH_ARM | 2268 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |