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

Side by Side Diff: runtime/vm/assembler_x64_test.cc

Issue 11573044: Inline Doubles truncate and round. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/disassembler_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 } 1689 }
1690 1690
1691 1691
1692 ASSEMBLER_TEST_RUN(XorpdZeroing2, entry) { 1692 ASSEMBLER_TEST_RUN(XorpdZeroing2, entry) {
1693 typedef double (*XorpdZeroing2Code)(double d); 1693 typedef double (*XorpdZeroing2Code)(double d);
1694 double res = reinterpret_cast<XorpdZeroing2Code>(entry)(12.56e3); 1694 double res = reinterpret_cast<XorpdZeroing2Code>(entry)(12.56e3);
1695 EXPECT_FLOAT_EQ(0.0, res, 0.0001); 1695 EXPECT_FLOAT_EQ(0.0, res, 0.0001);
1696 } 1696 }
1697 1697
1698 1698
1699 ASSEMBLER_TEST_GENERATE(Pxor, assembler) {
1700 __ pxor(XMM0, XMM0);
1701 __ ret();
1702 }
1703
1704
1705 ASSEMBLER_TEST_RUN(Pxor, entry) {
1706 typedef double (*PxorCode)(double d);
1707 double res = reinterpret_cast<PxorCode>(entry)(12.3456e3);
1708 EXPECT_FLOAT_EQ(0.0, res, 0.0);
1709 }
1710
1711
1699 ASSEMBLER_TEST_GENERATE(SquareRootDouble, assembler) { 1712 ASSEMBLER_TEST_GENERATE(SquareRootDouble, assembler) {
1700 __ sqrtsd(XMM0, XMM0); 1713 __ sqrtsd(XMM0, XMM0);
1701 __ ret(); 1714 __ ret();
1702 } 1715 }
1703 1716
1704 1717
1705 ASSEMBLER_TEST_RUN(SquareRootDouble, entry) { 1718 ASSEMBLER_TEST_RUN(SquareRootDouble, entry) {
1706 typedef double (*SquareRootDoubleCode)(double d); 1719 typedef double (*SquareRootDoubleCode)(double d);
1707 const double kDoubleConst = .7; 1720 const double kDoubleConst = .7;
1708 double res = reinterpret_cast<SquareRootDoubleCode>(entry)(kDoubleConst); 1721 double res = reinterpret_cast<SquareRootDoubleCode>(entry)(kDoubleConst);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 __ ret(); 1817 __ ret();
1805 } 1818 }
1806 1819
1807 1820
1808 ASSEMBLER_TEST_RUN(IntToDoubleConversion2, entry) { 1821 ASSEMBLER_TEST_RUN(IntToDoubleConversion2, entry) {
1809 typedef double (*IntToDoubleConversion2Code)(int i); 1822 typedef double (*IntToDoubleConversion2Code)(int i);
1810 double res = reinterpret_cast<IntToDoubleConversion2Code>(entry)(3); 1823 double res = reinterpret_cast<IntToDoubleConversion2Code>(entry)(3);
1811 EXPECT_FLOAT_EQ(3.0, res, 0.001); 1824 EXPECT_FLOAT_EQ(3.0, res, 0.001);
1812 } 1825 }
1813 1826
1827 ASSEMBLER_TEST_GENERATE(DoubleToDoubleTrunc, assembler) {
1828 __ roundsd(XMM0, XMM0, Assembler::kRoundToZero);
1829 __ ret();
1830 }
1831
1832
1833 ASSEMBLER_TEST_RUN(DoubleToDoubleTrunc, entry) {
1834 typedef double (*DoubleToDoubleTruncCode)(double d);
1835 double res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(12.3);
1836 EXPECT_EQ(12.0, res);
1837 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(12.8);
1838 EXPECT_EQ(12.0, res);
1839 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(-12.3);
1840 EXPECT_EQ(-12.0, res);
1841 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(-12.8);
1842 EXPECT_EQ(-12.0, res);
1843 }
1844
1845
1846 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) {
1847 __ DoubleAbs(XMM0);
1848 __ ret();
1849 }
1850
1851
1852 ASSEMBLER_TEST_RUN(DoubleAbs, entry) {
1853 typedef double (*DoubleAbsCode)(double d);
1854 double val = -12.45;
1855 double res = reinterpret_cast<DoubleAbsCode>(entry)(val);
1856 EXPECT_FLOAT_EQ(-val, res, 0.001);
1857 val = 12.45;
1858 res = reinterpret_cast<DoubleAbsCode>(entry)(val);
1859 EXPECT_FLOAT_EQ(val, res, 0.001);
1860 }
1861
1862
1863 ASSEMBLER_TEST_GENERATE(DoubleToDoubleRound, assembler) {
1864 __ DoubleRound(XMM0, XMM0, XMM1);
1865 __ ret();
1866 }
1867
1868
1869 ASSEMBLER_TEST_RUN(DoubleToDoubleRound, entry) {
1870 typedef double (*DoubleToDoubleRoundCode)(double d);
1871 double res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(12.3);
1872 EXPECT_EQ(12.0, res);
1873 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(12.8);
1874 EXPECT_EQ(13.0, res);
1875 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(0.5);
1876 EXPECT_EQ(1.0, res);
1877 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-12.3);
1878 EXPECT_EQ(-12.0, res);
1879 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-12.8);
1880 EXPECT_EQ(-13.0, res);
1881 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-0.5);
1882 EXPECT_EQ(-1.0, res);
1883 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(0.49999999999999994);
1884 EXPECT_EQ(0.0, res);
1885 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-0.49999999999999994);
1886 EXPECT_EQ(-0.0, res);
1887 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(9007199254740991.0);
1888 EXPECT_EQ(9007199254740991.0, res);
1889 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-9007199254740991.0);
1890 EXPECT_EQ(-9007199254740991.0, res);
1891 }
1892
1814 1893
1815 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { 1894 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) {
1816 __ movmskpd(RAX, XMM0); 1895 __ movmskpd(RAX, XMM0);
1817 __ andq(RAX, Immediate(0x1)); 1896 __ andq(RAX, Immediate(0x1));
1818 __ ret(); 1897 __ ret();
1819 } 1898 }
1820 1899
1821 1900
1822 ASSEMBLER_TEST_RUN(ExtractSignBits, entry) { 1901 ASSEMBLER_TEST_RUN(ExtractSignBits, entry) {
1823 typedef int (*ExtractSignBits)(double d); 1902 typedef int (*ExtractSignBits)(double d);
1824 int res = reinterpret_cast<ExtractSignBits>(entry)(1.0); 1903 int res = reinterpret_cast<ExtractSignBits>(entry)(1.0);
1825 EXPECT_EQ(0, res); 1904 EXPECT_EQ(0, res);
1826 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0); 1905 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0);
1827 EXPECT_EQ(1, res); 1906 EXPECT_EQ(1, res);
1828 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0); 1907 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0);
1829 EXPECT_EQ(1, res); 1908 EXPECT_EQ(1, res);
1830 } 1909 }
1831 1910
1832 } // namespace dart 1911 } // namespace dart
1833 1912
1834 #endif // defined TARGET_ARCH_X64 1913 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/disassembler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698