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

Side by Side Diff: src/arm64/macro-assembler-arm64.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/arm/macro-assembler-arm.cc ('k') | src/assembler.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 7 #if V8_TARGET_ARCH_ARM64
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 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 20
(...skipping 5305 matching lines...) Expand 10 before | Expand all | Expand 10 after
5325 isolate->code_aging_helper()->IsOld(sequence)); 5326 isolate->code_aging_helper()->IsOld(sequence));
5326 return is_young; 5327 return is_young;
5327 } 5328 }
5328 5329
5329 5330
5330 void MacroAssembler::TruncatingDiv(Register result, 5331 void MacroAssembler::TruncatingDiv(Register result,
5331 Register dividend, 5332 Register dividend,
5332 int32_t divisor) { 5333 int32_t divisor) {
5333 DCHECK(!AreAliased(result, dividend)); 5334 DCHECK(!AreAliased(result, dividend));
5334 DCHECK(result.Is32Bits() && dividend.Is32Bits()); 5335 DCHECK(result.Is32Bits() && dividend.Is32Bits());
5335 MultiplierAndShift ms(divisor); 5336 base::MagicNumbersForDivision<uint32_t> mag =
5336 Mov(result, ms.multiplier()); 5337 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor));
5338 Mov(result, mag.multiplier);
5337 Smull(result.X(), dividend, result); 5339 Smull(result.X(), dividend, result);
5338 Asr(result.X(), result.X(), 32); 5340 Asr(result.X(), result.X(), 32);
5339 if (divisor > 0 && ms.multiplier() < 0) Add(result, result, dividend); 5341 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0;
5340 if (divisor < 0 && ms.multiplier() > 0) Sub(result, result, dividend); 5342 if (divisor > 0 && neg) Add(result, result, dividend);
5341 if (ms.shift() > 0) Asr(result, result, ms.shift()); 5343 if (divisor < 0 && !neg && mag.multiplier > 0) Sub(result, result, dividend);
5344 if (mag.shift > 0) Asr(result, result, mag.shift);
5342 Add(result, result, Operand(dividend, LSR, 31)); 5345 Add(result, result, Operand(dividend, LSR, 31));
5343 } 5346 }
5344 5347
5345 5348
5346 #undef __ 5349 #undef __
5347 5350
5348 5351
5349 UseScratchRegisterScope::~UseScratchRegisterScope() { 5352 UseScratchRegisterScope::~UseScratchRegisterScope() {
5350 available_->set_list(old_available_); 5353 available_->set_list(old_available_);
5351 availablefp_->set_list(old_availablefp_); 5354 availablefp_->set_list(old_availablefp_);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
5425 } 5428 }
5426 } 5429 }
5427 5430
5428 5431
5429 #undef __ 5432 #undef __
5430 5433
5431 5434
5432 } } // namespace v8::internal 5435 } } // namespace v8::internal
5433 5436
5434 #endif // V8_TARGET_ARCH_ARM64 5437 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698