OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4887 __ bind(&assure_seq_string); | 4887 __ bind(&assure_seq_string); |
4888 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 4888 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
4889 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 4889 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
4890 // Check that parent is not an external string. Go to runtime otherwise. | 4890 // Check that parent is not an external string. Go to runtime otherwise. |
4891 STATIC_ASSERT(kSeqStringTag == 0); | 4891 STATIC_ASSERT(kSeqStringTag == 0); |
4892 __ tst(result_, Operand(kStringRepresentationMask)); | 4892 __ tst(result_, Operand(kStringRepresentationMask)); |
4893 __ b(ne, &call_runtime_); | 4893 __ b(ne, &call_runtime_); |
4894 | 4894 |
4895 // Check for 1-byte or 2-byte string. | 4895 // Check for 1-byte or 2-byte string. |
4896 __ bind(&flat_string); | 4896 __ bind(&flat_string); |
4897 STATIC_ASSERT(kAsciiStringTag != 0); | 4897 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0); |
| 4898 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
4898 __ tst(result_, Operand(kStringEncodingMask)); | 4899 __ tst(result_, Operand(kStringEncodingMask)); |
4899 __ b(ne, &ascii_string); | 4900 __ b(ne, &ascii_string); |
4900 | 4901 |
4901 // 2-byte string. | 4902 // 2-byte string. |
4902 // Load the 2-byte character code into the result register. We can | 4903 // Load the 2-byte character code into the result register. We can |
4903 // add without shifting since the smi tag size is the log2 of the | 4904 // add without shifting since the smi tag size is the log2 of the |
4904 // number of bytes in a two-byte character. | 4905 // number of bytes in a two-byte character. |
4905 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1 && kSmiShiftSize == 0); | 4906 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1 && kSmiShiftSize == 0); |
4906 __ add(scratch_, object_, Operand(scratch_)); | 4907 __ add(scratch_, object_, Operand(scratch_)); |
4907 __ ldrh(result_, FieldMemOperand(scratch_, SeqTwoByteString::kHeaderSize)); | 4908 __ ldrh(result_, FieldMemOperand(scratch_, SeqTwoByteString::kHeaderSize)); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 // If any of these assumptions fail, we call the runtime system. | 5462 // If any of these assumptions fail, we call the runtime system. |
5462 | 5463 |
5463 static const int kToOffset = 0 * kPointerSize; | 5464 static const int kToOffset = 0 * kPointerSize; |
5464 static const int kFromOffset = 1 * kPointerSize; | 5465 static const int kFromOffset = 1 * kPointerSize; |
5465 static const int kStringOffset = 2 * kPointerSize; | 5466 static const int kStringOffset = 2 * kPointerSize; |
5466 | 5467 |
5467 // Check bounds and smi-ness. | 5468 // Check bounds and smi-ness. |
5468 Register to = r6; | 5469 Register to = r6; |
5469 Register from = r7; | 5470 Register from = r7; |
5470 | 5471 |
5471 if (FLAG_string_slices) { | |
5472 __ nop(0); // Jumping as first instruction would crash the code generation. | |
5473 __ jmp(&runtime); | |
5474 } | |
5475 | |
5476 __ Ldrd(to, from, MemOperand(sp, kToOffset)); | 5472 __ Ldrd(to, from, MemOperand(sp, kToOffset)); |
5477 STATIC_ASSERT(kFromOffset == kToOffset + 4); | 5473 STATIC_ASSERT(kFromOffset == kToOffset + 4); |
5478 STATIC_ASSERT(kSmiTag == 0); | 5474 STATIC_ASSERT(kSmiTag == 0); |
5479 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 5475 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
5480 | 5476 |
5481 // I.e., arithmetic shift right by one un-smi-tags. | 5477 // I.e., arithmetic shift right by one un-smi-tags. |
5482 __ mov(r2, Operand(to, ASR, 1), SetCC); | 5478 __ mov(r2, Operand(to, ASR, 1), SetCC); |
5483 __ mov(r3, Operand(from, ASR, 1), SetCC, cc); | 5479 __ mov(r3, Operand(from, ASR, 1), SetCC, cc); |
5484 // If either to or from had the smi tag bit set, then carry is set now. | 5480 // If either to or from had the smi tag bit set, then carry is set now. |
5485 __ b(cs, &runtime); // Either "from" or "to" is not a smi. | 5481 __ b(cs, &runtime); // Either "from" or "to" is not a smi. |
5486 __ b(mi, &runtime); // From is negative. | 5482 __ b(mi, &runtime); // From is negative. |
5487 | 5483 |
5488 // Both to and from are smis. | 5484 // Both to and from are smis. |
5489 __ sub(r2, r2, Operand(r3), SetCC); | 5485 __ sub(r2, r2, Operand(r3), SetCC); |
5490 __ b(mi, &runtime); // Fail if from > to. | 5486 __ b(mi, &runtime); // Fail if from > to. |
5491 // Special handling of sub-strings of length 1 and 2. One character strings | 5487 // Special handling of sub-strings of length 1 and 2. One character strings |
5492 // are handled in the runtime system (looked up in the single character | 5488 // are handled in the runtime system (looked up in the single character |
5493 // cache). Two character strings are looked for in the symbol cache. | 5489 // cache). Two character strings are looked for in the symbol cache in |
| 5490 // generated code. |
5494 __ cmp(r2, Operand(2)); | 5491 __ cmp(r2, Operand(2)); |
5495 __ b(lt, &runtime); | 5492 __ b(lt, &runtime); |
5496 | 5493 |
5497 // r2: length | 5494 // r2: result string length |
5498 // r3: from index (untaged smi) | 5495 // r3: from index (untagged smi) |
5499 // r6 (a.k.a. to): to (smi) | 5496 // r6 (a.k.a. to): to (smi) |
5500 // r7 (a.k.a. from): from offset (smi) | 5497 // r7 (a.k.a. from): from offset (smi) |
5501 | |
5502 // Make sure first argument is a sequential (or flat) string. | 5498 // Make sure first argument is a sequential (or flat) string. |
5503 __ ldr(r5, MemOperand(sp, kStringOffset)); | 5499 __ ldr(r0, MemOperand(sp, kStringOffset)); |
5504 STATIC_ASSERT(kSmiTag == 0); | 5500 STATIC_ASSERT(kSmiTag == 0); |
5505 __ JumpIfSmi(r5, &runtime); | 5501 __ JumpIfSmi(r0, &runtime); |
5506 Condition is_string = masm->IsObjectStringType(r5, r1); | 5502 Condition is_string = masm->IsObjectStringType(r0, r1); |
5507 __ b(NegateCondition(is_string), &runtime); | 5503 __ b(NegateCondition(is_string), &runtime); |
5508 | 5504 |
| 5505 // Short-cut for the case of trivial substring. |
| 5506 Label return_r0; |
| 5507 // r0: original string |
| 5508 // r2: result string length |
| 5509 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); |
| 5510 __ cmp(r2, Operand(r4, ASR, 1)); |
| 5511 __ b(eq, &return_r0); |
| 5512 |
| 5513 Label create_slice; |
| 5514 if (FLAG_string_slices) { |
| 5515 __ cmp(r2, Operand(SlicedString::kMinLength)); |
| 5516 __ b(ge, &create_slice); |
| 5517 } |
| 5518 |
| 5519 // r0: original string |
5509 // r1: instance type | 5520 // r1: instance type |
5510 // r2: length | 5521 // r2: result string length |
5511 // r3: from index (untagged smi) | 5522 // r3: from index (untagged smi) |
5512 // r5: string | |
5513 // r6 (a.k.a. to): to (smi) | 5523 // r6 (a.k.a. to): to (smi) |
5514 // r7 (a.k.a. from): from offset (smi) | 5524 // r7 (a.k.a. from): from offset (smi) |
5515 Label seq_string; | 5525 Label seq_string; |
5516 __ and_(r4, r1, Operand(kStringRepresentationMask)); | 5526 __ and_(r4, r1, Operand(kStringRepresentationMask)); |
5517 STATIC_ASSERT(kSeqStringTag < kConsStringTag); | 5527 STATIC_ASSERT(kSeqStringTag < kConsStringTag); |
5518 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 5528 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
| 5529 STATIC_ASSERT(kConsStringTag < kSlicedStringTag); |
5519 __ cmp(r4, Operand(kConsStringTag)); | 5530 __ cmp(r4, Operand(kConsStringTag)); |
5520 __ b(gt, &runtime); // External strings go to runtime. | 5531 __ b(gt, &runtime); // Slices and external strings go to runtime. |
5521 __ b(lt, &seq_string); // Sequential strings are handled directly. | 5532 __ b(lt, &seq_string); // Sequential strings are handled directly. |
5522 | 5533 |
5523 // Cons string. Try to recurse (once) on the first substring. | 5534 // Cons string. Try to recurse (once) on the first substring. |
5524 // (This adds a little more generality than necessary to handle flattened | 5535 // (This adds a little more generality than necessary to handle flattened |
5525 // cons strings, but not much). | 5536 // cons strings, but not much). |
5526 __ ldr(r5, FieldMemOperand(r5, ConsString::kFirstOffset)); | 5537 __ ldr(r0, FieldMemOperand(r0, ConsString::kFirstOffset)); |
5527 __ ldr(r4, FieldMemOperand(r5, HeapObject::kMapOffset)); | 5538 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); |
5528 __ ldrb(r1, FieldMemOperand(r4, Map::kInstanceTypeOffset)); | 5539 __ ldrb(r1, FieldMemOperand(r4, Map::kInstanceTypeOffset)); |
5529 __ tst(r1, Operand(kStringRepresentationMask)); | 5540 __ tst(r1, Operand(kStringRepresentationMask)); |
5530 STATIC_ASSERT(kSeqStringTag == 0); | 5541 STATIC_ASSERT(kSeqStringTag == 0); |
5531 __ b(ne, &runtime); // Cons and External strings go to runtime. | 5542 __ b(ne, &runtime); // Cons, slices and external strings go to runtime. |
5532 | 5543 |
5533 // Definitly a sequential string. | 5544 // Definitly a sequential string. |
5534 __ bind(&seq_string); | 5545 __ bind(&seq_string); |
5535 | 5546 |
5536 // r1: instance type. | 5547 // r0: original string |
5537 // r2: length | 5548 // r1: instance type |
5538 // r3: from index (untaged smi) | 5549 // r2: result string length |
5539 // r5: string | 5550 // r3: from index (untagged smi) |
5540 // r6 (a.k.a. to): to (smi) | 5551 // r6 (a.k.a. to): to (smi) |
5541 // r7 (a.k.a. from): from offset (smi) | 5552 // r7 (a.k.a. from): from offset (smi) |
5542 __ ldr(r4, FieldMemOperand(r5, String::kLengthOffset)); | 5553 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); |
5543 __ cmp(r4, Operand(to)); | 5554 __ cmp(r4, Operand(to)); |
5544 __ b(lt, &runtime); // Fail if to > length. | 5555 __ b(lt, &runtime); // Fail if to > length. |
5545 to = no_reg; | 5556 to = no_reg; |
5546 | 5557 |
5547 // r1: instance type. | 5558 // r0: original string or left hand side of the original cons string. |
5548 // r2: result string length. | 5559 // r1: instance type |
5549 // r3: from index (untaged smi) | 5560 // r2: result string length |
5550 // r5: string. | 5561 // r3: from index (untagged smi) |
5551 // r7 (a.k.a. from): from offset (smi) | 5562 // r7 (a.k.a. from): from offset (smi) |
5552 // Check for flat ASCII string. | 5563 // Check for flat ASCII string. |
5553 Label non_ascii_flat; | 5564 Label non_ascii_flat; |
5554 __ tst(r1, Operand(kStringEncodingMask)); | 5565 __ tst(r1, Operand(kStringEncodingMask)); |
5555 STATIC_ASSERT(kTwoByteStringTag == 0); | 5566 STATIC_ASSERT(kTwoByteStringTag == 0); |
5556 __ b(eq, &non_ascii_flat); | 5567 __ b(eq, &non_ascii_flat); |
5557 | 5568 |
5558 Label result_longer_than_two; | 5569 Label result_longer_than_two; |
5559 __ cmp(r2, Operand(2)); | 5570 __ cmp(r2, Operand(2)); |
5560 __ b(gt, &result_longer_than_two); | 5571 __ b(gt, &result_longer_than_two); |
5561 | 5572 |
5562 // Sub string of length 2 requested. | 5573 // Sub string of length 2 requested. |
5563 // Get the two characters forming the sub string. | 5574 // Get the two characters forming the sub string. |
5564 __ add(r5, r5, Operand(r3)); | 5575 __ add(r0, r0, Operand(r3)); |
5565 __ ldrb(r3, FieldMemOperand(r5, SeqAsciiString::kHeaderSize)); | 5576 __ ldrb(r3, FieldMemOperand(r0, SeqAsciiString::kHeaderSize)); |
5566 __ ldrb(r4, FieldMemOperand(r5, SeqAsciiString::kHeaderSize + 1)); | 5577 __ ldrb(r4, FieldMemOperand(r0, SeqAsciiString::kHeaderSize + 1)); |
5567 | 5578 |
5568 // Try to lookup two character string in symbol table. | 5579 // Try to lookup two character string in symbol table. |
5569 Label make_two_character_string; | 5580 Label make_two_character_string; |
5570 StringHelper::GenerateTwoCharacterSymbolTableProbe( | 5581 StringHelper::GenerateTwoCharacterSymbolTableProbe( |
5571 masm, r3, r4, r1, r5, r6, r7, r9, &make_two_character_string); | 5582 masm, r3, r4, r1, r5, r6, r7, r9, &make_two_character_string); |
5572 Counters* counters = masm->isolate()->counters(); | 5583 Counters* counters = masm->isolate()->counters(); |
5573 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 5584 __ jmp(&return_r0); |
5574 __ add(sp, sp, Operand(3 * kPointerSize)); | |
5575 __ Ret(); | |
5576 | 5585 |
5577 // r2: result string length. | 5586 // r2: result string length. |
5578 // r3: two characters combined into halfword in little endian byte order. | 5587 // r3: two characters combined into halfword in little endian byte order. |
5579 __ bind(&make_two_character_string); | 5588 __ bind(&make_two_character_string); |
5580 __ AllocateAsciiString(r0, r2, r4, r5, r9, &runtime); | 5589 __ AllocateAsciiString(r0, r2, r4, r5, r9, &runtime); |
5581 __ strh(r3, FieldMemOperand(r0, SeqAsciiString::kHeaderSize)); | 5590 __ strh(r3, FieldMemOperand(r0, SeqAsciiString::kHeaderSize)); |
5582 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 5591 __ jmp(&return_r0); |
5583 __ add(sp, sp, Operand(3 * kPointerSize)); | |
5584 __ Ret(); | |
5585 | 5592 |
5586 __ bind(&result_longer_than_two); | 5593 __ bind(&result_longer_than_two); |
5587 | 5594 |
| 5595 // Locate 'from' character of string. |
| 5596 __ add(r5, r0, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); |
| 5597 __ add(r5, r5, Operand(from, ASR, 1)); |
| 5598 |
5588 // Allocate the result. | 5599 // Allocate the result. |
5589 __ AllocateAsciiString(r0, r2, r3, r4, r1, &runtime); | 5600 __ AllocateAsciiString(r0, r2, r3, r4, r1, &runtime); |
5590 | 5601 |
5591 // r0: result string. | 5602 // r0: result string |
5592 // r2: result string length. | 5603 // r2: result string length |
5593 // r5: string. | 5604 // r5: first character of substring to copy |
5594 // r7 (a.k.a. from): from offset (smi) | 5605 // r7 (a.k.a. from): from offset (smi) |
5595 // Locate first character of result. | 5606 // Locate first character of result. |
5596 __ add(r1, r0, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); | 5607 __ add(r1, r0, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); |
5597 // Locate 'from' character of string. | |
5598 __ add(r5, r5, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); | |
5599 __ add(r5, r5, Operand(from, ASR, 1)); | |
5600 | 5608 |
5601 // r0: result string. | 5609 // r0: result string |
5602 // r1: first character of result string. | 5610 // r1: first character of result string |
5603 // r2: result string length. | 5611 // r2: result string length |
5604 // r5: first character of sub string to copy. | 5612 // r5: first character of substring to copy |
5605 STATIC_ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0); | 5613 STATIC_ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0); |
5606 StringHelper::GenerateCopyCharactersLong(masm, r1, r5, r2, r3, r4, r6, r7, r9, | 5614 StringHelper::GenerateCopyCharactersLong(masm, r1, r5, r2, r3, r4, r6, r7, r9, |
5607 COPY_ASCII | DEST_ALWAYS_ALIGNED); | 5615 COPY_ASCII | DEST_ALWAYS_ALIGNED); |
5608 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 5616 __ jmp(&return_r0); |
5609 __ add(sp, sp, Operand(3 * kPointerSize)); | |
5610 __ Ret(); | |
5611 | 5617 |
5612 __ bind(&non_ascii_flat); | 5618 __ bind(&non_ascii_flat); |
5613 // r2: result string length. | 5619 // r0: original string |
5614 // r5: string. | 5620 // r2: result string length |
5615 // r7 (a.k.a. from): from offset (smi) | 5621 // r7 (a.k.a. from): from offset (smi) |
5616 // Check for flat two byte string. | 5622 // Check for flat two byte string. |
5617 | 5623 |
| 5624 // Locate 'from' character of string. |
| 5625 __ add(r5, r0, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 5626 // As "from" is a smi it is 2 times the value which matches the size of a two |
| 5627 // byte character. |
| 5628 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 5629 __ add(r5, r5, Operand(from)); |
| 5630 |
5618 // Allocate the result. | 5631 // Allocate the result. |
5619 __ AllocateTwoByteString(r0, r2, r1, r3, r4, &runtime); | 5632 __ AllocateTwoByteString(r0, r2, r1, r3, r4, &runtime); |
5620 | 5633 |
5621 // r0: result string. | 5634 // r0: result string |
5622 // r2: result string length. | 5635 // r2: result string length |
5623 // r5: string. | 5636 // r5: first character of substring to copy |
5624 // Locate first character of result. | 5637 // Locate first character of result. |
5625 __ add(r1, r0, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 5638 __ add(r1, r0, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
5626 // Locate 'from' character of string. | 5639 |
5627 __ add(r5, r5, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | |
5628 // As "from" is a smi it is 2 times the value which matches the size of a two | |
5629 // byte character. | |
5630 __ add(r5, r5, Operand(from)); | |
5631 from = no_reg; | 5640 from = no_reg; |
5632 | 5641 |
5633 // r0: result string. | 5642 // r0: result string. |
5634 // r1: first character of result. | 5643 // r1: first character of result. |
5635 // r2: result length. | 5644 // r2: result length. |
5636 // r5: first character of string to copy. | 5645 // r5: first character of substring to copy. |
5637 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 5646 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
5638 StringHelper::GenerateCopyCharactersLong( | 5647 StringHelper::GenerateCopyCharactersLong( |
5639 masm, r1, r5, r2, r3, r4, r6, r7, r9, DEST_ALWAYS_ALIGNED); | 5648 masm, r1, r5, r2, r3, r4, r6, r7, r9, DEST_ALWAYS_ALIGNED); |
| 5649 __ jmp(&return_r0); |
| 5650 |
| 5651 if (FLAG_string_slices) { |
| 5652 __ bind(&create_slice); |
| 5653 // r0: original string |
| 5654 // r1: instance type |
| 5655 // r2: length |
| 5656 // r3: from index (untagged smi) |
| 5657 // r6 (a.k.a. to): to (smi) |
| 5658 // r7 (a.k.a. from): from offset (smi) |
| 5659 Label allocate_slice, sliced_string, seq_string; |
| 5660 STATIC_ASSERT(kSeqStringTag == 0); |
| 5661 __ tst(r1, Operand(kStringRepresentationMask)); |
| 5662 __ b(eq, &seq_string); |
| 5663 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); |
| 5664 STATIC_ASSERT(kIsIndirectStringMask != 0); |
| 5665 __ tst(r1, Operand(kIsIndirectStringMask)); |
| 5666 // External string. Jump to runtime. |
| 5667 __ b(eq, &runtime); |
| 5668 |
| 5669 __ tst(r1, Operand(kSlicedNotConsMask)); |
| 5670 __ b(ne, &sliced_string); |
| 5671 // Cons string. Check whether it is flat, then fetch first part. |
| 5672 __ ldr(r5, FieldMemOperand(r0, ConsString::kSecondOffset)); |
| 5673 __ LoadRoot(r9, Heap::kEmptyStringRootIndex); |
| 5674 __ cmp(r5, r9); |
| 5675 __ b(ne, &runtime); |
| 5676 __ ldr(r5, FieldMemOperand(r0, ConsString::kFirstOffset)); |
| 5677 __ jmp(&allocate_slice); |
| 5678 |
| 5679 __ bind(&sliced_string); |
| 5680 // Sliced string. Fetch parent and correct start index by offset. |
| 5681 __ ldr(r5, FieldMemOperand(r0, SlicedString::kOffsetOffset)); |
| 5682 __ add(r7, r7, r5); |
| 5683 __ ldr(r5, FieldMemOperand(r0, SlicedString::kParentOffset)); |
| 5684 __ jmp(&allocate_slice); |
| 5685 |
| 5686 __ bind(&seq_string); |
| 5687 // Sequential string. Just move string to the right register. |
| 5688 __ mov(r5, r0); |
| 5689 |
| 5690 __ bind(&allocate_slice); |
| 5691 // r1: instance type of original string |
| 5692 // r2: length |
| 5693 // r5: underlying subject string |
| 5694 // r7 (a.k.a. from): from offset (smi) |
| 5695 // Allocate new sliced string. At this point we do not reload the instance |
| 5696 // type including the string encoding because we simply rely on the info |
| 5697 // provided by the original string. It does not matter if the original |
| 5698 // string's encoding is wrong because we always have to recheck encoding of |
| 5699 // the newly created string's parent anyways due to externalized strings. |
| 5700 Label two_byte_slice, set_slice_header; |
| 5701 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0); |
| 5702 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
| 5703 __ tst(r1, Operand(kStringEncodingMask)); |
| 5704 __ b(eq, &two_byte_slice); |
| 5705 __ AllocateAsciiSlicedString(r0, r2, r3, r4, &runtime); |
| 5706 __ jmp(&set_slice_header); |
| 5707 __ bind(&two_byte_slice); |
| 5708 __ AllocateTwoByteSlicedString(r0, r2, r3, r4, &runtime); |
| 5709 __ bind(&set_slice_header); |
| 5710 __ str(r7, FieldMemOperand(r0, SlicedString::kOffsetOffset)); |
| 5711 __ str(r5, FieldMemOperand(r0, SlicedString::kParentOffset)); |
| 5712 } |
| 5713 |
| 5714 __ bind(&return_r0); |
5640 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 5715 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); |
5641 __ add(sp, sp, Operand(3 * kPointerSize)); | 5716 __ add(sp, sp, Operand(3 * kPointerSize)); |
5642 __ Ret(); | 5717 __ Ret(); |
5643 | 5718 |
5644 // Just jump to runtime to create the sub string. | 5719 // Just jump to runtime to create the sub string. |
5645 __ bind(&runtime); | 5720 __ bind(&runtime); |
5646 __ TailCallRuntime(Runtime::kSubString, 3, 1); | 5721 __ TailCallRuntime(Runtime::kSubString, 3, 1); |
5647 } | 5722 } |
5648 | 5723 |
5649 | 5724 |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6610 __ mov(result, Operand::Zero()); | 6685 __ mov(result, Operand::Zero()); |
6611 __ Ret(); | 6686 __ Ret(); |
6612 } | 6687 } |
6613 | 6688 |
6614 | 6689 |
6615 #undef __ | 6690 #undef __ |
6616 | 6691 |
6617 } } // namespace v8::internal | 6692 } } // namespace v8::internal |
6618 | 6693 |
6619 #endif // V8_TARGET_ARCH_ARM | 6694 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |