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

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

Issue 519283005: MIPS: First step to cleanup the power-of-2 mess. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/mips64/code-stubs-mips64.cc ('k') | src/mips64/macro-assembler-mips64.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/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/hydrogen-osr.h" 8 #include "src/hydrogen-osr.h"
9 #include "src/mips64/lithium-codegen-mips64.h" 9 #include "src/mips64/lithium-codegen-mips64.h"
10 #include "src/mips64/lithium-gap-resolver-mips64.h" 10 #include "src/mips64/lithium-gap-resolver-mips64.h"
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); 1149 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg));
1150 } 1150 }
1151 __ bind(&done); 1151 __ bind(&done);
1152 } 1152 }
1153 1153
1154 1154
1155 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { 1155 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
1156 Register dividend = ToRegister(instr->dividend()); 1156 Register dividend = ToRegister(instr->dividend());
1157 int32_t divisor = instr->divisor(); 1157 int32_t divisor = instr->divisor();
1158 Register result = ToRegister(instr->result()); 1158 Register result = ToRegister(instr->result());
1159 DCHECK(divisor == kMinInt || IsPowerOf2(Abs(divisor))); 1159 DCHECK(divisor == kMinInt || base::bits::IsPowerOfTwo32(Abs(divisor)));
1160 DCHECK(!result.is(dividend)); 1160 DCHECK(!result.is(dividend));
1161 1161
1162 // Check for (0 / -x) that will produce negative zero. 1162 // Check for (0 / -x) that will produce negative zero.
1163 HDiv* hdiv = instr->hydrogen(); 1163 HDiv* hdiv = instr->hydrogen();
1164 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { 1164 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
1165 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); 1165 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg));
1166 } 1166 }
1167 // Check for (kMinInt / -1). 1167 // Check for (kMinInt / -1).
1168 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) { 1168 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
1169 DeoptimizeIf(eq, instr->environment(), dividend, Operand(kMinInt)); 1169 DeoptimizeIf(eq, instr->environment(), dividend, Operand(kMinInt));
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 // Nothing to do. 1473 // Nothing to do.
1474 __ Move(result, left); 1474 __ Move(result, left);
1475 break; 1475 break;
1476 default: 1476 default:
1477 // Multiplying by powers of two and powers of two plus or minus 1477 // Multiplying by powers of two and powers of two plus or minus
1478 // one can be done faster with shifted operands. 1478 // one can be done faster with shifted operands.
1479 // For other constants we emit standard code. 1479 // For other constants we emit standard code.
1480 int32_t mask = constant >> 31; 1480 int32_t mask = constant >> 31;
1481 uint32_t constant_abs = (constant + mask) ^ mask; 1481 uint32_t constant_abs = (constant + mask) ^ mask;
1482 1482
1483 if (IsPowerOf2(constant_abs)) { 1483 if (base::bits::IsPowerOfTwo32(constant_abs)) {
1484 int32_t shift = WhichPowerOf2(constant_abs); 1484 int32_t shift = WhichPowerOf2(constant_abs);
1485 __ dsll(result, left, shift); 1485 __ dsll(result, left, shift);
1486 // Correct the sign of the result if the constant is negative. 1486 // Correct the sign of the result if the constant is negative.
1487 if (constant < 0) __ Dsubu(result, zero_reg, result); 1487 if (constant < 0) __ Dsubu(result, zero_reg, result);
1488 } else if (IsPowerOf2(constant_abs - 1)) { 1488 } else if (base::bits::IsPowerOfTwo32(constant_abs - 1)) {
1489 int32_t shift = WhichPowerOf2(constant_abs - 1); 1489 int32_t shift = WhichPowerOf2(constant_abs - 1);
1490 __ dsll(scratch, left, shift); 1490 __ dsll(scratch, left, shift);
1491 __ Daddu(result, scratch, left); 1491 __ Daddu(result, scratch, left);
1492 // Correct the sign of the result if the constant is negative. 1492 // Correct the sign of the result if the constant is negative.
1493 if (constant < 0) __ Dsubu(result, zero_reg, result); 1493 if (constant < 0) __ Dsubu(result, zero_reg, result);
1494 } else if (IsPowerOf2(constant_abs + 1)) { 1494 } else if (base::bits::IsPowerOfTwo32(constant_abs + 1)) {
1495 int32_t shift = WhichPowerOf2(constant_abs + 1); 1495 int32_t shift = WhichPowerOf2(constant_abs + 1);
1496 __ dsll(scratch, left, shift); 1496 __ dsll(scratch, left, shift);
1497 __ Dsubu(result, scratch, left); 1497 __ Dsubu(result, scratch, left);
1498 // Correct the sign of the result if the constant is negative. 1498 // Correct the sign of the result if the constant is negative.
1499 if (constant < 0) __ Dsubu(result, zero_reg, result); 1499 if (constant < 0) __ Dsubu(result, zero_reg, result);
1500 } else { 1500 } else {
1501 // Generate standard code. 1501 // Generate standard code.
1502 __ li(at, constant); 1502 __ li(at, constant);
1503 __ Dmul(result, left, at); 1503 __ Dmul(result, left, at);
1504 } 1504 }
(...skipping 3627 matching lines...) Expand 10 before | Expand all | Expand 10 after
5132 // Omit check for the last type. 5132 // Omit check for the last type.
5133 if (last != LAST_TYPE) { 5133 if (last != LAST_TYPE) {
5134 DeoptimizeIf(hi, instr->environment(), scratch, Operand(last)); 5134 DeoptimizeIf(hi, instr->environment(), scratch, Operand(last));
5135 } 5135 }
5136 } 5136 }
5137 } else { 5137 } else {
5138 uint8_t mask; 5138 uint8_t mask;
5139 uint8_t tag; 5139 uint8_t tag;
5140 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag); 5140 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag);
5141 5141
5142 if (IsPowerOf2(mask)) { 5142 if (base::bits::IsPowerOfTwo32(mask)) {
5143 DCHECK(tag == 0 || IsPowerOf2(tag)); 5143 DCHECK(tag == 0 || base::bits::IsPowerOfTwo32(tag));
5144 __ And(at, scratch, mask); 5144 __ And(at, scratch, mask);
5145 DeoptimizeIf(tag == 0 ? ne : eq, instr->environment(), 5145 DeoptimizeIf(tag == 0 ? ne : eq, instr->environment(),
5146 at, Operand(zero_reg)); 5146 at, Operand(zero_reg));
5147 } else { 5147 } else {
5148 __ And(scratch, scratch, Operand(mask)); 5148 __ And(scratch, scratch, Operand(mask));
5149 DeoptimizeIf(ne, instr->environment(), scratch, Operand(tag)); 5149 DeoptimizeIf(ne, instr->environment(), scratch, Operand(tag));
5150 } 5150 }
5151 } 5151 }
5152 } 5152 }
5153 5153
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
5936 __ li(at, scope_info); 5936 __ li(at, scope_info);
5937 __ Push(at, ToRegister(instr->function())); 5937 __ Push(at, ToRegister(instr->function()));
5938 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5938 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5939 RecordSafepoint(Safepoint::kNoLazyDeopt); 5939 RecordSafepoint(Safepoint::kNoLazyDeopt);
5940 } 5940 }
5941 5941
5942 5942
5943 #undef __ 5943 #undef __
5944 5944
5945 } } // namespace v8::internal 5945 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/mips64/macro-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698