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

Unified Diff: src/x87/macro-assembler-x87.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x87/macro-assembler-x87.cc
diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc
index 6c5ba5d3d82d3b02ddba7932018175553e473fa8..9846d8998fdaf71b61a094952fd94f808c810e18 100644
--- a/src/x87/macro-assembler-x87.cc
+++ b/src/x87/macro-assembler-x87.cc
@@ -7,6 +7,7 @@
#if V8_TARGET_ARCH_X87
#include "src/base/bits.h"
+#include "src/base/division-by-constant.h"
#include "src/bootstrapper.h"
#include "src/codegen.h"
#include "src/cpu-profiler.h"
@@ -3310,12 +3311,14 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) {
DCHECK(!dividend.is(eax));
DCHECK(!dividend.is(edx));
- MultiplierAndShift ms(divisor);
- mov(eax, Immediate(ms.multiplier()));
+ base::MagicNumbersForDivision<uint32_t> mag =
+ base::SignedDivisionByConstant(static_cast<uint32_t>(divisor));
+ mov(eax, Immediate(mag.multiplier));
imul(dividend);
- if (divisor > 0 && ms.multiplier() < 0) add(edx, dividend);
- if (divisor < 0 && ms.multiplier() > 0) sub(edx, dividend);
- if (ms.shift() > 0) sar(edx, ms.shift());
+ bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0;
+ if (divisor > 0 && neg) add(edx, dividend);
+ if (divisor < 0 && !neg && mag.multiplier > 0) sub(edx, dividend);
+ if (mag.shift > 0) sar(edx, mag.shift);
mov(eax, dividend);
shr(eax, 31);
add(edx, eax);
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698