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

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

Issue 2122363002: DBC: Implement TestCids instruction. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync, review 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 | « runtime/vm/assembler_dbc.h ('k') | runtime/vm/constants_dbc.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) 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 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 __ PushConstant(Bool::False()); 1643 __ PushConstant(Bool::False());
1644 __ ReturnTOS(); 1644 __ ReturnTOS();
1645 } 1645 }
1646 1646
1647 1647
1648 ASSEMBLER_TEST_RUN(TestSmiFalse, test) { 1648 ASSEMBLER_TEST_RUN(TestSmiFalse, test) {
1649 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code())); 1649 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code()));
1650 } 1650 }
1651 1651
1652 1652
1653 // - TestCids rA, D
1654 //
1655 // The next D instructions must be Nops whose D field encodes a class id. If
1656 // the class id of FP[rA] matches, jump to PC + N + 1 if the matching Nop's
1657 // A != 0 or PC + N + 2 if the matching Nop's A = 0. If no match is found,
1658 // jump to PC + N.
1659 ASSEMBLER_TEST_GENERATE(TestCidsTrue, assembler) {
1660 Label true_branch, no_match_branch;
1661 __ Frame(2);
1662 __ LoadConstant(0, Object::Handle(String::New("Hi", Heap::kOld)));
1663 const intptr_t num_cases = 2;
1664 __ TestCids(0, num_cases);
1665 __ Nop(0, static_cast<uint16_t>(kSmiCid)); // Smi => false
1666 __ Nop(1, static_cast<uint16_t>(kOneByteStringCid)); // String => true
1667 __ Jump(&no_match_branch);
1668 __ Jump(&true_branch);
1669 __ LoadConstant(1, Smi::Handle(Smi::New(0))); // false branch
1670 __ Return(1);
1671 __ Bind(&true_branch);
1672 __ LoadConstant(1, Smi::Handle(Smi::New(1)));
1673 __ Return(1);
1674 __ Bind(&no_match_branch);
1675 __ LoadConstant(1, Smi::Handle(Smi::New(2)));
1676 __ Return(1);
1677 }
1678
1679
1680 ASSEMBLER_TEST_RUN(TestCidsTrue, test) {
1681 EXPECT_EQ(1, EXECUTE_TEST_CODE_INTPTR(test->code()));
1682 }
1683
1684
1685 ASSEMBLER_TEST_GENERATE(TestCidsFalse, assembler) {
1686 Label true_branch, no_match_branch;
1687 __ Frame(2);
1688 __ LoadConstant(0, Object::Handle(Smi::New(42)));
1689 const intptr_t num_cases = 2;
1690 __ TestCids(0, num_cases);
1691 __ Nop(0, static_cast<uint16_t>(kSmiCid)); // Smi => false
1692 __ Nop(1, static_cast<uint16_t>(kOneByteStringCid)); // String => true
1693 __ Jump(&no_match_branch);
1694 __ Jump(&true_branch);
1695 __ LoadConstant(1, Smi::Handle(Smi::New(0))); // false branch
1696 __ Return(1);
1697 __ Bind(&true_branch);
1698 __ LoadConstant(1, Smi::Handle(Smi::New(1)));
1699 __ Return(1);
1700 __ Bind(&no_match_branch);
1701 __ LoadConstant(1, Smi::Handle(Smi::New(2)));
1702 __ Return(1);
1703 }
1704
1705
1706 ASSEMBLER_TEST_RUN(TestCidsFalse, test) {
1707 EXPECT_EQ(0, EXECUTE_TEST_CODE_INTPTR(test->code()));
1708 }
1709
1710
1711 ASSEMBLER_TEST_GENERATE(TestCidsNoMatch, assembler) {
1712 Label true_branch, no_match_branch;
1713 __ Frame(2);
1714 __ LoadConstant(0, Object::Handle(Array::New(1, Heap::kOld)));
1715 const intptr_t num_cases = 2;
1716 __ TestCids(0, num_cases);
1717 __ Nop(0, static_cast<uint16_t>(kSmiCid)); // Smi => false
1718 __ Nop(1, static_cast<uint16_t>(kOneByteStringCid)); // String => true
1719 __ Jump(&no_match_branch);
1720 __ Jump(&true_branch);
1721 __ LoadConstant(1, Smi::Handle(Smi::New(0))); // false branch
1722 __ Return(1);
1723 __ Bind(&true_branch);
1724 __ LoadConstant(1, Smi::Handle(Smi::New(1)));
1725 __ Return(1);
1726 __ Bind(&no_match_branch);
1727 __ LoadConstant(1, Smi::Handle(Smi::New(2)));
1728 __ Return(1);
1729 }
1730
1731
1732 ASSEMBLER_TEST_RUN(TestCidsNoMatch, test) {
1733 EXPECT_EQ(2, EXECUTE_TEST_CODE_INTPTR(test->code()));
1734 }
1735
1736
1737
1653 // - CheckSmi rA 1738 // - CheckSmi rA
1654 // 1739 //
1655 // If FP[rA] is a Smi, then skip the next instruction. 1740 // If FP[rA] is a Smi, then skip the next instruction.
1656 ASSEMBLER_TEST_GENERATE(CheckSmiPass, assembler) { 1741 ASSEMBLER_TEST_GENERATE(CheckSmiPass, assembler) {
1657 __ Frame(1); 1742 __ Frame(1);
1658 __ PushConstant(Smi::Handle(Smi::New(42))); 1743 __ PushConstant(Smi::Handle(Smi::New(42)));
1659 __ LoadConstant(0, Smi::Handle(Smi::New(0))); 1744 __ LoadConstant(0, Smi::Handle(Smi::New(0)));
1660 __ CheckSmi(0); 1745 __ CheckSmi(0);
1661 __ PushConstant(Smi::Handle(Smi::New(-1))); 1746 __ PushConstant(Smi::Handle(Smi::New(-1)));
1662 __ ReturnTOS(); 1747 __ ReturnTOS();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 } 1873 }
1789 1874
1790 1875
1791 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) { 1876 ASSEMBLER_TEST_RUN(IfNeNullNotNull, test) {
1792 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 1877 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1793 } 1878 }
1794 1879
1795 } // namespace dart 1880 } // namespace dart
1796 1881
1797 #endif // defined(TARGET_ARCH_DBC) 1882 #endif // defined(TARGET_ARCH_DBC)
OLDNEW
« no previous file with comments | « runtime/vm/assembler_dbc.h ('k') | runtime/vm/constants_dbc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698