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

Side by Side Diff: runtime/vm/intrinsifier_arm.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, 5 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 | « no previous file | 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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 1434
1435 1435
1436 bool Intrinsifier::String_getLength(Assembler* assembler) { 1436 bool Intrinsifier::String_getLength(Assembler* assembler) {
1437 __ ldr(R0, Address(SP, 0 * kWordSize)); 1437 __ ldr(R0, Address(SP, 0 * kWordSize));
1438 __ ldr(R0, FieldAddress(R0, String::length_offset())); 1438 __ ldr(R0, FieldAddress(R0, String::length_offset()));
1439 __ Ret(); 1439 __ Ret();
1440 return true; 1440 return true;
1441 } 1441 }
1442 1442
1443 1443
1444 // TODO(srdjan): Implement for two and four byte strings as well.
1445 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { 1444 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) {
1446 Label fall_through; 1445 Label fall_through, try_two_byte_string;
1447 1446
1448 __ ldr(R1, Address(SP, 0 * kWordSize)); // Index. 1447 __ ldr(R1, Address(SP, 0 * kWordSize)); // Index.
1449 __ ldr(R0, Address(SP, 1 * kWordSize)); // String. 1448 __ ldr(R0, Address(SP, 1 * kWordSize)); // String.
1450 __ tst(R1, ShifterOperand(kSmiTagMask)); 1449 __ tst(R1, ShifterOperand(kSmiTagMask));
1451 __ b(&fall_through, NE); // Index is not a Smi. 1450 __ b(&fall_through, NE); // Index is not a Smi.
1452 // Range check. 1451 // Range check.
1453 __ ldr(R2, FieldAddress(R0, String::length_offset())); 1452 __ ldr(R2, FieldAddress(R0, String::length_offset()));
1454 __ cmp(R1, ShifterOperand(R2)); 1453 __ cmp(R1, ShifterOperand(R2));
1455 __ b(&fall_through, CS); // Runtime throws exception. 1454 __ b(&fall_through, CS); // Runtime throws exception.
1456 __ CompareClassId(R0, kOneByteStringCid, R3); 1455 __ CompareClassId(R0, kOneByteStringCid, R3);
1457 __ b(&fall_through, NE); 1456 __ b(&try_two_byte_string, NE);
1458 __ SmiUntag(R1); 1457 __ SmiUntag(R1);
1459 __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag); 1458 __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag);
1460 __ ldrb(R0, Address(R0, R1)); 1459 __ ldrb(R0, Address(R0, R1));
1461 __ SmiTag(R0); 1460 __ SmiTag(R0);
1462 __ Ret(); 1461 __ Ret();
1462
1463 __ Bind(&try_two_byte_string);
1464 __ CompareClassId(R0, kTwoByteStringCid, R3);
1465 __ b(&fall_through, NE);
1466 ASSERT(kSmiTagShift == 1);
1467 __ AddImmediate(R0, OneByteString::data_offset() - kHeapObjectTag);
1468 __ ldrh(R0, Address(R0, R1));
1469 __ SmiTag(R0);
1470 __ Ret();
1471
1463 __ Bind(&fall_through); 1472 __ Bind(&fall_through);
1464 return false; 1473 return false;
1465 } 1474 }
1466 1475
1467 1476
1468 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) { 1477 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) {
1469 __ ldr(R0, Address(SP, 0 * kWordSize)); 1478 __ ldr(R0, Address(SP, 0 * kWordSize));
1470 __ ldr(R0, FieldAddress(R0, String::length_offset())); 1479 __ ldr(R0, FieldAddress(R0, String::length_offset()));
1471 __ cmp(R0, ShifterOperand(Smi::RawValue(0))); 1480 __ cmp(R0, ShifterOperand(Smi::RawValue(0)));
1472 __ LoadObject(R0, Bool::True(), EQ); 1481 __ LoadObject(R0, Bool::True(), EQ);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 __ Bind(&ok); 1698 __ Bind(&ok);
1690 __ Ret(); 1699 __ Ret();
1691 1700
1692 __ Bind(&fall_through); 1701 __ Bind(&fall_through);
1693 return false; 1702 return false;
1694 } 1703 }
1695 1704
1696 } // namespace dart 1705 } // namespace dart
1697 1706
1698 #endif // defined TARGET_ARCH_ARM 1707 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intrinsifier_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698