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/mips/codegen-mips.h" | 5 #include "src/mips/codegen-mips.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 726 |
727 __ push(ra); | 727 __ push(ra); |
728 __ lw(length, FieldMemOperand(elements, FixedArray::kLengthOffset)); | 728 __ lw(length, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
729 // elements: source FixedArray | 729 // elements: source FixedArray |
730 // length: number of elements (smi-tagged) | 730 // length: number of elements (smi-tagged) |
731 | 731 |
732 // Allocate new FixedDoubleArray. | 732 // Allocate new FixedDoubleArray. |
733 __ sll(scratch, length, 2); | 733 __ sll(scratch, length, 2); |
734 __ Addu(scratch, scratch, FixedDoubleArray::kHeaderSize); | 734 __ Addu(scratch, scratch, FixedDoubleArray::kHeaderSize); |
735 __ Allocate(scratch, array, t3, scratch2, &gc_required, DOUBLE_ALIGNMENT); | 735 __ Allocate(scratch, array, t3, scratch2, &gc_required, DOUBLE_ALIGNMENT); |
736 // array: destination FixedDoubleArray, not tagged as heap object | 736 // array: destination FixedDoubleArray, tagged as heap object |
737 | 737 |
738 // Set destination FixedDoubleArray's length and map. | 738 // Set destination FixedDoubleArray's length and map. |
739 __ LoadRoot(scratch2, Heap::kFixedDoubleArrayMapRootIndex); | 739 __ LoadRoot(scratch2, Heap::kFixedDoubleArrayMapRootIndex); |
740 __ sw(length, MemOperand(array, FixedDoubleArray::kLengthOffset)); | 740 __ sw(length, FieldMemOperand(array, FixedDoubleArray::kLengthOffset)); |
741 // Update receiver's map. | 741 // Update receiver's map. |
742 __ sw(scratch2, MemOperand(array, HeapObject::kMapOffset)); | 742 __ sw(scratch2, FieldMemOperand(array, HeapObject::kMapOffset)); |
743 | 743 |
744 __ sw(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 744 __ sw(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
745 __ RecordWriteField(receiver, | 745 __ RecordWriteField(receiver, |
746 HeapObject::kMapOffset, | 746 HeapObject::kMapOffset, |
747 target_map, | 747 target_map, |
748 scratch2, | 748 scratch2, |
749 kRAHasBeenSaved, | 749 kRAHasBeenSaved, |
750 kDontSaveFPRegs, | 750 kDontSaveFPRegs, |
751 OMIT_REMEMBERED_SET, | 751 OMIT_REMEMBERED_SET, |
752 OMIT_SMI_CHECK); | 752 OMIT_SMI_CHECK); |
753 // Replace receiver's backing store with newly created FixedDoubleArray. | 753 // Replace receiver's backing store with newly created FixedDoubleArray. |
754 __ Addu(scratch1, array, Operand(kHeapObjectTag)); | 754 __ Addu(scratch1, array, Operand(kHeapObjectTag - kHeapObjectTag)); |
755 __ sw(scratch1, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 755 __ sw(scratch1, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
756 __ RecordWriteField(receiver, | 756 __ RecordWriteField(receiver, |
757 JSObject::kElementsOffset, | 757 JSObject::kElementsOffset, |
758 scratch1, | 758 scratch1, |
759 scratch2, | 759 scratch2, |
760 kRAHasBeenSaved, | 760 kRAHasBeenSaved, |
761 kDontSaveFPRegs, | 761 kDontSaveFPRegs, |
762 EMIT_REMEMBERED_SET, | 762 EMIT_REMEMBERED_SET, |
763 OMIT_SMI_CHECK); | 763 OMIT_SMI_CHECK); |
764 | 764 |
765 | 765 |
766 // Prepare for conversion loop. | 766 // Prepare for conversion loop. |
767 __ Addu(scratch1, elements, | 767 __ Addu(scratch1, elements, |
768 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 768 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
769 __ Addu(scratch3, array, Operand(FixedDoubleArray::kHeaderSize)); | 769 __ Addu(scratch3, array, |
| 770 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); |
770 __ Lsa(array_end, scratch3, length, 2); | 771 __ Lsa(array_end, scratch3, length, 2); |
771 | 772 |
772 // Repurpose registers no longer in use. | 773 // Repurpose registers no longer in use. |
773 Register hole_lower = elements; | 774 Register hole_lower = elements; |
774 Register hole_upper = length; | 775 Register hole_upper = length; |
775 __ li(hole_lower, Operand(kHoleNanLower32)); | 776 __ li(hole_lower, Operand(kHoleNanLower32)); |
776 __ li(hole_upper, Operand(kHoleNanUpper32)); | 777 __ li(hole_upper, Operand(kHoleNanUpper32)); |
777 | 778 |
778 // scratch1: begin of source FixedArray element fields, not tagged | 779 // scratch1: begin of source FixedArray element fields, not tagged |
779 // hole_lower: kHoleNanLower32 | 780 // hole_lower: kHoleNanLower32 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 // stack. | 880 // stack. |
880 Register array_size = value; | 881 Register array_size = value; |
881 Register allocate_scratch = target_map; | 882 Register allocate_scratch = target_map; |
882 __ sll(array_size, length, 1); | 883 __ sll(array_size, length, 1); |
883 __ Addu(array_size, array_size, FixedDoubleArray::kHeaderSize); | 884 __ Addu(array_size, array_size, FixedDoubleArray::kHeaderSize); |
884 __ Allocate(array_size, array, allocate_scratch, scratch, &gc_required, | 885 __ Allocate(array_size, array, allocate_scratch, scratch, &gc_required, |
885 NO_ALLOCATION_FLAGS); | 886 NO_ALLOCATION_FLAGS); |
886 // array: destination FixedArray, not tagged as heap object | 887 // array: destination FixedArray, not tagged as heap object |
887 // Set destination FixedDoubleArray's length and map. | 888 // Set destination FixedDoubleArray's length and map. |
888 __ LoadRoot(scratch, Heap::kFixedArrayMapRootIndex); | 889 __ LoadRoot(scratch, Heap::kFixedArrayMapRootIndex); |
889 __ sw(length, MemOperand(array, FixedDoubleArray::kLengthOffset)); | 890 __ sw(length, FieldMemOperand(array, FixedDoubleArray::kLengthOffset)); |
890 __ sw(scratch, MemOperand(array, HeapObject::kMapOffset)); | 891 __ sw(scratch, FieldMemOperand(array, HeapObject::kMapOffset)); |
891 | 892 |
892 // Prepare for conversion loop. | 893 // Prepare for conversion loop. |
893 Register src_elements = elements; | 894 Register src_elements = elements; |
894 Register dst_elements = target_map; | 895 Register dst_elements = target_map; |
895 Register dst_end = length; | 896 Register dst_end = length; |
896 Register heap_number_map = scratch; | 897 Register heap_number_map = scratch; |
897 __ Addu(src_elements, src_elements, Operand( | 898 __ Addu(src_elements, src_elements, Operand( |
898 FixedDoubleArray::kHeaderSize - kHeapObjectTag | 899 FixedDoubleArray::kHeaderSize - kHeapObjectTag |
899 + Register::kExponentOffset)); | 900 + Register::kExponentOffset)); |
900 __ Addu(dst_elements, array, Operand(FixedArray::kHeaderSize)); | 901 __ Addu(dst_elements, array, |
| 902 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
901 __ Lsa(dst_end, dst_elements, dst_end, 1); | 903 __ Lsa(dst_end, dst_elements, dst_end, 1); |
902 | 904 |
903 // Allocating heap numbers in the loop below can fail and cause a jump to | 905 // Allocating heap numbers in the loop below can fail and cause a jump to |
904 // gc_required. We can't leave a partly initialized FixedArray behind, | 906 // gc_required. We can't leave a partly initialized FixedArray behind, |
905 // so pessimistically fill it with holes now. | 907 // so pessimistically fill it with holes now. |
906 Label initialization_loop, initialization_loop_entry; | 908 Label initialization_loop, initialization_loop_entry; |
907 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); | 909 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); |
908 __ Branch(&initialization_loop_entry); | 910 __ Branch(&initialization_loop_entry); |
909 __ bind(&initialization_loop); | 911 __ bind(&initialization_loop); |
910 __ sw(scratch, MemOperand(dst_elements)); | 912 __ sw(scratch, MemOperand(dst_elements)); |
911 __ Addu(dst_elements, dst_elements, Operand(kPointerSize)); | 913 __ Addu(dst_elements, dst_elements, Operand(kPointerSize)); |
912 __ bind(&initialization_loop_entry); | 914 __ bind(&initialization_loop_entry); |
913 __ Branch(&initialization_loop, lt, dst_elements, Operand(dst_end)); | 915 __ Branch(&initialization_loop, lt, dst_elements, Operand(dst_end)); |
914 | 916 |
915 __ Addu(dst_elements, array, Operand(FixedArray::kHeaderSize)); | 917 __ Addu(dst_elements, array, |
916 __ Addu(array, array, Operand(kHeapObjectTag)); | 918 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
917 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); | 919 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); |
918 // Using offsetted addresses. | 920 // Using offsetted addresses. |
919 // dst_elements: begin of destination FixedArray element fields, not tagged | 921 // dst_elements: begin of destination FixedArray element fields, not tagged |
920 // src_elements: begin of source FixedDoubleArray element fields, not tagged, | 922 // src_elements: begin of source FixedDoubleArray element fields, not tagged, |
921 // points to the exponent | 923 // points to the exponent |
922 // dst_end: end of destination FixedArray, not tagged | 924 // dst_end: end of destination FixedArray, not tagged |
923 // array: destination FixedArray | 925 // array: destination FixedArray |
924 // heap_number_map: heap number map | 926 // heap_number_map: heap number map |
925 __ Branch(&entry); | 927 __ Branch(&entry); |
926 | 928 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 } | 1259 } |
1258 } | 1260 } |
1259 | 1261 |
1260 | 1262 |
1261 #undef __ | 1263 #undef __ |
1262 | 1264 |
1263 } // namespace internal | 1265 } // namespace internal |
1264 } // namespace v8 | 1266 } // namespace v8 |
1265 | 1267 |
1266 #endif // V8_TARGET_ARCH_MIPS | 1268 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |