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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 | 1618 |
1619 | 1619 |
1620 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { | 1620 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { |
1621 typedef uint32_t (*PackedCompareNLECode)(); | 1621 typedef uint32_t (*PackedCompareNLECode)(); |
1622 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); | 1622 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); |
1623 EXPECT_EQ(static_cast<uword>(0x0), res); | 1623 EXPECT_EQ(static_cast<uword>(0x0), res); |
1624 } | 1624 } |
1625 | 1625 |
1626 | 1626 |
1627 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { | 1627 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { |
1628 __ EnterDartFrame(0); | |
1629 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 1628 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
1630 __ movd(XMM0, RAX); | 1629 __ movd(XMM0, RAX); |
1631 __ shufps(XMM0, XMM0, Immediate(0x0)); | 1630 __ shufps(XMM0, XMM0, Immediate(0x0)); |
1632 __ negateps(XMM0); | 1631 __ negateps(XMM0); |
1633 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 1632 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
1634 __ LeaveFrameWithPP(); | |
1635 __ ret(); | 1633 __ ret(); |
1636 } | 1634 } |
1637 | 1635 |
1638 | 1636 |
1639 ASSEMBLER_TEST_RUN(PackedNegate, test) { | 1637 ASSEMBLER_TEST_RUN(PackedNegate, test) { |
1640 typedef float (*PackedNegateCode)(); | 1638 typedef float (*PackedNegateCode)(); |
1641 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); | 1639 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); |
1642 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); | 1640 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); |
1643 } | 1641 } |
1644 | 1642 |
1645 | 1643 |
1646 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { | 1644 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { |
1647 __ EnterDartFrame(0); | |
1648 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); | 1645 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); |
1649 __ movd(XMM0, RAX); | 1646 __ movd(XMM0, RAX); |
1650 __ shufps(XMM0, XMM0, Immediate(0x0)); | 1647 __ shufps(XMM0, XMM0, Immediate(0x0)); |
1651 __ absps(XMM0); | 1648 __ absps(XMM0); |
1652 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 1649 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
1653 __ LeaveFrameWithPP(); | |
1654 __ ret(); | 1650 __ ret(); |
1655 } | 1651 } |
1656 | 1652 |
1657 | 1653 |
1658 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { | 1654 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { |
1659 typedef float (*PackedAbsoluteCode)(); | 1655 typedef float (*PackedAbsoluteCode)(); |
1660 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); | 1656 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); |
1661 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); | 1657 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); |
1662 } | 1658 } |
1663 | 1659 |
1664 | 1660 |
1665 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { | 1661 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { |
1666 __ EnterDartFrame(0); | |
1667 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 1662 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
1668 __ zerowps(XMM0); | 1663 __ zerowps(XMM0); |
1669 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. | 1664 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. |
1670 __ LeaveFrameWithPP(); | |
1671 __ ret(); | 1665 __ ret(); |
1672 } | 1666 } |
1673 | 1667 |
1674 | 1668 |
1675 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { | 1669 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { |
1676 typedef float (*PackedSetWZeroCode)(); | 1670 typedef float (*PackedSetWZeroCode)(); |
1677 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())(); | 1671 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())(); |
1678 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); | 1672 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); |
1679 } | 1673 } |
1680 | 1674 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 | 1771 |
1778 | 1772 |
1779 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { | 1773 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { |
1780 static const struct ALIGN16 { | 1774 static const struct ALIGN16 { |
1781 uint32_t a; | 1775 uint32_t a; |
1782 uint32_t b; | 1776 uint32_t b; |
1783 uint32_t c; | 1777 uint32_t c; |
1784 uint32_t d; | 1778 uint32_t d; |
1785 } constant1 = | 1779 } constant1 = |
1786 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; | 1780 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; |
1787 __ EnterDartFrame(0); | 1781 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
| 1782 __ LoadPoolPointer(PP); |
1788 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); | 1783 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); |
1789 __ movups(XMM9, Address(RAX, 0)); | 1784 __ movups(XMM9, Address(RAX, 0)); |
1790 __ notps(XMM9); | 1785 __ notps(XMM9); |
1791 __ movaps(XMM0, XMM9); | 1786 __ movaps(XMM0, XMM9); |
1792 __ pushq(RAX); | 1787 __ pushq(RAX); |
1793 __ movss(Address(RSP, 0), XMM0); | 1788 __ movss(Address(RSP, 0), XMM0); |
1794 __ popq(RAX); | 1789 __ popq(RAX); |
1795 __ LeaveFrameWithPP(); | 1790 __ popq(PP); // Restore caller's pool pointer. |
1796 __ ret(); | 1791 __ ret(); |
1797 } | 1792 } |
1798 | 1793 |
1799 | 1794 |
1800 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { | 1795 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { |
1801 typedef uint32_t (*PackedLogicalNotCode)(); | 1796 typedef uint32_t (*PackedLogicalNotCode)(); |
1802 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); | 1797 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); |
1803 EXPECT_EQ(static_cast<uword>(0x0), res); | 1798 EXPECT_EQ(static_cast<uword>(0x0), res); |
1804 } | 1799 } |
1805 | 1800 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2182 typedef int64_t (*DoubleToInt64ConversionCode)(); | 2177 typedef int64_t (*DoubleToInt64ConversionCode)(); |
2183 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); | 2178 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); |
2184 EXPECT_EQ(0, res); | 2179 EXPECT_EQ(0, res); |
2185 } | 2180 } |
2186 | 2181 |
2187 | 2182 |
2188 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { | 2183 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { |
2189 ObjectStore* object_store = Isolate::Current()->object_store(); | 2184 ObjectStore* object_store = Isolate::Current()->object_store(); |
2190 const Object& obj = Object::ZoneHandle(object_store->smi_class()); | 2185 const Object& obj = Object::ZoneHandle(object_store->smi_class()); |
2191 Label fail; | 2186 Label fail; |
2192 __ EnterDartFrame(0); | 2187 __ EnterFrame(0); |
| 2188 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
| 2189 __ LoadPoolPointer(PP); |
2193 __ LoadObject(RAX, obj, PP); | 2190 __ LoadObject(RAX, obj, PP); |
2194 __ CompareObject(RAX, obj, PP); | 2191 __ CompareObject(RAX, obj, PP); |
2195 __ j(NOT_EQUAL, &fail); | 2192 __ j(NOT_EQUAL, &fail); |
2196 __ LoadObject(RCX, obj, PP); | 2193 __ LoadObject(RCX, obj, PP); |
2197 __ CompareObject(RCX, obj, PP); | 2194 __ CompareObject(RCX, obj, PP); |
2198 __ j(NOT_EQUAL, &fail); | 2195 __ j(NOT_EQUAL, &fail); |
2199 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); | 2196 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); |
2200 __ LoadObject(RCX, smi, PP); | 2197 __ LoadObject(RCX, smi, PP); |
2201 __ CompareObject(RCX, smi, PP); | 2198 __ CompareObject(RCX, smi, PP); |
2202 __ j(NOT_EQUAL, &fail); | 2199 __ j(NOT_EQUAL, &fail); |
2203 __ pushq(RAX); | 2200 __ pushq(RAX); |
2204 __ StoreObject(Address(RSP, 0), obj, PP); | 2201 __ StoreObject(Address(RSP, 0), obj, PP); |
2205 __ popq(RCX); | 2202 __ popq(RCX); |
2206 __ CompareObject(RCX, obj, PP); | 2203 __ CompareObject(RCX, obj, PP); |
2207 __ j(NOT_EQUAL, &fail); | 2204 __ j(NOT_EQUAL, &fail); |
2208 __ pushq(RAX); | 2205 __ pushq(RAX); |
2209 __ StoreObject(Address(RSP, 0), smi, PP); | 2206 __ StoreObject(Address(RSP, 0), smi, PP); |
2210 __ popq(RCX); | 2207 __ popq(RCX); |
2211 __ CompareObject(RCX, smi, PP); | 2208 __ CompareObject(RCX, smi, PP); |
2212 __ j(NOT_EQUAL, &fail); | 2209 __ j(NOT_EQUAL, &fail); |
2213 __ movl(RAX, Immediate(1)); // OK | 2210 __ movl(RAX, Immediate(1)); // OK |
2214 __ LeaveFrameWithPP(); | 2211 __ LeaveDartFrame(); |
2215 __ ret(); | 2212 __ ret(); |
2216 __ Bind(&fail); | 2213 __ Bind(&fail); |
2217 __ movl(RAX, Immediate(0)); // Fail. | 2214 __ movl(RAX, Immediate(0)); // Fail. |
2218 __ LeaveFrameWithPP(); | 2215 __ popq(PP); // Restore caller's pool pointer. |
| 2216 __ LeaveFrame(); |
2219 __ ret(); | 2217 __ ret(); |
2220 } | 2218 } |
2221 | 2219 |
2222 | 2220 |
2223 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { | 2221 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { |
2224 typedef bool (*TestObjectCompare)(); | 2222 typedef bool (*TestObjectCompare)(); |
2225 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); | 2223 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); |
2226 EXPECT_EQ(true, res); | 2224 EXPECT_EQ(true, res); |
2227 } | 2225 } |
2228 | 2226 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 typedef double (*SquareRootDoubleCode)(double d); | 2417 typedef double (*SquareRootDoubleCode)(double d); |
2420 const double kDoubleConst = .7; | 2418 const double kDoubleConst = .7; |
2421 double res = | 2419 double res = |
2422 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); | 2420 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); |
2423 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); | 2421 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); |
2424 } | 2422 } |
2425 | 2423 |
2426 | 2424 |
2427 // Called from assembler_test.cc. | 2425 // Called from assembler_test.cc. |
2428 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 2426 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
2429 __ EnterDartFrame(0); | 2427 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
| 2428 __ LoadPoolPointer(PP); |
2430 __ pushq(CTX); | 2429 __ pushq(CTX); |
2431 __ movq(CTX, RDI); | 2430 __ movq(CTX, RDI); |
2432 __ StoreIntoObject(RDX, | 2431 __ StoreIntoObject(RDX, |
2433 FieldAddress(RDX, GrowableObjectArray::data_offset()), | 2432 FieldAddress(RDX, GrowableObjectArray::data_offset()), |
2434 RSI); | 2433 RSI); |
2435 __ popq(CTX); | 2434 __ popq(CTX); |
2436 __ LeaveFrameWithPP(); | 2435 __ popq(PP); // Restore caller's pool pointer. |
2437 __ ret(); | 2436 __ ret(); |
2438 } | 2437 } |
2439 | 2438 |
2440 | 2439 |
2441 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { | 2440 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { |
2442 int64_t l = bit_cast<int64_t, double>(1024.67); | 2441 int64_t l = bit_cast<int64_t, double>(1024.67); |
2443 __ movq(RAX, Immediate(l)); | 2442 __ movq(RAX, Immediate(l)); |
2444 __ pushq(RAX); | 2443 __ pushq(RAX); |
2445 __ fldl(Address(RSP, 0)); | 2444 __ fldl(Address(RSP, 0)); |
2446 __ movq(Address(RSP, 0), Immediate(0)); | 2445 __ movq(Address(RSP, 0), Immediate(0)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); | 2539 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); |
2541 EXPECT_EQ(12.0, res); | 2540 EXPECT_EQ(12.0, res); |
2542 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); | 2541 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); |
2543 EXPECT_EQ(-12.0, res); | 2542 EXPECT_EQ(-12.0, res); |
2544 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); | 2543 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); |
2545 EXPECT_EQ(-12.0, res); | 2544 EXPECT_EQ(-12.0, res); |
2546 } | 2545 } |
2547 | 2546 |
2548 | 2547 |
2549 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { | 2548 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { |
2550 __ EnterDartFrame(0); | |
2551 __ DoubleAbs(XMM0); | 2549 __ DoubleAbs(XMM0); |
2552 __ LeaveFrameWithPP(); | |
2553 __ ret(); | 2550 __ ret(); |
2554 } | 2551 } |
2555 | 2552 |
2556 | 2553 |
2557 ASSEMBLER_TEST_RUN(DoubleAbs, test) { | 2554 ASSEMBLER_TEST_RUN(DoubleAbs, test) { |
2558 typedef double (*DoubleAbsCode)(double d); | 2555 typedef double (*DoubleAbsCode)(double d); |
2559 double val = -12.45; | 2556 double val = -12.45; |
2560 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 2557 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); |
2561 EXPECT_FLOAT_EQ(-val, res, 0.001); | 2558 EXPECT_FLOAT_EQ(-val, res, 0.001); |
2562 val = 12.45; | 2559 val = 12.45; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 EXPECT_EQ(1, res); // Greater equal. | 2643 EXPECT_EQ(1, res); // Greater equal. |
2647 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); | 2644 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); |
2648 EXPECT_EQ(1, res); // Greater equal. | 2645 EXPECT_EQ(1, res); // Greater equal. |
2649 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); | 2646 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); |
2650 EXPECT_EQ(-1, res); // Less. | 2647 EXPECT_EQ(-1, res); // Less. |
2651 } | 2648 } |
2652 | 2649 |
2653 } // namespace dart | 2650 } // namespace dart |
2654 | 2651 |
2655 #endif // defined TARGET_ARCH_X64 | 2652 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |