| Index: src/ia32/code-stubs-ia32.cc
|
| diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
|
| index 68aa844cfdc832a0ec7f3a449a95346702f071f2..efc714bff48786d66550e14bf134b4db3cc5e572 100644
|
| --- a/src/ia32/code-stubs-ia32.cc
|
| +++ b/src/ia32/code-stubs-ia32.cc
|
| @@ -3180,18 +3180,12 @@ void StringCharFromCodeGenerator::GenerateSlow(
|
| }
|
|
|
|
|
| -void StringHelper::GenerateCopyCharactersREP(MacroAssembler* masm,
|
| - Register dest,
|
| - Register src,
|
| - Register count,
|
| - Register scratch,
|
| - bool ascii) {
|
| - // Copy characters using rep movs of doublewords.
|
| - // The destination is aligned on a 4 byte boundary because we are
|
| - // copying to the beginning of a newly allocated string.
|
| - ASSERT(dest.is(edi)); // rep movs destination
|
| - ASSERT(src.is(esi)); // rep movs source
|
| - ASSERT(count.is(ecx)); // rep movs count
|
| +void StringHelper::GenerateCopyCharacters(MacroAssembler* masm,
|
| + Register dest,
|
| + Register src,
|
| + Register count,
|
| + Register scratch,
|
| + String::Encoding encoding) {
|
| ASSERT(!scratch.is(dest));
|
| ASSERT(!scratch.is(src));
|
| ASSERT(!scratch.is(count));
|
| @@ -3202,38 +3196,17 @@ void StringHelper::GenerateCopyCharactersREP(MacroAssembler* masm,
|
| __ j(zero, &done);
|
|
|
| // Make count the number of bytes to copy.
|
| - if (!ascii) {
|
| + if (encoding == String::TWO_BYTE_ENCODING) {
|
| __ shl(count, 1);
|
| }
|
|
|
| - // Don't enter the rep movs if there are less than 4 bytes to copy.
|
| - Label last_bytes;
|
| - __ test(count, Immediate(~3));
|
| - __ j(zero, &last_bytes, Label::kNear);
|
| -
|
| - // Copy from edi to esi using rep movs instruction.
|
| - __ mov(scratch, count);
|
| - __ sar(count, 2); // Number of doublewords to copy.
|
| - __ cld();
|
| - __ rep_movs();
|
| -
|
| - // Find number of bytes left.
|
| - __ mov(count, scratch);
|
| - __ and_(count, 3);
|
| -
|
| - // Check if there are more bytes to copy.
|
| - __ bind(&last_bytes);
|
| - __ test(count, count);
|
| - __ j(zero, &done);
|
| -
|
| - // Copy remaining characters.
|
| Label loop;
|
| __ bind(&loop);
|
| __ mov_b(scratch, Operand(src, 0));
|
| __ mov_b(Operand(dest, 0), scratch);
|
| - __ add(src, Immediate(1));
|
| - __ add(dest, Immediate(1));
|
| - __ sub(count, Immediate(1));
|
| + __ inc(src);
|
| + __ inc(dest);
|
| + __ dec(count);
|
| __ j(not_zero, &loop);
|
|
|
| __ bind(&done);
|
| @@ -3462,23 +3435,21 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
|
|
| // eax: result string
|
| // ecx: result string length
|
| - __ mov(edx, esi); // esi used by following code.
|
| // Locate first character of result.
|
| __ mov(edi, eax);
|
| __ add(edi, Immediate(SeqOneByteString::kHeaderSize - kHeapObjectTag));
|
| // Load string argument and locate character of sub string start.
|
| - __ pop(esi);
|
| + __ pop(edx);
|
| __ pop(ebx);
|
| __ SmiUntag(ebx);
|
| - __ lea(esi, FieldOperand(esi, ebx, times_1, SeqOneByteString::kHeaderSize));
|
| + __ lea(edx, FieldOperand(edx, ebx, times_1, SeqOneByteString::kHeaderSize));
|
|
|
| // eax: result string
|
| // ecx: result length
|
| - // edx: original value of esi
|
| // edi: first character of result
|
| - // esi: character of sub string start
|
| - StringHelper::GenerateCopyCharactersREP(masm, edi, esi, ecx, ebx, true);
|
| - __ mov(esi, edx); // Restore esi.
|
| + // edx: character of sub string start
|
| + StringHelper::GenerateCopyCharacters(
|
| + masm, edi, edx, ecx, ebx, String::ONE_BYTE_ENCODING);
|
| __ IncrementCounter(counters->sub_string_native(), 1);
|
| __ ret(3 * kPointerSize);
|
|
|
| @@ -3488,27 +3459,25 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
|
|
| // eax: result string
|
| // ecx: result string length
|
| - __ mov(edx, esi); // esi used by following code.
|
| // Locate first character of result.
|
| __ mov(edi, eax);
|
| __ add(edi,
|
| Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
|
| // Load string argument and locate character of sub string start.
|
| - __ pop(esi);
|
| + __ pop(edx);
|
| __ pop(ebx);
|
| // As from is a smi it is 2 times the value which matches the size of a two
|
| // byte character.
|
| STATIC_ASSERT(kSmiTag == 0);
|
| STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1);
|
| - __ lea(esi, FieldOperand(esi, ebx, times_1, SeqTwoByteString::kHeaderSize));
|
| + __ lea(edx, FieldOperand(edx, ebx, times_1, SeqTwoByteString::kHeaderSize));
|
|
|
| // eax: result string
|
| // ecx: result length
|
| - // edx: original value of esi
|
| // edi: first character of result
|
| - // esi: character of sub string start
|
| - StringHelper::GenerateCopyCharactersREP(masm, edi, esi, ecx, ebx, false);
|
| - __ mov(esi, edx); // Restore esi.
|
| + // edx: character of sub string start
|
| + StringHelper::GenerateCopyCharacters(
|
| + masm, edi, edx, ecx, ebx, String::TWO_BYTE_ENCODING);
|
| __ IncrementCounter(counters->sub_string_native(), 1);
|
| __ ret(3 * kPointerSize);
|
|
|
|
|