Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 532003004: Generalized division via multiplication. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/base/division-by-constant-unittest.cc ('k') | src/mips/macro-assembler-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/base/division-by-constant-unittest.cc ('k') | src/mips/macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698