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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 } | 1285 } |
1286 | 1286 |
1287 | 1287 |
1288 ASSEMBLER_TEST_RUN(XorpdZeroing, entry) { | 1288 ASSEMBLER_TEST_RUN(XorpdZeroing, entry) { |
1289 typedef double (*XorpdZeroingCode)(double d); | 1289 typedef double (*XorpdZeroingCode)(double d); |
1290 double res = reinterpret_cast<XorpdZeroingCode>(entry)(12.56e3); | 1290 double res = reinterpret_cast<XorpdZeroingCode>(entry)(12.56e3); |
1291 EXPECT_FLOAT_EQ(0.0, res, 0.0001); | 1291 EXPECT_FLOAT_EQ(0.0, res, 0.0001); |
1292 } | 1292 } |
1293 | 1293 |
1294 | 1294 |
| 1295 ASSEMBLER_TEST_GENERATE(XorpdZeroing2, assembler) { |
| 1296 __ xorpd(XMM0, XMM0); |
| 1297 __ ret(); |
| 1298 } |
| 1299 |
| 1300 |
| 1301 ASSEMBLER_TEST_RUN(XorpdZeroing2, entry) { |
| 1302 typedef double (*XorpdZeroing2Code)(double d); |
| 1303 double res = reinterpret_cast<XorpdZeroing2Code>(entry)(12.56e3); |
| 1304 EXPECT_FLOAT_EQ(0.0, res, 0.0001); |
| 1305 } |
| 1306 |
| 1307 |
1295 ASSEMBLER_TEST_GENERATE(SquareRootDouble, assembler) { | 1308 ASSEMBLER_TEST_GENERATE(SquareRootDouble, assembler) { |
1296 __ sqrtsd(XMM0, XMM0); | 1309 __ sqrtsd(XMM0, XMM0); |
1297 __ ret(); | 1310 __ ret(); |
1298 } | 1311 } |
1299 | 1312 |
1300 | 1313 |
1301 ASSEMBLER_TEST_RUN(SquareRootDouble, entry) { | 1314 ASSEMBLER_TEST_RUN(SquareRootDouble, entry) { |
1302 typedef double (*SquareRootDoubleCode)(double d); | 1315 typedef double (*SquareRootDoubleCode)(double d); |
1303 const double kDoubleConst = .7; | 1316 const double kDoubleConst = .7; |
1304 double res = reinterpret_cast<SquareRootDoubleCode>(entry)(kDoubleConst); | 1317 double res = reinterpret_cast<SquareRootDoubleCode>(entry)(kDoubleConst); |
1305 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); | 1318 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); |
1306 } | 1319 } |
1307 | 1320 |
1308 | 1321 |
1309 // Called from assembler_test.cc. | 1322 // Called from assembler_test.cc. |
1310 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 1323 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
1311 __ pushq(CTX); | 1324 __ pushq(CTX); |
1312 __ movq(CTX, RDI); | 1325 __ movq(CTX, RDI); |
1313 __ StoreIntoObject(RDX, | 1326 __ StoreIntoObject(RDX, |
1314 FieldAddress(RDX, GrowableObjectArray::data_offset()), | 1327 FieldAddress(RDX, GrowableObjectArray::data_offset()), |
1315 RSI); | 1328 RSI); |
1316 __ popq(CTX); | 1329 __ popq(CTX); |
1317 __ ret(); | 1330 __ ret(); |
1318 } | 1331 } |
1319 | 1332 |
| 1333 |
| 1334 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { |
| 1335 int64_t l = bit_cast<int64_t, double>(1024.67); |
| 1336 __ movq(RAX, Immediate(l)); |
| 1337 __ pushq(RAX); |
| 1338 __ fldl(Address(RSP, 0)); |
| 1339 __ movq(Address(RSP, 0), Immediate(0)); |
| 1340 __ fstpl(Address(RSP, 0)); |
| 1341 __ popq(RAX); |
| 1342 __ ret(); |
| 1343 } |
| 1344 |
| 1345 |
| 1346 ASSEMBLER_TEST_RUN(DoubleFPUStackMoves, entry) { |
| 1347 typedef int64_t (*DoubleFPUStackMovesCode)(); |
| 1348 int64_t res = reinterpret_cast<DoubleFPUStackMovesCode>(entry)(); |
| 1349 EXPECT_FLOAT_EQ(1024.67, (bit_cast<double, int64_t>(res)), 0.001); |
| 1350 } |
| 1351 |
| 1352 |
| 1353 ASSEMBLER_TEST_GENERATE(Sine, assembler) { |
| 1354 __ pushq(RAX); |
| 1355 __ movsd(Address(RSP, 0), XMM0); |
| 1356 __ fldl(Address(RSP, 0)); |
| 1357 __ fsin(); |
| 1358 __ fstpl(Address(RSP, 0)); |
| 1359 __ movsd(XMM0, Address(RSP, 0)); |
| 1360 __ popq(RAX); |
| 1361 __ ret(); |
| 1362 } |
| 1363 |
| 1364 |
| 1365 ASSEMBLER_TEST_RUN(Sine, entry) { |
| 1366 typedef double (*SineCode)(double d); |
| 1367 const double kDoubleConst = 0.7; |
| 1368 double res = reinterpret_cast<SineCode>(entry)(kDoubleConst); |
| 1369 EXPECT_FLOAT_EQ(sin(kDoubleConst), res, 0.0001); |
| 1370 } |
| 1371 |
| 1372 |
| 1373 ASSEMBLER_TEST_GENERATE(Cosine, assembler) { |
| 1374 __ pushq(RAX); |
| 1375 __ movsd(Address(RSP, 0), XMM0); |
| 1376 __ fldl(Address(RSP, 0)); |
| 1377 __ fcos(); |
| 1378 __ fstpl(Address(RSP, 0)); |
| 1379 __ movsd(XMM0, Address(RSP, 0)); |
| 1380 __ popq(RAX); |
| 1381 __ ret(); |
| 1382 } |
| 1383 |
| 1384 |
| 1385 ASSEMBLER_TEST_RUN(Cosine, entry) { |
| 1386 typedef double (*CosineCode)(double f); |
| 1387 const double kDoubleConst = 0.7; |
| 1388 double res = reinterpret_cast<CosineCode>(entry)(kDoubleConst); |
| 1389 EXPECT_FLOAT_EQ(cos(kDoubleConst), res, 0.0001); |
| 1390 } |
| 1391 |
| 1392 |
| 1393 ASSEMBLER_TEST_GENERATE(IntToDoubleConversion, assembler) { |
| 1394 __ movq(RDX, Immediate(6)); |
| 1395 __ cvtsi2sd(XMM0, RDX); |
| 1396 __ ret(); |
| 1397 } |
| 1398 |
| 1399 |
| 1400 ASSEMBLER_TEST_RUN(IntToDoubleConversion, entry) { |
| 1401 typedef double (*IntToDoubleConversionCode)(); |
| 1402 double res = reinterpret_cast<IntToDoubleConversionCode>(entry)(); |
| 1403 EXPECT_FLOAT_EQ(6.0, res, 0.001); |
| 1404 } |
| 1405 |
| 1406 |
| 1407 ASSEMBLER_TEST_GENERATE(IntToDoubleConversion2, assembler) { |
| 1408 __ pushq(RDI); |
| 1409 __ fildl(Address(RSP, 0)); |
| 1410 __ fstpl(Address(RSP, 0)); |
| 1411 __ movsd(XMM0, Address(RSP, 0)); |
| 1412 __ popq(RAX); |
| 1413 __ ret(); |
| 1414 } |
| 1415 |
| 1416 |
| 1417 ASSEMBLER_TEST_RUN(IntToDoubleConversion2, entry) { |
| 1418 typedef double (*IntToDoubleConversion2Code)(int i); |
| 1419 double res = reinterpret_cast<IntToDoubleConversion2Code>(entry)(3); |
| 1420 EXPECT_FLOAT_EQ(3.0, res, 0.001); |
| 1421 } |
| 1422 |
| 1423 |
| 1424 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { |
| 1425 __ movmskpd(RAX, XMM0); |
| 1426 __ ret(); |
| 1427 } |
| 1428 |
| 1429 |
| 1430 ASSEMBLER_TEST_RUN(ExtractSignBits, entry) { |
| 1431 typedef int (*ExtractSignBits)(double d); |
| 1432 int res = reinterpret_cast<ExtractSignBits>(entry)(1.0); |
| 1433 EXPECT_EQ(0, res); |
| 1434 res = reinterpret_cast<ExtractSignBits>(entry)(-1.0); |
| 1435 EXPECT_EQ(1, res); |
| 1436 res = reinterpret_cast<ExtractSignBits>(entry)(-0.0); |
| 1437 EXPECT_EQ(1, res); |
| 1438 } |
| 1439 |
1320 } // namespace dart | 1440 } // namespace dart |
1321 | 1441 |
1322 #endif // defined TARGET_ARCH_X64 | 1442 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |