| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4905 // If coming from the make_two_character_string path, the string | 4905 // If coming from the make_two_character_string path, the string |
| 4906 // is too short to be sliced anyways. | 4906 // is too short to be sliced anyways. |
| 4907 STATIC_ASSERT(2 < SlicedString::kMinLength); | 4907 STATIC_ASSERT(2 < SlicedString::kMinLength); |
| 4908 __ jmp(©_routine); | 4908 __ jmp(©_routine); |
| 4909 __ bind(&result_longer_than_two); | 4909 __ bind(&result_longer_than_two); |
| 4910 | 4910 |
| 4911 // rax: string | 4911 // rax: string |
| 4912 // rbx: instance type | 4912 // rbx: instance type |
| 4913 // rcx: sub string length | 4913 // rcx: sub string length |
| 4914 // rdx: from index (smi) | 4914 // rdx: from index (smi) |
| 4915 Label allocate_slice, sliced_string, seq_string; | 4915 Label allocate_slice, sliced_string, seq_or_external_string; |
| 4916 __ cmpq(rcx, Immediate(SlicedString::kMinLength)); | 4916 __ cmpq(rcx, Immediate(SlicedString::kMinLength)); |
| 4917 // Short slice. Copy instead of slicing. | 4917 // Short slice. Copy instead of slicing. |
| 4918 __ j(less, ©_routine); | 4918 __ j(less, ©_routine); |
| 4919 STATIC_ASSERT(kSeqStringTag == 0); | |
| 4920 __ testb(rbx, Immediate(kStringRepresentationMask)); | |
| 4921 __ j(zero, &seq_string, Label::kNear); | |
| 4922 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | 4919 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); |
| 4923 STATIC_ASSERT(kIsIndirectStringMask != 0); | 4920 STATIC_ASSERT(kIsIndirectStringMask != 0); |
| 4924 __ testb(rbx, Immediate(kIsIndirectStringMask)); | 4921 __ testb(rbx, Immediate(kIsIndirectStringMask)); |
| 4925 // External string. Jump to runtime. | 4922 __ j(zero, &seq_or_external_string, Label::kNear); |
| 4926 __ j(zero, &runtime); | |
| 4927 | 4923 |
| 4928 __ testb(rbx, Immediate(kSlicedNotConsMask)); | 4924 __ testb(rbx, Immediate(kSlicedNotConsMask)); |
| 4929 __ j(not_zero, &sliced_string, Label::kNear); | 4925 __ j(not_zero, &sliced_string, Label::kNear); |
| 4930 // Cons string. Check whether it is flat, then fetch first part. | 4926 // Cons string. Check whether it is flat, then fetch first part. |
| 4931 __ CompareRoot(FieldOperand(rax, ConsString::kSecondOffset), | 4927 __ CompareRoot(FieldOperand(rax, ConsString::kSecondOffset), |
| 4932 Heap::kEmptyStringRootIndex); | 4928 Heap::kEmptyStringRootIndex); |
| 4933 __ j(not_equal, &runtime); | 4929 __ j(not_equal, &runtime); |
| 4934 __ movq(rdi, FieldOperand(rax, ConsString::kFirstOffset)); | 4930 __ movq(rdi, FieldOperand(rax, ConsString::kFirstOffset)); |
| 4935 __ jmp(&allocate_slice, Label::kNear); | 4931 __ jmp(&allocate_slice, Label::kNear); |
| 4936 | 4932 |
| 4937 __ bind(&sliced_string); | 4933 __ bind(&sliced_string); |
| 4938 // Sliced string. Fetch parent and correct start index by offset. | 4934 // Sliced string. Fetch parent and correct start index by offset. |
| 4939 __ addq(rdx, FieldOperand(rax, SlicedString::kOffsetOffset)); | 4935 __ addq(rdx, FieldOperand(rax, SlicedString::kOffsetOffset)); |
| 4940 __ movq(rdi, FieldOperand(rax, SlicedString::kParentOffset)); | 4936 __ movq(rdi, FieldOperand(rax, SlicedString::kParentOffset)); |
| 4941 __ jmp(&allocate_slice, Label::kNear); | 4937 __ jmp(&allocate_slice, Label::kNear); |
| 4942 | 4938 |
| 4943 __ bind(&seq_string); | 4939 __ bind(&seq_or_external_string); |
| 4944 // Sequential string. Just move string to the right register. | 4940 // Sequential or external string. Just move string to the correct register. |
| 4945 __ movq(rdi, rax); | 4941 __ movq(rdi, rax); |
| 4946 | 4942 |
| 4947 __ bind(&allocate_slice); | 4943 __ bind(&allocate_slice); |
| 4948 // edi: underlying subject string | 4944 // edi: underlying subject string |
| 4949 // ebx: instance type of original subject string | 4945 // ebx: instance type of original subject string |
| 4950 // edx: offset | 4946 // edx: offset |
| 4951 // ecx: length | 4947 // ecx: length |
| 4952 // Allocate new sliced string. At this point we do not reload the instance | 4948 // Allocate new sliced string. At this point we do not reload the instance |
| 4953 // type including the string encoding because we simply rely on the info | 4949 // type including the string encoding because we simply rely on the info |
| 4954 // provided by the original string. It does not matter if the original | 4950 // provided by the original string. It does not matter if the original |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6027 xmm0, | 6023 xmm0, |
| 6028 &slow_elements); | 6024 &slow_elements); |
| 6029 __ ret(0); | 6025 __ ret(0); |
| 6030 } | 6026 } |
| 6031 | 6027 |
| 6032 #undef __ | 6028 #undef __ |
| 6033 | 6029 |
| 6034 } } // namespace v8::internal | 6030 } } // namespace v8::internal |
| 6035 | 6031 |
| 6036 #endif // V8_TARGET_ARCH_X64 | 6032 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |