OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 3727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3738 __ AssertString(rax); | 3738 __ AssertString(rax); |
3739 | 3739 |
3740 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); | 3740 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); |
3741 DCHECK(String::kHashShift >= kSmiTagSize); | 3741 DCHECK(String::kHashShift >= kSmiTagSize); |
3742 __ IndexFromHash(rax, rax); | 3742 __ IndexFromHash(rax, rax); |
3743 | 3743 |
3744 context()->Plug(rax); | 3744 context()->Plug(rax); |
3745 } | 3745 } |
3746 | 3746 |
3747 | 3747 |
3748 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { | 3748 void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) { |
3749 Label bailout, return_result, done, one_char_separator, long_separator, | 3749 Label bailout, return_result, done, one_char_separator, long_separator, |
3750 non_trivial_array, not_size_one_array, loop, | 3750 non_trivial_array, not_size_one_array, loop, |
3751 loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry; | 3751 loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry; |
3752 ZoneList<Expression*>* args = expr->arguments(); | 3752 ZoneList<Expression*>* args = expr->arguments(); |
3753 DCHECK(args->length() == 2); | 3753 DCHECK(args->length() == 2); |
3754 // We will leave the separator on the stack until the end of the function. | 3754 // We will leave the separator on the stack until the end of the function. |
3755 VisitForStackValue(args->at(1)); | 3755 VisitForStackValue(args->at(1)); |
3756 // Load this to rax (= array) | 3756 // Load this to rax (= array) |
3757 VisitForAccumulatorValue(args->at(0)); | 3757 VisitForAccumulatorValue(args->at(0)); |
3758 // All aliases of the same register have disjoint lifetimes. | 3758 // All aliases of the same register have disjoint lifetimes. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 __ SmiToInteger32(array_length, array_length); | 3799 __ SmiToInteger32(array_length, array_length); |
3800 __ movl(array_length_operand, array_length); | 3800 __ movl(array_length_operand, array_length); |
3801 | 3801 |
3802 // Save the FixedArray containing array's elements. | 3802 // Save the FixedArray containing array's elements. |
3803 // End of array's live range. | 3803 // End of array's live range. |
3804 elements = array; | 3804 elements = array; |
3805 __ movp(elements, FieldOperand(array, JSArray::kElementsOffset)); | 3805 __ movp(elements, FieldOperand(array, JSArray::kElementsOffset)); |
3806 array = no_reg; | 3806 array = no_reg; |
3807 | 3807 |
3808 | 3808 |
3809 // Check that all array elements are sequential ASCII strings, and | 3809 // Check that all array elements are sequential one-byte strings, and |
3810 // accumulate the sum of their lengths, as a smi-encoded value. | 3810 // accumulate the sum of their lengths, as a smi-encoded value. |
3811 __ Set(index, 0); | 3811 __ Set(index, 0); |
3812 __ Set(string_length, 0); | 3812 __ Set(string_length, 0); |
3813 // Loop condition: while (index < array_length). | 3813 // Loop condition: while (index < array_length). |
3814 // Live loop registers: index(int32), array_length(int32), string(String*), | 3814 // Live loop registers: index(int32), array_length(int32), string(String*), |
3815 // scratch, string_length(int32), elements(FixedArray*). | 3815 // scratch, string_length(int32), elements(FixedArray*). |
3816 if (generate_debug_code_) { | 3816 if (generate_debug_code_) { |
3817 __ cmpp(index, array_length); | 3817 __ cmpp(index, array_length); |
3818 __ Assert(below, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); | 3818 __ Assert(below, kNoEmptyArraysHereInEmitFastOneByteArrayJoin); |
3819 } | 3819 } |
3820 __ bind(&loop); | 3820 __ bind(&loop); |
3821 __ movp(string, FieldOperand(elements, | 3821 __ movp(string, FieldOperand(elements, |
3822 index, | 3822 index, |
3823 times_pointer_size, | 3823 times_pointer_size, |
3824 FixedArray::kHeaderSize)); | 3824 FixedArray::kHeaderSize)); |
3825 __ JumpIfSmi(string, &bailout); | 3825 __ JumpIfSmi(string, &bailout); |
3826 __ movp(scratch, FieldOperand(string, HeapObject::kMapOffset)); | 3826 __ movp(scratch, FieldOperand(string, HeapObject::kMapOffset)); |
3827 __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | 3827 __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
3828 __ andb(scratch, Immediate( | 3828 __ andb(scratch, Immediate( |
(...skipping 23 matching lines...) Expand all Loading... |
3852 | 3852 |
3853 // End of array_length live range. | 3853 // End of array_length live range. |
3854 result_pos = array_length; | 3854 result_pos = array_length; |
3855 array_length = no_reg; | 3855 array_length = no_reg; |
3856 | 3856 |
3857 // Live registers: | 3857 // Live registers: |
3858 // string_length: Sum of string lengths. | 3858 // string_length: Sum of string lengths. |
3859 // elements: FixedArray of strings. | 3859 // elements: FixedArray of strings. |
3860 // index: Array length. | 3860 // index: Array length. |
3861 | 3861 |
3862 // Check that the separator is a sequential ASCII string. | 3862 // Check that the separator is a sequential one-byte string. |
3863 __ movp(string, separator_operand); | 3863 __ movp(string, separator_operand); |
3864 __ JumpIfSmi(string, &bailout); | 3864 __ JumpIfSmi(string, &bailout); |
3865 __ movp(scratch, FieldOperand(string, HeapObject::kMapOffset)); | 3865 __ movp(scratch, FieldOperand(string, HeapObject::kMapOffset)); |
3866 __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | 3866 __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
3867 __ andb(scratch, Immediate( | 3867 __ andb(scratch, Immediate( |
3868 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); | 3868 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); |
3869 __ cmpb(scratch, Immediate(kStringTag | kOneByteStringTag | kSeqStringTag)); | 3869 __ cmpb(scratch, Immediate(kStringTag | kOneByteStringTag | kSeqStringTag)); |
3870 __ j(not_equal, &bailout); | 3870 __ j(not_equal, &bailout); |
3871 | 3871 |
3872 // Live registers: | 3872 // Live registers: |
3873 // string_length: Sum of string lengths. | 3873 // string_length: Sum of string lengths. |
3874 // elements: FixedArray of strings. | 3874 // elements: FixedArray of strings. |
3875 // index: Array length. | 3875 // index: Array length. |
3876 // string: Separator string. | 3876 // string: Separator string. |
3877 | 3877 |
3878 // Add (separator length times (array_length - 1)) to string_length. | 3878 // Add (separator length times (array_length - 1)) to string_length. |
3879 __ SmiToInteger32(scratch, | 3879 __ SmiToInteger32(scratch, |
3880 FieldOperand(string, SeqOneByteString::kLengthOffset)); | 3880 FieldOperand(string, SeqOneByteString::kLengthOffset)); |
3881 __ decl(index); | 3881 __ decl(index); |
3882 __ imull(scratch, index); | 3882 __ imull(scratch, index); |
3883 __ j(overflow, &bailout); | 3883 __ j(overflow, &bailout); |
3884 __ addl(string_length, scratch); | 3884 __ addl(string_length, scratch); |
3885 __ j(overflow, &bailout); | 3885 __ j(overflow, &bailout); |
3886 | 3886 |
3887 // Live registers and stack values: | 3887 // Live registers and stack values: |
3888 // string_length: Total length of result string. | 3888 // string_length: Total length of result string. |
3889 // elements: FixedArray of strings. | 3889 // elements: FixedArray of strings. |
3890 __ AllocateAsciiString(result_pos, string_length, scratch, | 3890 __ AllocateOneByteString(result_pos, string_length, scratch, index, string, |
3891 index, string, &bailout); | 3891 &bailout); |
3892 __ movp(result_operand, result_pos); | 3892 __ movp(result_operand, result_pos); |
3893 __ leap(result_pos, FieldOperand(result_pos, SeqOneByteString::kHeaderSize)); | 3893 __ leap(result_pos, FieldOperand(result_pos, SeqOneByteString::kHeaderSize)); |
3894 | 3894 |
3895 __ movp(string, separator_operand); | 3895 __ movp(string, separator_operand); |
3896 __ SmiCompare(FieldOperand(string, SeqOneByteString::kLengthOffset), | 3896 __ SmiCompare(FieldOperand(string, SeqOneByteString::kLengthOffset), |
3897 Smi::FromInt(1)); | 3897 Smi::FromInt(1)); |
3898 __ j(equal, &one_char_separator); | 3898 __ j(equal, &one_char_separator); |
3899 __ j(greater, &long_separator); | 3899 __ j(greater, &long_separator); |
3900 | 3900 |
3901 | 3901 |
(...skipping 26 matching lines...) Expand all Loading... |
3928 __ jmp(&done); | 3928 __ jmp(&done); |
3929 | 3929 |
3930 // Generic bailout code used from several places. | 3930 // Generic bailout code used from several places. |
3931 __ bind(&bailout); | 3931 __ bind(&bailout); |
3932 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 3932 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
3933 __ jmp(&return_result); | 3933 __ jmp(&return_result); |
3934 | 3934 |
3935 | 3935 |
3936 // One-character separator case | 3936 // One-character separator case |
3937 __ bind(&one_char_separator); | 3937 __ bind(&one_char_separator); |
3938 // Get the separator ASCII character value. | 3938 // Get the separator one-byte character value. |
3939 // Register "string" holds the separator. | 3939 // Register "string" holds the separator. |
3940 __ movzxbl(scratch, FieldOperand(string, SeqOneByteString::kHeaderSize)); | 3940 __ movzxbl(scratch, FieldOperand(string, SeqOneByteString::kHeaderSize)); |
3941 __ Set(index, 0); | 3941 __ Set(index, 0); |
3942 // Jump into the loop after the code that copies the separator, so the first | 3942 // Jump into the loop after the code that copies the separator, so the first |
3943 // element is not preceded by a separator | 3943 // element is not preceded by a separator |
3944 __ jmp(&loop_2_entry); | 3944 __ jmp(&loop_2_entry); |
3945 // Loop condition: while (index < length). | 3945 // Loop condition: while (index < length). |
3946 __ bind(&loop_2); | 3946 __ bind(&loop_2); |
3947 // Each iteration of the loop concatenates one string to the result. | 3947 // Each iteration of the loop concatenates one string to the result. |
3948 // Live values in registers: | 3948 // Live values in registers: |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4836 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4836 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4837 Assembler::target_address_at(call_target_address, | 4837 Assembler::target_address_at(call_target_address, |
4838 unoptimized_code)); | 4838 unoptimized_code)); |
4839 return OSR_AFTER_STACK_CHECK; | 4839 return OSR_AFTER_STACK_CHECK; |
4840 } | 4840 } |
4841 | 4841 |
4842 | 4842 |
4843 } } // namespace v8::internal | 4843 } } // namespace v8::internal |
4844 | 4844 |
4845 #endif // V8_TARGET_ARCH_X64 | 4845 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |