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 3a33c9e6f91c53979a41cbfbda043837ddd6f455..0c99a1488f8f664b60e1c64fc0c24ff6fa0eb3f9 100644 |
| --- a/src/ia32/code-stubs-ia32.cc |
| +++ b/src/ia32/code-stubs-ia32.cc |
| @@ -4827,6 +4827,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
| Label flat_string; |
| Label ascii_string; |
| Label got_char_code; |
| + Label sliced_string; |
| // If the receiver is a smi trigger the non-string case. |
| STATIC_ASSERT(kSmiTag == 0); |
| @@ -4857,8 +4858,11 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
| __ j(zero, &flat_string); |
| // Handle non-flat strings. |
| - __ test(result_, Immediate(kIsConsStringMask)); |
| - __ j(zero, &call_runtime_); |
| + __ and_(result_, kStringRepresentationMask); |
| + __ cmp(result_, kSlicedStringTag); |
| + __ j(equal, &sliced_string); |
| + __ cmp(result_, kExternalStringTag); |
| + __ j(equal, &call_runtime_); |
| // ConsString. |
| // Check whether the right hand side is the empty string (i.e. if |
| @@ -4876,6 +4880,14 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
| STATIC_ASSERT(kSeqStringTag == 0); |
| __ test(result_, Immediate(kStringRepresentationMask)); |
| __ j(not_zero, &call_runtime_); |
| + __ jmp(&flat_string); |
| + |
| + // SlicedString, unpack and add offset. |
| + __ bind(&sliced_string); |
| + __ add(scratch_, FieldOperand(object_, SlicedString::kOffsetOffset)); |
| + __ mov(object_, FieldOperand(object_, SlicedString::kParentOffset)); |
| + __ mov(result_, FieldOperand(object_, HeapObject::kMapOffset)); |
| + __ movzx_b(result_, FieldOperand(result_, Map::kInstanceTypeOffset)); |
| // Check for 1-byte or 2-byte string. |
| __ bind(&flat_string); |
| @@ -5201,6 +5213,8 @@ void StringAddStub::Generate(MacroAssembler* masm) { |
| __ and_(ecx, kStringRepresentationMask); |
| __ cmp(ecx, kExternalStringTag); |
| __ j(equal, &string_add_runtime); |
| + // We cannot encounter sliced strings here since: |
| + STATIC_ASSERT(SlicedString::kMinLength >= String::kMinNonFlatLength); |
| // Now check if both strings are ascii strings. |
| // eax: first string |
| // ebx: length of resulting flat string as a smi |
| @@ -5612,6 +5626,9 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm, |
| void SubStringStub::Generate(MacroAssembler* masm) { |
| Label runtime; |
|
Yang
2011/07/27 11:51:58
Do not create string slice unless experimental fla
|
| + if (FLAG_string_slices) { |
| + __ jmp(&runtime); |
| + } |
| // Stack frame on entry. |
| // esp[0]: return address |
| // esp[4]: to |