OLD | NEW |
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 5864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5875 __ push(code_); | 5875 __ push(code_); |
5876 __ CallRuntime(Runtime::kCharFromCode, 1); | 5876 __ CallRuntime(Runtime::kCharFromCode, 1); |
5877 __ Move(result_, r0); | 5877 __ Move(result_, r0); |
5878 call_helper.AfterCall(masm); | 5878 call_helper.AfterCall(masm); |
5879 __ jmp(&exit_); | 5879 __ jmp(&exit_); |
5880 | 5880 |
5881 __ Abort("Unexpected fallthrough from CharFromCode slow case"); | 5881 __ Abort("Unexpected fallthrough from CharFromCode slow case"); |
5882 } | 5882 } |
5883 | 5883 |
5884 | 5884 |
5885 // ------------------------------------------------------------------------- | |
5886 // StringCharAtGenerator | |
5887 | |
5888 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) { | |
5889 char_code_at_generator_.GenerateFast(masm); | |
5890 char_from_code_generator_.GenerateFast(masm); | |
5891 } | |
5892 | |
5893 | |
5894 void StringCharAtGenerator::GenerateSlow( | |
5895 MacroAssembler* masm, | |
5896 const RuntimeCallHelper& call_helper) { | |
5897 char_code_at_generator_.GenerateSlow(masm, call_helper); | |
5898 char_from_code_generator_.GenerateSlow(masm, call_helper); | |
5899 } | |
5900 | |
5901 | |
5902 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, | 5885 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, |
5903 Register dest, | 5886 Register dest, |
5904 Register src, | 5887 Register src, |
5905 Register count, | 5888 Register count, |
5906 Register scratch, | 5889 Register scratch, |
5907 bool ascii) { | 5890 bool ascii) { |
5908 Label loop; | 5891 Label loop; |
5909 Label done; | 5892 Label done; |
5910 // This loop just copies one character at a time, as it is only used for very | 5893 // This loop just copies one character at a time, as it is only used for very |
5911 // short strings. | 5894 // short strings. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6299 | 6282 |
6300 // Make sure first argument is a string. | 6283 // Make sure first argument is a string. |
6301 __ ldr(r0, MemOperand(sp, kStringOffset)); | 6284 __ ldr(r0, MemOperand(sp, kStringOffset)); |
6302 STATIC_ASSERT(kSmiTag == 0); | 6285 STATIC_ASSERT(kSmiTag == 0); |
6303 // Do a JumpIfSmi, but fold its jump into the subsequent string test. | 6286 // Do a JumpIfSmi, but fold its jump into the subsequent string test. |
6304 __ tst(r0, Operand(kSmiTagMask)); | 6287 __ tst(r0, Operand(kSmiTagMask)); |
6305 Condition is_string = masm->IsObjectStringType(r0, r1, ne); | 6288 Condition is_string = masm->IsObjectStringType(r0, r1, ne); |
6306 ASSERT(is_string == eq); | 6289 ASSERT(is_string == eq); |
6307 __ b(NegateCondition(is_string), &runtime); | 6290 __ b(NegateCondition(is_string), &runtime); |
6308 | 6291 |
| 6292 Label single_char; |
| 6293 __ cmp(r2, Operand(1)); |
| 6294 __ b(eq, &single_char); |
| 6295 |
6309 // Short-cut for the case of trivial substring. | 6296 // Short-cut for the case of trivial substring. |
6310 Label return_r0; | 6297 Label return_r0; |
6311 // r0: original string | 6298 // r0: original string |
6312 // r2: result string length | 6299 // r2: result string length |
6313 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); | 6300 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); |
6314 __ cmp(r2, Operand(r4, ASR, 1)); | 6301 __ cmp(r2, Operand(r4, ASR, 1)); |
6315 // Return original string. | 6302 // Return original string. |
6316 __ b(eq, &return_r0); | 6303 __ b(eq, &return_r0); |
6317 // Longer than original string's length or negative: unsafe arguments. | 6304 // Longer than original string's length or negative: unsafe arguments. |
6318 __ b(hi, &runtime); | 6305 __ b(hi, &runtime); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6452 // r1: first character of result. | 6439 // r1: first character of result. |
6453 // r2: result length. | 6440 // r2: result length. |
6454 // r5: first character of substring to copy. | 6441 // r5: first character of substring to copy. |
6455 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 6442 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
6456 StringHelper::GenerateCopyCharactersLong( | 6443 StringHelper::GenerateCopyCharactersLong( |
6457 masm, r1, r5, r2, r3, r4, r6, r7, r9, DEST_ALWAYS_ALIGNED); | 6444 masm, r1, r5, r2, r3, r4, r6, r7, r9, DEST_ALWAYS_ALIGNED); |
6458 | 6445 |
6459 __ bind(&return_r0); | 6446 __ bind(&return_r0); |
6460 Counters* counters = masm->isolate()->counters(); | 6447 Counters* counters = masm->isolate()->counters(); |
6461 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 6448 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); |
6462 __ add(sp, sp, Operand(3 * kPointerSize)); | 6449 __ Drop(3); |
6463 __ Ret(); | 6450 __ Ret(); |
6464 | 6451 |
6465 // Just jump to runtime to create the sub string. | 6452 // Just jump to runtime to create the sub string. |
6466 __ bind(&runtime); | 6453 __ bind(&runtime); |
6467 __ TailCallRuntime(Runtime::kSubString, 3, 1); | 6454 __ TailCallRuntime(Runtime::kSubString, 3, 1); |
| 6455 |
| 6456 __ bind(&single_char); |
| 6457 // r0: original string |
| 6458 // r1: instance type |
| 6459 // r2: length |
| 6460 // r3: from index (untagged) |
| 6461 __ SmiTag(r3, r3); |
| 6462 StringCharAtGenerator generator( |
| 6463 r0, r3, r2, r0, &runtime, &runtime, &runtime, STRING_INDEX_IS_NUMBER); |
| 6464 generator.GenerateFast(masm); |
| 6465 __ Drop(3); |
| 6466 __ Ret(); |
| 6467 generator.SkipSlow(masm, &runtime); |
6468 } | 6468 } |
6469 | 6469 |
6470 | 6470 |
6471 void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, | 6471 void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, |
6472 Register left, | 6472 Register left, |
6473 Register right, | 6473 Register right, |
6474 Register scratch1, | 6474 Register scratch1, |
6475 Register scratch2, | 6475 Register scratch2, |
6476 Register scratch3) { | 6476 Register scratch3) { |
6477 Register length = scratch1; | 6477 Register length = scratch1; |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7946 | 7946 |
7947 __ Pop(lr, r5, r1); | 7947 __ Pop(lr, r5, r1); |
7948 __ Ret(); | 7948 __ Ret(); |
7949 } | 7949 } |
7950 | 7950 |
7951 #undef __ | 7951 #undef __ |
7952 | 7952 |
7953 } } // namespace v8::internal | 7953 } } // namespace v8::internal |
7954 | 7954 |
7955 #endif // V8_TARGET_ARCH_ARM | 7955 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |