OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/stack_frame.h" | 9 #include "vm/stack_frame.h" |
10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 thread); | 21 thread); |
22 } | 22 } |
23 | 23 |
24 | 24 |
25 #define EXECUTE_TEST_CODE_INTPTR(code) \ | 25 #define EXECUTE_TEST_CODE_INTPTR(code) \ |
26 Smi::Value(Smi::RawCast(ExecuteTest(code))) | 26 Smi::Value(Smi::RawCast(ExecuteTest(code))) |
27 #define EXECUTE_TEST_CODE_BOOL(code) \ | 27 #define EXECUTE_TEST_CODE_BOOL(code) \ |
28 (Bool::RawCast(ExecuteTest(code)) == Bool::True().raw()) | 28 (Bool::RawCast(ExecuteTest(code)) == Bool::True().raw()) |
29 #define EXECUTE_TEST_CODE_OBJECT(code) \ | 29 #define EXECUTE_TEST_CODE_OBJECT(code) \ |
30 Object::Handle(ExecuteTest(code)) | 30 Object::Handle(ExecuteTest(code)) |
| 31 #define EXECUTE_TEST_CODE_DOUBLE(code) \ |
| 32 bit_cast<double, RawObject*>(ExecuteTest(code)) |
31 | 33 |
32 #define __ assembler-> | 34 #define __ assembler-> |
33 | 35 |
34 | 36 |
35 static RawClass* CreateDummyClass(const String& class_name, | 37 static RawClass* CreateDummyClass(const String& class_name, |
36 const Script& script) { | 38 const Script& script) { |
37 const Class& cls = Class::Handle(Class::New( | 39 const Class& cls = Class::Handle(Class::New( |
38 Library::Handle(), class_name, script, TokenPosition::kNoSource)); | 40 Library::Handle(), class_name, script, TokenPosition::kNoSource)); |
39 cls.set_is_synthesized_class(); // Dummy class for testing. | 41 cls.set_is_synthesized_class(); // Dummy class for testing. |
40 return cls.raw(); | 42 return cls.raw(); |
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 ASSEMBLER_TEST_RUN(CheckSmiFail, test) { | 1768 ASSEMBLER_TEST_RUN(CheckSmiFail, test) { |
1767 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 1769 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
1768 } | 1770 } |
1769 | 1771 |
1770 | 1772 |
1771 // - CheckClassId rA, D | 1773 // - CheckClassId rA, D |
1772 // | 1774 // |
1773 // If the object at FP[rA]'s class id matches hthe class id in PP[D], then | 1775 // If the object at FP[rA]'s class id matches hthe class id in PP[D], then |
1774 // skip the following instruction. | 1776 // skip the following instruction. |
1775 ASSEMBLER_TEST_GENERATE(CheckClassIdSmiPass, assembler) { | 1777 ASSEMBLER_TEST_GENERATE(CheckClassIdSmiPass, assembler) { |
1776 __ Frame(1); | 1778 __ Frame(2); |
1777 __ LoadConstant(0, Smi::Handle(Smi::New(42))); | 1779 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
1778 __ CheckClassId(0, kSmiCid); | 1780 __ LoadClassId(1, 0); |
| 1781 __ CheckClassId(1, kSmiCid); |
1779 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); | 1782 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
1780 __ Return(0); | 1783 __ Return(0); |
1781 } | 1784 } |
1782 | 1785 |
1783 | 1786 |
1784 ASSEMBLER_TEST_RUN(CheckClassIdSmiPass, test) { | 1787 ASSEMBLER_TEST_RUN(CheckClassIdSmiPass, test) { |
1785 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 1788 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
1786 } | 1789 } |
1787 | 1790 |
1788 | 1791 |
1789 ASSEMBLER_TEST_GENERATE(CheckClassIdNonSmiPass, assembler) { | 1792 ASSEMBLER_TEST_GENERATE(CheckClassIdNonSmiPass, assembler) { |
1790 __ Frame(1); | 1793 __ Frame(2); |
1791 __ LoadConstant(0, Bool::True()); | 1794 __ LoadConstant(0, Bool::True()); |
1792 __ CheckClassId(0, kBoolCid); | 1795 __ LoadClassId(1, 0); |
| 1796 __ CheckClassId(1, kBoolCid); |
1793 __ LoadConstant(0, Bool::False()); | 1797 __ LoadConstant(0, Bool::False()); |
1794 __ Return(0); | 1798 __ Return(0); |
1795 } | 1799 } |
1796 | 1800 |
1797 | 1801 |
1798 ASSEMBLER_TEST_RUN(CheckClassIdNonSmiPass, test) { | 1802 ASSEMBLER_TEST_RUN(CheckClassIdNonSmiPass, test) { |
1799 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); | 1803 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); |
1800 } | 1804 } |
1801 | 1805 |
1802 | 1806 |
1803 ASSEMBLER_TEST_GENERATE(CheckClassIdFail, assembler) { | 1807 ASSEMBLER_TEST_GENERATE(CheckClassIdFail, assembler) { |
1804 __ Frame(1); | 1808 __ Frame(2); |
1805 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); | 1809 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
1806 __ CheckClassId(0, kBoolCid); | 1810 __ LoadClassId(1, 0); |
| 1811 __ CheckClassId(1, kBoolCid); |
1807 __ LoadConstant(0, Smi::Handle(Smi::New(42))); | 1812 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
1808 __ Return(0); | 1813 __ Return(0); |
1809 } | 1814 } |
1810 | 1815 |
1811 | 1816 |
1812 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) { | 1817 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) { |
1813 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 1818 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
1814 } | 1819 } |
1815 | 1820 |
1816 | 1821 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 __ Return(1); | 1877 __ Return(1); |
1873 } | 1878 } |
1874 | 1879 |
1875 | 1880 |
1876 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) { | 1881 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) { |
1877 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 1882 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
1878 } | 1883 } |
1879 | 1884 |
1880 // - If<Cond> rA, rD | 1885 // - If<Cond> rA, rD |
1881 // | 1886 // |
1882 // Cond is Le, Lt, Ge, Gt, or unsigned variants ULe, ULt, UGe, UGt. | 1887 // Cond is Le, Lt, Ge, Gt, unsigned variants ULe, ULt, UGe, UGt, and |
| 1888 // unboxed double variants DEq, DNe, DLe, DLt, DGe, DGt. |
1883 // Skips the next instruction unless FP[rA] <Cond> FP[rD]. Assumes that | 1889 // Skips the next instruction unless FP[rA] <Cond> FP[rD]. Assumes that |
1884 // FP[rA] and FP[rD] are Smis. | 1890 // FP[rA] and FP[rD] are Smis or unboxed doubles as inidcated by <Cond>. |
1885 ASSEMBLER_TEST_GENERATE(IfLeTrue, assembler) { | 1891 ASSEMBLER_TEST_GENERATE(IfLeTrue, assembler) { |
1886 __ Frame(3); | 1892 __ Frame(3); |
1887 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); | 1893 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
1888 __ LoadConstant(1, Smi::Handle(Smi::New(-5))); | 1894 __ LoadConstant(1, Smi::Handle(Smi::New(-5))); |
1889 __ LoadConstant(2, Smi::Handle(Smi::New(100))); | 1895 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
1890 __ IfLe(1, 2); | 1896 __ IfLe(1, 2); |
1891 __ LoadConstant(0, Smi::Handle(Smi::New(42))); | 1897 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
1892 __ Return(0); | 1898 __ Return(0); |
1893 } | 1899 } |
1894 | 1900 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); | 2009 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
2004 __ Return(0); | 2010 __ Return(0); |
2005 } | 2011 } |
2006 | 2012 |
2007 | 2013 |
2008 ASSEMBLER_TEST_RUN(IfGtFalse, test) { | 2014 ASSEMBLER_TEST_RUN(IfGtFalse, test) { |
2009 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 2015 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
2010 } | 2016 } |
2011 | 2017 |
2012 | 2018 |
| 2019 #if defined(ARCH_IS_64_BIT) |
| 2020 ASSEMBLER_TEST_GENERATE(IfDNeTrue, assembler) { |
| 2021 __ Frame(3); |
| 2022 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2023 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2024 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2025 __ UnboxDouble(1, 1); |
| 2026 __ UnboxDouble(2, 2); |
| 2027 __ IfDNe(1, 2); |
| 2028 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2029 __ Return(0); |
| 2030 } |
| 2031 |
| 2032 |
| 2033 ASSEMBLER_TEST_RUN(IfDNeTrue, test) { |
| 2034 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2035 } |
| 2036 |
| 2037 |
| 2038 ASSEMBLER_TEST_GENERATE(IfDNeFalse, assembler) { |
| 2039 __ Frame(3); |
| 2040 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2041 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2042 __ LoadConstant(2, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2043 __ UnboxDouble(1, 1); |
| 2044 __ UnboxDouble(2, 2); |
| 2045 __ IfDNe(1, 2); |
| 2046 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2047 __ Return(0); |
| 2048 } |
| 2049 |
| 2050 |
| 2051 ASSEMBLER_TEST_RUN(IfDNeFalse, test) { |
| 2052 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2053 } |
| 2054 |
| 2055 |
| 2056 ASSEMBLER_TEST_GENERATE(IfDNeNan, assembler) { |
| 2057 const double not_a_number = bit_cast<double, intptr_t>(0x7FF8000000000000LL); |
| 2058 __ Frame(3); |
| 2059 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2060 __ LoadConstant(1, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2061 __ LoadConstant(2, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2062 __ UnboxDouble(1, 1); |
| 2063 __ UnboxDouble(2, 2); |
| 2064 __ IfDNe(1, 2); |
| 2065 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2066 __ Return(0); |
| 2067 } |
| 2068 |
| 2069 |
| 2070 ASSEMBLER_TEST_RUN(IfDNeNan, test) { |
| 2071 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2072 } |
| 2073 |
| 2074 |
| 2075 ASSEMBLER_TEST_GENERATE(IfDEqTrue, assembler) { |
| 2076 __ Frame(3); |
| 2077 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2078 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2079 __ LoadConstant(2, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2080 __ UnboxDouble(1, 1); |
| 2081 __ UnboxDouble(2, 2); |
| 2082 __ IfDEq(1, 2); |
| 2083 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2084 __ Return(0); |
| 2085 } |
| 2086 |
| 2087 |
| 2088 ASSEMBLER_TEST_RUN(IfDEqTrue, test) { |
| 2089 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2090 } |
| 2091 |
| 2092 |
| 2093 ASSEMBLER_TEST_GENERATE(IfDEqFalse, assembler) { |
| 2094 __ Frame(3); |
| 2095 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2096 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2097 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2098 __ UnboxDouble(1, 1); |
| 2099 __ UnboxDouble(2, 2); |
| 2100 __ IfDEq(1, 2); |
| 2101 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2102 __ Return(0); |
| 2103 } |
| 2104 |
| 2105 |
| 2106 ASSEMBLER_TEST_RUN(IfDEqFalse, test) { |
| 2107 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2108 } |
| 2109 |
| 2110 |
| 2111 ASSEMBLER_TEST_GENERATE(IfDEqNan, assembler) { |
| 2112 const double not_a_number = bit_cast<double, intptr_t>(0x7FF8000000000000LL); |
| 2113 __ Frame(3); |
| 2114 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2115 __ LoadConstant(1, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2116 __ LoadConstant(2, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2117 __ UnboxDouble(1, 1); |
| 2118 __ UnboxDouble(2, 2); |
| 2119 __ IfDEq(1, 2); |
| 2120 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2121 __ Return(0); |
| 2122 } |
| 2123 |
| 2124 |
| 2125 ASSEMBLER_TEST_RUN(IfDEqNan, test) { |
| 2126 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2127 } |
| 2128 |
| 2129 |
| 2130 ASSEMBLER_TEST_GENERATE(IfDLeTrue, assembler) { |
| 2131 __ Frame(3); |
| 2132 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2133 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2134 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2135 __ UnboxDouble(1, 1); |
| 2136 __ UnboxDouble(2, 2); |
| 2137 __ IfDLe(1, 2); |
| 2138 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2139 __ Return(0); |
| 2140 } |
| 2141 |
| 2142 |
| 2143 ASSEMBLER_TEST_RUN(IfDLeTrue, test) { |
| 2144 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2145 } |
| 2146 |
| 2147 |
| 2148 ASSEMBLER_TEST_GENERATE(IfDLeFalse, assembler) { |
| 2149 __ Frame(3); |
| 2150 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2151 __ LoadConstant(1, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2152 __ LoadConstant(2, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2153 __ UnboxDouble(1, 1); |
| 2154 __ UnboxDouble(2, 2); |
| 2155 __ IfDLe(1, 2); |
| 2156 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2157 __ Return(0); |
| 2158 } |
| 2159 |
| 2160 |
| 2161 ASSEMBLER_TEST_RUN(IfDLeFalse, test) { |
| 2162 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2163 } |
| 2164 |
| 2165 |
| 2166 ASSEMBLER_TEST_GENERATE(IfDLeNan, assembler) { |
| 2167 const double not_a_number = bit_cast<double, intptr_t>(0x7FF8000000000000LL); |
| 2168 __ Frame(3); |
| 2169 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2170 __ LoadConstant(1, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2171 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2172 __ UnboxDouble(1, 1); |
| 2173 __ UnboxDouble(2, 2); |
| 2174 __ IfDLe(1, 2); |
| 2175 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2176 __ Return(0); |
| 2177 } |
| 2178 |
| 2179 |
| 2180 ASSEMBLER_TEST_RUN(IfDLeNan, test) { |
| 2181 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2182 } |
| 2183 |
| 2184 |
| 2185 ASSEMBLER_TEST_GENERATE(IfDLtTrue, assembler) { |
| 2186 __ Frame(3); |
| 2187 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2188 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2189 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2190 __ UnboxDouble(1, 1); |
| 2191 __ UnboxDouble(2, 2); |
| 2192 __ IfDLt(1, 2); |
| 2193 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2194 __ Return(0); |
| 2195 } |
| 2196 |
| 2197 |
| 2198 ASSEMBLER_TEST_RUN(IfDLtTrue, test) { |
| 2199 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2200 } |
| 2201 |
| 2202 |
| 2203 ASSEMBLER_TEST_GENERATE(IfDLtFalse, assembler) { |
| 2204 __ Frame(3); |
| 2205 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2206 __ LoadConstant(1, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2207 __ LoadConstant(2, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2208 __ UnboxDouble(1, 1); |
| 2209 __ UnboxDouble(2, 2); |
| 2210 __ IfDLt(1, 2); |
| 2211 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2212 __ Return(0); |
| 2213 } |
| 2214 |
| 2215 |
| 2216 ASSEMBLER_TEST_RUN(IfDLtFalse, test) { |
| 2217 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2218 } |
| 2219 |
| 2220 |
| 2221 ASSEMBLER_TEST_GENERATE(IfDLtNan, assembler) { |
| 2222 const double not_a_number = bit_cast<double, intptr_t>(0x7FF8000000000000LL); |
| 2223 __ Frame(3); |
| 2224 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2225 __ LoadConstant(1, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2226 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2227 __ UnboxDouble(1, 1); |
| 2228 __ UnboxDouble(2, 2); |
| 2229 __ IfDLt(1, 2); |
| 2230 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2231 __ Return(0); |
| 2232 } |
| 2233 |
| 2234 |
| 2235 ASSEMBLER_TEST_RUN(IfDLtNan, test) { |
| 2236 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2237 } |
| 2238 |
| 2239 |
| 2240 ASSEMBLER_TEST_GENERATE(IfDGeTrue, assembler) { |
| 2241 __ Frame(3); |
| 2242 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2243 __ LoadConstant(1, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2244 __ LoadConstant(2, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2245 __ UnboxDouble(1, 1); |
| 2246 __ UnboxDouble(2, 2); |
| 2247 __ IfDGe(1, 2); |
| 2248 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2249 __ Return(0); |
| 2250 } |
| 2251 |
| 2252 |
| 2253 ASSEMBLER_TEST_RUN(IfDGeTrue, test) { |
| 2254 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2255 } |
| 2256 |
| 2257 |
| 2258 ASSEMBLER_TEST_GENERATE(IfDGeFalse, assembler) { |
| 2259 __ Frame(3); |
| 2260 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2261 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2262 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2263 __ UnboxDouble(1, 1); |
| 2264 __ UnboxDouble(2, 2); |
| 2265 __ IfDGe(1, 2); |
| 2266 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2267 __ Return(0); |
| 2268 } |
| 2269 |
| 2270 |
| 2271 ASSEMBLER_TEST_RUN(IfDGeFalse, test) { |
| 2272 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2273 } |
| 2274 |
| 2275 |
| 2276 ASSEMBLER_TEST_GENERATE(IfDGeNan, assembler) { |
| 2277 const double not_a_number = bit_cast<double, intptr_t>(0x7FF8000000000000LL); |
| 2278 __ Frame(3); |
| 2279 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2280 __ LoadConstant(1, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2281 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2282 __ UnboxDouble(1, 1); |
| 2283 __ UnboxDouble(2, 2); |
| 2284 __ IfDGe(1, 2); |
| 2285 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2286 __ Return(0); |
| 2287 } |
| 2288 |
| 2289 |
| 2290 ASSEMBLER_TEST_RUN(IfDGeNan, test) { |
| 2291 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2292 } |
| 2293 |
| 2294 |
| 2295 ASSEMBLER_TEST_GENERATE(IfDGtTrue, assembler) { |
| 2296 __ Frame(3); |
| 2297 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2298 __ LoadConstant(1, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2299 __ LoadConstant(2, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2300 __ UnboxDouble(1, 1); |
| 2301 __ UnboxDouble(2, 2); |
| 2302 __ IfDGt(1, 2); |
| 2303 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2304 __ Return(0); |
| 2305 } |
| 2306 |
| 2307 |
| 2308 ASSEMBLER_TEST_RUN(IfDGtTrue, test) { |
| 2309 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2310 } |
| 2311 |
| 2312 |
| 2313 ASSEMBLER_TEST_GENERATE(IfDGtFalse, assembler) { |
| 2314 __ Frame(3); |
| 2315 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2316 __ LoadConstant(1, Double::Handle(Double::New(-5.0, Heap::kOld))); |
| 2317 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2318 __ UnboxDouble(1, 1); |
| 2319 __ UnboxDouble(2, 2); |
| 2320 __ IfDGt(1, 2); |
| 2321 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2322 __ Return(0); |
| 2323 } |
| 2324 |
| 2325 |
| 2326 ASSEMBLER_TEST_RUN(IfDGtFalse, test) { |
| 2327 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2328 } |
| 2329 |
| 2330 |
| 2331 ASSEMBLER_TEST_GENERATE(IfDGtNan, assembler) { |
| 2332 const double not_a_number = bit_cast<double, intptr_t>(0x7FF8000000000000LL); |
| 2333 __ Frame(3); |
| 2334 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2335 __ LoadConstant(1, Double::Handle(Double::New(not_a_number, Heap::kOld))); |
| 2336 __ LoadConstant(2, Double::Handle(Double::New(100.0, Heap::kOld))); |
| 2337 __ UnboxDouble(1, 1); |
| 2338 __ UnboxDouble(2, 2); |
| 2339 __ IfDGt(1, 2); |
| 2340 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 2341 __ Return(0); |
| 2342 } |
| 2343 |
| 2344 |
| 2345 ASSEMBLER_TEST_RUN(IfDGtNan, test) { |
| 2346 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2347 } |
| 2348 #endif // defined(ARCH_IS_64_BIT) |
| 2349 |
| 2350 |
2013 ASSEMBLER_TEST_GENERATE(IfULeTrue, assembler) { | 2351 ASSEMBLER_TEST_GENERATE(IfULeTrue, assembler) { |
2014 __ Frame(3); | 2352 __ Frame(3); |
2015 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); | 2353 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
2016 __ LoadConstant(1, Smi::Handle(Smi::New(5))); | 2354 __ LoadConstant(1, Smi::Handle(Smi::New(5))); |
2017 __ LoadConstant(2, Smi::Handle(Smi::New(100))); | 2355 __ LoadConstant(2, Smi::Handle(Smi::New(100))); |
2018 __ IfULe(1, 2); | 2356 __ IfULe(1, 2); |
2019 __ LoadConstant(0, Smi::Handle(Smi::New(42))); | 2357 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
2020 __ Return(0); | 2358 __ Return(0); |
2021 } | 2359 } |
2022 | 2360 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 __ IfUGt(1, 2); | 2484 __ IfUGt(1, 2); |
2147 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); | 2485 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
2148 __ Return(0); | 2486 __ Return(0); |
2149 } | 2487 } |
2150 | 2488 |
2151 | 2489 |
2152 ASSEMBLER_TEST_RUN(IfUGtFalse, test) { | 2490 ASSEMBLER_TEST_RUN(IfUGtFalse, test) { |
2153 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 2491 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
2154 } | 2492 } |
2155 | 2493 |
| 2494 |
| 2495 #if defined(ARCH_IS_64_BIT) |
| 2496 // - UnboxDouble rA, rD |
| 2497 // |
| 2498 // Unbox the double in FP[rD] into FP[rA]. Assumes FP[rD] is a double. |
| 2499 // |
| 2500 // - CheckedUnboxDouble rA, rD |
| 2501 // |
| 2502 // Unboxes FP[rD] into FP[rA] and skips the following instruction unless |
| 2503 // FP[rD] is not a double or a Smi. When FP[rD] is a Smi, converts it to a |
| 2504 // double. |
| 2505 ASSEMBLER_TEST_GENERATE(Unbox, assembler) { |
| 2506 __ Frame(2); |
| 2507 __ LoadConstant(0, Double::Handle(Double::New(42.0, Heap::kOld))); |
| 2508 __ UnboxDouble(1, 0); |
| 2509 __ Return(1); |
| 2510 } |
| 2511 |
| 2512 |
| 2513 ASSEMBLER_TEST_RUN(Unbox, test) { |
| 2514 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2515 } |
| 2516 |
| 2517 |
| 2518 ASSEMBLER_TEST_GENERATE(CheckedUnboxDouble, assembler) { |
| 2519 __ Frame(2); |
| 2520 __ LoadConstant(0, Double::Handle(Double::New(42.0, Heap::kOld))); |
| 2521 __ CheckedUnboxDouble(1, 0); |
| 2522 __ LoadConstant(1, Smi::Handle(Smi::New(0))); |
| 2523 __ Return(1); |
| 2524 } |
| 2525 |
| 2526 |
| 2527 ASSEMBLER_TEST_RUN(CheckedUnboxDouble, test) { |
| 2528 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2529 } |
| 2530 |
| 2531 |
| 2532 ASSEMBLER_TEST_GENERATE(CheckedUnboxSmi, assembler) { |
| 2533 __ Frame(2); |
| 2534 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 2535 __ CheckedUnboxDouble(1, 0); |
| 2536 __ LoadConstant(1, Smi::Handle(Smi::New(0))); |
| 2537 __ Return(1); |
| 2538 } |
| 2539 |
| 2540 |
| 2541 ASSEMBLER_TEST_RUN(CheckedUnboxSmi, test) { |
| 2542 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2543 } |
| 2544 |
| 2545 |
| 2546 ASSEMBLER_TEST_GENERATE(CheckedUnboxFail, assembler) { |
| 2547 __ Frame(2); |
| 2548 __ LoadConstant(0, Bool::True()); |
| 2549 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 2550 __ CheckedUnboxDouble(1, 0); |
| 2551 __ LoadConstant(1, Smi::Handle(Smi::New(42))); |
| 2552 __ Return(1); |
| 2553 } |
| 2554 |
| 2555 |
| 2556 ASSEMBLER_TEST_RUN(CheckedUnboxFail, test) { |
| 2557 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 2558 } |
| 2559 |
| 2560 |
| 2561 // - DAdd, DSub, DMul, DDiv rA, rB, rC |
| 2562 // |
| 2563 // Arithmetic operaions on unboxed doubles. FP[rA] <- FP[rB] op FP[rC]. |
| 2564 ASSEMBLER_TEST_GENERATE(DAdd, assembler) { |
| 2565 __ Frame(3); |
| 2566 __ LoadConstant(0, Double::Handle(Double::New(41.0, Heap::kOld))); |
| 2567 __ LoadConstant(1, Double::Handle(Double::New(1.0, Heap::kOld))); |
| 2568 __ UnboxDouble(0, 0); |
| 2569 __ UnboxDouble(1, 1); |
| 2570 __ DAdd(2, 1, 0); |
| 2571 __ Return(2); |
| 2572 } |
| 2573 |
| 2574 |
| 2575 ASSEMBLER_TEST_RUN(DAdd, test) { |
| 2576 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2577 } |
| 2578 |
| 2579 |
| 2580 ASSEMBLER_TEST_GENERATE(DSub, assembler) { |
| 2581 __ Frame(3); |
| 2582 __ LoadConstant(0, Double::Handle(Double::New(1.0, Heap::kOld))); |
| 2583 __ LoadConstant(1, Double::Handle(Double::New(43.0, Heap::kOld))); |
| 2584 __ UnboxDouble(0, 0); |
| 2585 __ UnboxDouble(1, 1); |
| 2586 __ DSub(2, 1, 0); |
| 2587 __ Return(2); |
| 2588 } |
| 2589 |
| 2590 |
| 2591 ASSEMBLER_TEST_RUN(DSub, test) { |
| 2592 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2593 } |
| 2594 |
| 2595 |
| 2596 ASSEMBLER_TEST_GENERATE(DMul, assembler) { |
| 2597 __ Frame(3); |
| 2598 __ LoadConstant(0, Double::Handle(Double::New(6.0, Heap::kOld))); |
| 2599 __ LoadConstant(1, Double::Handle(Double::New(7.0, Heap::kOld))); |
| 2600 __ UnboxDouble(0, 0); |
| 2601 __ UnboxDouble(1, 1); |
| 2602 __ DMul(2, 1, 0); |
| 2603 __ Return(2); |
| 2604 } |
| 2605 |
| 2606 |
| 2607 ASSEMBLER_TEST_RUN(DMul, test) { |
| 2608 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2609 } |
| 2610 |
| 2611 |
| 2612 ASSEMBLER_TEST_GENERATE(DDiv, assembler) { |
| 2613 __ Frame(3); |
| 2614 __ LoadConstant(0, Double::Handle(Double::New(2.0, Heap::kOld))); |
| 2615 __ LoadConstant(1, Double::Handle(Double::New(84.0, Heap::kOld))); |
| 2616 __ UnboxDouble(0, 0); |
| 2617 __ UnboxDouble(1, 1); |
| 2618 __ DDiv(2, 1, 0); |
| 2619 __ Return(2); |
| 2620 } |
| 2621 |
| 2622 |
| 2623 ASSEMBLER_TEST_RUN(DDiv, test) { |
| 2624 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2625 } |
| 2626 |
| 2627 |
| 2628 ASSEMBLER_TEST_GENERATE(DNeg, assembler) { |
| 2629 __ Frame(2); |
| 2630 __ LoadConstant(0, Double::Handle(Double::New(-42.0, Heap::kOld))); |
| 2631 __ UnboxDouble(0, 0); |
| 2632 __ DNeg(1, 0); |
| 2633 __ Return(1); |
| 2634 } |
| 2635 |
| 2636 |
| 2637 ASSEMBLER_TEST_RUN(DNeg, test) { |
| 2638 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); |
| 2639 } |
| 2640 |
| 2641 #endif // defined(ARCH_IS_64_BIT) |
| 2642 |
2156 } // namespace dart | 2643 } // namespace dart |
2157 | 2644 |
2158 #endif // defined(TARGET_ARCH_DBC) | 2645 #endif // defined(TARGET_ARCH_DBC) |
OLD | NEW |