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

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);
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 }
1330
1331
1272 static const double kDoubleConst = 3.226; 1332 static const double kDoubleConst = 3.226;
1273 1333
1274 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) { 1334 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) {
1275 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst))); 1335 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst)));
1276 __ pushl(EAX); 1336 __ pushl(EAX);
1277 __ pushl(EAX); 1337 __ pushl(EAX);
1278 __ movsd(Address(ESP, 0), XMM0); 1338 __ movsd(Address(ESP, 0), XMM0);
1279 __ fldl(Address(ESP, 0)); 1339 __ fldl(Address(ESP, 0));
1280 __ popl(EAX); 1340 __ popl(EAX);
1281 __ popl(EAX); 1341 __ popl(EAX);
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 EAX); 2169 EAX);
2110 __ popl(EAX); 2170 __ popl(EAX);
2111 __ popl(CTX); 2171 __ popl(CTX);
2112 __ ret(); 2172 __ ret();
2113 } 2173 }
2114 2174
2115 2175
2116 } // namespace dart 2176 } // namespace dart
2117 2177
2118 #endif // defined TARGET_ARCH_IA32 2178 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698