| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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" // Needed here to get TARGET_ARCH_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 | 1730 |
| 1731 __ lw(T2, Address(SP, 0 * kWordSize)); // Length. | 1731 __ lw(T2, Address(SP, 0 * kWordSize)); // Length. |
| 1732 TryAllocateOnebyteString(assembler, &ok, &fall_through); | 1732 TryAllocateOnebyteString(assembler, &ok, &fall_through); |
| 1733 | 1733 |
| 1734 __ Bind(&ok); | 1734 __ Bind(&ok); |
| 1735 __ Ret(); | 1735 __ Ret(); |
| 1736 | 1736 |
| 1737 __ Bind(&fall_through); | 1737 __ Bind(&fall_through); |
| 1738 } | 1738 } |
| 1739 | 1739 |
| 1740 |
| 1741 // TODO(srdjan): Add combinations (one-byte/two-byte/external strings). |
| 1742 void StringEquality(Assembler* assembler, intptr_t string_cid) { |
| 1743 Label fall_through, is_true, is_false, loop; |
| 1744 __ lw(T0, Address(SP, 1 * kWordSize)); // This. |
| 1745 __ lw(T1, Address(SP, 0 * kWordSize)); // Other. |
| 1746 |
| 1747 // Are identical? |
| 1748 __ beq(T0, T1, &is_true); |
| 1749 |
| 1750 // Is other OneByteString? |
| 1751 __ andi(CMPRES, T1, Immediate(kSmiTagMask)); |
| 1752 __ beq(CMPRES, ZR, &fall_through); // Other is Smi. |
| 1753 __ LoadClassId(CMPRES1, T1); // Class ID check. |
| 1754 __ BranchNotEqual(CMPRES1, string_cid, &fall_through); |
| 1755 |
| 1756 // Have same length? |
| 1757 __ lw(T2, FieldAddress(T0, String::length_offset())); |
| 1758 __ lw(T3, FieldAddress(T1, String::length_offset())); |
| 1759 __ bne(T2, T3, &is_false); |
| 1760 |
| 1761 // Check contents, no fall-through possible. |
| 1762 ASSERT((string_cid == kOneByteStringCid) || |
| 1763 (string_cid == kTwoByteStringCid)); |
| 1764 __ SmiUntag(T2); |
| 1765 __ Bind(&loop); |
| 1766 __ AddImmediate(T2, -1); |
| 1767 __ BranchSignedLess(T2, 0, &is_true); |
| 1768 if (string_cid == kOneByteStringCid) { |
| 1769 __ lbu(V0, FieldAddress(T0, OneByteString::data_offset())); |
| 1770 __ lbu(V1, FieldAddress(T1, OneByteString::data_offset())); |
| 1771 __ AddImmediate(T0, 1); |
| 1772 __ AddImmediate(T1, 1); |
| 1773 } else if (string_cid == kTwoByteStringCid) { |
| 1774 __ lhu(V0, FieldAddress(T0, OneByteString::data_offset())); |
| 1775 __ lhu(V1, FieldAddress(T1, OneByteString::data_offset())); |
| 1776 __ AddImmediate(T0, 2); |
| 1777 __ AddImmediate(T1, 2); |
| 1778 } else { |
| 1779 UNIMPLEMENTED(); |
| 1780 } |
| 1781 __ bne(V0, V1, &is_false); |
| 1782 __ b(&loop); |
| 1783 |
| 1784 __ Bind(&is_false); |
| 1785 __ LoadObject(V0, Bool::False()); |
| 1786 __ Ret(); |
| 1787 __ Bind(&is_true); |
| 1788 __ LoadObject(V0, Bool::True()); |
| 1789 __ Ret(); |
| 1790 |
| 1791 __ Bind(&fall_through); |
| 1792 } |
| 1793 |
| 1794 |
| 1795 void Intrinsifier::OneByteString_equality(Assembler* assembler) { |
| 1796 StringEquality(assembler, kOneByteStringCid); |
| 1797 } |
| 1798 |
| 1799 |
| 1800 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
| 1801 StringEquality(assembler, kTwoByteStringCid); |
| 1802 } |
| 1803 |
| 1740 } // namespace dart | 1804 } // namespace dart |
| 1741 | 1805 |
| 1742 #endif // defined TARGET_ARCH_MIPS | 1806 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |