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

Side by Side Diff: runtime/vm/assembler_ia32_test.cc

Issue 12334080: For Doubl erounding call C-function instead of attempting to inline it. Fixes issue 8760. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 EXPECT_EQ(12.0, res); 1668 EXPECT_EQ(12.0, res);
1669 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); 1669 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8);
1670 EXPECT_EQ(12.0, res); 1670 EXPECT_EQ(12.0, res);
1671 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); 1671 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3);
1672 EXPECT_EQ(-12.0, res); 1672 EXPECT_EQ(-12.0, res);
1673 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); 1673 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8);
1674 EXPECT_EQ(-12.0, res); 1674 EXPECT_EQ(-12.0, res);
1675 } 1675 }
1676 1676
1677 1677
1678 ASSEMBLER_TEST_GENERATE(DoubleToDoubleRound, assembler) {
1679 __ movsd(XMM3, Address(ESP, kWordSize));
1680 __ DoubleRound(XMM2, XMM3, XMM0);
1681 __ pushl(EAX);
1682 __ pushl(EAX);
1683 __ movsd(Address(ESP, 0), XMM2);
1684 __ fldl(Address(ESP, 0));
1685 __ popl(EAX);
1686 __ popl(EAX);
1687 __ ret();
1688 }
1689
1690
1691 ASSEMBLER_TEST_RUN(DoubleToDoubleRound, test) {
1692 typedef double (*DoubleToDoubleRoundCode)(double d);
1693 double res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(12.3);
1694 EXPECT_EQ(12.0, res);
1695 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(12.8);
1696 EXPECT_EQ(13.0, res);
1697 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(0.5);
1698 EXPECT_EQ(1.0, res);
1699 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(-12.3);
1700 EXPECT_EQ(-12.0, res);
1701 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(-12.8);
1702 EXPECT_EQ(-13.0, res);
1703 res = reinterpret_cast<DoubleToDoubleRoundCode>(test->entry())(-0.5);
1704 EXPECT_EQ(-1.0, res);
1705 res = reinterpret_cast<DoubleToDoubleRoundCode>(
1706 test->entry())(0.49999999999999994);
1707 EXPECT_EQ(0.0, res);
1708 res = reinterpret_cast<DoubleToDoubleRoundCode>(
1709 test->entry())(-0.49999999999999994);
1710 EXPECT_EQ(-0.0, res);
1711 res = reinterpret_cast<DoubleToDoubleRoundCode>(
1712 test->entry())(9007199254740991.0);
1713 EXPECT_EQ(9007199254740991.0, res);
1714 res = reinterpret_cast<DoubleToDoubleRoundCode>(
1715 test->entry())(-9007199254740991.0);
1716 EXPECT_EQ(-9007199254740991.0, res);
1717 }
1718
1719
1720 static const double kDoubleConst = 3.226; 1678 static const double kDoubleConst = 3.226;
1721 1679
1722 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) { 1680 ASSEMBLER_TEST_GENERATE(GlobalAddress, assembler) {
1723 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst))); 1681 __ movsd(XMM0, Address::Absolute(reinterpret_cast<uword>(&kDoubleConst)));
1724 __ pushl(EAX); 1682 __ pushl(EAX);
1725 __ pushl(EAX); 1683 __ pushl(EAX);
1726 __ movsd(Address(ESP, 0), XMM0); 1684 __ movsd(Address(ESP, 0), XMM0);
1727 __ fldl(Address(ESP, 0)); 1685 __ fldl(Address(ESP, 0));
1728 __ popl(EAX); 1686 __ popl(EAX);
1729 __ popl(EAX); 1687 __ popl(EAX);
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 EAX); 2518 EAX);
2561 __ popl(EAX); 2519 __ popl(EAX);
2562 __ popl(CTX); 2520 __ popl(CTX);
2563 __ ret(); 2521 __ ret();
2564 } 2522 }
2565 2523
2566 2524
2567 } // namespace dart 2525 } // namespace dart
2568 2526
2569 #endif // defined TARGET_ARCH_IA32 2527 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698