| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 } | 714 } |
| 715 | 715 |
| 716 | 716 |
| 717 typedef int (*F6)(float x, float y); | 717 typedef int (*F6)(float x, float y); |
| 718 TEST(AssemblerX64SSE) { | 718 TEST(AssemblerX64SSE) { |
| 719 CcTest::InitializeVM(); | 719 CcTest::InitializeVM(); |
| 720 | 720 |
| 721 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 721 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 722 HandleScope scope(isolate); | 722 HandleScope scope(isolate); |
| 723 v8::internal::byte buffer[256]; | 723 v8::internal::byte buffer[256]; |
| 724 MacroAssembler assm(isolate, buffer, sizeof buffer); | 724 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 725 v8::internal::CodeObjectRequired::kYes); |
| 725 { | 726 { |
| 726 __ shufps(xmm0, xmm0, 0x0); // brocast first argument | 727 __ shufps(xmm0, xmm0, 0x0); // brocast first argument |
| 727 __ shufps(xmm1, xmm1, 0x0); // brocast second argument | 728 __ shufps(xmm1, xmm1, 0x0); // brocast second argument |
| 728 __ movaps(xmm2, xmm1); | 729 __ movaps(xmm2, xmm1); |
| 729 __ addps(xmm2, xmm0); | 730 __ addps(xmm2, xmm0); |
| 730 __ mulps(xmm2, xmm1); | 731 __ mulps(xmm2, xmm1); |
| 731 __ subps(xmm2, xmm0); | 732 __ subps(xmm2, xmm0); |
| 732 __ divps(xmm2, xmm1); | 733 __ divps(xmm2, xmm1); |
| 733 __ cvttss2si(rax, xmm2); | 734 __ cvttss2si(rax, xmm2); |
| 734 __ ret(0); | 735 __ ret(0); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 751 | 752 |
| 752 | 753 |
| 753 typedef int (*F7)(double x, double y, double z); | 754 typedef int (*F7)(double x, double y, double z); |
| 754 TEST(AssemblerX64FMA_sd) { | 755 TEST(AssemblerX64FMA_sd) { |
| 755 CcTest::InitializeVM(); | 756 CcTest::InitializeVM(); |
| 756 if (!CpuFeatures::IsSupported(FMA3)) return; | 757 if (!CpuFeatures::IsSupported(FMA3)) return; |
| 757 | 758 |
| 758 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 759 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 759 HandleScope scope(isolate); | 760 HandleScope scope(isolate); |
| 760 v8::internal::byte buffer[1024]; | 761 v8::internal::byte buffer[1024]; |
| 761 MacroAssembler assm(isolate, buffer, sizeof buffer); | 762 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 763 v8::internal::CodeObjectRequired::kYes); |
| 762 { | 764 { |
| 763 CpuFeatureScope fscope(&assm, FMA3); | 765 CpuFeatureScope fscope(&assm, FMA3); |
| 764 Label exit; | 766 Label exit; |
| 765 // argument in xmm0, xmm1 and xmm2 | 767 // argument in xmm0, xmm1 and xmm2 |
| 766 // xmm0 * xmm1 + xmm2 | 768 // xmm0 * xmm1 + xmm2 |
| 767 __ movaps(xmm3, xmm0); | 769 __ movaps(xmm3, xmm0); |
| 768 __ mulsd(xmm3, xmm1); | 770 __ mulsd(xmm3, xmm1); |
| 769 __ addsd(xmm3, xmm2); // Expected result in xmm3 | 771 __ addsd(xmm3, xmm2); // Expected result in xmm3 |
| 770 | 772 |
| 771 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand | 773 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 | 978 |
| 977 | 979 |
| 978 typedef int (*F8)(float x, float y, float z); | 980 typedef int (*F8)(float x, float y, float z); |
| 979 TEST(AssemblerX64FMA_ss) { | 981 TEST(AssemblerX64FMA_ss) { |
| 980 CcTest::InitializeVM(); | 982 CcTest::InitializeVM(); |
| 981 if (!CpuFeatures::IsSupported(FMA3)) return; | 983 if (!CpuFeatures::IsSupported(FMA3)) return; |
| 982 | 984 |
| 983 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 985 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 984 HandleScope scope(isolate); | 986 HandleScope scope(isolate); |
| 985 v8::internal::byte buffer[1024]; | 987 v8::internal::byte buffer[1024]; |
| 986 MacroAssembler assm(isolate, buffer, sizeof buffer); | 988 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 989 v8::internal::CodeObjectRequired::kYes); |
| 987 { | 990 { |
| 988 CpuFeatureScope fscope(&assm, FMA3); | 991 CpuFeatureScope fscope(&assm, FMA3); |
| 989 Label exit; | 992 Label exit; |
| 990 // arguments in xmm0, xmm1 and xmm2 | 993 // arguments in xmm0, xmm1 and xmm2 |
| 991 // xmm0 * xmm1 + xmm2 | 994 // xmm0 * xmm1 + xmm2 |
| 992 __ movaps(xmm3, xmm0); | 995 __ movaps(xmm3, xmm0); |
| 993 __ mulss(xmm3, xmm1); | 996 __ mulss(xmm3, xmm1); |
| 994 __ addss(xmm3, xmm2); // Expected result in xmm3 | 997 __ addss(xmm3, xmm2); // Expected result in xmm3 |
| 995 | 998 |
| 996 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand | 999 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 } | 1604 } |
| 1602 | 1605 |
| 1603 | 1606 |
| 1604 TEST(AssemblerX64BMI1) { | 1607 TEST(AssemblerX64BMI1) { |
| 1605 CcTest::InitializeVM(); | 1608 CcTest::InitializeVM(); |
| 1606 if (!CpuFeatures::IsSupported(BMI1)) return; | 1609 if (!CpuFeatures::IsSupported(BMI1)) return; |
| 1607 | 1610 |
| 1608 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1611 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1609 HandleScope scope(isolate); | 1612 HandleScope scope(isolate); |
| 1610 v8::internal::byte buffer[1024]; | 1613 v8::internal::byte buffer[1024]; |
| 1611 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1614 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 1615 v8::internal::CodeObjectRequired::kYes); |
| 1612 { | 1616 { |
| 1613 CpuFeatureScope fscope(&assm, BMI1); | 1617 CpuFeatureScope fscope(&assm, BMI1); |
| 1614 Label exit; | 1618 Label exit; |
| 1615 | 1619 |
| 1616 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand | 1620 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand |
| 1617 __ pushq(rcx); // For memory operand | 1621 __ pushq(rcx); // For memory operand |
| 1618 | 1622 |
| 1619 // andn | 1623 // andn |
| 1620 __ movq(rdx, V8_UINT64_C(0x1000000020000000)); | 1624 __ movq(rdx, V8_UINT64_C(0x1000000020000000)); |
| 1621 | 1625 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 } | 1794 } |
| 1791 | 1795 |
| 1792 | 1796 |
| 1793 TEST(AssemblerX64LZCNT) { | 1797 TEST(AssemblerX64LZCNT) { |
| 1794 CcTest::InitializeVM(); | 1798 CcTest::InitializeVM(); |
| 1795 if (!CpuFeatures::IsSupported(LZCNT)) return; | 1799 if (!CpuFeatures::IsSupported(LZCNT)) return; |
| 1796 | 1800 |
| 1797 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1801 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1798 HandleScope scope(isolate); | 1802 HandleScope scope(isolate); |
| 1799 v8::internal::byte buffer[256]; | 1803 v8::internal::byte buffer[256]; |
| 1800 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1804 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 1805 v8::internal::CodeObjectRequired::kYes); |
| 1801 { | 1806 { |
| 1802 CpuFeatureScope fscope(&assm, LZCNT); | 1807 CpuFeatureScope fscope(&assm, LZCNT); |
| 1803 Label exit; | 1808 Label exit; |
| 1804 | 1809 |
| 1805 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand | 1810 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand |
| 1806 __ pushq(rcx); // For memory operand | 1811 __ pushq(rcx); // For memory operand |
| 1807 | 1812 |
| 1808 __ movl(rax, Immediate(1)); // Test number | 1813 __ movl(rax, Immediate(1)); // Test number |
| 1809 __ lzcntq(r8, rcx); | 1814 __ lzcntq(r8, rcx); |
| 1810 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result | 1815 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 } | 1854 } |
| 1850 | 1855 |
| 1851 | 1856 |
| 1852 TEST(AssemblerX64POPCNT) { | 1857 TEST(AssemblerX64POPCNT) { |
| 1853 CcTest::InitializeVM(); | 1858 CcTest::InitializeVM(); |
| 1854 if (!CpuFeatures::IsSupported(POPCNT)) return; | 1859 if (!CpuFeatures::IsSupported(POPCNT)) return; |
| 1855 | 1860 |
| 1856 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1861 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1857 HandleScope scope(isolate); | 1862 HandleScope scope(isolate); |
| 1858 v8::internal::byte buffer[256]; | 1863 v8::internal::byte buffer[256]; |
| 1859 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1864 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 1865 v8::internal::CodeObjectRequired::kYes); |
| 1860 { | 1866 { |
| 1861 CpuFeatureScope fscope(&assm, POPCNT); | 1867 CpuFeatureScope fscope(&assm, POPCNT); |
| 1862 Label exit; | 1868 Label exit; |
| 1863 | 1869 |
| 1864 __ movq(rcx, V8_UINT64_C(0x1111111111111100)); // source operand | 1870 __ movq(rcx, V8_UINT64_C(0x1111111111111100)); // source operand |
| 1865 __ pushq(rcx); // For memory operand | 1871 __ pushq(rcx); // For memory operand |
| 1866 | 1872 |
| 1867 __ movl(rax, Immediate(1)); // Test number | 1873 __ movl(rax, Immediate(1)); // Test number |
| 1868 __ popcntq(r8, rcx); | 1874 __ popcntq(r8, rcx); |
| 1869 __ movq(r9, V8_UINT64_C(0x000000000000000e)); // expected result | 1875 __ movq(r9, V8_UINT64_C(0x000000000000000e)); // expected result |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 } | 1914 } |
| 1909 | 1915 |
| 1910 | 1916 |
| 1911 TEST(AssemblerX64BMI2) { | 1917 TEST(AssemblerX64BMI2) { |
| 1912 CcTest::InitializeVM(); | 1918 CcTest::InitializeVM(); |
| 1913 if (!CpuFeatures::IsSupported(BMI2)) return; | 1919 if (!CpuFeatures::IsSupported(BMI2)) return; |
| 1914 | 1920 |
| 1915 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1921 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1916 HandleScope scope(isolate); | 1922 HandleScope scope(isolate); |
| 1917 v8::internal::byte buffer[2048]; | 1923 v8::internal::byte buffer[2048]; |
| 1918 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1924 MacroAssembler assm(isolate, buffer, sizeof(buffer), |
| 1925 v8::internal::CodeObjectRequired::kYes); |
| 1919 { | 1926 { |
| 1920 CpuFeatureScope fscope(&assm, BMI2); | 1927 CpuFeatureScope fscope(&assm, BMI2); |
| 1921 Label exit; | 1928 Label exit; |
| 1922 __ pushq(rbx); // save rbx | 1929 __ pushq(rbx); // save rbx |
| 1923 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand | 1930 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand |
| 1924 __ pushq(rcx); // For memory operand | 1931 __ pushq(rcx); // For memory operand |
| 1925 | 1932 |
| 1926 // bzhi | 1933 // bzhi |
| 1927 __ movq(rdx, V8_UINT64_C(0x0000000000000009)); | 1934 __ movq(rdx, V8_UINT64_C(0x0000000000000009)); |
| 1928 | 1935 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 F0 f = FUNCTION_CAST<F0>(code->entry()); | 2175 F0 f = FUNCTION_CAST<F0>(code->entry()); |
| 2169 CHECK_EQ(0, f()); | 2176 CHECK_EQ(0, f()); |
| 2170 } | 2177 } |
| 2171 | 2178 |
| 2172 | 2179 |
| 2173 TEST(AssemblerX64JumpTables1) { | 2180 TEST(AssemblerX64JumpTables1) { |
| 2174 // Test jump tables with forward jumps. | 2181 // Test jump tables with forward jumps. |
| 2175 CcTest::InitializeVM(); | 2182 CcTest::InitializeVM(); |
| 2176 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 2183 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 2177 HandleScope scope(isolate); | 2184 HandleScope scope(isolate); |
| 2178 MacroAssembler assm(isolate, nullptr, 0); | 2185 MacroAssembler assm(isolate, nullptr, 0, |
| 2186 v8::internal::CodeObjectRequired::kYes); |
| 2179 | 2187 |
| 2180 const int kNumCases = 512; | 2188 const int kNumCases = 512; |
| 2181 int values[kNumCases]; | 2189 int values[kNumCases]; |
| 2182 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | 2190 isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
| 2183 Label labels[kNumCases]; | 2191 Label labels[kNumCases]; |
| 2184 | 2192 |
| 2185 Label done, table; | 2193 Label done, table; |
| 2186 __ leaq(arg2, Operand(&table)); | 2194 __ leaq(arg2, Operand(&table)); |
| 2187 __ jmp(Operand(arg2, arg1, times_8, 0)); | 2195 __ jmp(Operand(arg2, arg1, times_8, 0)); |
| 2188 __ ud2(); | 2196 __ ud2(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2215 CHECK_EQ(values[i], res); | 2223 CHECK_EQ(values[i], res); |
| 2216 } | 2224 } |
| 2217 } | 2225 } |
| 2218 | 2226 |
| 2219 | 2227 |
| 2220 TEST(AssemblerX64JumpTables2) { | 2228 TEST(AssemblerX64JumpTables2) { |
| 2221 // Test jump tables with backwards jumps. | 2229 // Test jump tables with backwards jumps. |
| 2222 CcTest::InitializeVM(); | 2230 CcTest::InitializeVM(); |
| 2223 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 2231 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 2224 HandleScope scope(isolate); | 2232 HandleScope scope(isolate); |
| 2225 MacroAssembler assm(isolate, nullptr, 0); | 2233 MacroAssembler assm(isolate, nullptr, 0, |
| 2234 v8::internal::CodeObjectRequired::kYes); |
| 2226 | 2235 |
| 2227 const int kNumCases = 512; | 2236 const int kNumCases = 512; |
| 2228 int values[kNumCases]; | 2237 int values[kNumCases]; |
| 2229 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | 2238 isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
| 2230 Label labels[kNumCases]; | 2239 Label labels[kNumCases]; |
| 2231 | 2240 |
| 2232 Label done, table; | 2241 Label done, table; |
| 2233 __ leaq(arg2, Operand(&table)); | 2242 __ leaq(arg2, Operand(&table)); |
| 2234 __ jmp(Operand(arg2, arg1, times_8, 0)); | 2243 __ jmp(Operand(arg2, arg1, times_8, 0)); |
| 2235 __ ud2(); | 2244 __ ud2(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2258 | 2267 |
| 2259 F1 f = FUNCTION_CAST<F1>(code->entry()); | 2268 F1 f = FUNCTION_CAST<F1>(code->entry()); |
| 2260 for (int i = 0; i < kNumCases; ++i) { | 2269 for (int i = 0; i < kNumCases; ++i) { |
| 2261 int res = f(i); | 2270 int res = f(i); |
| 2262 PrintF("f(%d) = %d\n", i, res); | 2271 PrintF("f(%d) = %d\n", i, res); |
| 2263 CHECK_EQ(values[i], res); | 2272 CHECK_EQ(values[i], res); |
| 2264 } | 2273 } |
| 2265 } | 2274 } |
| 2266 | 2275 |
| 2267 #undef __ | 2276 #undef __ |
| OLD | NEW |