| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 | 1262 |
| 1263 ASSEMBLER_TEST_RUN(DoubleToIntConversionTrunc, entry) { | 1263 ASSEMBLER_TEST_RUN(DoubleToIntConversionTrunc, entry) { |
| 1264 typedef int (*DoubleToIntConversionTruncCode)(double d); | 1264 typedef int (*DoubleToIntConversionTruncCode)(double d); |
| 1265 int res = reinterpret_cast<DoubleToIntConversionTruncCode>(entry)(12.3); | 1265 int res = reinterpret_cast<DoubleToIntConversionTruncCode>(entry)(12.3); |
| 1266 EXPECT_EQ(12, res); | 1266 EXPECT_EQ(12, res); |
| 1267 res = reinterpret_cast<DoubleToIntConversionTruncCode>(entry)(12.8); | 1267 res = reinterpret_cast<DoubleToIntConversionTruncCode>(entry)(12.8); |
| 1268 EXPECT_EQ(12, res); | 1268 EXPECT_EQ(12, res); |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 | 1271 |
| 1272 ASSEMBLER_TEST_GENERATE(DoubleToDoubleTrunc, assembler) { |
| 1273 __ movsd(XMM3, Address(ESP, kWordSize)); |
| 1274 __ roundsd(XMM2, XMM3, Assembler::kRoundToZero); |
| 1275 __ pushl(EAX); |
| 1276 __ pushl(EAX); |
| 1277 __ movsd(Address(ESP, 0), XMM2); |
| 1278 __ fldl(Address(ESP, 0)); |
| 1279 __ popl(EAX); |
| 1280 __ popl(EAX); |
| 1281 __ ret(); |
| 1282 } |
| 1283 |
| 1284 |
| 1285 ASSEMBLER_TEST_RUN(DoubleToDoubleTrunc, entry) { |
| 1286 typedef double (*DoubleToDoubleTruncCode)(double d); |
| 1287 double res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(12.3); |
| 1288 EXPECT_EQ(12.0, res); |
| 1289 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(12.8); |
| 1290 EXPECT_EQ(12.0, res); |
| 1291 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(-12.3); |
| 1292 EXPECT_EQ(-12.0, res); |
| 1293 res = reinterpret_cast<DoubleToDoubleTruncCode>(entry)(-12.8); |
| 1294 EXPECT_EQ(-12.0, res); |
| 1295 } |
| 1296 |
| 1297 |
| 1298 ASSEMBLER_TEST_GENERATE(DoubleToDoubleRound, assembler) { |
| 1299 __ movsd(XMM3, Address(ESP, kWordSize)); |
| 1300 __ DoubleRound(XMM2, XMM3, XMM0); |
| 1301 __ pushl(EAX); |
| 1302 __ pushl(EAX); |
| 1303 __ movsd(Address(ESP, 0), XMM2); |
| 1304 __ fldl(Address(ESP, 0)); |
| 1305 __ popl(EAX); |
| 1306 __ popl(EAX); |
| 1307 __ ret(); |
| 1308 } |
| 1309 |
| 1310 |
| 1311 ASSEMBLER_TEST_RUN(DoubleToDoubleRound, entry) { |
| 1312 typedef double (*DoubleToDoubleRoundCode)(double d); |
| 1313 double res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(12.3); |
| 1314 EXPECT_EQ(12.0, res); |
| 1315 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(12.8); |
| 1316 EXPECT_EQ(13.0, res); |
| 1317 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(0.5); |
| 1318 EXPECT_EQ(1.0, res); |
| 1319 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-12.3); |
| 1320 EXPECT_EQ(-12.0, res); |
| 1321 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-12.8); |
| 1322 EXPECT_EQ(-13.0, res); |
| 1323 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-0.5); |
| 1324 EXPECT_EQ(-1.0, res); |
| 1325 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(0.49999999999999994); |
| 1326 EXPECT_EQ(0.0, res); |
| 1327 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-0.49999999999999994); |
| 1328 EXPECT_EQ(-0.0, res); |
| 1329 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(9007199254740991.0); |
| 1330 EXPECT_EQ(9007199254740991.0, res); |
| 1331 res = reinterpret_cast<DoubleToDoubleRoundCode>(entry)(-9007199254740991.0); |
| 1332 EXPECT_EQ(-9007199254740991.0, res); |
| 1333 } |
| 1334 |
| 1335 |
| 1272 static const double kDoubleConst = 3.226; | 1336 static const double kDoubleConst = 3.226; |
| 1273 | 1337 |
| 1274 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) { | 1338 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) { |
| 1275 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst))); | 1339 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst))); |
| 1276 __ pushl(EAX); | 1340 __ pushl(EAX); |
| 1277 __ pushl(EAX); | 1341 __ pushl(EAX); |
| 1278 __ movsd(Address(ESP, 0), XMM0); | 1342 __ movsd(Address(ESP, 0), XMM0); |
| 1279 __ fldl(Address(ESP, 0)); | 1343 __ fldl(Address(ESP, 0)); |
| 1280 __ popl(EAX); | 1344 __ popl(EAX); |
| 1281 __ popl(EAX); | 1345 __ popl(EAX); |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 EAX); | 2173 EAX); |
| 2110 __ popl(EAX); | 2174 __ popl(EAX); |
| 2111 __ popl(CTX); | 2175 __ popl(CTX); |
| 2112 __ ret(); | 2176 __ ret(); |
| 2113 } | 2177 } |
| 2114 | 2178 |
| 2115 | 2179 |
| 2116 } // namespace dart | 2180 } // namespace dart |
| 2117 | 2181 |
| 2118 #endif // defined TARGET_ARCH_IA32 | 2182 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |