Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 9625003: Tweaks to SubStringStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 6137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6148 __ mov(eax, Operand(esp, 3 * kPointerSize)); 6148 __ mov(eax, Operand(esp, 3 * kPointerSize));
6149 STATIC_ASSERT(kSmiTag == 0); 6149 STATIC_ASSERT(kSmiTag == 0);
6150 __ JumpIfSmi(eax, &runtime); 6150 __ JumpIfSmi(eax, &runtime);
6151 Condition is_string = masm->IsObjectStringType(eax, ebx, ebx); 6151 Condition is_string = masm->IsObjectStringType(eax, ebx, ebx);
6152 __ j(NegateCondition(is_string), &runtime); 6152 __ j(NegateCondition(is_string), &runtime);
6153 6153
6154 // eax: string 6154 // eax: string
6155 // ebx: instance type 6155 // ebx: instance type
6156 6156
6157 // Calculate length of sub string using the smi values. 6157 // Calculate length of sub string using the smi values.
6158 Label result_longer_than_two;
6159 __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index. 6158 __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index.
6160 __ JumpIfNotSmi(ecx, &runtime); 6159 __ JumpIfNotSmi(ecx, &runtime);
6161 __ mov(edx, Operand(esp, 2 * kPointerSize)); // From index. 6160 __ mov(edx, Operand(esp, 2 * kPointerSize)); // From index.
6162 __ JumpIfNotSmi(edx, &runtime); 6161 __ JumpIfNotSmi(edx, &runtime);
6163 __ sub(ecx, edx); 6162 __ sub(ecx, edx);
6164 __ cmp(ecx, FieldOperand(eax, String::kLengthOffset)); 6163 __ cmp(ecx, FieldOperand(eax, String::kLengthOffset));
6165 Label not_original_string; 6164 Label not_original_string;
6166 __ j(not_equal, &not_original_string, Label::kNear); 6165 __ j(not_equal, &not_original_string, Label::kNear);
6167 Counters* counters = masm->isolate()->counters(); 6166 Counters* counters = masm->isolate()->counters();
6168 __ IncrementCounter(counters->sub_string_native(), 1); 6167 __ IncrementCounter(counters->sub_string_native(), 1);
6169 __ ret(3 * kPointerSize); 6168 __ ret(3 * kPointerSize);
6170 __ bind(&not_original_string); 6169 __ bind(&not_original_string);
6171 // Special handling of sub-strings of length 1 and 2. One character strings
6172 // are handled in the runtime system (looked up in the single character
6173 // cache). Two character strings are looked for in the symbol cache.
6174 __ cmp(ecx, Immediate(Smi::FromInt(2)));
6175 __ j(greater, &result_longer_than_two);
6176 __ j(less, &runtime);
6177 6170
6178 // Sub string of length 2 requested.
6179 // eax: string
6180 // ebx: instance type
6181 // ecx: sub string length (smi, value is 2)
6182 // edx: from index (smi)
6183 __ JumpIfInstanceTypeIsNotSequentialAscii(ebx, ebx, &runtime);
6184
6185 // Get the two characters forming the sub string.
6186 __ SmiUntag(edx); // From index is no longer smi.
6187 __ movzx_b(ebx, FieldOperand(eax, edx, times_1, SeqAsciiString::kHeaderSize));
6188 __ movzx_b(ecx,
6189 FieldOperand(eax, edx, times_1, SeqAsciiString::kHeaderSize + 1));
6190
6191 // Try to lookup two character string in symbol table.
6192 Label combine_two_char, save_two_char;
6193 StringHelper::GenerateTwoCharacterSymbolTableProbe(
6194 masm, ebx, ecx, eax, edx, edi, &combine_two_char, &save_two_char);
6195 __ IncrementCounter(counters->sub_string_native(), 1);
6196 __ ret(3 * kPointerSize);
6197
6198 __ bind(&combine_two_char);
6199 __ shl(ecx, kBitsPerByte);
6200 __ or_(ebx, ecx);
6201 __ bind(&save_two_char);
6202 __ AllocateAsciiString(eax, 2, ecx, edx, &runtime);
6203 __ mov_w(FieldOperand(eax, SeqAsciiString::kHeaderSize), ebx);
6204 __ IncrementCounter(counters->sub_string_native(), 1);
6205 __ ret(3 * kPointerSize);
6206
6207 __ bind(&result_longer_than_two);
6208 // eax: string 6171 // eax: string
6209 // ebx: instance type 6172 // ebx: instance type
6210 // ecx: sub string length (smi) 6173 // ecx: sub string length (smi)
6211 // edx: from index (smi) 6174 // edx: from index (smi)
6212 // Deal with different string types: update the index if necessary 6175 // Deal with different string types: update the index if necessary
6213 // and put the underlying string into edi. 6176 // and put the underlying string into edi.
6214 Label underlying_unpacked, sliced_string, seq_or_external_string; 6177 Label underlying_unpacked, sliced_string, seq_or_external_string;
6215 // If the string is not indirect, it can only be sequential or external. 6178 // If the string is not indirect, it can only be sequential or external.
6216 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); 6179 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag));
6217 STATIC_ASSERT(kIsIndirectStringMask != 0); 6180 STATIC_ASSERT(kIsIndirectStringMask != 0);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6264 Label two_byte_slice, set_slice_header; 6227 Label two_byte_slice, set_slice_header;
6265 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0); 6228 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
6266 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); 6229 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
6267 __ test(ebx, Immediate(kStringEncodingMask)); 6230 __ test(ebx, Immediate(kStringEncodingMask));
6268 __ j(zero, &two_byte_slice, Label::kNear); 6231 __ j(zero, &two_byte_slice, Label::kNear);
6269 __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime); 6232 __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime);
6270 __ jmp(&set_slice_header, Label::kNear); 6233 __ jmp(&set_slice_header, Label::kNear);
6271 __ bind(&two_byte_slice); 6234 __ bind(&two_byte_slice);
6272 __ AllocateTwoByteSlicedString(eax, ebx, no_reg, &runtime); 6235 __ AllocateTwoByteSlicedString(eax, ebx, no_reg, &runtime);
6273 __ bind(&set_slice_header); 6236 __ bind(&set_slice_header);
6274 __ mov(FieldOperand(eax, SlicedString::kOffsetOffset), edx);
6275 __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx); 6237 __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx);
6276 __ mov(FieldOperand(eax, SlicedString::kParentOffset), edi);
6277 __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset), 6238 __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset),
6278 Immediate(String::kEmptyHashField)); 6239 Immediate(String::kEmptyHashField));
6240 __ mov(FieldOperand(eax, SlicedString::kParentOffset), edi);
6241 __ mov(FieldOperand(eax, SlicedString::kOffsetOffset), edx);
6279 __ IncrementCounter(counters->sub_string_native(), 1); 6242 __ IncrementCounter(counters->sub_string_native(), 1);
6280 __ ret(3 * kPointerSize); 6243 __ ret(3 * kPointerSize);
6281 6244
6282 __ bind(&copy_routine); 6245 __ bind(&copy_routine);
6283 } 6246 }
6284 6247
6285 // edi: underlying subject string 6248 // edi: underlying subject string
6286 // ebx: instance type of underlying subject string 6249 // ebx: instance type of underlying subject string
6287 // edx: adjusted start index (smi) 6250 // edx: adjusted start index (smi)
6288 // ecx: length (smi) 6251 // ecx: length (smi)
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
7400 false); 7363 false);
7401 __ pop(edx); 7364 __ pop(edx);
7402 __ ret(0); 7365 __ ret(0);
7403 } 7366 }
7404 7367
7405 #undef __ 7368 #undef __
7406 7369
7407 } } // namespace v8::internal 7370 } } // namespace v8::internal
7408 7371
7409 #endif // V8_TARGET_ARCH_IA32 7372 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698