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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/division-by-constant.h" |
10 #include "src/bootstrapper.h" | 11 #include "src/bootstrapper.h" |
11 #include "src/codegen.h" | 12 #include "src/codegen.h" |
12 #include "src/cpu-profiler.h" | 13 #include "src/cpu-profiler.h" |
13 #include "src/debug.h" | 14 #include "src/debug.h" |
14 #include "src/isolate-inl.h" | 15 #include "src/isolate-inl.h" |
15 #include "src/runtime.h" | 16 #include "src/runtime.h" |
16 #include "src/serialize.h" | 17 #include "src/serialize.h" |
17 | 18 |
18 namespace v8 { | 19 namespace v8 { |
19 namespace internal { | 20 namespace internal { |
(...skipping 3396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 j(equal, found); | 3417 j(equal, found); |
3417 mov(current, FieldOperand(current, Map::kPrototypeOffset)); | 3418 mov(current, FieldOperand(current, Map::kPrototypeOffset)); |
3418 cmp(current, Immediate(factory->null_value())); | 3419 cmp(current, Immediate(factory->null_value())); |
3419 j(not_equal, &loop_again); | 3420 j(not_equal, &loop_again); |
3420 } | 3421 } |
3421 | 3422 |
3422 | 3423 |
3423 void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) { | 3424 void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) { |
3424 DCHECK(!dividend.is(eax)); | 3425 DCHECK(!dividend.is(eax)); |
3425 DCHECK(!dividend.is(edx)); | 3426 DCHECK(!dividend.is(edx)); |
3426 MultiplierAndShift ms(divisor); | 3427 base::MagicNumbersForDivision<uint32_t> mag = |
3427 mov(eax, Immediate(ms.multiplier())); | 3428 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
| 3429 mov(eax, Immediate(mag.multiplier)); |
3428 imul(dividend); | 3430 imul(dividend); |
3429 if (divisor > 0 && ms.multiplier() < 0) add(edx, dividend); | 3431 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
3430 if (divisor < 0 && ms.multiplier() > 0) sub(edx, dividend); | 3432 if (divisor > 0 && neg) add(edx, dividend); |
3431 if (ms.shift() > 0) sar(edx, ms.shift()); | 3433 if (divisor < 0 && !neg && mag.multiplier > 0) sub(edx, dividend); |
| 3434 if (mag.shift > 0) sar(edx, mag.shift); |
3432 mov(eax, dividend); | 3435 mov(eax, dividend); |
3433 shr(eax, 31); | 3436 shr(eax, 31); |
3434 add(edx, eax); | 3437 add(edx, eax); |
3435 } | 3438 } |
3436 | 3439 |
3437 | 3440 |
3438 } } // namespace v8::internal | 3441 } } // namespace v8::internal |
3439 | 3442 |
3440 #endif // V8_TARGET_ARCH_IA32 | 3443 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |