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

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

Issue 17907003: Add two-byte string support in codeunitAt intrinsic. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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_ia32.cc ('k') | runtime/vm/intrinsifier_x64.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_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 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 1501
1502 1502
1503 bool Intrinsifier::String_getLength(Assembler* assembler) { 1503 bool Intrinsifier::String_getLength(Assembler* assembler) {
1504 __ lw(T0, Address(SP, 0 * kWordSize)); 1504 __ lw(T0, Address(SP, 0 * kWordSize));
1505 __ Ret(); 1505 __ Ret();
1506 __ delay_slot()->lw(V0, FieldAddress(T0, String::length_offset())); 1506 __ delay_slot()->lw(V0, FieldAddress(T0, String::length_offset()));
1507 return true; 1507 return true;
1508 } 1508 }
1509 1509
1510 1510
1511 // TODO(srdjan): Implement for two and four byte strings as well.
1512 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { 1511 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) {
1513 Label fall_through; 1512 Label fall_through, try_two_byte_string;
1514 1513
1515 __ lw(T1, Address(SP, 0 * kWordSize)); // Index. 1514 __ lw(T1, Address(SP, 0 * kWordSize)); // Index.
1516 __ lw(T0, Address(SP, 1 * kWordSize)); // String. 1515 __ lw(T0, Address(SP, 1 * kWordSize)); // String.
1517 1516
1518 // Checks. 1517 // Checks.
1519 __ andi(CMPRES, T1, Immediate(kSmiTagMask)); 1518 __ andi(CMPRES, T1, Immediate(kSmiTagMask));
1520 __ bne(T1, ZR, &fall_through); // Index is not a Smi. 1519 __ bne(T1, ZR, &fall_through); // Index is not a Smi.
1521 __ lw(T2, FieldAddress(T0, String::length_offset())); // Range check. 1520 __ lw(T2, FieldAddress(T0, String::length_offset())); // Range check.
1522 // Runtime throws exception. 1521 // Runtime throws exception.
1523 __ BranchUnsignedGreaterEqual(T1, T2, &fall_through); 1522 __ BranchUnsignedGreaterEqual(T1, T2, &fall_through);
1524 __ LoadClassId(TMP1, T0); // Class ID check. 1523 __ LoadClassId(TMP1, T0); // Class ID check.
1525 __ BranchNotEqual(TMP1, kOneByteStringCid, &fall_through); 1524 __ BranchNotEqual(TMP1, kOneByteStringCid, &try_two_byte_string);
1526 1525
1527 // Grab byte and return. 1526 // Grab byte and return.
1528 __ SmiUntag(T1); 1527 __ SmiUntag(T1);
1529 __ addu(T2, T0, T1); 1528 __ addu(T2, T0, T1);
1530 __ lbu(V0, FieldAddress(T2, OneByteString::data_offset())); 1529 __ lbu(V0, FieldAddress(T2, OneByteString::data_offset()));
1531 __ Ret(); 1530 __ Ret();
1532 __ delay_slot()->SmiTag(V0); 1531 __ delay_slot()->SmiTag(V0);
1532
1533 __ Bind(&try_two_byte_string);
1534 __ BranchNotEqual(TMP1, kTwoByteStringCid, &fall_through);
1535 ASSERT(kSmiTagShift == 1);
1536 __ addu(T2, T0, T1);
1537 __ lhu(V0, FieldAddress(T2, OneByteString::data_offset()));
1538 __ Ret();
1539 __ delay_slot()->SmiTag(V0);
1540
1533 __ Bind(&fall_through); 1541 __ Bind(&fall_through);
1534 return false; 1542 return false;
1535 } 1543 }
1536 1544
1537 1545
1538 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) { 1546 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) {
1539 Label is_true; 1547 Label is_true;
1540 1548
1541 __ lw(T0, Address(SP, 0 * kWordSize)); 1549 __ lw(T0, Address(SP, 0 * kWordSize));
1542 __ lw(T0, FieldAddress(T0, String::length_offset())); 1550 __ lw(T0, FieldAddress(T0, String::length_offset()));
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 __ Bind(&ok); 1777 __ Bind(&ok);
1770 __ Ret(); 1778 __ Ret();
1771 1779
1772 __ Bind(&fall_through); 1780 __ Bind(&fall_through);
1773 return false; 1781 return false;
1774 } 1782 }
1775 1783
1776 } // namespace dart 1784 } // namespace dart
1777 1785
1778 #endif // defined TARGET_ARCH_MIPS 1786 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_ia32.cc ('k') | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698