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 5624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5635 __ test(hash, Operand(hash)); | 5635 __ test(hash, Operand(hash)); |
5636 __ j(not_zero, &hash_not_zero, Label::kNear); | 5636 __ j(not_zero, &hash_not_zero, Label::kNear); |
5637 __ mov(hash, Immediate(27)); | 5637 __ mov(hash, Immediate(27)); |
5638 __ bind(&hash_not_zero); | 5638 __ bind(&hash_not_zero); |
5639 } | 5639 } |
5640 | 5640 |
5641 | 5641 |
5642 void SubStringStub::Generate(MacroAssembler* masm) { | 5642 void SubStringStub::Generate(MacroAssembler* masm) { |
5643 Label runtime; | 5643 Label runtime; |
5644 | 5644 |
5645 if (FLAG_string_slices) { | |
5646 __ jmp(&runtime); | |
5647 } | |
5648 // Stack frame on entry. | 5645 // Stack frame on entry. |
5649 // esp[0]: return address | 5646 // esp[0]: return address |
5650 // esp[4]: to | 5647 // esp[4]: to |
5651 // esp[8]: from | 5648 // esp[8]: from |
5652 // esp[12]: string | 5649 // esp[12]: string |
5653 | 5650 |
5654 // Make sure first argument is a string. | 5651 // Make sure first argument is a string. |
5655 __ mov(eax, Operand(esp, 3 * kPointerSize)); | 5652 __ mov(eax, Operand(esp, 3 * kPointerSize)); |
5656 STATIC_ASSERT(kSmiTag == 0); | 5653 STATIC_ASSERT(kSmiTag == 0); |
5657 __ JumpIfSmi(eax, &runtime); | 5654 __ JumpIfSmi(eax, &runtime); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5699 &make_two_character_string, &make_two_character_string); | 5696 &make_two_character_string, &make_two_character_string); |
5700 __ ret(3 * kPointerSize); | 5697 __ ret(3 * kPointerSize); |
5701 | 5698 |
5702 __ bind(&make_two_character_string); | 5699 __ bind(&make_two_character_string); |
5703 // Setup registers for allocating the two character string. | 5700 // Setup registers for allocating the two character string. |
5704 __ mov(eax, Operand(esp, 3 * kPointerSize)); | 5701 __ mov(eax, Operand(esp, 3 * kPointerSize)); |
5705 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 5702 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
5706 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 5703 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
5707 __ Set(ecx, Immediate(2)); | 5704 __ Set(ecx, Immediate(2)); |
5708 | 5705 |
5709 __ bind(&result_longer_than_two); | 5706 if (FLAG_string_slices) { |
5707 Label copy_rountine; | |
5708 // If coming from the make_two_character_string path, the string | |
5709 // is too short to be sliced anyways. | |
5710 STATIC_ASSERT(2 < SlicedString::kMinLength); | |
5711 __ jmp(©_routine); | |
5712 __ bind(&result_longer_than_two); | |
5713 | |
5714 // eax: string | |
5715 // ebx: instance type | |
5716 // ecx: sub string length | |
5717 // edx: from index (smi) | |
5718 Label allocate_slice, sliced_string, seq_string; | |
5719 __ cmp(ecx, SlicedString::kMinLength); | |
5720 // Short slice. Copy instead of slicing. | |
5721 __ j(less, ©_routine); | |
5722 STATIC_ASSERT(kSeqStringTag == 0); | |
5723 __ test(ebx, Immediate(kStringRepresentationMask)); | |
5724 __ j(zero, &seq_string, Label::kNear); | |
5725 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | |
antonm
2011/08/29 17:19:26
may those go too?
| |
5726 STATIC_ASSERT(kIsIndirectStringMask != 0); | |
5727 __ test(ebx, Immediate(kIsIndirectStringMask)); | |
5728 // External string. Jump to runtime. | |
5729 __ j(zero, &runtime); | |
5730 | |
5731 Factory* factory = masm->isolate()->factory(); | |
5732 __ test(ebx, Immediate(kSlicedNotConsMask)); | |
5733 __ j(not_zero, &sliced_string, Label::kNear); | |
5734 // Cons string. Check whether it is flat, then fetch first part. | |
5735 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), | |
5736 factory->empty_string()); | |
5737 __ j(not_equal, &runtime); | |
5738 __ mov(edi, FieldOperand(eax, ConsString::kFirstOffset)); | |
5739 __ jmp(&allocate_slice, Label::kNear); | |
5740 | |
5741 __ bind(&sliced_string); | |
5742 // Sliced string. Fetch parent and correct start index by offset. | |
5743 __ add(edx, FieldOperand(eax, SlicedString::kOffsetOffset)); | |
5744 __ mov(edi, FieldOperand(eax, SlicedString::kParentOffset)); | |
5745 __ jmp(&allocate_slice, Label::kNear); | |
5746 | |
5747 __ bind(&seq_string); | |
5748 // Sequential string. Just move string to the right register. | |
5749 __ mov(edi, eax); | |
5750 | |
5751 __ bind(&allocate_slice); | |
5752 // edi: underlying subject string | |
5753 // ebx: instance type of original subject string | |
5754 // edx: offset | |
5755 // ecx: length | |
5756 // Allocate new sliced string. At this point we do not reload the instance | |
Vitaly Repeshko
2011/08/30 01:17:48
This is clever, but the comment is a bit confusing
| |
5757 // type including the string encoding because we simply rely on the info | |
5758 // provided by the parent string. It does not matter if the parent's | |
5759 // encoding is wrong because we always have to recheck encoding of the | |
5760 // slice's parent anyways due to externalized strings. | |
5761 Label two_byte_slice, set_slice_header; | |
5762 STATIC_ASSERT(kAsciiStringTag != 0); | |
5763 __ test(ebx, Immediate(kAsciiStringTag)); | |
5764 __ j(zero, &two_byte_slice, Label::kNear); | |
5765 __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime); | |
5766 __ jmp(&set_slice_header, Label::kNear); | |
5767 __ bind(&two_byte_slice); | |
5768 __ AllocateSlicedString(eax, ebx, no_reg, &runtime); | |
5769 __ bind(&set_slice_header); | |
5770 __ mov(FieldOperand(eax, SlicedString::kOffsetOffset), edx); | |
5771 __ SmiTag(ecx); | |
5772 __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx); | |
5773 __ mov(FieldOperand(eax, SlicedString::kParentOffset), edi); | |
5774 __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset), | |
5775 Immediate(String::kEmptyHashField)); | |
5776 __ jmp(&return_eax); | |
5777 | |
5778 __ bind(©_routine); | |
5779 } else { | |
5780 __ bind(&result_longer_than_two); | |
5781 } | |
5782 | |
5710 // eax: string | 5783 // eax: string |
5711 // ebx: instance type | 5784 // ebx: instance type |
5712 // ecx: result string length | 5785 // ecx: result string length |
5713 // Check for flat ascii string | 5786 // Check for flat ascii string |
5714 Label non_ascii_flat; | 5787 Label non_ascii_flat; |
5715 __ JumpIfInstanceTypeIsNotSequentialAscii(ebx, ebx, &non_ascii_flat); | 5788 __ JumpIfInstanceTypeIsNotSequentialAscii(ebx, ebx, &non_ascii_flat); |
5716 | 5789 |
5717 // Allocate the result. | 5790 // Allocate the result. |
5718 __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime); | 5791 __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime); |
5719 | 5792 |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6414 __ Drop(1); | 6487 __ Drop(1); |
6415 __ ret(2 * kPointerSize); | 6488 __ ret(2 * kPointerSize); |
6416 } | 6489 } |
6417 | 6490 |
6418 | 6491 |
6419 #undef __ | 6492 #undef __ |
6420 | 6493 |
6421 } } // namespace v8::internal | 6494 } } // namespace v8::internal |
6422 | 6495 |
6423 #endif // V8_TARGET_ARCH_IA32 | 6496 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |