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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 528993002: First step to cleanup the power-of-2 mess. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: clang-format 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/code-stubs-arm.cc ('k') | src/arm/macro-assembler-arm.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 #include "src/arm/lithium-codegen-arm.h" 7 #include "src/arm/lithium-codegen-arm.h"
8 #include "src/arm/lithium-gap-resolver-arm.h" 8 #include "src/arm/lithium-gap-resolver-arm.h"
9 #include "src/base/bits.h"
9 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
10 #include "src/hydrogen-osr.h" 11 #include "src/hydrogen-osr.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 15
15 16
16 class SafepointGenerator FINAL : public CallWrapper { 17 class SafepointGenerator FINAL : public CallWrapper {
17 public: 18 public:
18 SafepointGenerator(LCodeGen* codegen, 19 SafepointGenerator(LCodeGen* codegen,
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 } 1303 }
1303 __ bind(&done); 1304 __ bind(&done);
1304 } 1305 }
1305 } 1306 }
1306 1307
1307 1308
1308 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { 1309 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
1309 Register dividend = ToRegister(instr->dividend()); 1310 Register dividend = ToRegister(instr->dividend());
1310 int32_t divisor = instr->divisor(); 1311 int32_t divisor = instr->divisor();
1311 Register result = ToRegister(instr->result()); 1312 Register result = ToRegister(instr->result());
1312 DCHECK(divisor == kMinInt || IsPowerOf2(Abs(divisor))); 1313 DCHECK(divisor == kMinInt || base::bits::IsPowerOfTwo32(Abs(divisor)));
1313 DCHECK(!result.is(dividend)); 1314 DCHECK(!result.is(dividend));
1314 1315
1315 // Check for (0 / -x) that will produce negative zero. 1316 // Check for (0 / -x) that will produce negative zero.
1316 HDiv* hdiv = instr->hydrogen(); 1317 HDiv* hdiv = instr->hydrogen();
1317 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { 1318 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
1318 __ cmp(dividend, Operand::Zero()); 1319 __ cmp(dividend, Operand::Zero());
1319 DeoptimizeIf(eq, instr->environment()); 1320 DeoptimizeIf(eq, instr->environment());
1320 } 1321 }
1321 // Check for (kMinInt / -1). 1322 // Check for (kMinInt / -1).
1322 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) { 1323 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 case 1: 1660 case 1:
1660 __ Move(result, left); 1661 __ Move(result, left);
1661 break; 1662 break;
1662 default: 1663 default:
1663 // Multiplying by powers of two and powers of two plus or minus 1664 // Multiplying by powers of two and powers of two plus or minus
1664 // one can be done faster with shifted operands. 1665 // one can be done faster with shifted operands.
1665 // For other constants we emit standard code. 1666 // For other constants we emit standard code.
1666 int32_t mask = constant >> 31; 1667 int32_t mask = constant >> 31;
1667 uint32_t constant_abs = (constant + mask) ^ mask; 1668 uint32_t constant_abs = (constant + mask) ^ mask;
1668 1669
1669 if (IsPowerOf2(constant_abs)) { 1670 if (base::bits::IsPowerOfTwo32(constant_abs)) {
1670 int32_t shift = WhichPowerOf2(constant_abs); 1671 int32_t shift = WhichPowerOf2(constant_abs);
1671 __ mov(result, Operand(left, LSL, shift)); 1672 __ mov(result, Operand(left, LSL, shift));
1672 // Correct the sign of the result is the constant is negative. 1673 // Correct the sign of the result is the constant is negative.
1673 if (constant < 0) __ rsb(result, result, Operand::Zero()); 1674 if (constant < 0) __ rsb(result, result, Operand::Zero());
1674 } else if (IsPowerOf2(constant_abs - 1)) { 1675 } else if (base::bits::IsPowerOfTwo32(constant_abs - 1)) {
1675 int32_t shift = WhichPowerOf2(constant_abs - 1); 1676 int32_t shift = WhichPowerOf2(constant_abs - 1);
1676 __ add(result, left, Operand(left, LSL, shift)); 1677 __ add(result, left, Operand(left, LSL, shift));
1677 // Correct the sign of the result is the constant is negative. 1678 // Correct the sign of the result is the constant is negative.
1678 if (constant < 0) __ rsb(result, result, Operand::Zero()); 1679 if (constant < 0) __ rsb(result, result, Operand::Zero());
1679 } else if (IsPowerOf2(constant_abs + 1)) { 1680 } else if (base::bits::IsPowerOfTwo32(constant_abs + 1)) {
1680 int32_t shift = WhichPowerOf2(constant_abs + 1); 1681 int32_t shift = WhichPowerOf2(constant_abs + 1);
1681 __ rsb(result, left, Operand(left, LSL, shift)); 1682 __ rsb(result, left, Operand(left, LSL, shift));
1682 // Correct the sign of the result is the constant is negative. 1683 // Correct the sign of the result is the constant is negative.
1683 if (constant < 0) __ rsb(result, result, Operand::Zero()); 1684 if (constant < 0) __ rsb(result, result, Operand::Zero());
1684 } else { 1685 } else {
1685 // Generate standard code. 1686 // Generate standard code.
1686 __ mov(ip, Operand(constant)); 1687 __ mov(ip, Operand(constant));
1687 __ mul(result, left, ip); 1688 __ mul(result, left, ip);
1688 } 1689 }
1689 } 1690 }
(...skipping 3422 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 if (last != LAST_TYPE) { 5113 if (last != LAST_TYPE) {
5113 __ cmp(scratch, Operand(last)); 5114 __ cmp(scratch, Operand(last));
5114 DeoptimizeIf(hi, instr->environment()); 5115 DeoptimizeIf(hi, instr->environment());
5115 } 5116 }
5116 } 5117 }
5117 } else { 5118 } else {
5118 uint8_t mask; 5119 uint8_t mask;
5119 uint8_t tag; 5120 uint8_t tag;
5120 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag); 5121 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag);
5121 5122
5122 if (IsPowerOf2(mask)) { 5123 if (base::bits::IsPowerOfTwo32(mask)) {
5123 DCHECK(tag == 0 || IsPowerOf2(tag)); 5124 DCHECK(tag == 0 || base::bits::IsPowerOfTwo32(tag));
5124 __ tst(scratch, Operand(mask)); 5125 __ tst(scratch, Operand(mask));
5125 DeoptimizeIf(tag == 0 ? ne : eq, instr->environment()); 5126 DeoptimizeIf(tag == 0 ? ne : eq, instr->environment());
5126 } else { 5127 } else {
5127 __ and_(scratch, scratch, Operand(mask)); 5128 __ and_(scratch, scratch, Operand(mask));
5128 __ cmp(scratch, Operand(tag)); 5129 __ cmp(scratch, Operand(tag));
5129 DeoptimizeIf(ne, instr->environment()); 5130 DeoptimizeIf(ne, instr->environment());
5130 } 5131 }
5131 } 5132 }
5132 } 5133 }
5133 5134
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
5879 __ Push(scope_info); 5880 __ Push(scope_info);
5880 __ push(ToRegister(instr->function())); 5881 __ push(ToRegister(instr->function()));
5881 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5882 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5882 RecordSafepoint(Safepoint::kNoLazyDeopt); 5883 RecordSafepoint(Safepoint::kNoLazyDeopt);
5883 } 5884 }
5884 5885
5885 5886
5886 #undef __ 5887 #undef __
5887 5888
5888 } } // namespace v8::internal 5889 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/arm/macro-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698