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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 // Clear the first non null bit. | 800 // Clear the first non null bit. |
801 __ li(scratch2, Operand(1)); | 801 __ li(scratch2, Operand(1)); |
802 __ sllv(scratch2, scratch2, dst_mantissa); | 802 __ sllv(scratch2, scratch2, dst_mantissa); |
803 __ li(at, -1); | 803 __ li(at, -1); |
804 __ Xor(scratch2, scratch2, at); | 804 __ Xor(scratch2, scratch2, at); |
805 __ And(int_scratch, int_scratch, scratch2); | 805 __ And(int_scratch, int_scratch, scratch2); |
806 | 806 |
807 // Get the number of bits to set in the lower part of the mantissa. | 807 // Get the number of bits to set in the lower part of the mantissa. |
808 __ Subu(scratch2, dst_mantissa, | 808 __ Subu(scratch2, dst_mantissa, |
809 Operand(HeapNumber::kMantissaBitsInTopWord)); | 809 Operand(HeapNumber::kMantissaBitsInTopWord)); |
810 __ Branch(&fewer_than_20_useful_bits, lt, scratch2, Operand(zero_reg)); | 810 __ Branch(&fewer_than_20_useful_bits, le, scratch2, Operand(zero_reg)); |
811 // Set the higher 20 bits of the mantissa. | 811 // Set the higher 20 bits of the mantissa. |
812 __ srlv(at, int_scratch, scratch2); | 812 __ srlv(at, int_scratch, scratch2); |
813 __ or_(dst_exponent, dst_exponent, at); | 813 __ or_(dst_exponent, dst_exponent, at); |
814 __ li(at, 32); | 814 __ li(at, 32); |
815 __ subu(scratch2, at, scratch2); | 815 __ subu(scratch2, at, scratch2); |
816 __ sllv(dst_mantissa, int_scratch, scratch2); | 816 __ sllv(dst_mantissa, int_scratch, scratch2); |
817 __ Branch(&done); | 817 __ Branch(&done); |
818 | 818 |
819 __ bind(&fewer_than_20_useful_bits); | 819 __ bind(&fewer_than_20_useful_bits); |
820 __ li(at, HeapNumber::kMantissaBitsInTopWord); | 820 __ li(at, HeapNumber::kMantissaBitsInTopWord); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 884 |
885 } else { | 885 } else { |
886 ASSERT(!scratch1.is(object) && !scratch2.is(object)); | 886 ASSERT(!scratch1.is(object) && !scratch2.is(object)); |
887 // Load the double value in the destination registers. | 887 // Load the double value in the destination registers. |
888 bool save_registers = object.is(dst_mantissa) || object.is(dst_exponent); | 888 bool save_registers = object.is(dst_mantissa) || object.is(dst_exponent); |
889 if (save_registers) { | 889 if (save_registers) { |
890 // Save both output registers, because the other one probably holds | 890 // Save both output registers, because the other one probably holds |
891 // an important value too. | 891 // an important value too. |
892 __ Push(dst_exponent, dst_mantissa); | 892 __ Push(dst_exponent, dst_mantissa); |
893 } | 893 } |
894 __ lw(dst_exponent, FieldMemOperand(object, HeapNumber::kExponentOffset)); | 894 if (object.is(dst_mantissa)) { |
895 __ lw(dst_mantissa, FieldMemOperand(object, HeapNumber::kMantissaOffset)); | 895 __ lw(dst_exponent, FieldMemOperand(object, HeapNumber::kExponentOffset)); |
| 896 __ lw(dst_mantissa, FieldMemOperand(object, HeapNumber::kMantissaOffset)); |
| 897 } else { |
| 898 __ lw(dst_mantissa, FieldMemOperand(object, HeapNumber::kMantissaOffset)); |
| 899 __ lw(dst_exponent, FieldMemOperand(object, HeapNumber::kExponentOffset)); |
| 900 } |
896 | 901 |
897 // Check for 0 and -0. | 902 // Check for 0 and -0. |
898 Label zero; | 903 Label zero; |
899 __ And(scratch1, dst_exponent, Operand(~HeapNumber::kSignMask)); | 904 __ And(scratch1, dst_exponent, Operand(~HeapNumber::kSignMask)); |
900 __ Or(scratch1, scratch1, Operand(dst_mantissa)); | 905 __ Or(scratch1, scratch1, Operand(dst_mantissa)); |
901 __ Branch(&zero, eq, scratch1, Operand(zero_reg)); | 906 __ Branch(&zero, eq, scratch1, Operand(zero_reg)); |
902 | 907 |
903 // Check that the value can be exactly represented by a 32-bit integer. | 908 // Check that the value can be exactly represented by a 32-bit integer. |
904 // Jump to not_int32 if that's not the case. | 909 // Jump to not_int32 if that's not the case. |
905 Label restore_input_and_miss; | 910 Label restore_input_and_miss; |
906 DoubleIs32BitInteger(masm, dst_exponent, dst_mantissa, scratch1, scratch2, | 911 DoubleIs32BitInteger(masm, dst_exponent, dst_mantissa, scratch1, scratch2, |
907 &restore_input_and_miss); | 912 &restore_input_and_miss); |
908 | 913 |
909 // dst_* were trashed. Reload the double value. | 914 // dst_* were trashed. Reload the double value. |
910 if (save_registers) { | 915 if (save_registers) { |
911 __ Pop(dst_exponent, dst_mantissa); | 916 __ Pop(dst_exponent, dst_mantissa); |
912 } | 917 } |
913 __ lw(dst_exponent, FieldMemOperand(object, HeapNumber::kExponentOffset)); | 918 if (object.is(dst_mantissa)) { |
914 __ lw(dst_mantissa, FieldMemOperand(object, HeapNumber::kMantissaOffset)); | 919 __ lw(dst_exponent, FieldMemOperand(object, HeapNumber::kExponentOffset)); |
| 920 __ lw(dst_mantissa, FieldMemOperand(object, HeapNumber::kMantissaOffset)); |
| 921 } else { |
| 922 __ lw(dst_mantissa, FieldMemOperand(object, HeapNumber::kMantissaOffset)); |
| 923 __ lw(dst_exponent, FieldMemOperand(object, HeapNumber::kExponentOffset)); |
| 924 } |
| 925 |
915 __ Branch(&done); | 926 __ Branch(&done); |
916 | 927 |
917 __ bind(&restore_input_and_miss); | 928 __ bind(&restore_input_and_miss); |
918 if (save_registers) { | 929 if (save_registers) { |
919 __ Pop(dst_exponent, dst_mantissa); | 930 __ Pop(dst_exponent, dst_mantissa); |
920 } | 931 } |
921 __ Branch(not_int32); | 932 __ Branch(not_int32); |
922 | 933 |
923 __ bind(&zero); | 934 __ bind(&zero); |
924 if (save_registers) { | 935 if (save_registers) { |
(...skipping 7097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8022 __ Pop(ra, t1, a1); | 8033 __ Pop(ra, t1, a1); |
8023 __ Ret(); | 8034 __ Ret(); |
8024 } | 8035 } |
8025 | 8036 |
8026 | 8037 |
8027 #undef __ | 8038 #undef __ |
8028 | 8039 |
8029 } } // namespace v8::internal | 8040 } } // namespace v8::internal |
8030 | 8041 |
8031 #endif // V8_TARGET_ARCH_MIPS | 8042 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |