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

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

Issue 14122002: Use rep_movsb for copying one-byte strings in substring intrinsic. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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') | no next file » | 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 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 1491
1492 1492
1493 // Arg0: Onebyte String 1493 // Arg0: Onebyte String
1494 // Arg1: Start index as Smi. 1494 // Arg1: Start index as Smi.
1495 // Arg2: End index as Smi. 1495 // Arg2: End index as Smi.
1496 // The indexes must be valid. 1496 // The indexes must be valid.
1497 bool Intrinsifier::OneByteString_substringUnchecked(Assembler* assembler) { 1497 bool Intrinsifier::OneByteString_substringUnchecked(Assembler* assembler) {
1498 const intptr_t kStringOffset = 3 * kWordSize; 1498 const intptr_t kStringOffset = 3 * kWordSize;
1499 const intptr_t kStartIndexOffset = 2 * kWordSize; 1499 const intptr_t kStartIndexOffset = 2 * kWordSize;
1500 const intptr_t kEndIndexOffset = 1 * kWordSize; 1500 const intptr_t kEndIndexOffset = 1 * kWordSize;
1501 Label fall_through, done; 1501 Label fall_through;
1502 TryAllocateOnebyteString( 1502 TryAllocateOnebyteString(
1503 assembler, &fall_through, kStartIndexOffset, kEndIndexOffset); 1503 assembler, &fall_through, kStartIndexOffset, kEndIndexOffset);
1504 // RAX: new string as tagged pointer. 1504 // RAX: new string as tagged pointer.
1505 // Copy string. 1505 // Copy string.
1506 __ movq(RDI, Address(RSP, + kStringOffset)); 1506 __ movq(RSI, Address(RSP, + kStringOffset));
1507 __ movq(RBX, Address(RSP, + kStartIndexOffset)); 1507 __ movq(RBX, Address(RSP, + kStartIndexOffset));
1508 __ SmiUntag(RBX); 1508 __ SmiUntag(RBX);
1509 __ leaq(RDI, FieldAddress(RDI, RBX, TIMES_1, OneByteString::data_offset())); 1509 __ leaq(RSI, FieldAddress(RSI, RBX, TIMES_1, OneByteString::data_offset()));
1510 // RDI: Start address to copy from (untagged). 1510 // RDI: Start address to copy from (untagged).
1511 __ movq(RDX, Address(RSP, + kEndIndexOffset)); 1511 // RBX: Untagged start index.
1512 __ SmiUntag(RDX); 1512 __ movq(RCX, Address(RSP, + kEndIndexOffset));
1513 __ subq(RDX, RBX); 1513 __ SmiUntag(RCX);
1514 __ xorq(RCX, RCX); 1514 __ subq(RCX, RBX);
1515 // RDX: Number of bytes to copy. 1515 // RCX: Untagged number of bytes to copy.
1516 // RCX: Loop counter.
1517 // TODO(srdjan): For large substrings it could be better if we would group
1518 // the byte copies into word copies or even call memcpy.
1519 Label loop, check;
1520 // TODO(srdjan): Use rep movsb instead.
1521 __ jmp(&check, Assembler::kNearJump);
1522 __ Bind(&loop);
1523 __ movzxb(RBX, Address(RDI, RCX, TIMES_1, 0));
1524 __ movb(FieldAddress(RAX, RCX, TIMES_1, OneByteString::data_offset()), RBX);
1525 __ incq(RCX);
1526 __ Bind(&check);
1527 __ cmpq(RCX, RDX);
1528 __ j(LESS, &loop, Assembler::kNearJump);
1529 1516
1530 __ Bind(&done); 1517 __ leaq(RDI, FieldAddress(RAX, OneByteString::data_offset())); // to.
1518 __ rep_movsb();
1519
1531 __ ret(); 1520 __ ret();
1532 __ Bind(&fall_through); 1521 __ Bind(&fall_through);
1533 return false; 1522 return false;
1534 } 1523 }
1535 1524
1536 1525
1537 #undef __ 1526 #undef __
1538 1527
1539 } // namespace dart 1528 } // namespace dart
1540 1529
1541 #endif // defined TARGET_ARCH_X64 1530 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698