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

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

Issue 41573003: Specialize string equality for various string classes. Implement intrinsics for string equal… (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) 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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 Label fall_through, ok; 1728 Label fall_through, ok;
1729 TryAllocateOnebyteString(assembler, &ok, &fall_through, EDI); 1729 TryAllocateOnebyteString(assembler, &ok, &fall_through, EDI);
1730 // EDI: Start address to copy from (untagged). 1730 // EDI: Start address to copy from (untagged).
1731 1731
1732 __ Bind(&ok); 1732 __ Bind(&ok);
1733 __ ret(); 1733 __ ret();
1734 1734
1735 __ Bind(&fall_through); 1735 __ Bind(&fall_through);
1736 } 1736 }
1737 1737
1738
1739 // TODO(srdjan): Add combinations (one-byte/two-byte/external strings).
1740 void StringEquality(Assembler* assembler, intptr_t string_cid) {
1741 Label fall_through, is_true, is_false, loop;
1742 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // This.
1743 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Other.
1744
1745 // Are identical?
1746 __ cmpl(EAX, EBX);
1747 __ j(EQUAL, &is_true, Assembler::kNearJump);
1748
1749 // Is other OneByteString?
1750 __ testl(EBX, Immediate(kSmiTagMask));
1751 __ j(ZERO, &is_false); // Smi
1752 __ CompareClassId(EBX, string_cid, EDI);
1753 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump);
1754
1755 // Have same length?
1756 __ movl(EDI, FieldAddress(EAX, String::length_offset()));
1757 __ cmpl(EDI, FieldAddress(EBX, String::length_offset()));
1758 __ j(NOT_EQUAL, &is_false, Assembler::kNearJump);
1759
1760 // Check contents, no fall-through possible.
1761 // TODO(srdjan): write a faster check.
1762 __ SmiUntag(EDI);
1763 __ Bind(&loop);
1764 __ decl(EDI);
1765 __ cmpl(EDI, Immediate(0));
1766 __ j(LESS, &is_true, Assembler::kNearJump);
1767 if (string_cid == kOneByteStringCid) {
1768 __ movzxb(ECX,
1769 FieldAddress(EAX, EDI, TIMES_1, OneByteString::data_offset()));
1770 __ movzxb(EDX,
1771 FieldAddress(EBX, EDI, TIMES_1, OneByteString::data_offset()));
1772 } else if (string_cid == kTwoByteStringCid) {
1773 __ movzxw(ECX,
1774 FieldAddress(EAX, EDI, TIMES_2, TwoByteString::data_offset()));
1775 __ movzxw(EDX,
1776 FieldAddress(EBX, EDI, TIMES_2, TwoByteString::data_offset()));
1777 } else {
1778 UNIMPLEMENTED();
1779 }
1780 __ cmpl(ECX, EDX);
1781 __ j(NOT_EQUAL, &is_false, Assembler::kNearJump);
1782 __ jmp(&loop, Assembler::kNearJump);
1783
1784 __ Bind(&is_true);
1785 __ LoadObject(EAX, Bool::True());
1786 __ ret();
1787
1788 __ Bind(&is_false);
1789 __ LoadObject(EAX, Bool::False());
1790 __ ret();
1791
1792 __ Bind(&fall_through);
1793 }
1794
1795
1796 void Intrinsifier::OneByteString_equality(Assembler* assembler) {
1797 StringEquality(assembler, kOneByteStringCid);
1798 }
1799
1800
1801 void Intrinsifier::TwoByteString_equality(Assembler* assembler) {
1802 StringEquality(assembler, kTwoByteStringCid);
1803 }
1804
1738 #undef __ 1805 #undef __
1739 } // namespace dart 1806 } // namespace dart
1740 1807
1741 #endif // defined TARGET_ARCH_IA32 1808 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698