| 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 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3652 __ Assert(gt, "No empty arrays here in EmitFastAsciiArrayJoin", | 3652 __ Assert(gt, "No empty arrays here in EmitFastAsciiArrayJoin", |
| 3653 array_length, Operand(zero_reg)); | 3653 array_length, Operand(zero_reg)); |
| 3654 } | 3654 } |
| 3655 __ bind(&loop); | 3655 __ bind(&loop); |
| 3656 __ lw(string, MemOperand(element)); | 3656 __ lw(string, MemOperand(element)); |
| 3657 __ Addu(element, element, kPointerSize); | 3657 __ Addu(element, element, kPointerSize); |
| 3658 __ JumpIfSmi(string, &bailout); | 3658 __ JumpIfSmi(string, &bailout); |
| 3659 __ lw(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); | 3659 __ lw(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3660 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | 3660 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
| 3661 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); | 3661 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); |
| 3662 __ lw(scratch1, FieldMemOperand(string, SeqAsciiString::kLengthOffset)); | 3662 __ lw(scratch1, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); |
| 3663 __ AdduAndCheckForOverflow(string_length, string_length, scratch1, scratch3); | 3663 __ AdduAndCheckForOverflow(string_length, string_length, scratch1, scratch3); |
| 3664 __ BranchOnOverflow(&bailout, scratch3); | 3664 __ BranchOnOverflow(&bailout, scratch3); |
| 3665 __ Branch(&loop, lt, element, Operand(elements_end)); | 3665 __ Branch(&loop, lt, element, Operand(elements_end)); |
| 3666 | 3666 |
| 3667 // If array_length is 1, return elements[0], a string. | 3667 // If array_length is 1, return elements[0], a string. |
| 3668 __ Branch(¬_size_one_array, ne, array_length, Operand(1)); | 3668 __ Branch(¬_size_one_array, ne, array_length, Operand(1)); |
| 3669 __ lw(v0, FieldMemOperand(elements, FixedArray::kHeaderSize)); | 3669 __ lw(v0, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
| 3670 __ Branch(&done); | 3670 __ Branch(&done); |
| 3671 | 3671 |
| 3672 __ bind(¬_size_one_array); | 3672 __ bind(¬_size_one_array); |
| 3673 | 3673 |
| 3674 // Live values in registers: | 3674 // Live values in registers: |
| 3675 // separator: Separator string | 3675 // separator: Separator string |
| 3676 // array_length: Length of the array. | 3676 // array_length: Length of the array. |
| 3677 // string_length: Sum of string lengths (smi). | 3677 // string_length: Sum of string lengths (smi). |
| 3678 // elements: FixedArray of strings. | 3678 // elements: FixedArray of strings. |
| 3679 | 3679 |
| 3680 // Check that the separator is a flat ASCII string. | 3680 // Check that the separator is a flat ASCII string. |
| 3681 __ JumpIfSmi(separator, &bailout); | 3681 __ JumpIfSmi(separator, &bailout); |
| 3682 __ lw(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); | 3682 __ lw(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); |
| 3683 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | 3683 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
| 3684 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); | 3684 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); |
| 3685 | 3685 |
| 3686 // Add (separator length times array_length) - separator length to the | 3686 // Add (separator length times array_length) - separator length to the |
| 3687 // string_length to get the length of the result string. array_length is not | 3687 // string_length to get the length of the result string. array_length is not |
| 3688 // smi but the other values are, so the result is a smi. | 3688 // smi but the other values are, so the result is a smi. |
| 3689 __ lw(scratch1, FieldMemOperand(separator, SeqAsciiString::kLengthOffset)); | 3689 __ lw(scratch1, FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); |
| 3690 __ Subu(string_length, string_length, Operand(scratch1)); | 3690 __ Subu(string_length, string_length, Operand(scratch1)); |
| 3691 __ Mult(array_length, scratch1); | 3691 __ Mult(array_length, scratch1); |
| 3692 // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are | 3692 // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are |
| 3693 // zero. | 3693 // zero. |
| 3694 __ mfhi(scratch2); | 3694 __ mfhi(scratch2); |
| 3695 __ Branch(&bailout, ne, scratch2, Operand(zero_reg)); | 3695 __ Branch(&bailout, ne, scratch2, Operand(zero_reg)); |
| 3696 __ mflo(scratch2); | 3696 __ mflo(scratch2); |
| 3697 __ And(scratch3, scratch2, Operand(0x80000000)); | 3697 __ And(scratch3, scratch2, Operand(0x80000000)); |
| 3698 __ Branch(&bailout, ne, scratch3, Operand(zero_reg)); | 3698 __ Branch(&bailout, ne, scratch3, Operand(zero_reg)); |
| 3699 __ AdduAndCheckForOverflow(string_length, string_length, scratch2, scratch3); | 3699 __ AdduAndCheckForOverflow(string_length, string_length, scratch2, scratch3); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3719 &bailout); | 3719 &bailout); |
| 3720 // Prepare for looping. Set up elements_end to end of the array. Set | 3720 // Prepare for looping. Set up elements_end to end of the array. Set |
| 3721 // result_pos to the position of the result where to write the first | 3721 // result_pos to the position of the result where to write the first |
| 3722 // character. | 3722 // character. |
| 3723 __ sll(elements_end, array_length, kPointerSizeLog2); | 3723 __ sll(elements_end, array_length, kPointerSizeLog2); |
| 3724 __ Addu(elements_end, element, elements_end); | 3724 __ Addu(elements_end, element, elements_end); |
| 3725 result_pos = array_length; // End of live range for array_length. | 3725 result_pos = array_length; // End of live range for array_length. |
| 3726 array_length = no_reg; | 3726 array_length = no_reg; |
| 3727 __ Addu(result_pos, | 3727 __ Addu(result_pos, |
| 3728 result, | 3728 result, |
| 3729 Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); | 3729 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3730 | 3730 |
| 3731 // Check the length of the separator. | 3731 // Check the length of the separator. |
| 3732 __ lw(scratch1, FieldMemOperand(separator, SeqAsciiString::kLengthOffset)); | 3732 __ lw(scratch1, FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); |
| 3733 __ li(at, Operand(Smi::FromInt(1))); | 3733 __ li(at, Operand(Smi::FromInt(1))); |
| 3734 __ Branch(&one_char_separator, eq, scratch1, Operand(at)); | 3734 __ Branch(&one_char_separator, eq, scratch1, Operand(at)); |
| 3735 __ Branch(&long_separator, gt, scratch1, Operand(at)); | 3735 __ Branch(&long_separator, gt, scratch1, Operand(at)); |
| 3736 | 3736 |
| 3737 // Empty separator case. | 3737 // Empty separator case. |
| 3738 __ bind(&empty_separator_loop); | 3738 __ bind(&empty_separator_loop); |
| 3739 // Live values in registers: | 3739 // Live values in registers: |
| 3740 // result_pos: the position to which we are currently copying characters. | 3740 // result_pos: the position to which we are currently copying characters. |
| 3741 // element: Current array element. | 3741 // element: Current array element. |
| 3742 // elements_end: Array end. | 3742 // elements_end: Array end. |
| 3743 | 3743 |
| 3744 // Copy next array element to the result. | 3744 // Copy next array element to the result. |
| 3745 __ lw(string, MemOperand(element)); | 3745 __ lw(string, MemOperand(element)); |
| 3746 __ Addu(element, element, kPointerSize); | 3746 __ Addu(element, element, kPointerSize); |
| 3747 __ lw(string_length, FieldMemOperand(string, String::kLengthOffset)); | 3747 __ lw(string_length, FieldMemOperand(string, String::kLengthOffset)); |
| 3748 __ SmiUntag(string_length); | 3748 __ SmiUntag(string_length); |
| 3749 __ Addu(string, string, SeqAsciiString::kHeaderSize - kHeapObjectTag); | 3749 __ Addu(string, string, SeqOneByteString::kHeaderSize - kHeapObjectTag); |
| 3750 __ CopyBytes(string, result_pos, string_length, scratch1); | 3750 __ CopyBytes(string, result_pos, string_length, scratch1); |
| 3751 // End while (element < elements_end). | 3751 // End while (element < elements_end). |
| 3752 __ Branch(&empty_separator_loop, lt, element, Operand(elements_end)); | 3752 __ Branch(&empty_separator_loop, lt, element, Operand(elements_end)); |
| 3753 ASSERT(result.is(v0)); | 3753 ASSERT(result.is(v0)); |
| 3754 __ Branch(&done); | 3754 __ Branch(&done); |
| 3755 | 3755 |
| 3756 // One-character separator case. | 3756 // One-character separator case. |
| 3757 __ bind(&one_char_separator); | 3757 __ bind(&one_char_separator); |
| 3758 // Replace separator with its ASCII character value. | 3758 // Replace separator with its ASCII character value. |
| 3759 __ lbu(separator, FieldMemOperand(separator, SeqAsciiString::kHeaderSize)); | 3759 __ lbu(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize)); |
| 3760 // Jump into the loop after the code that copies the separator, so the first | 3760 // Jump into the loop after the code that copies the separator, so the first |
| 3761 // element is not preceded by a separator. | 3761 // element is not preceded by a separator. |
| 3762 __ jmp(&one_char_separator_loop_entry); | 3762 __ jmp(&one_char_separator_loop_entry); |
| 3763 | 3763 |
| 3764 __ bind(&one_char_separator_loop); | 3764 __ bind(&one_char_separator_loop); |
| 3765 // Live values in registers: | 3765 // Live values in registers: |
| 3766 // result_pos: the position to which we are currently copying characters. | 3766 // result_pos: the position to which we are currently copying characters. |
| 3767 // element: Current array element. | 3767 // element: Current array element. |
| 3768 // elements_end: Array end. | 3768 // elements_end: Array end. |
| 3769 // separator: Single separator ASCII char (in lower byte). | 3769 // separator: Single separator ASCII char (in lower byte). |
| 3770 | 3770 |
| 3771 // Copy the separator character to the result. | 3771 // Copy the separator character to the result. |
| 3772 __ sb(separator, MemOperand(result_pos)); | 3772 __ sb(separator, MemOperand(result_pos)); |
| 3773 __ Addu(result_pos, result_pos, 1); | 3773 __ Addu(result_pos, result_pos, 1); |
| 3774 | 3774 |
| 3775 // Copy next array element to the result. | 3775 // Copy next array element to the result. |
| 3776 __ bind(&one_char_separator_loop_entry); | 3776 __ bind(&one_char_separator_loop_entry); |
| 3777 __ lw(string, MemOperand(element)); | 3777 __ lw(string, MemOperand(element)); |
| 3778 __ Addu(element, element, kPointerSize); | 3778 __ Addu(element, element, kPointerSize); |
| 3779 __ lw(string_length, FieldMemOperand(string, String::kLengthOffset)); | 3779 __ lw(string_length, FieldMemOperand(string, String::kLengthOffset)); |
| 3780 __ SmiUntag(string_length); | 3780 __ SmiUntag(string_length); |
| 3781 __ Addu(string, string, SeqAsciiString::kHeaderSize - kHeapObjectTag); | 3781 __ Addu(string, string, SeqOneByteString::kHeaderSize - kHeapObjectTag); |
| 3782 __ CopyBytes(string, result_pos, string_length, scratch1); | 3782 __ CopyBytes(string, result_pos, string_length, scratch1); |
| 3783 // End while (element < elements_end). | 3783 // End while (element < elements_end). |
| 3784 __ Branch(&one_char_separator_loop, lt, element, Operand(elements_end)); | 3784 __ Branch(&one_char_separator_loop, lt, element, Operand(elements_end)); |
| 3785 ASSERT(result.is(v0)); | 3785 ASSERT(result.is(v0)); |
| 3786 __ Branch(&done); | 3786 __ Branch(&done); |
| 3787 | 3787 |
| 3788 // Long separator case (separator is more than one character). Entry is at the | 3788 // Long separator case (separator is more than one character). Entry is at the |
| 3789 // label long_separator below. | 3789 // label long_separator below. |
| 3790 __ bind(&long_separator_loop); | 3790 __ bind(&long_separator_loop); |
| 3791 // Live values in registers: | 3791 // Live values in registers: |
| 3792 // result_pos: the position to which we are currently copying characters. | 3792 // result_pos: the position to which we are currently copying characters. |
| 3793 // element: Current array element. | 3793 // element: Current array element. |
| 3794 // elements_end: Array end. | 3794 // elements_end: Array end. |
| 3795 // separator: Separator string. | 3795 // separator: Separator string. |
| 3796 | 3796 |
| 3797 // Copy the separator to the result. | 3797 // Copy the separator to the result. |
| 3798 __ lw(string_length, FieldMemOperand(separator, String::kLengthOffset)); | 3798 __ lw(string_length, FieldMemOperand(separator, String::kLengthOffset)); |
| 3799 __ SmiUntag(string_length); | 3799 __ SmiUntag(string_length); |
| 3800 __ Addu(string, | 3800 __ Addu(string, |
| 3801 separator, | 3801 separator, |
| 3802 Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); | 3802 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3803 __ CopyBytes(string, result_pos, string_length, scratch1); | 3803 __ CopyBytes(string, result_pos, string_length, scratch1); |
| 3804 | 3804 |
| 3805 __ bind(&long_separator); | 3805 __ bind(&long_separator); |
| 3806 __ lw(string, MemOperand(element)); | 3806 __ lw(string, MemOperand(element)); |
| 3807 __ Addu(element, element, kPointerSize); | 3807 __ Addu(element, element, kPointerSize); |
| 3808 __ lw(string_length, FieldMemOperand(string, String::kLengthOffset)); | 3808 __ lw(string_length, FieldMemOperand(string, String::kLengthOffset)); |
| 3809 __ SmiUntag(string_length); | 3809 __ SmiUntag(string_length); |
| 3810 __ Addu(string, string, SeqAsciiString::kHeaderSize - kHeapObjectTag); | 3810 __ Addu(string, string, SeqOneByteString::kHeaderSize - kHeapObjectTag); |
| 3811 __ CopyBytes(string, result_pos, string_length, scratch1); | 3811 __ CopyBytes(string, result_pos, string_length, scratch1); |
| 3812 // End while (element < elements_end). | 3812 // End while (element < elements_end). |
| 3813 __ Branch(&long_separator_loop, lt, element, Operand(elements_end)); | 3813 __ Branch(&long_separator_loop, lt, element, Operand(elements_end)); |
| 3814 ASSERT(result.is(v0)); | 3814 ASSERT(result.is(v0)); |
| 3815 __ Branch(&done); | 3815 __ Branch(&done); |
| 3816 | 3816 |
| 3817 __ bind(&bailout); | 3817 __ bind(&bailout); |
| 3818 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); | 3818 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
| 3819 __ bind(&done); | 3819 __ bind(&done); |
| 3820 context()->Plug(v0); | 3820 context()->Plug(v0); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4571 *context_length = 0; | 4571 *context_length = 0; |
| 4572 return previous_; | 4572 return previous_; |
| 4573 } | 4573 } |
| 4574 | 4574 |
| 4575 | 4575 |
| 4576 #undef __ | 4576 #undef __ |
| 4577 | 4577 |
| 4578 } } // namespace v8::internal | 4578 } } // namespace v8::internal |
| 4579 | 4579 |
| 4580 #endif // V8_TARGET_ARCH_MIPS | 4580 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |