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_ARM | 9 #if V8_TARGET_ARCH_ARM |
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 4064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4086 masm_.emit(instr); | 4087 masm_.emit(instr); |
4087 } | 4088 } |
4088 | 4089 |
4089 | 4090 |
4090 void MacroAssembler::TruncatingDiv(Register result, | 4091 void MacroAssembler::TruncatingDiv(Register result, |
4091 Register dividend, | 4092 Register dividend, |
4092 int32_t divisor) { | 4093 int32_t divisor) { |
4093 DCHECK(!dividend.is(result)); | 4094 DCHECK(!dividend.is(result)); |
4094 DCHECK(!dividend.is(ip)); | 4095 DCHECK(!dividend.is(ip)); |
4095 DCHECK(!result.is(ip)); | 4096 DCHECK(!result.is(ip)); |
4096 MultiplierAndShift ms(divisor); | 4097 base::MagicNumbersForDivision<uint32_t> mag = |
4097 mov(ip, Operand(ms.multiplier())); | 4098 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
| 4099 mov(ip, Operand(mag.multiplier)); |
4098 smull(ip, result, dividend, ip); | 4100 smull(ip, result, dividend, ip); |
4099 if (divisor > 0 && ms.multiplier() < 0) { | 4101 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
| 4102 if (divisor > 0 && neg) { |
4100 add(result, result, Operand(dividend)); | 4103 add(result, result, Operand(dividend)); |
4101 } | 4104 } |
4102 if (divisor < 0 && ms.multiplier() > 0) { | 4105 if (divisor < 0 && !neg && mag.multiplier > 0) { |
4103 sub(result, result, Operand(dividend)); | 4106 sub(result, result, Operand(dividend)); |
4104 } | 4107 } |
4105 if (ms.shift() > 0) mov(result, Operand(result, ASR, ms.shift())); | 4108 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
4106 add(result, result, Operand(dividend, LSR, 31)); | 4109 add(result, result, Operand(dividend, LSR, 31)); |
4107 } | 4110 } |
4108 | 4111 |
4109 | 4112 |
4110 } } // namespace v8::internal | 4113 } } // namespace v8::internal |
4111 | 4114 |
4112 #endif // V8_TARGET_ARCH_ARM | 4115 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |