Chromium Code Reviews| Index: src/ia32/code-stubs-ia32.cc |
| diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
| index d76e4bf1f444a40f4021827d747738cd21bd7d53..813bc1caf30a924419e46118f33f83505744569d 100644 |
| --- a/src/ia32/code-stubs-ia32.cc |
| +++ b/src/ia32/code-stubs-ia32.cc |
| @@ -5642,9 +5642,6 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm, |
| void SubStringStub::Generate(MacroAssembler* masm) { |
| Label runtime; |
| - if (FLAG_string_slices) { |
| - __ jmp(&runtime); |
| - } |
| // Stack frame on entry. |
| // esp[0]: return address |
| // esp[4]: to |
| @@ -5706,7 +5703,81 @@ void SubStringStub::Generate(MacroAssembler* masm) { |
| __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| __ Set(ecx, Immediate(2)); |
| - __ bind(&result_longer_than_two); |
| + if (FLAG_string_slices) { |
| + __ SmiTag(edx); // Make edx a smi again. |
|
antonm
2011/08/26 16:10:55
do you want to fallback here from make_two_charact
Yang
2011/08/29 12:55:56
Yes.
antonm
2011/08/29 14:51:27
Brevity is .... :) I meant you know for sure you
Yang
2011/08/29 15:17:07
Oups. I actually managed to overlook this simple f
|
| + __ bind(&result_longer_than_two); |
| + |
| + // eax: string |
| + // ebx: instance type |
| + // ecx: sub string length |
| + // edx: from index (smi) |
| + Label copy_routine, allocate_slice, sliced_string, seq_string; |
| + __ cmp(ecx, SlicedString::kMinLength); |
| + // Short slice. Copy instead of slicing. |
| + __ j(less, ©_routine); |
| + STATIC_ASSERT(kSeqStringTag == 0); |
| + __ test(ebx, Immediate(kStringRepresentationMask)); |
| + __ j(zero, &seq_string, Label::kNear); |
| + STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); |
| + STATIC_ASSERT(kIsIndirectStringMask != 0); |
| + __ test(ebx, Immediate(kIsIndirectStringMask)); |
| + // External string. Jump to runtime. |
| + __ j(zero, &runtime); |
| + |
| + Factory* factory = masm->isolate()->factory(); |
| + const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag; |
|
antonm
2011/08/26 16:10:55
lift those constants into objects.h?
antonm
2011/08/29 14:51:27
any response?
Yang
2011/08/29 15:17:07
I did move these two lines into objects.h
Maybe yo
antonm
2011/08/29 17:19:26
Sorry, didn't notice that. Usually people respond
|
| + ASSERT(IsPowerOf2(kSlicedNotConsMask) && kSlicedNotConsMask != 0); |
| + __ test(ebx, Immediate(kSlicedNotConsMask)); |
| + __ j(not_zero, &sliced_string, Label::kNear); |
| + // Cons string. Check whether it is flat, then fetch first part. |
| + __ cmp(FieldOperand(eax, ConsString::kSecondOffset), |
| + factory->empty_string()); |
| + __ j(not_equal, &runtime); |
| + __ mov(edi, FieldOperand(eax, ConsString::kFirstOffset)); |
| + __ jmp(&allocate_slice, Label::kNear); |
| + |
| + __ bind(&sliced_string); |
| + // Sliced string. Fetch parent and correct start index by offset. |
| + __ add(edx, FieldOperand(eax, SlicedString::kOffsetOffset)); |
| + __ mov(edi, FieldOperand(eax, SlicedString::kParentOffset)); |
| + __ jmp(&allocate_slice, Label::kNear); |
| + |
| + __ bind(&seq_string); |
| + // Sequential string. Just move string to the right register. |
| + __ mov(edi, eax); |
|
antonm
2011/08/26 16:10:55
maybe keep the parent string in eax and save this
Yang
2011/08/29 12:55:56
eax has to be used as destination when allocation
antonm
2011/08/29 14:51:27
I am not sure, apparently you can allocate into an
Yang
2011/08/29 15:17:07
Yes but the issue is that the return value of this
antonm
2011/08/29 17:19:26
ok
|
| + |
| + __ bind(&allocate_slice); |
| + // edi: parent string |
| + // ebx: instance type of parent string |
| + // edx: offset |
| + // ecx: length |
| + // Allocate new sliced string. At this point we do not reload the instance |
| + // type including the string encoding because we simply rely on the info |
| + // provided by the parent string. It does not matter if the parent's |
| + // encoding is wrong because we have to recheck encoding of the slice's |
| + // parent anyways due to externalized strings |
| + Label two_byte_slice, set_slice_header; |
| + STATIC_ASSERT(kAsciiStringTag != 0); |
| + __ test(ebx, Immediate(kAsciiStringTag)); |
| + __ j(zero, &two_byte_slice, Label::kNear); |
| + __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime); |
| + __ jmp(&set_slice_header, Label::kNear); |
| + __ bind(&two_byte_slice); |
| + __ AllocateSlicedString(eax, ebx, no_reg, &runtime); |
| + __ bind(&set_slice_header); |
| + __ mov(FieldOperand(eax, SlicedString::kOffsetOffset), edx); |
| + __ SmiTag(ecx); |
|
antonm
2011/08/26 16:10:55
apparently there is too much of tagging/untagging,
Yang
2011/08/29 12:55:56
The alternative saves this one tagging, but would
antonm
2011/08/29 14:51:27
Up to you.
|
| + __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx); |
| + __ mov(FieldOperand(eax, SlicedString::kParentOffset), edi); |
| + __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset), |
| + Immediate(String::kEmptyHashField)); |
| + __ jmp(&return_eax); |
| + |
| + __ bind(©_routine); |
| + } else { |
| + __ bind(&result_longer_than_two); |
| + } |
| + |
| // eax: string |
| // ebx: instance type |
| // ecx: result string length |