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

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

Issue 63093003: Fix for issue 14790 - Crash when using dartium devtools (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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_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
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); 1628 __ EnterDartFrame(0);
Ivan Posva 2013/11/07 22:11:58 I don't think we need to use EnterDartFrame at all
siva 2013/11/07 23:08:19 Done.
1629 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); 1629 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1630 __ movd(XMM0, RAX); 1630 __ movd(XMM0, RAX);
1631 __ shufps(XMM0, XMM0, Immediate(0x0)); 1631 __ shufps(XMM0, XMM0, Immediate(0x0));
1632 __ negateps(XMM0); 1632 __ negateps(XMM0);
1633 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. 1633 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes.
1634 __ LeaveFrameWithPP(); 1634 __ LeaveDartFrame();
1635 __ ret(); 1635 __ ret();
1636 } 1636 }
1637 1637
1638 1638
1639 ASSEMBLER_TEST_RUN(PackedNegate, test) { 1639 ASSEMBLER_TEST_RUN(PackedNegate, test) {
1640 typedef float (*PackedNegateCode)(); 1640 typedef float (*PackedNegateCode)();
1641 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); 1641 float res = reinterpret_cast<PackedNegateCode>(test->entry())();
1642 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); 1642 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f);
1643 } 1643 }
1644 1644
1645 1645
1646 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { 1646 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) {
1647 __ EnterDartFrame(0); 1647 __ EnterDartFrame(0);
1648 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); 1648 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f)));
1649 __ movd(XMM0, RAX); 1649 __ movd(XMM0, RAX);
1650 __ shufps(XMM0, XMM0, Immediate(0x0)); 1650 __ shufps(XMM0, XMM0, Immediate(0x0));
1651 __ absps(XMM0); 1651 __ absps(XMM0);
1652 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. 1652 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes.
1653 __ LeaveFrameWithPP(); 1653 __ LeaveDartFrame();
1654 __ ret(); 1654 __ ret();
1655 } 1655 }
1656 1656
1657 1657
1658 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { 1658 ASSEMBLER_TEST_RUN(PackedAbsolute, test) {
1659 typedef float (*PackedAbsoluteCode)(); 1659 typedef float (*PackedAbsoluteCode)();
1660 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); 1660 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())();
1661 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); 1661 EXPECT_FLOAT_EQ(15.3f, res, 0.001f);
1662 } 1662 }
1663 1663
1664 1664
1665 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { 1665 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) {
1666 __ EnterDartFrame(0); 1666 __ EnterDartFrame(0);
1667 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); 1667 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1668 __ zerowps(XMM0); 1668 __ zerowps(XMM0);
1669 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. 1669 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0.
1670 __ LeaveFrameWithPP(); 1670 __ LeaveDartFrame();
1671 __ ret(); 1671 __ ret();
1672 } 1672 }
1673 1673
1674 1674
1675 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { 1675 ASSEMBLER_TEST_RUN(PackedSetWZero, test) {
1676 typedef float (*PackedSetWZeroCode)(); 1676 typedef float (*PackedSetWZeroCode)();
1677 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())(); 1677 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())();
1678 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); 1678 EXPECT_FLOAT_EQ(0.0f, res, 0.001f);
1679 } 1679 }
1680 1680
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1777
1778 1778
1779 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { 1779 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) {
1780 static const struct ALIGN16 { 1780 static const struct ALIGN16 {
1781 uint32_t a; 1781 uint32_t a;
1782 uint32_t b; 1782 uint32_t b;
1783 uint32_t c; 1783 uint32_t c;
1784 uint32_t d; 1784 uint32_t d;
1785 } constant1 = 1785 } constant1 =
1786 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; 1786 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
1787 __ EnterDartFrame(0); 1787 __ EnterDartFrame(0);
Ivan Posva 2013/11/07 22:11:58 All we need here is saving and restoring of PP.
siva 2013/11/07 23:08:19 Changed to EnterFrame() ... LeaveFrame as it is ne
1788 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); 1788 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP);
1789 __ movups(XMM9, Address(RAX, 0)); 1789 __ movups(XMM9, Address(RAX, 0));
1790 __ notps(XMM9); 1790 __ notps(XMM9);
1791 __ movaps(XMM0, XMM9); 1791 __ movaps(XMM0, XMM9);
1792 __ pushq(RAX); 1792 __ pushq(RAX);
1793 __ movss(Address(RSP, 0), XMM0); 1793 __ movss(Address(RSP, 0), XMM0);
1794 __ popq(RAX); 1794 __ popq(RAX);
1795 __ LeaveFrameWithPP(); 1795 __ LeaveDartFrame();
1796 __ ret(); 1796 __ ret();
1797 } 1797 }
1798 1798
1799 1799
1800 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { 1800 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) {
1801 typedef uint32_t (*PackedLogicalNotCode)(); 1801 typedef uint32_t (*PackedLogicalNotCode)();
1802 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); 1802 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())();
1803 EXPECT_EQ(static_cast<uword>(0x0), res); 1803 EXPECT_EQ(static_cast<uword>(0x0), res);
1804 } 1804 }
1805 1805
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 __ StoreObject(Address(RSP, 0), obj, PP); 2204 __ StoreObject(Address(RSP, 0), obj, PP);
2205 __ popq(RCX); 2205 __ popq(RCX);
2206 __ CompareObject(RCX, obj, PP); 2206 __ CompareObject(RCX, obj, PP);
2207 __ j(NOT_EQUAL, &fail); 2207 __ j(NOT_EQUAL, &fail);
2208 __ pushq(RAX); 2208 __ pushq(RAX);
2209 __ StoreObject(Address(RSP, 0), smi, PP); 2209 __ StoreObject(Address(RSP, 0), smi, PP);
2210 __ popq(RCX); 2210 __ popq(RCX);
2211 __ CompareObject(RCX, smi, PP); 2211 __ CompareObject(RCX, smi, PP);
2212 __ j(NOT_EQUAL, &fail); 2212 __ j(NOT_EQUAL, &fail);
2213 __ movl(RAX, Immediate(1)); // OK 2213 __ movl(RAX, Immediate(1)); // OK
2214 __ LeaveFrameWithPP(); 2214 __ LeaveDartFrame();
2215 __ ret(); 2215 __ ret();
2216 __ Bind(&fail); 2216 __ Bind(&fail);
2217 __ movl(RAX, Immediate(0)); // Fail. 2217 __ movl(RAX, Immediate(0)); // Fail.
2218 __ LeaveFrameWithPP(); 2218 __ LeaveDartFrame();
2219 __ ret(); 2219 __ ret();
2220 } 2220 }
2221 2221
2222 2222
2223 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { 2223 ASSEMBLER_TEST_RUN(TestObjectCompare, test) {
2224 typedef bool (*TestObjectCompare)(); 2224 typedef bool (*TestObjectCompare)();
2225 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); 2225 bool res = reinterpret_cast<TestObjectCompare>(test->entry())();
2226 EXPECT_EQ(true, res); 2226 EXPECT_EQ(true, res);
2227 } 2227 }
2228 2228
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 2426
2427 // Called from assembler_test.cc. 2427 // Called from assembler_test.cc.
2428 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { 2428 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
2429 __ EnterDartFrame(0); 2429 __ EnterDartFrame(0);
2430 __ pushq(CTX); 2430 __ pushq(CTX);
2431 __ movq(CTX, RDI); 2431 __ movq(CTX, RDI);
2432 __ StoreIntoObject(RDX, 2432 __ StoreIntoObject(RDX,
2433 FieldAddress(RDX, GrowableObjectArray::data_offset()), 2433 FieldAddress(RDX, GrowableObjectArray::data_offset()),
2434 RSI); 2434 RSI);
2435 __ popq(CTX); 2435 __ popq(CTX);
2436 __ LeaveFrameWithPP(); 2436 __ LeaveDartFrame();
2437 __ ret(); 2437 __ ret();
2438 } 2438 }
2439 2439
2440 2440
2441 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { 2441 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) {
2442 int64_t l = bit_cast<int64_t, double>(1024.67); 2442 int64_t l = bit_cast<int64_t, double>(1024.67);
2443 __ movq(RAX, Immediate(l)); 2443 __ movq(RAX, Immediate(l));
2444 __ pushq(RAX); 2444 __ pushq(RAX);
2445 __ fldl(Address(RSP, 0)); 2445 __ fldl(Address(RSP, 0));
2446 __ movq(Address(RSP, 0), Immediate(0)); 2446 __ movq(Address(RSP, 0), Immediate(0));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); 2542 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3);
2543 EXPECT_EQ(-12.0, res); 2543 EXPECT_EQ(-12.0, res);
2544 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); 2544 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8);
2545 EXPECT_EQ(-12.0, res); 2545 EXPECT_EQ(-12.0, res);
2546 } 2546 }
2547 2547
2548 2548
2549 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { 2549 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) {
2550 __ EnterDartFrame(0); 2550 __ EnterDartFrame(0);
2551 __ DoubleAbs(XMM0); 2551 __ DoubleAbs(XMM0);
2552 __ LeaveFrameWithPP(); 2552 __ LeaveDartFrame();
2553 __ ret(); 2553 __ ret();
2554 } 2554 }
2555 2555
2556 2556
2557 ASSEMBLER_TEST_RUN(DoubleAbs, test) { 2557 ASSEMBLER_TEST_RUN(DoubleAbs, test) {
2558 typedef double (*DoubleAbsCode)(double d); 2558 typedef double (*DoubleAbsCode)(double d);
2559 double val = -12.45; 2559 double val = -12.45;
2560 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); 2560 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val);
2561 EXPECT_FLOAT_EQ(-val, res, 0.001); 2561 EXPECT_FLOAT_EQ(-val, res, 0.001);
2562 val = 12.45; 2562 val = 12.45;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 EXPECT_EQ(1, res); // Greater equal. 2646 EXPECT_EQ(1, res); // Greater equal.
2647 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); 2647 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5);
2648 EXPECT_EQ(1, res); // Greater equal. 2648 EXPECT_EQ(1, res); // Greater equal.
2649 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); 2649 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5);
2650 EXPECT_EQ(-1, res); // Less. 2650 EXPECT_EQ(-1, res); // Less.
2651 } 2651 }
2652 2652
2653 } // namespace dart 2653 } // namespace dart
2654 2654
2655 #endif // defined TARGET_ARCH_X64 2655 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698