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

Side by Side Diff: runtime/vm/intrinsifier_arm.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, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/intrinsifier_ia32.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_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 __ SmiUntag(R1); 1415 __ SmiUntag(R1);
1416 __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag); 1416 __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag);
1417 __ ldrb(R0, Address(R0, R1)); 1417 __ ldrb(R0, Address(R0, R1));
1418 __ SmiTag(R0); 1418 __ SmiTag(R0);
1419 __ Ret(); 1419 __ Ret();
1420 1420
1421 __ Bind(&try_two_byte_string); 1421 __ Bind(&try_two_byte_string);
1422 __ CompareClassId(R0, kTwoByteStringCid, R3); 1422 __ CompareClassId(R0, kTwoByteStringCid, R3);
1423 __ b(&fall_through, NE); 1423 __ b(&fall_through, NE);
1424 ASSERT(kSmiTagShift == 1); 1424 ASSERT(kSmiTagShift == 1);
1425 __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag); 1425 __ AddImmediate(R0, TwoByteString::data_offset() - kHeapObjectTag);
1426 __ ldrh(R0, Address(R0, R1)); 1426 __ ldrh(R0, Address(R0, R1));
1427 __ SmiTag(R0); 1427 __ SmiTag(R0);
1428 __ Ret(); 1428 __ Ret();
1429 1429
1430 __ Bind(&fall_through); 1430 __ Bind(&fall_through);
1431 } 1431 }
1432 1432
1433 1433
1434 void Intrinsifier::String_getIsEmpty(Assembler* assembler) { 1434 void Intrinsifier::String_getIsEmpty(Assembler* assembler) {
1435 __ ldr(R0, Address(SP, 0 * kWordSize)); 1435 __ ldr(R0, Address(SP, 0 * kWordSize));
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 __ ldr(R2, Address(SP, 0 * kWordSize)); // Length. 1647 __ ldr(R2, Address(SP, 0 * kWordSize)); // Length.
1648 Label fall_through, ok; 1648 Label fall_through, ok;
1649 TryAllocateOnebyteString(assembler, &ok, &fall_through); 1649 TryAllocateOnebyteString(assembler, &ok, &fall_through);
1650 1650
1651 __ Bind(&ok); 1651 __ Bind(&ok);
1652 __ Ret(); 1652 __ Ret();
1653 1653
1654 __ Bind(&fall_through); 1654 __ Bind(&fall_through);
1655 } 1655 }
1656 1656
1657
1658 // TODO(srdjan): Add combinations (one-byte/two-byte/external strings).
1659 void StringEquality(Assembler* assembler, intptr_t string_cid) {
1660 Label fall_through, is_true, is_false, loop;
1661 __ ldr(R0, Address(SP, 1 * kWordSize)); // This.
1662 __ ldr(R1, Address(SP, 0 * kWordSize)); // Other.
1663
1664 // Are identical?
1665 __ cmp(R0, ShifterOperand(R1));
1666 __ b(&is_true, EQ);
1667
1668 // Is other OneByteString?
1669 __ tst(R1, ShifterOperand(kSmiTagMask));
1670 __ b(&fall_through, EQ);
1671 __ CompareClassId(R1, string_cid, R2);
1672 __ b(&fall_through, NE);
1673
1674 // Have same length?
1675 __ ldr(R2, FieldAddress(R0, String::length_offset()));
1676 __ ldr(R3, FieldAddress(R1, String::length_offset()));
1677 __ cmp(R2, ShifterOperand(R3));
1678 __ b(&is_false, NE);
1679
1680 // Check contents, no fall-through possible.
1681 // TODO(zra): try out other sequences.
1682 ASSERT((string_cid == kOneByteStringCid) ||
1683 (string_cid == kTwoByteStringCid));
1684 const intptr_t offset = (string_cid == kOneByteStringCid) ?
1685 OneByteString::data_offset() : TwoByteString::data_offset();
1686 __ AddImmediate(R0, offset - kHeapObjectTag);
1687 __ AddImmediate(R1, offset - kHeapObjectTag);
1688 __ SmiUntag(R2);
1689 __ Bind(&loop);
1690 __ AddImmediate(R2, -1);
1691 __ cmp(R2, ShifterOperand(0));
1692 __ b(&is_true, LT);
1693 if (string_cid == kOneByteStringCid) {
1694 __ ldrb(R3, Address(R0));
1695 __ ldrb(R4, Address(R1));
1696 __ AddImmediate(R0, 1);
1697 __ AddImmediate(R1, 1);
1698 } else if (string_cid == kTwoByteStringCid) {
1699 __ ldrh(R3, Address(R0));
1700 __ ldrh(R4, Address(R1));
1701 __ AddImmediate(R0, 2);
1702 __ AddImmediate(R1, 2);
1703 } else {
1704 UNIMPLEMENTED();
1705 }
1706 __ cmp(R3, ShifterOperand(R4));
1707 __ b(&is_false, NE);
1708 __ b(&loop);
1709
1710 __ Bind(&is_true);
1711 __ LoadObject(R0, Bool::True());
1712 __ Ret();
1713
1714 __ Bind(&is_false);
1715 __ LoadObject(R0, Bool::False());
1716 __ Ret();
1717
1718 __ Bind(&fall_through);
1719 }
1720
1721
1722 void Intrinsifier::OneByteString_equality(Assembler* assembler) {
1723 StringEquality(assembler, kOneByteStringCid);
1724 }
1725
1726
1727 void Intrinsifier::TwoByteString_equality(Assembler* assembler) {
1728 StringEquality(assembler, kTwoByteStringCid);
1729 }
1730
1731
1657 } // namespace dart 1732 } // namespace dart
1658 1733
1659 #endif // defined TARGET_ARCH_ARM 1734 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/intrinsifier_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698