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 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
11 #include "src/base/bits.h" | 11 #include "src/base/bits.h" |
| 12 #include "src/base/division-by-constant.h" |
12 #include "src/bootstrapper.h" | 13 #include "src/bootstrapper.h" |
13 #include "src/codegen.h" | 14 #include "src/codegen.h" |
14 #include "src/cpu-profiler.h" | 15 #include "src/cpu-profiler.h" |
15 #include "src/debug.h" | 16 #include "src/debug.h" |
16 #include "src/isolate-inl.h" | 17 #include "src/isolate-inl.h" |
17 #include "src/runtime.h" | 18 #include "src/runtime.h" |
18 | 19 |
19 namespace v8 { | 20 namespace v8 { |
20 namespace internal { | 21 namespace internal { |
21 | 22 |
(...skipping 6077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6099 masm_.emit(instr); | 6100 masm_.emit(instr); |
6100 } | 6101 } |
6101 | 6102 |
6102 | 6103 |
6103 void MacroAssembler::TruncatingDiv(Register result, | 6104 void MacroAssembler::TruncatingDiv(Register result, |
6104 Register dividend, | 6105 Register dividend, |
6105 int32_t divisor) { | 6106 int32_t divisor) { |
6106 DCHECK(!dividend.is(result)); | 6107 DCHECK(!dividend.is(result)); |
6107 DCHECK(!dividend.is(at)); | 6108 DCHECK(!dividend.is(at)); |
6108 DCHECK(!result.is(at)); | 6109 DCHECK(!result.is(at)); |
6109 MultiplierAndShift ms(divisor); | 6110 base::MagicNumbersForDivision<uint32_t> mag = |
6110 li(at, Operand(ms.multiplier())); | 6111 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
| 6112 li(at, Operand(mag.multiplier)); |
6111 Mulh(result, dividend, Operand(at)); | 6113 Mulh(result, dividend, Operand(at)); |
6112 if (divisor > 0 && ms.multiplier() < 0) { | 6114 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
| 6115 if (divisor > 0 && neg) { |
6113 Addu(result, result, Operand(dividend)); | 6116 Addu(result, result, Operand(dividend)); |
6114 } | 6117 } |
6115 if (divisor < 0 && ms.multiplier() > 0) { | 6118 if (divisor < 0 && !neg && mag.multiplier > 0) { |
6116 Subu(result, result, Operand(dividend)); | 6119 Subu(result, result, Operand(dividend)); |
6117 } | 6120 } |
6118 if (ms.shift() > 0) sra(result, result, ms.shift()); | 6121 if (mag.shift > 0) sra(result, result, mag.shift); |
6119 srl(at, dividend, 31); | 6122 srl(at, dividend, 31); |
6120 Addu(result, result, Operand(at)); | 6123 Addu(result, result, Operand(at)); |
6121 } | 6124 } |
6122 | 6125 |
6123 | 6126 |
6124 } } // namespace v8::internal | 6127 } } // namespace v8::internal |
6125 | 6128 |
6126 #endif // V8_TARGET_ARCH_MIPS | 6129 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |