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

Side by Side Diff: runtime/vm/intrinsifier_x64.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
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/object.cc » ('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) 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 TryAllocateOnebyteString(assembler, &ok, &fall_through, RDI); 1640 TryAllocateOnebyteString(assembler, &ok, &fall_through, RDI);
1641 // EDI: Start address to copy from (untagged). 1641 // EDI: Start address to copy from (untagged).
1642 1642
1643 __ Bind(&ok); 1643 __ Bind(&ok);
1644 __ ret(); 1644 __ ret();
1645 1645
1646 __ Bind(&fall_through); 1646 __ Bind(&fall_through);
1647 } 1647 }
1648 1648
1649 1649
1650 // TODO(srdjan): Add combinations (one-byte/two-byte/external strings).
1651 void StringEquality(Assembler* assembler, intptr_t string_cid) {
1652 Label fall_through, is_true, is_false, loop;
1653 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // This.
1654 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Other.
1655
1656 // Are identical?
1657 __ cmpq(RAX, RCX);
1658 __ j(EQUAL, &is_true, Assembler::kNearJump);
1659
1660 // Is other OneByteString?
1661 __ testq(RCX, Immediate(kSmiTagMask));
1662 __ j(ZERO, &is_false); // Smi
1663 __ CompareClassId(RCX, string_cid);
1664 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump);
1665
1666 // Have same length?
1667 __ movq(RDI, FieldAddress(RAX, String::length_offset()));
1668 __ cmpq(RDI, FieldAddress(RCX, String::length_offset()));
1669 __ j(NOT_EQUAL, &is_false, Assembler::kNearJump);
1670
1671 // Check contents, no fall-through possible.
1672 // TODO(srdjan): write a faster check.
1673 __ SmiUntag(RDI);
1674 __ Bind(&loop);
1675 __ decq(RDI);
1676 __ cmpq(RDI, Immediate(0));
1677 __ j(LESS, &is_true, Assembler::kNearJump);
1678 if (string_cid == kOneByteStringCid) {
1679 __ movzxb(RBX,
1680 FieldAddress(RAX, RDI, TIMES_1, OneByteString::data_offset()));
1681 __ movzxb(RDX,
1682 FieldAddress(RCX, RDI, TIMES_1, OneByteString::data_offset()));
1683 } else if (string_cid == kTwoByteStringCid) {
1684 __ movzxw(RBX,
1685 FieldAddress(RAX, RDI, TIMES_2, TwoByteString::data_offset()));
1686 __ movzxw(RDX,
1687 FieldAddress(RCX, RDI, TIMES_2, TwoByteString::data_offset()));
1688 } else {
1689 UNIMPLEMENTED();
1690 }
1691 __ cmpq(RBX, RDX);
1692 __ j(NOT_EQUAL, &is_false, Assembler::kNearJump);
1693 __ jmp(&loop, Assembler::kNearJump);
1694
1695 __ Bind(&is_true);
1696 __ LoadObject(RAX, Bool::True(), PP);
1697 __ ret();
1698
1699 __ Bind(&is_false);
1700 __ LoadObject(RAX, Bool::False(), PP);
1701 __ ret();
1702
1703 __ Bind(&fall_through);
1704 }
1705
1706
1707 void Intrinsifier::OneByteString_equality(Assembler* assembler) {
1708 StringEquality(assembler, kOneByteStringCid);
1709 }
1710
1711
1712 void Intrinsifier::TwoByteString_equality(Assembler* assembler) {
1713 StringEquality(assembler, kTwoByteStringCid);
1714 }
1715
1650 #undef __ 1716 #undef __
1651 1717
1652 } // namespace dart 1718 } // namespace dart
1653 1719
1654 #endif // defined TARGET_ARCH_X64 1720 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698