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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/base/division-by-constant.h" | 9 #include "src/base/division-by-constant.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 5853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5864 and_(overflow_dst, scratch, overflow_dst); | 5864 and_(overflow_dst, scratch, overflow_dst); |
5865 } else { | 5865 } else { |
5866 dsubu(dst, left, right); | 5866 dsubu(dst, left, right); |
5867 xor_(overflow_dst, dst, left); | 5867 xor_(overflow_dst, dst, left); |
5868 xor_(scratch, left, right); | 5868 xor_(scratch, left, right); |
5869 and_(overflow_dst, scratch, overflow_dst); | 5869 and_(overflow_dst, scratch, overflow_dst); |
5870 } | 5870 } |
5871 BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label); | 5871 BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label); |
5872 } | 5872 } |
5873 | 5873 |
| 5874 static inline void BranchOvfHelperMult(MacroAssembler* masm, |
| 5875 Register overflow_dst, |
| 5876 Label* overflow_label, |
| 5877 Label* no_overflow_label) { |
| 5878 DCHECK(overflow_label || no_overflow_label); |
| 5879 if (!overflow_label) { |
| 5880 DCHECK(no_overflow_label); |
| 5881 masm->Branch(no_overflow_label, eq, overflow_dst, Operand(zero_reg)); |
| 5882 } else { |
| 5883 masm->Branch(overflow_label, ne, overflow_dst, Operand(zero_reg)); |
| 5884 if (no_overflow_label) masm->Branch(no_overflow_label); |
| 5885 } |
| 5886 } |
| 5887 |
| 5888 void MacroAssembler::MulBranchOvf(Register dst, Register left, |
| 5889 const Operand& right, Label* overflow_label, |
| 5890 Label* no_overflow_label, Register scratch) { |
| 5891 DCHECK(overflow_label || no_overflow_label); |
| 5892 if (right.is_reg()) { |
| 5893 MulBranchOvf(dst, left, right.rm(), overflow_label, no_overflow_label, |
| 5894 scratch); |
| 5895 } else { |
| 5896 Register overflow_dst = t9; |
| 5897 DCHECK(!dst.is(scratch)); |
| 5898 DCHECK(!dst.is(overflow_dst)); |
| 5899 DCHECK(!scratch.is(overflow_dst)); |
| 5900 DCHECK(!left.is(overflow_dst)); |
| 5901 DCHECK(!left.is(scratch)); |
| 5902 |
| 5903 if (dst.is(left)) { |
| 5904 Mul(scratch, left, static_cast<int32_t>(right.immediate())); |
| 5905 Mulh(overflow_dst, left, static_cast<int32_t>(right.immediate())); |
| 5906 mov(dst, scratch); |
| 5907 } else { |
| 5908 Mul(dst, left, static_cast<int32_t>(right.immediate())); |
| 5909 Mulh(overflow_dst, left, static_cast<int32_t>(right.immediate())); |
| 5910 } |
| 5911 |
| 5912 dsra32(scratch, dst, 0); |
| 5913 xor_(overflow_dst, overflow_dst, scratch); |
| 5914 |
| 5915 BranchOvfHelperMult(this, overflow_dst, overflow_label, no_overflow_label); |
| 5916 } |
| 5917 } |
| 5918 |
| 5919 void MacroAssembler::MulBranchOvf(Register dst, Register left, Register right, |
| 5920 Label* overflow_label, |
| 5921 Label* no_overflow_label, Register scratch) { |
| 5922 DCHECK(overflow_label || no_overflow_label); |
| 5923 Register overflow_dst = t9; |
| 5924 DCHECK(!dst.is(scratch)); |
| 5925 DCHECK(!dst.is(overflow_dst)); |
| 5926 DCHECK(!scratch.is(overflow_dst)); |
| 5927 DCHECK(!overflow_dst.is(left)); |
| 5928 DCHECK(!overflow_dst.is(right)); |
| 5929 DCHECK(!scratch.is(left)); |
| 5930 DCHECK(!scratch.is(right)); |
| 5931 |
| 5932 if (dst.is(left) || dst.is(right)) { |
| 5933 Mul(scratch, left, right); |
| 5934 Mulh(overflow_dst, left, right); |
| 5935 mov(dst, scratch); |
| 5936 } else { |
| 5937 Mul(dst, left, right); |
| 5938 Mulh(overflow_dst, left, right); |
| 5939 } |
| 5940 |
| 5941 dsra32(scratch, dst, 0); |
| 5942 xor_(overflow_dst, overflow_dst, scratch); |
| 5943 |
| 5944 BranchOvfHelperMult(this, overflow_dst, overflow_label, no_overflow_label); |
| 5945 } |
5874 | 5946 |
5875 void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, | 5947 void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, |
5876 SaveFPRegsMode save_doubles, | 5948 SaveFPRegsMode save_doubles, |
5877 BranchDelaySlot bd) { | 5949 BranchDelaySlot bd) { |
5878 // All parameters are on the stack. v0 has the return value after call. | 5950 // All parameters are on the stack. v0 has the return value after call. |
5879 | 5951 |
5880 // If the expected number of arguments of the runtime function is | 5952 // If the expected number of arguments of the runtime function is |
5881 // constant, we check that the actual number of arguments match the | 5953 // constant, we check that the actual number of arguments match the |
5882 // expectation. | 5954 // expectation. |
5883 CHECK(f->nargs < 0 || f->nargs == num_arguments); | 5955 CHECK(f->nargs < 0 || f->nargs == num_arguments); |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7262 if (mag.shift > 0) sra(result, result, mag.shift); | 7334 if (mag.shift > 0) sra(result, result, mag.shift); |
7263 srl(at, dividend, 31); | 7335 srl(at, dividend, 31); |
7264 Addu(result, result, Operand(at)); | 7336 Addu(result, result, Operand(at)); |
7265 } | 7337 } |
7266 | 7338 |
7267 | 7339 |
7268 } // namespace internal | 7340 } // namespace internal |
7269 } // namespace v8 | 7341 } // namespace v8 |
7270 | 7342 |
7271 #endif // V8_TARGET_ARCH_MIPS64 | 7343 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |