| OLD | NEW |
| 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 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 typedef double (*DoubleAbsCode)(double d); | 2219 typedef double (*DoubleAbsCode)(double d); |
| 2220 double val = -12.45; | 2220 double val = -12.45; |
| 2221 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 2221 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); |
| 2222 EXPECT_FLOAT_EQ(-val, res, 0.001); | 2222 EXPECT_FLOAT_EQ(-val, res, 0.001); |
| 2223 val = 12.45; | 2223 val = 12.45; |
| 2224 res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 2224 res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); |
| 2225 EXPECT_FLOAT_EQ(val, res, 0.001); | 2225 EXPECT_FLOAT_EQ(val, res, 0.001); |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 | 2228 |
| 2229 ASSEMBLER_TEST_GENERATE(DoubleToDoubleRound, assembler) { | |
| 2230 __ DoubleRound(XMM0, XMM0, XMM1); | |
| 2231 __ ret(); | |
| 2232 } | |
| 2233 | |
| 2234 | |
| 2235 ASSEMBLER_TEST_RUN(DoubleToDoubleRound, test) { | |
| 2236 typedef double (*DoubleToDoubleRoundCode)(double d); | |
| 2237 double res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(12.3); | |
| 2238 EXPECT_EQ(12.0, res); | |
| 2239 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(12.8); | |
| 2240 EXPECT_EQ(13.0, res); | |
| 2241 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(0.5); | |
| 2242 EXPECT_EQ(1.0, res); | |
| 2243 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(-12.3); | |
| 2244 EXPECT_EQ(-12.0, res); | |
| 2245 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(-12.8); | |
| 2246 EXPECT_EQ(-13.0, res); | |
| 2247 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(-0.5); | |
| 2248 EXPECT_EQ(-1.0, res); | |
| 2249 res = reinterpret_cast<DoubleToDoubleRoundCode>( | |
| 2250 test->entry())(0.49999999999999994); | |
| 2251 EXPECT_EQ(0.0, res); | |
| 2252 res = reinterpret_cast<DoubleToDoubleRoundCode>( | |
| 2253 test->entry())(-0.49999999999999994); | |
| 2254 EXPECT_EQ(-0.0, res); | |
| 2255 res = reinterpret_cast<DoubleToDoubleRoundCode>( | |
| 2256 test->entry())(9007199254740991.0); | |
| 2257 EXPECT_EQ(9007199254740991.0, res); | |
| 2258 res = reinterpret_cast<DoubleToDoubleRoundCode>( | |
| 2259 test->entry())(-9007199254740991.0); | |
| 2260 EXPECT_EQ(-9007199254740991.0, res); | |
| 2261 } | |
| 2262 | |
| 2263 | |
| 2264 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { | 2229 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { |
| 2265 __ movmskpd(RAX, XMM0); | 2230 __ movmskpd(RAX, XMM0); |
| 2266 __ andq(RAX, Immediate(0x1)); | 2231 __ andq(RAX, Immediate(0x1)); |
| 2267 __ ret(); | 2232 __ ret(); |
| 2268 } | 2233 } |
| 2269 | 2234 |
| 2270 | 2235 |
| 2271 ASSEMBLER_TEST_RUN(ExtractSignBits, test) { | 2236 ASSEMBLER_TEST_RUN(ExtractSignBits, test) { |
| 2272 typedef int (*ExtractSignBits)(double d); | 2237 typedef int (*ExtractSignBits)(double d); |
| 2273 int res = reinterpret_cast<ExtractSignBits>(test->entry())(1.0); | 2238 int res = reinterpret_cast<ExtractSignBits>(test->entry())(1.0); |
| 2274 EXPECT_EQ(0, res); | 2239 EXPECT_EQ(0, res); |
| 2275 res = reinterpret_cast<ExtractSignBits>(test->entry())(-1.0); | 2240 res = reinterpret_cast<ExtractSignBits>(test->entry())(-1.0); |
| 2276 EXPECT_EQ(1, res); | 2241 EXPECT_EQ(1, res); |
| 2277 res = reinterpret_cast<ExtractSignBits>(test->entry())(-0.0); | 2242 res = reinterpret_cast<ExtractSignBits>(test->entry())(-0.0); |
| 2278 EXPECT_EQ(1, res); | 2243 EXPECT_EQ(1, res); |
| 2279 } | 2244 } |
| 2280 | 2245 |
| 2281 } // namespace dart | 2246 } // namespace dart |
| 2282 | 2247 |
| 2283 #endif // defined TARGET_ARCH_X64 | 2248 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |