| 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 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/heap/heap.h" | 15 #include "src/heap/heap.h" |
| 15 #include "src/isolate-inl.h" | 16 #include "src/isolate-inl.h" |
| 16 #include "src/serialize.h" | 17 #include "src/serialize.h" |
| 17 #include "src/x64/assembler-x64.h" | 18 #include "src/x64/assembler-x64.h" |
| 18 #include "src/x64/macro-assembler-x64.h" | 19 #include "src/x64/macro-assembler-x64.h" |
| 19 | 20 |
| (...skipping 5341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 j(equal, found); | 5362 j(equal, found); |
| 5362 movp(current, FieldOperand(current, Map::kPrototypeOffset)); | 5363 movp(current, FieldOperand(current, Map::kPrototypeOffset)); |
| 5363 CompareRoot(current, Heap::kNullValueRootIndex); | 5364 CompareRoot(current, Heap::kNullValueRootIndex); |
| 5364 j(not_equal, &loop_again); | 5365 j(not_equal, &loop_again); |
| 5365 } | 5366 } |
| 5366 | 5367 |
| 5367 | 5368 |
| 5368 void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) { | 5369 void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) { |
| 5369 DCHECK(!dividend.is(rax)); | 5370 DCHECK(!dividend.is(rax)); |
| 5370 DCHECK(!dividend.is(rdx)); | 5371 DCHECK(!dividend.is(rdx)); |
| 5371 MultiplierAndShift ms(divisor); | 5372 base::MagicNumbersForDivision<uint32_t> mag = |
| 5372 movl(rax, Immediate(ms.multiplier())); | 5373 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
| 5374 movl(rax, Immediate(mag.multiplier)); |
| 5373 imull(dividend); | 5375 imull(dividend); |
| 5374 if (divisor > 0 && ms.multiplier() < 0) addl(rdx, dividend); | 5376 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
| 5375 if (divisor < 0 && ms.multiplier() > 0) subl(rdx, dividend); | 5377 if (divisor > 0 && neg) addl(rdx, dividend); |
| 5376 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); | 5378 if (divisor < 0 && !neg && mag.multiplier > 0) subl(rdx, dividend); |
| 5379 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); |
| 5377 movl(rax, dividend); | 5380 movl(rax, dividend); |
| 5378 shrl(rax, Immediate(31)); | 5381 shrl(rax, Immediate(31)); |
| 5379 addl(rdx, rax); | 5382 addl(rdx, rax); |
| 5380 } | 5383 } |
| 5381 | 5384 |
| 5382 | 5385 |
| 5383 } } // namespace v8::internal | 5386 } } // namespace v8::internal |
| 5384 | 5387 |
| 5385 #endif // V8_TARGET_ARCH_X64 | 5388 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |