| 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 885 |
| 886 Label not_special, done; | 886 Label not_special, done; |
| 887 // Move sign bit from source to destination. This works because the sign | 887 // Move sign bit from source to destination. This works because the sign |
| 888 // bit in the exponent word of the double has the same position and polarity | 888 // bit in the exponent word of the double has the same position and polarity |
| 889 // as the 2's complement sign bit in a Smi. | 889 // as the 2's complement sign bit in a Smi. |
| 890 ASSERT(kBinary32SignMask == 0x80000000u); | 890 ASSERT(kBinary32SignMask == 0x80000000u); |
| 891 | 891 |
| 892 __ And(fval, ival, Operand(kBinary32SignMask)); | 892 __ And(fval, ival, Operand(kBinary32SignMask)); |
| 893 // Negate value if it is negative. | 893 // Negate value if it is negative. |
| 894 __ subu(scratch1, zero_reg, ival); | 894 __ subu(scratch1, zero_reg, ival); |
| 895 __ movn(ival, scratch1, fval); | 895 __ Movn(ival, scratch1, fval); |
| 896 | 896 |
| 897 // We have -1, 0 or 1, which we treat specially. Register ival contains | 897 // We have -1, 0 or 1, which we treat specially. Register ival contains |
| 898 // absolute value: it is either equal to 1 (special case of -1 and 1), | 898 // absolute value: it is either equal to 1 (special case of -1 and 1), |
| 899 // greater than 1 (not a special case) or less than 1 (special case of 0). | 899 // greater than 1 (not a special case) or less than 1 (special case of 0). |
| 900 __ Branch(¬_special, gt, ival, Operand(1)); | 900 __ Branch(¬_special, gt, ival, Operand(1)); |
| 901 | 901 |
| 902 // For 1 or -1 we need to or in the 0 exponent (biased). | 902 // For 1 or -1 we need to or in the 0 exponent (biased). |
| 903 static const uint32_t exponent_word_for_1 = | 903 static const uint32_t exponent_word_for_1 = |
| 904 kBinary32ExponentBias << kBinary32ExponentShift; | 904 kBinary32ExponentBias << kBinary32ExponentShift; |
| 905 | 905 |
| 906 __ Xor(scratch1, ival, Operand(1)); | 906 __ Xor(scratch1, ival, Operand(1)); |
| 907 __ li(scratch2, exponent_word_for_1); | 907 __ li(scratch2, exponent_word_for_1); |
| 908 __ or_(scratch2, fval, scratch2); | 908 __ or_(scratch2, fval, scratch2); |
| 909 __ movz(fval, scratch2, scratch1); // Only if ival is equal to 1. | 909 __ Movz(fval, scratch2, scratch1); // Only if ival is equal to 1. |
| 910 __ Branch(&done); | 910 __ Branch(&done); |
| 911 | 911 |
| 912 __ bind(¬_special); | 912 __ bind(¬_special); |
| 913 // Count leading zeros. | 913 // Count leading zeros. |
| 914 // Gets the wrong answer for 0, but we already checked for that case above. | 914 // Gets the wrong answer for 0, but we already checked for that case above. |
| 915 Register zeros = scratch2; | 915 Register zeros = scratch2; |
| 916 __ clz(zeros, ival); | 916 __ Clz(zeros, ival); |
| 917 | 917 |
| 918 // Compute exponent and or it into the exponent register. | 918 // Compute exponent and or it into the exponent register. |
| 919 __ li(scratch1, (kBitsPerInt - 1) + kBinary32ExponentBias); | 919 __ li(scratch1, (kBitsPerInt - 1) + kBinary32ExponentBias); |
| 920 __ subu(scratch1, scratch1, zeros); | 920 __ subu(scratch1, scratch1, zeros); |
| 921 | 921 |
| 922 __ sll(scratch1, scratch1, kBinary32ExponentShift); | 922 __ sll(scratch1, scratch1, kBinary32ExponentShift); |
| 923 __ or_(fval, fval, scratch1); | 923 __ or_(fval, fval, scratch1); |
| 924 | 924 |
| 925 // Shift up the source chopping the top bit off. | 925 // Shift up the source chopping the top bit off. |
| 926 __ Addu(zeros, zeros, Operand(1)); | 926 __ Addu(zeros, zeros, Operand(1)); |
| (...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3577 | 3577 |
| 3578 // Extract exponent to t5. | 3578 // Extract exponent to t5. |
| 3579 __ srl(t5, value, kBinary32MantissaBits); | 3579 __ srl(t5, value, kBinary32MantissaBits); |
| 3580 __ And(t5, t5, Operand(kBinary32ExponentMask >> kBinary32MantissaBits)); | 3580 __ And(t5, t5, Operand(kBinary32ExponentMask >> kBinary32MantissaBits)); |
| 3581 | 3581 |
| 3582 Label exponent_rebiased; | 3582 Label exponent_rebiased; |
| 3583 __ Branch(&exponent_rebiased, eq, t5, Operand(zero_reg)); | 3583 __ Branch(&exponent_rebiased, eq, t5, Operand(zero_reg)); |
| 3584 | 3584 |
| 3585 __ li(t0, 0x7ff); | 3585 __ li(t0, 0x7ff); |
| 3586 __ Xor(t1, t5, Operand(0xFF)); | 3586 __ Xor(t1, t5, Operand(0xFF)); |
| 3587 __ movz(t5, t0, t1); // Set t5 to 0x7ff only if t5 is equal to 0xff. | 3587 __ Movz(t5, t0, t1); // Set t5 to 0x7ff only if t5 is equal to 0xff. |
| 3588 __ Branch(&exponent_rebiased, eq, t0, Operand(0xff)); | 3588 __ Branch(&exponent_rebiased, eq, t0, Operand(0xff)); |
| 3589 | 3589 |
| 3590 // Rebias exponent. | 3590 // Rebias exponent. |
| 3591 __ Addu(t5, | 3591 __ Addu(t5, |
| 3592 t5, | 3592 t5, |
| 3593 Operand(-kBinary32ExponentBias + HeapNumber::kExponentBias)); | 3593 Operand(-kBinary32ExponentBias + HeapNumber::kExponentBias)); |
| 3594 | 3594 |
| 3595 __ bind(&exponent_rebiased); | 3595 __ bind(&exponent_rebiased); |
| 3596 __ And(a2, value, Operand(kBinary32SignMask)); | 3596 __ And(a2, value, Operand(kBinary32SignMask)); |
| 3597 value = no_reg; | 3597 value = no_reg; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 kBitsPerInt - kMantissaInHiWordShift; | 3871 kBitsPerInt - kMantissaInHiWordShift; |
| 3872 | 3872 |
| 3873 // Test for all special exponent values: zeros, subnormal numbers, NaNs | 3873 // Test for all special exponent values: zeros, subnormal numbers, NaNs |
| 3874 // and infinities. All these should be converted to 0. | 3874 // and infinities. All these should be converted to 0. |
| 3875 __ li(t5, HeapNumber::kExponentMask); | 3875 __ li(t5, HeapNumber::kExponentMask); |
| 3876 __ and_(t6, t3, t5); | 3876 __ and_(t6, t3, t5); |
| 3877 __ Branch(&nan_or_infinity_or_zero, eq, t6, Operand(zero_reg)); | 3877 __ Branch(&nan_or_infinity_or_zero, eq, t6, Operand(zero_reg)); |
| 3878 | 3878 |
| 3879 __ xor_(t1, t6, t5); | 3879 __ xor_(t1, t6, t5); |
| 3880 __ li(t2, kBinary32ExponentMask); | 3880 __ li(t2, kBinary32ExponentMask); |
| 3881 __ movz(t6, t2, t1); // Only if t6 is equal to t5. | 3881 __ Movz(t6, t2, t1); // Only if t6 is equal to t5. |
| 3882 __ Branch(&nan_or_infinity_or_zero, eq, t6, Operand(t5)); | 3882 __ Branch(&nan_or_infinity_or_zero, eq, t6, Operand(t5)); |
| 3883 | 3883 |
| 3884 // Rebias exponent. | 3884 // Rebias exponent. |
| 3885 __ srl(t6, t6, HeapNumber::kExponentShift); | 3885 __ srl(t6, t6, HeapNumber::kExponentShift); |
| 3886 __ Addu(t6, | 3886 __ Addu(t6, |
| 3887 t6, | 3887 t6, |
| 3888 Operand(kBinary32ExponentBias - HeapNumber::kExponentBias)); | 3888 Operand(kBinary32ExponentBias - HeapNumber::kExponentBias)); |
| 3889 | 3889 |
| 3890 __ li(t1, Operand(kBinary32MaxExponent)); | 3890 __ li(t1, Operand(kBinary32MaxExponent)); |
| 3891 __ Slt(t1, t1, t6); | 3891 __ Slt(t1, t1, t6); |
| 3892 __ And(t2, t3, Operand(HeapNumber::kSignMask)); | 3892 __ And(t2, t3, Operand(HeapNumber::kSignMask)); |
| 3893 __ Or(t2, t2, Operand(kBinary32ExponentMask)); | 3893 __ Or(t2, t2, Operand(kBinary32ExponentMask)); |
| 3894 __ movn(t3, t2, t1); // Only if t6 is gt kBinary32MaxExponent. | 3894 __ Movn(t3, t2, t1); // Only if t6 is gt kBinary32MaxExponent. |
| 3895 __ Branch(&done, gt, t6, Operand(kBinary32MaxExponent)); | 3895 __ Branch(&done, gt, t6, Operand(kBinary32MaxExponent)); |
| 3896 | 3896 |
| 3897 __ Slt(t1, t6, Operand(kBinary32MinExponent)); | 3897 __ Slt(t1, t6, Operand(kBinary32MinExponent)); |
| 3898 __ And(t2, t3, Operand(HeapNumber::kSignMask)); | 3898 __ And(t2, t3, Operand(HeapNumber::kSignMask)); |
| 3899 __ movn(t3, t2, t1); // Only if t6 is lt kBinary32MinExponent. | 3899 __ Movn(t3, t2, t1); // Only if t6 is lt kBinary32MinExponent. |
| 3900 __ Branch(&done, lt, t6, Operand(kBinary32MinExponent)); | 3900 __ Branch(&done, lt, t6, Operand(kBinary32MinExponent)); |
| 3901 | 3901 |
| 3902 __ And(t7, t3, Operand(HeapNumber::kSignMask)); | 3902 __ And(t7, t3, Operand(HeapNumber::kSignMask)); |
| 3903 __ And(t3, t3, Operand(HeapNumber::kMantissaMask)); | 3903 __ And(t3, t3, Operand(HeapNumber::kMantissaMask)); |
| 3904 __ sll(t3, t3, kMantissaInHiWordShift); | 3904 __ sll(t3, t3, kMantissaInHiWordShift); |
| 3905 __ or_(t7, t7, t3); | 3905 __ or_(t7, t7, t3); |
| 3906 __ srl(t4, t4, kMantissaInLoWordShift); | 3906 __ srl(t4, t4, kMantissaInLoWordShift); |
| 3907 __ or_(t7, t7, t4); | 3907 __ or_(t7, t7, t4); |
| 3908 __ sll(t6, t6, kBinary32ExponentShift); | 3908 __ sll(t6, t6, kBinary32ExponentShift); |
| 3909 __ or_(t3, t7, t6); | 3909 __ or_(t3, t7, t6); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3939 bool is_signed_type = IsElementTypeSigned(elements_kind); | 3939 bool is_signed_type = IsElementTypeSigned(elements_kind); |
| 3940 int meaningfull_bits = is_signed_type ? (kBitsPerInt - 1) : kBitsPerInt; | 3940 int meaningfull_bits = is_signed_type ? (kBitsPerInt - 1) : kBitsPerInt; |
| 3941 int32_t min_value = is_signed_type ? 0x80000000 : 0x00000000; | 3941 int32_t min_value = is_signed_type ? 0x80000000 : 0x00000000; |
| 3942 | 3942 |
| 3943 Label done, sign; | 3943 Label done, sign; |
| 3944 | 3944 |
| 3945 // Test for all special exponent values: zeros, subnormal numbers, NaNs | 3945 // Test for all special exponent values: zeros, subnormal numbers, NaNs |
| 3946 // and infinities. All these should be converted to 0. | 3946 // and infinities. All these should be converted to 0. |
| 3947 __ li(t5, HeapNumber::kExponentMask); | 3947 __ li(t5, HeapNumber::kExponentMask); |
| 3948 __ and_(t6, t3, t5); | 3948 __ and_(t6, t3, t5); |
| 3949 __ movz(t3, zero_reg, t6); // Only if t6 is equal to zero. | 3949 __ Movz(t3, zero_reg, t6); // Only if t6 is equal to zero. |
| 3950 __ Branch(&done, eq, t6, Operand(zero_reg)); | 3950 __ Branch(&done, eq, t6, Operand(zero_reg)); |
| 3951 | 3951 |
| 3952 __ xor_(t2, t6, t5); | 3952 __ xor_(t2, t6, t5); |
| 3953 __ movz(t3, zero_reg, t2); // Only if t6 is equal to t5. | 3953 __ Movz(t3, zero_reg, t2); // Only if t6 is equal to t5. |
| 3954 __ Branch(&done, eq, t6, Operand(t5)); | 3954 __ Branch(&done, eq, t6, Operand(t5)); |
| 3955 | 3955 |
| 3956 // Unbias exponent. | 3956 // Unbias exponent. |
| 3957 __ srl(t6, t6, HeapNumber::kExponentShift); | 3957 __ srl(t6, t6, HeapNumber::kExponentShift); |
| 3958 __ Subu(t6, t6, Operand(HeapNumber::kExponentBias)); | 3958 __ Subu(t6, t6, Operand(HeapNumber::kExponentBias)); |
| 3959 // If exponent is negative then result is 0. | 3959 // If exponent is negative then result is 0. |
| 3960 __ slt(t2, t6, zero_reg); | 3960 __ slt(t2, t6, zero_reg); |
| 3961 __ movn(t3, zero_reg, t2); // Only if exponent is negative. | 3961 __ Movn(t3, zero_reg, t2); // Only if exponent is negative. |
| 3962 __ Branch(&done, lt, t6, Operand(zero_reg)); | 3962 __ Branch(&done, lt, t6, Operand(zero_reg)); |
| 3963 | 3963 |
| 3964 // If exponent is too big then result is minimal value. | 3964 // If exponent is too big then result is minimal value. |
| 3965 __ slti(t1, t6, meaningfull_bits - 1); | 3965 __ slti(t1, t6, meaningfull_bits - 1); |
| 3966 __ li(t2, min_value); | 3966 __ li(t2, min_value); |
| 3967 __ movz(t3, t2, t1); // Only if t6 is ge meaningfull_bits - 1. | 3967 __ Movz(t3, t2, t1); // Only if t6 is ge meaningfull_bits - 1. |
| 3968 __ Branch(&done, ge, t6, Operand(meaningfull_bits - 1)); | 3968 __ Branch(&done, ge, t6, Operand(meaningfull_bits - 1)); |
| 3969 | 3969 |
| 3970 __ And(t5, t3, Operand(HeapNumber::kSignMask)); | 3970 __ And(t5, t3, Operand(HeapNumber::kSignMask)); |
| 3971 __ And(t3, t3, Operand(HeapNumber::kMantissaMask)); | 3971 __ And(t3, t3, Operand(HeapNumber::kMantissaMask)); |
| 3972 __ Or(t3, t3, Operand(1u << HeapNumber::kMantissaBitsInTopWord)); | 3972 __ Or(t3, t3, Operand(1u << HeapNumber::kMantissaBitsInTopWord)); |
| 3973 | 3973 |
| 3974 __ li(t9, HeapNumber::kMantissaBitsInTopWord); | 3974 __ li(t9, HeapNumber::kMantissaBitsInTopWord); |
| 3975 __ subu(t6, t9, t6); | 3975 __ subu(t6, t9, t6); |
| 3976 __ slt(t1, t6, zero_reg); | 3976 __ slt(t1, t6, zero_reg); |
| 3977 __ srlv(t2, t3, t6); | 3977 __ srlv(t2, t3, t6); |
| 3978 __ movz(t3, t2, t1); // Only if t6 is positive. | 3978 __ Movz(t3, t2, t1); // Only if t6 is positive. |
| 3979 __ Branch(&sign, ge, t6, Operand(zero_reg)); | 3979 __ Branch(&sign, ge, t6, Operand(zero_reg)); |
| 3980 | 3980 |
| 3981 __ subu(t6, zero_reg, t6); | 3981 __ subu(t6, zero_reg, t6); |
| 3982 __ sllv(t3, t3, t6); | 3982 __ sllv(t3, t3, t6); |
| 3983 __ li(t9, meaningfull_bits); | 3983 __ li(t9, meaningfull_bits); |
| 3984 __ subu(t6, t9, t6); | 3984 __ subu(t6, t9, t6); |
| 3985 __ srlv(t4, t4, t6); | 3985 __ srlv(t4, t4, t6); |
| 3986 __ or_(t3, t3, t4); | 3986 __ or_(t3, t3, t4); |
| 3987 | 3987 |
| 3988 __ bind(&sign); | 3988 __ bind(&sign); |
| 3989 __ subu(t2, t3, zero_reg); | 3989 __ subu(t2, t3, zero_reg); |
| 3990 __ movz(t3, t2, t5); // Only if t5 is zero. | 3990 __ Movz(t3, t2, t5); // Only if t5 is zero. |
| 3991 | 3991 |
| 3992 __ bind(&done); | 3992 __ bind(&done); |
| 3993 | 3993 |
| 3994 // Result is in t3. | 3994 // Result is in t3. |
| 3995 // This switch block should be exactly the same as above (FPU mode). | 3995 // This switch block should be exactly the same as above (FPU mode). |
| 3996 switch (elements_kind) { | 3996 switch (elements_kind) { |
| 3997 case EXTERNAL_BYTE_ELEMENTS: | 3997 case EXTERNAL_BYTE_ELEMENTS: |
| 3998 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3998 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3999 __ srl(t8, key, 1); | 3999 __ srl(t8, key, 1); |
| 4000 __ addu(t8, a3, t8); | 4000 __ addu(t8, a3, t8); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4470 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4470 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
| 4471 } | 4471 } |
| 4472 } | 4472 } |
| 4473 | 4473 |
| 4474 | 4474 |
| 4475 #undef __ | 4475 #undef __ |
| 4476 | 4476 |
| 4477 } } // namespace v8::internal | 4477 } } // namespace v8::internal |
| 4478 | 4478 |
| 4479 #endif // V8_TARGET_ARCH_MIPS | 4479 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |