Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 1476763002: Make whether or not a Code object should be created by masm explicit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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), true);
725 { 725 {
726 __ shufps(xmm0, xmm0, 0x0); // brocast first argument 726 __ shufps(xmm0, xmm0, 0x0); // brocast first argument
727 __ shufps(xmm1, xmm1, 0x0); // brocast second argument 727 __ shufps(xmm1, xmm1, 0x0); // brocast second argument
728 __ movaps(xmm2, xmm1); 728 __ movaps(xmm2, xmm1);
729 __ addps(xmm2, xmm0); 729 __ addps(xmm2, xmm0);
730 __ mulps(xmm2, xmm1); 730 __ mulps(xmm2, xmm1);
731 __ subps(xmm2, xmm0); 731 __ subps(xmm2, xmm0);
732 __ divps(xmm2, xmm1); 732 __ divps(xmm2, xmm1);
733 __ cvttss2si(rax, xmm2); 733 __ cvttss2si(rax, xmm2);
734 __ ret(0); 734 __ ret(0);
(...skipping 16 matching lines...) Expand all
751 751
752 752
753 typedef int (*F7)(double x, double y, double z); 753 typedef int (*F7)(double x, double y, double z);
754 TEST(AssemblerX64FMA_sd) { 754 TEST(AssemblerX64FMA_sd) {
755 CcTest::InitializeVM(); 755 CcTest::InitializeVM();
756 if (!CpuFeatures::IsSupported(FMA3)) return; 756 if (!CpuFeatures::IsSupported(FMA3)) return;
757 757
758 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 758 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
759 HandleScope scope(isolate); 759 HandleScope scope(isolate);
760 v8::internal::byte buffer[1024]; 760 v8::internal::byte buffer[1024];
761 MacroAssembler assm(isolate, buffer, sizeof buffer); 761 MacroAssembler assm(isolate, buffer, sizeof(buffer), true);
762 { 762 {
763 CpuFeatureScope fscope(&assm, FMA3); 763 CpuFeatureScope fscope(&assm, FMA3);
764 Label exit; 764 Label exit;
765 // argument in xmm0, xmm1 and xmm2 765 // argument in xmm0, xmm1 and xmm2
766 // xmm0 * xmm1 + xmm2 766 // xmm0 * xmm1 + xmm2
767 __ movaps(xmm3, xmm0); 767 __ movaps(xmm3, xmm0);
768 __ mulsd(xmm3, xmm1); 768 __ mulsd(xmm3, xmm1);
769 __ addsd(xmm3, xmm2); // Expected result in xmm3 769 __ addsd(xmm3, xmm2); // Expected result in xmm3
770 770
771 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand 771 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 976
977 977
978 typedef int (*F8)(float x, float y, float z); 978 typedef int (*F8)(float x, float y, float z);
979 TEST(AssemblerX64FMA_ss) { 979 TEST(AssemblerX64FMA_ss) {
980 CcTest::InitializeVM(); 980 CcTest::InitializeVM();
981 if (!CpuFeatures::IsSupported(FMA3)) return; 981 if (!CpuFeatures::IsSupported(FMA3)) return;
982 982
983 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 983 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
984 HandleScope scope(isolate); 984 HandleScope scope(isolate);
985 v8::internal::byte buffer[1024]; 985 v8::internal::byte buffer[1024];
986 MacroAssembler assm(isolate, buffer, sizeof buffer); 986 MacroAssembler assm(isolate, buffer, sizeof(buffer), true);
987 { 987 {
988 CpuFeatureScope fscope(&assm, FMA3); 988 CpuFeatureScope fscope(&assm, FMA3);
989 Label exit; 989 Label exit;
990 // arguments in xmm0, xmm1 and xmm2 990 // arguments in xmm0, xmm1 and xmm2
991 // xmm0 * xmm1 + xmm2 991 // xmm0 * xmm1 + xmm2
992 __ movaps(xmm3, xmm0); 992 __ movaps(xmm3, xmm0);
993 __ mulss(xmm3, xmm1); 993 __ mulss(xmm3, xmm1);
994 __ addss(xmm3, xmm2); // Expected result in xmm3 994 __ addss(xmm3, xmm2); // Expected result in xmm3
995 995
996 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand 996 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 } 1601 }
1602 1602
1603 1603
1604 TEST(AssemblerX64BMI1) { 1604 TEST(AssemblerX64BMI1) {
1605 CcTest::InitializeVM(); 1605 CcTest::InitializeVM();
1606 if (!CpuFeatures::IsSupported(BMI1)) return; 1606 if (!CpuFeatures::IsSupported(BMI1)) return;
1607 1607
1608 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 1608 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1609 HandleScope scope(isolate); 1609 HandleScope scope(isolate);
1610 v8::internal::byte buffer[1024]; 1610 v8::internal::byte buffer[1024];
1611 MacroAssembler assm(isolate, buffer, sizeof buffer); 1611 MacroAssembler assm(isolate, buffer, sizeof(buffer), true);
1612 { 1612 {
1613 CpuFeatureScope fscope(&assm, BMI1); 1613 CpuFeatureScope fscope(&assm, BMI1);
1614 Label exit; 1614 Label exit;
1615 1615
1616 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand 1616 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand
1617 __ pushq(rcx); // For memory operand 1617 __ pushq(rcx); // For memory operand
1618 1618
1619 // andn 1619 // andn
1620 __ movq(rdx, V8_UINT64_C(0x1000000020000000)); 1620 __ movq(rdx, V8_UINT64_C(0x1000000020000000));
1621 1621
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 } 1790 }
1791 1791
1792 1792
1793 TEST(AssemblerX64LZCNT) { 1793 TEST(AssemblerX64LZCNT) {
1794 CcTest::InitializeVM(); 1794 CcTest::InitializeVM();
1795 if (!CpuFeatures::IsSupported(LZCNT)) return; 1795 if (!CpuFeatures::IsSupported(LZCNT)) return;
1796 1796
1797 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 1797 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1798 HandleScope scope(isolate); 1798 HandleScope scope(isolate);
1799 v8::internal::byte buffer[256]; 1799 v8::internal::byte buffer[256];
1800 MacroAssembler assm(isolate, buffer, sizeof buffer); 1800 MacroAssembler assm(isolate, buffer, sizeof(buffer), true);
1801 { 1801 {
1802 CpuFeatureScope fscope(&assm, LZCNT); 1802 CpuFeatureScope fscope(&assm, LZCNT);
1803 Label exit; 1803 Label exit;
1804 1804
1805 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand 1805 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand
1806 __ pushq(rcx); // For memory operand 1806 __ pushq(rcx); // For memory operand
1807 1807
1808 __ movl(rax, Immediate(1)); // Test number 1808 __ movl(rax, Immediate(1)); // Test number
1809 __ lzcntq(r8, rcx); 1809 __ lzcntq(r8, rcx);
1810 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result 1810 __ movq(r9, V8_UINT64_C(0x0000000000000003)); // expected result
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 } 1849 }
1850 1850
1851 1851
1852 TEST(AssemblerX64POPCNT) { 1852 TEST(AssemblerX64POPCNT) {
1853 CcTest::InitializeVM(); 1853 CcTest::InitializeVM();
1854 if (!CpuFeatures::IsSupported(POPCNT)) return; 1854 if (!CpuFeatures::IsSupported(POPCNT)) return;
1855 1855
1856 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 1856 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1857 HandleScope scope(isolate); 1857 HandleScope scope(isolate);
1858 v8::internal::byte buffer[256]; 1858 v8::internal::byte buffer[256];
1859 MacroAssembler assm(isolate, buffer, sizeof buffer); 1859 MacroAssembler assm(isolate, buffer, sizeof(buffer), true);
1860 { 1860 {
1861 CpuFeatureScope fscope(&assm, POPCNT); 1861 CpuFeatureScope fscope(&assm, POPCNT);
1862 Label exit; 1862 Label exit;
1863 1863
1864 __ movq(rcx, V8_UINT64_C(0x1111111111111100)); // source operand 1864 __ movq(rcx, V8_UINT64_C(0x1111111111111100)); // source operand
1865 __ pushq(rcx); // For memory operand 1865 __ pushq(rcx); // For memory operand
1866 1866
1867 __ movl(rax, Immediate(1)); // Test number 1867 __ movl(rax, Immediate(1)); // Test number
1868 __ popcntq(r8, rcx); 1868 __ popcntq(r8, rcx);
1869 __ movq(r9, V8_UINT64_C(0x000000000000000e)); // expected result 1869 __ movq(r9, V8_UINT64_C(0x000000000000000e)); // expected result
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 } 1908 }
1909 1909
1910 1910
1911 TEST(AssemblerX64BMI2) { 1911 TEST(AssemblerX64BMI2) {
1912 CcTest::InitializeVM(); 1912 CcTest::InitializeVM();
1913 if (!CpuFeatures::IsSupported(BMI2)) return; 1913 if (!CpuFeatures::IsSupported(BMI2)) return;
1914 1914
1915 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 1915 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1916 HandleScope scope(isolate); 1916 HandleScope scope(isolate);
1917 v8::internal::byte buffer[2048]; 1917 v8::internal::byte buffer[2048];
1918 MacroAssembler assm(isolate, buffer, sizeof buffer); 1918 MacroAssembler assm(isolate, buffer, sizeof(buffer), true);
1919 { 1919 {
1920 CpuFeatureScope fscope(&assm, BMI2); 1920 CpuFeatureScope fscope(&assm, BMI2);
1921 Label exit; 1921 Label exit;
1922 __ pushq(rbx); // save rbx 1922 __ pushq(rbx); // save rbx
1923 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand 1923 __ movq(rcx, V8_UINT64_C(0x1122334455667788)); // source operand
1924 __ pushq(rcx); // For memory operand 1924 __ pushq(rcx); // For memory operand
1925 1925
1926 // bzhi 1926 // bzhi
1927 __ movq(rdx, V8_UINT64_C(0x0000000000000009)); 1927 __ movq(rdx, V8_UINT64_C(0x0000000000000009));
1928 1928
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 F0 f = FUNCTION_CAST<F0>(code->entry()); 2168 F0 f = FUNCTION_CAST<F0>(code->entry());
2169 CHECK_EQ(0, f()); 2169 CHECK_EQ(0, f());
2170 } 2170 }
2171 2171
2172 2172
2173 TEST(AssemblerX64JumpTables1) { 2173 TEST(AssemblerX64JumpTables1) {
2174 // Test jump tables with forward jumps. 2174 // Test jump tables with forward jumps.
2175 CcTest::InitializeVM(); 2175 CcTest::InitializeVM();
2176 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 2176 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
2177 HandleScope scope(isolate); 2177 HandleScope scope(isolate);
2178 MacroAssembler assm(isolate, nullptr, 0); 2178 MacroAssembler assm(isolate, nullptr, 0, true);
2179 2179
2180 const int kNumCases = 512; 2180 const int kNumCases = 512;
2181 int values[kNumCases]; 2181 int values[kNumCases];
2182 isolate->random_number_generator()->NextBytes(values, sizeof(values)); 2182 isolate->random_number_generator()->NextBytes(values, sizeof(values));
2183 Label labels[kNumCases]; 2183 Label labels[kNumCases];
2184 2184
2185 Label done, table; 2185 Label done, table;
2186 __ leaq(arg2, Operand(&table)); 2186 __ leaq(arg2, Operand(&table));
2187 __ jmp(Operand(arg2, arg1, times_8, 0)); 2187 __ jmp(Operand(arg2, arg1, times_8, 0));
2188 __ ud2(); 2188 __ ud2();
(...skipping 26 matching lines...) Expand all
2215 CHECK_EQ(values[i], res); 2215 CHECK_EQ(values[i], res);
2216 } 2216 }
2217 } 2217 }
2218 2218
2219 2219
2220 TEST(AssemblerX64JumpTables2) { 2220 TEST(AssemblerX64JumpTables2) {
2221 // Test jump tables with backwards jumps. 2221 // Test jump tables with backwards jumps.
2222 CcTest::InitializeVM(); 2222 CcTest::InitializeVM();
2223 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 2223 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
2224 HandleScope scope(isolate); 2224 HandleScope scope(isolate);
2225 MacroAssembler assm(isolate, nullptr, 0); 2225 MacroAssembler assm(isolate, nullptr, 0, true);
2226 2226
2227 const int kNumCases = 512; 2227 const int kNumCases = 512;
2228 int values[kNumCases]; 2228 int values[kNumCases];
2229 isolate->random_number_generator()->NextBytes(values, sizeof(values)); 2229 isolate->random_number_generator()->NextBytes(values, sizeof(values));
2230 Label labels[kNumCases]; 2230 Label labels[kNumCases];
2231 2231
2232 Label done, table; 2232 Label done, table;
2233 __ leaq(arg2, Operand(&table)); 2233 __ leaq(arg2, Operand(&table));
2234 __ jmp(Operand(arg2, arg1, times_8, 0)); 2234 __ jmp(Operand(arg2, arg1, times_8, 0));
2235 __ ud2(); 2235 __ ud2();
(...skipping 22 matching lines...) Expand all
2258 2258
2259 F1 f = FUNCTION_CAST<F1>(code->entry()); 2259 F1 f = FUNCTION_CAST<F1>(code->entry());
2260 for (int i = 0; i < kNumCases; ++i) { 2260 for (int i = 0; i < kNumCases; ++i) {
2261 int res = f(i); 2261 int res = f(i);
2262 PrintF("f(%d) = %d\n", i, res); 2262 PrintF("f(%d) = %d\n", i, res);
2263 CHECK_EQ(values[i], res); 2263 CHECK_EQ(values[i], res);
2264 } 2264 }
2265 } 2265 }
2266 2266
2267 #undef __ 2267 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698