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

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

Issue 2098573004: DBC: CheckClassInstr (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 5 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
« no previous file with comments | « no previous file | runtime/vm/constants_dbc.h » ('j') | runtime/vm/intermediate_language_dbc.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 116
117 ASSEMBLER_TEST_RUN(Simple, test) { 117 ASSEMBLER_TEST_RUN(Simple, test) {
118 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 118 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
119 } 119 }
120 120
121 121
122 ASSEMBLER_TEST_GENERATE(Nop, assembler) { 122 ASSEMBLER_TEST_GENERATE(Nop, assembler) {
123 __ PushConstant(Smi::Handle(Smi::New(42))); 123 __ PushConstant(Smi::Handle(Smi::New(42)));
124 __ Nop(); 124 __ Nop(0);
125 __ Nop(); 125 __ Nop(0);
126 __ Nop(); 126 __ Nop(0);
127 __ Nop(); 127 __ Nop(0);
128 __ Nop(); 128 __ Nop(0);
129 __ ReturnTOS(); 129 __ ReturnTOS();
130 } 130 }
131 131
132 132
133 ASSEMBLER_TEST_RUN(Nop, test) { 133 ASSEMBLER_TEST_RUN(Nop, test) {
134 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 134 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
135 } 135 }
136 136
137 137
138 // Called from assembler_test.cc. 138 // Called from assembler_test.cc.
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 } 1639 }
1640 1640
1641 1641
1642 // - CheckClassId rA, D 1642 // - CheckClassId rA, D
1643 // 1643 //
1644 // If the object at FP[rA]'s class id matches hthe class id in PP[D], then 1644 // If the object at FP[rA]'s class id matches hthe class id in PP[D], then
1645 // skip the following instruction. 1645 // skip the following instruction.
1646 ASSEMBLER_TEST_GENERATE(CheckClassIdSmiPass, assembler) { 1646 ASSEMBLER_TEST_GENERATE(CheckClassIdSmiPass, assembler) {
1647 __ Frame(1); 1647 __ Frame(1);
1648 __ LoadConstant(0, Smi::Handle(Smi::New(42))); 1648 __ LoadConstant(0, Smi::Handle(Smi::New(42)));
1649 __ CheckClassId(0, __ AddConstant(Smi::Handle(Smi::New(kSmiCid)))); 1649 __ CheckClassId(0, kSmiCid);
1650 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); 1650 __ LoadConstant(0, Smi::Handle(Smi::New(-1)));
1651 __ Return(0); 1651 __ Return(0);
1652 } 1652 }
1653 1653
1654 1654
1655 ASSEMBLER_TEST_RUN(CheckClassIdSmiPass, test) { 1655 ASSEMBLER_TEST_RUN(CheckClassIdSmiPass, test) {
1656 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 1656 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1657 } 1657 }
1658 1658
1659 1659
1660 ASSEMBLER_TEST_GENERATE(CheckClassIdNonSmiPass, assembler) { 1660 ASSEMBLER_TEST_GENERATE(CheckClassIdNonSmiPass, assembler) {
1661 __ Frame(1); 1661 __ Frame(1);
1662 __ LoadConstant(0, Bool::True()); 1662 __ LoadConstant(0, Bool::True());
1663 __ CheckClassId(0, __ AddConstant(Smi::Handle(Smi::New(kBoolCid)))); 1663 __ CheckClassId(0, kBoolCid);
1664 __ LoadConstant(0, Bool::False()); 1664 __ LoadConstant(0, Bool::False());
1665 __ Return(0); 1665 __ Return(0);
1666 } 1666 }
1667 1667
1668 1668
1669 ASSEMBLER_TEST_RUN(CheckClassIdNonSmiPass, test) { 1669 ASSEMBLER_TEST_RUN(CheckClassIdNonSmiPass, test) {
1670 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 1670 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
1671 } 1671 }
1672 1672
1673 1673
1674 ASSEMBLER_TEST_GENERATE(CheckClassIdFail, assembler) { 1674 ASSEMBLER_TEST_GENERATE(CheckClassIdFail, assembler) {
1675 __ Frame(1); 1675 __ Frame(1);
1676 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); 1676 __ LoadConstant(0, Smi::Handle(Smi::New(-1)));
1677 __ CheckClassId(0, __ AddConstant(Smi::Handle(Smi::New(kBoolCid)))); 1677 __ CheckClassId(0, kBoolCid);
1678 __ LoadConstant(0, Smi::Handle(Smi::New(42))); 1678 __ LoadConstant(0, Smi::Handle(Smi::New(42)));
1679 __ Return(0); 1679 __ Return(0);
1680 } 1680 }
1681 1681
1682 1682
1683 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) { 1683 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) {
1684 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 1684 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1685 } 1685 }
1686 1686
1687
1688 // - If<Cond>Null rA
1689 //
1690 // Cond is Eq or Ne. Skips the next instruction unless the given condition
1691 // holds.
1692 ASSEMBLER_TEST_GENERATE(IfEqNullNotNull, assembler) {
1693 __ Frame(2);
1694 __ LoadConstant(0, Smi::Handle(Smi::New(-1)));
1695 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
1696 __ IfEqNull(0);
1697 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
1698 __ Return(1);
1699 }
1700
1701
1702 ASSEMBLER_TEST_RUN(IfEqNullNotNull, test) {
1703 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1704 }
1705
1706
1707 ASSEMBLER_TEST_GENERATE(IfEqNullIsNull, assembler) {
1708 __ Frame(2);
1709 __ LoadConstant(0, Object::null_object());
1710 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
1711 __ IfEqNull(0);
1712 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
1713 __ Return(1);
1714 }
1715
1716
1717 ASSEMBLER_TEST_RUN(IfEqNullIsNull, test) {
1718 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1719 }
1720
1721
1722 ASSEMBLER_TEST_GENERATE(IfNeNullIsNull, assembler) {
1723 __ Frame(2);
1724 __ LoadConstant(0, Object::null_object());
1725 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
1726 __ IfNeNull(0);
1727 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
1728 __ Return(1);
1729 }
1730
1731
1732 ASSEMBLER_TEST_RUN(IfNeNullIsNull, test) {
1733 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1734 }
1735
1736
1737 ASSEMBLER_TEST_GENERATE(IfNeNullNotNull, assembler) {
1738 __ Frame(2);
1739 __ LoadConstant(0, Smi::Handle(Smi::New(-1)));
1740 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
1741 __ IfNeNull(0);
1742 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
1743 __ Return(1);
1744 }
1745
1746
1747 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) {
1748 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1749 }
1750
1687 } // namespace dart 1751 } // namespace dart
1688 1752
1689 #endif // defined(TARGET_ARCH_DBC) 1753 #endif // defined(TARGET_ARCH_DBC)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/constants_dbc.h » ('j') | runtime/vm/intermediate_language_dbc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698