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 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 __ mov(scratch, exponent); | 816 __ mov(scratch, exponent); |
817 } else { | 817 } else { |
818 // Exponent has previously been stored into scratch as untagged integer. | 818 // Exponent has previously been stored into scratch as untagged integer. |
819 __ mov(exponent, scratch); | 819 __ mov(exponent, scratch); |
820 } | 820 } |
821 | 821 |
822 __ mov_d(double_scratch, double_base); // Back up base. | 822 __ mov_d(double_scratch, double_base); // Back up base. |
823 __ Move(double_result, 1.0); | 823 __ Move(double_result, 1.0); |
824 | 824 |
825 // Get absolute value of exponent. | 825 // Get absolute value of exponent. |
826 Label positive_exponent; | 826 Label positive_exponent, bail_out; |
827 __ Branch(&positive_exponent, ge, scratch, Operand(zero_reg)); | 827 __ Branch(&positive_exponent, ge, scratch, Operand(zero_reg)); |
828 __ Subu(scratch, zero_reg, scratch); | 828 __ Subu(scratch, zero_reg, scratch); |
| 829 // Check when Subu overflows and we get negative result |
| 830 // (happens only when input is MIN_INT). |
| 831 __ Branch(&bail_out, gt, zero_reg, Operand(scratch)); |
829 __ bind(&positive_exponent); | 832 __ bind(&positive_exponent); |
| 833 __ Assert(ge, kUnexpectedNegativeValue, scratch, Operand(zero_reg)); |
830 | 834 |
831 Label while_true, no_carry, loop_end; | 835 Label while_true, no_carry, loop_end; |
832 __ bind(&while_true); | 836 __ bind(&while_true); |
833 | 837 |
834 __ And(scratch2, scratch, 1); | 838 __ And(scratch2, scratch, 1); |
835 | 839 |
836 __ Branch(&no_carry, eq, scratch2, Operand(zero_reg)); | 840 __ Branch(&no_carry, eq, scratch2, Operand(zero_reg)); |
837 __ mul_d(double_result, double_result, double_scratch); | 841 __ mul_d(double_result, double_result, double_scratch); |
838 __ bind(&no_carry); | 842 __ bind(&no_carry); |
839 | 843 |
(...skipping 12 matching lines...) Expand all Loading... |
852 // Test whether result is zero. Bail out to check for subnormal result. | 856 // Test whether result is zero. Bail out to check for subnormal result. |
853 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. | 857 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. |
854 __ BranchF(&done, NULL, ne, double_result, kDoubleRegZero); | 858 __ BranchF(&done, NULL, ne, double_result, kDoubleRegZero); |
855 | 859 |
856 // double_exponent may not contain the exponent value if the input was a | 860 // double_exponent may not contain the exponent value if the input was a |
857 // smi. We set it with exponent value before bailing out. | 861 // smi. We set it with exponent value before bailing out. |
858 __ mtc1(exponent, single_scratch); | 862 __ mtc1(exponent, single_scratch); |
859 __ cvt_d_w(double_exponent, single_scratch); | 863 __ cvt_d_w(double_exponent, single_scratch); |
860 | 864 |
861 // Returning or bailing out. | 865 // Returning or bailing out. |
| 866 __ bind(&bail_out); |
862 __ push(ra); | 867 __ push(ra); |
863 { | 868 { |
864 AllowExternalCallThatCantCauseGC scope(masm); | 869 AllowExternalCallThatCantCauseGC scope(masm); |
865 __ PrepareCallCFunction(0, 2, scratch); | 870 __ PrepareCallCFunction(0, 2, scratch); |
866 __ MovToFloatParameters(double_base, double_exponent); | 871 __ MovToFloatParameters(double_base, double_exponent); |
867 __ CallCFunction(ExternalReference::power_double_double_function(isolate()), | 872 __ CallCFunction(ExternalReference::power_double_double_function(isolate()), |
868 0, 2); | 873 0, 2); |
869 } | 874 } |
870 __ pop(ra); | 875 __ pop(ra); |
871 __ MovFromFloatResult(double_result); | 876 __ MovFromFloatResult(double_result); |
(...skipping 4533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5405 kStackUnwindSpace, kInvalidStackOffset, | 5410 kStackUnwindSpace, kInvalidStackOffset, |
5406 return_value_operand, NULL); | 5411 return_value_operand, NULL); |
5407 } | 5412 } |
5408 | 5413 |
5409 #undef __ | 5414 #undef __ |
5410 | 5415 |
5411 } // namespace internal | 5416 } // namespace internal |
5412 } // namespace v8 | 5417 } // namespace v8 |
5413 | 5418 |
5414 #endif // V8_TARGET_ARCH_MIPS | 5419 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |