Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Side by Side Diff: src/mips64/code-stubs-mips64.cc

Issue 2163963003: MIPS: Fix infinite loop in Math.pow(2,-2147483648) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nits Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | test/mjsunit/regress/regress-5213.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 __ mov(scratch, exponent); 813 __ mov(scratch, exponent);
814 } else { 814 } else {
815 // Exponent has previously been stored into scratch as untagged integer. 815 // Exponent has previously been stored into scratch as untagged integer.
816 __ mov(exponent, scratch); 816 __ mov(exponent, scratch);
817 } 817 }
818 818
819 __ mov_d(double_scratch, double_base); // Back up base. 819 __ mov_d(double_scratch, double_base); // Back up base.
820 __ Move(double_result, 1.0); 820 __ Move(double_result, 1.0);
821 821
822 // Get absolute value of exponent. 822 // Get absolute value of exponent.
823 Label positive_exponent; 823 Label positive_exponent, bail_out;
824 __ Branch(&positive_exponent, ge, scratch, Operand(zero_reg)); 824 __ Branch(&positive_exponent, ge, scratch, Operand(zero_reg));
825 __ Dsubu(scratch, zero_reg, scratch); 825 __ Dsubu(scratch, zero_reg, scratch);
826 // Check when Dsubu overflows and we get negative result
827 // (happens only when input is MIN_INT).
828 __ Branch(&bail_out, gt, zero_reg, Operand(scratch));
826 __ bind(&positive_exponent); 829 __ bind(&positive_exponent);
830 __ Assert(ge, kUnexpectedNegativeValue, scratch, Operand(zero_reg));
827 831
828 Label while_true, no_carry, loop_end; 832 Label while_true, no_carry, loop_end;
829 __ bind(&while_true); 833 __ bind(&while_true);
830 834
831 __ And(scratch2, scratch, 1); 835 __ And(scratch2, scratch, 1);
832 836
833 __ Branch(&no_carry, eq, scratch2, Operand(zero_reg)); 837 __ Branch(&no_carry, eq, scratch2, Operand(zero_reg));
834 __ mul_d(double_result, double_result, double_scratch); 838 __ mul_d(double_result, double_result, double_scratch);
835 __ bind(&no_carry); 839 __ bind(&no_carry);
836 840
(...skipping 12 matching lines...) Expand all
849 // Test whether result is zero. Bail out to check for subnormal result. 853 // Test whether result is zero. Bail out to check for subnormal result.
850 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. 854 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases.
851 __ BranchF(&done, NULL, ne, double_result, kDoubleRegZero); 855 __ BranchF(&done, NULL, ne, double_result, kDoubleRegZero);
852 856
853 // double_exponent may not contain the exponent value if the input was a 857 // double_exponent may not contain the exponent value if the input was a
854 // smi. We set it with exponent value before bailing out. 858 // smi. We set it with exponent value before bailing out.
855 __ mtc1(exponent, single_scratch); 859 __ mtc1(exponent, single_scratch);
856 __ cvt_d_w(double_exponent, single_scratch); 860 __ cvt_d_w(double_exponent, single_scratch);
857 861
858 // Returning or bailing out. 862 // Returning or bailing out.
863 __ bind(&bail_out);
859 __ push(ra); 864 __ push(ra);
860 { 865 {
861 AllowExternalCallThatCantCauseGC scope(masm); 866 AllowExternalCallThatCantCauseGC scope(masm);
862 __ PrepareCallCFunction(0, 2, scratch); 867 __ PrepareCallCFunction(0, 2, scratch);
863 __ MovToFloatParameters(double_base, double_exponent); 868 __ MovToFloatParameters(double_base, double_exponent);
864 __ CallCFunction(ExternalReference::power_double_double_function(isolate()), 869 __ CallCFunction(ExternalReference::power_double_double_function(isolate()),
865 0, 2); 870 0, 2);
866 } 871 }
867 __ pop(ra); 872 __ pop(ra);
868 __ MovFromFloatResult(double_result); 873 __ MovFromFloatResult(double_result);
(...skipping 4569 matching lines...) Expand 10 before | Expand all | Expand 10 after
5438 kStackUnwindSpace, kInvalidStackOffset, 5443 kStackUnwindSpace, kInvalidStackOffset,
5439 return_value_operand, NULL); 5444 return_value_operand, NULL);
5440 } 5445 }
5441 5446
5442 #undef __ 5447 #undef __
5443 5448
5444 } // namespace internal 5449 } // namespace internal
5445 } // namespace v8 5450 } // namespace v8
5446 5451
5447 #endif // V8_TARGET_ARCH_MIPS64 5452 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | test/mjsunit/regress/regress-5213.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698