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

Side by Side Diff: runtime/vm/assembler_ia32_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
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_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
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);
Florian Schneider 2013/01/08 14:24:04 Please also add the corner cases from the existing
srdjan 2013/01/10 22:35:52 Added more tests, but mainly adapted test in tests
1325 }
1326
1327
1272 static const double kDoubleConst = 3.226; 1328 static const double kDoubleConst = 3.226;
1273 1329
1274 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) { 1330 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) {
1275 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst))); 1331 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst)));
1276 __ pushl(EAX); 1332 __ pushl(EAX);
1277 __ pushl(EAX); 1333 __ pushl(EAX);
1278 __ movsd(Address(ESP, 0), XMM0); 1334 __ movsd(Address(ESP, 0), XMM0);
1279 __ fldl(Address(ESP, 0)); 1335 __ fldl(Address(ESP, 0));
1280 __ popl(EAX); 1336 __ popl(EAX);
1281 __ popl(EAX); 1337 __ popl(EAX);
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 EAX); 2165 EAX);
2110 __ popl(EAX); 2166 __ popl(EAX);
2111 __ popl(CTX); 2167 __ popl(CTX);
2112 __ ret(); 2168 __ ret();
2113 } 2169 }
2114 2170
2115 2171
2116 } // namespace dart 2172 } // namespace dart
2117 2173
2118 #endif // defined TARGET_ARCH_IA32 2174 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698