| 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 5855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5866 __ JumpIfSmi(r0, &runtime); | 5866 __ JumpIfSmi(r0, &runtime); |
| 5867 Condition is_string = masm->IsObjectStringType(r0, r1); | 5867 Condition is_string = masm->IsObjectStringType(r0, r1); |
| 5868 __ b(NegateCondition(is_string), &runtime); | 5868 __ b(NegateCondition(is_string), &runtime); |
| 5869 | 5869 |
| 5870 // Short-cut for the case of trivial substring. | 5870 // Short-cut for the case of trivial substring. |
| 5871 Label return_r0; | 5871 Label return_r0; |
| 5872 // r0: original string | 5872 // r0: original string |
| 5873 // r2: result string length | 5873 // r2: result string length |
| 5874 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); | 5874 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); |
| 5875 __ cmp(r2, Operand(r4, ASR, 1)); | 5875 __ cmp(r2, Operand(r4, ASR, 1)); |
| 5876 // Return original string. |
| 5876 __ b(eq, &return_r0); | 5877 __ b(eq, &return_r0); |
| 5878 // Longer than original string's length or negative: unsafe arguments. |
| 5879 __ b(hi, &runtime); |
| 5880 // Shorter than original string's length: an actual substring. |
| 5877 | 5881 |
| 5878 Label result_longer_than_two; | |
| 5879 // Check for special case of two character ASCII string, in which case | |
| 5880 // we do a lookup in the symbol table first. | |
| 5881 __ cmp(r2, Operand(2)); | |
| 5882 __ b(gt, &result_longer_than_two); | |
| 5883 __ b(lt, &runtime); | |
| 5884 | |
| 5885 __ JumpIfInstanceTypeIsNotSequentialAscii(r1, r1, &runtime); | |
| 5886 | |
| 5887 // Get the two characters forming the sub string. | |
| 5888 __ add(r0, r0, Operand(r3)); | |
| 5889 __ ldrb(r3, FieldMemOperand(r0, SeqAsciiString::kHeaderSize)); | |
| 5890 __ ldrb(r4, FieldMemOperand(r0, SeqAsciiString::kHeaderSize + 1)); | |
| 5891 | |
| 5892 // Try to lookup two character string in symbol table. | |
| 5893 Label make_two_character_string; | |
| 5894 StringHelper::GenerateTwoCharacterSymbolTableProbe( | |
| 5895 masm, r3, r4, r1, r5, r6, r7, r9, &make_two_character_string); | |
| 5896 __ jmp(&return_r0); | |
| 5897 | |
| 5898 // r2: result string length. | |
| 5899 // r3: two characters combined into halfword in little endian byte order. | |
| 5900 __ bind(&make_two_character_string); | |
| 5901 __ AllocateAsciiString(r0, r2, r4, r5, r9, &runtime); | |
| 5902 __ strh(r3, FieldMemOperand(r0, SeqAsciiString::kHeaderSize)); | |
| 5903 __ jmp(&return_r0); | |
| 5904 | |
| 5905 __ bind(&result_longer_than_two); | |
| 5906 // Deal with different string types: update the index if necessary | 5882 // Deal with different string types: update the index if necessary |
| 5907 // and put the underlying string into r5. | 5883 // and put the underlying string into r5. |
| 5908 // r0: original string | 5884 // r0: original string |
| 5909 // r1: instance type | 5885 // r1: instance type |
| 5910 // r2: length | 5886 // r2: length |
| 5911 // r3: from index (untagged) | 5887 // r3: from index (untagged) |
| 5912 Label underlying_unpacked, sliced_string, seq_or_external_string; | 5888 Label underlying_unpacked, sliced_string, seq_or_external_string; |
| 5913 // If the string is not indirect, it can only be sequential or external. | 5889 // If the string is not indirect, it can only be sequential or external. |
| 5914 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | 5890 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); |
| 5915 STATIC_ASSERT(kIsIndirectStringMask != 0); | 5891 STATIC_ASSERT(kIsIndirectStringMask != 0); |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7409 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r2, | 7385 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r2, |
| 7410 &slow_elements); | 7386 &slow_elements); |
| 7411 __ Ret(); | 7387 __ Ret(); |
| 7412 } | 7388 } |
| 7413 | 7389 |
| 7414 #undef __ | 7390 #undef __ |
| 7415 | 7391 |
| 7416 } } // namespace v8::internal | 7392 } } // namespace v8::internal |
| 7417 | 7393 |
| 7418 #endif // V8_TARGET_ARCH_ARM | 7394 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |