OLD | NEW |
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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS64 | 9 #if V8_TARGET_ARCH_MIPS64 |
10 | 10 |
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 if (instr->representation().IsSmiOrInteger32()) { | 1494 if (instr->representation().IsSmiOrInteger32()) { |
1495 DCHECK(instr->left()->representation().Equals(instr->representation())); | 1495 DCHECK(instr->left()->representation().Equals(instr->representation())); |
1496 DCHECK(instr->right()->representation().Equals(instr->representation())); | 1496 DCHECK(instr->right()->representation().Equals(instr->representation())); |
1497 HValue* left = instr->BetterLeftOperand(); | 1497 HValue* left = instr->BetterLeftOperand(); |
1498 HValue* right = instr->BetterRightOperand(); | 1498 HValue* right = instr->BetterRightOperand(); |
1499 LOperand* left_op; | 1499 LOperand* left_op; |
1500 LOperand* right_op; | 1500 LOperand* right_op; |
1501 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); | 1501 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
1502 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero); | 1502 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero); |
1503 | 1503 |
| 1504 int32_t constant_value = 0; |
1504 if (right->IsConstant()) { | 1505 if (right->IsConstant()) { |
1505 HConstant* constant = HConstant::cast(right); | 1506 HConstant* constant = HConstant::cast(right); |
1506 int32_t constant_value = constant->Integer32Value(); | 1507 constant_value = constant->Integer32Value(); |
1507 // Constants -1, 0 and 1 can be optimized if the result can overflow. | 1508 // Constants -1, 0 and 1 can be optimized if the result can overflow. |
1508 // For other constants, it can be optimized only without overflow. | 1509 // For other constants, it can be optimized only without overflow. |
1509 if (!can_overflow || ((constant_value >= -1) && (constant_value <= 1))) { | 1510 if (!can_overflow || ((constant_value >= -1) && (constant_value <= 1))) { |
1510 left_op = UseRegisterAtStart(left); | 1511 left_op = UseRegisterAtStart(left); |
1511 right_op = UseConstant(right); | 1512 right_op = UseConstant(right); |
1512 } else { | 1513 } else { |
1513 if (bailout_on_minus_zero) { | 1514 if (bailout_on_minus_zero) { |
1514 left_op = UseRegister(left); | 1515 left_op = UseRegister(left); |
1515 } else { | 1516 } else { |
1516 left_op = UseRegisterAtStart(left); | 1517 left_op = UseRegisterAtStart(left); |
1517 } | 1518 } |
1518 right_op = UseRegister(right); | 1519 right_op = UseRegister(right); |
1519 } | 1520 } |
1520 } else { | 1521 } else { |
1521 if (bailout_on_minus_zero) { | 1522 if (bailout_on_minus_zero) { |
1522 left_op = UseRegister(left); | 1523 left_op = UseRegister(left); |
1523 } else { | 1524 } else { |
1524 left_op = UseRegisterAtStart(left); | 1525 left_op = UseRegisterAtStart(left); |
1525 } | 1526 } |
1526 right_op = UseRegister(right); | 1527 right_op = UseRegister(right); |
1527 } | 1528 } |
1528 LMulI* mul = new(zone()) LMulI(left_op, right_op); | 1529 LMulI* mul = new(zone()) LMulI(left_op, right_op); |
1529 if (can_overflow || bailout_on_minus_zero) { | 1530 if (right_op->IsConstantOperand() |
| 1531 ? ((can_overflow && constant_value == -1) || |
| 1532 (bailout_on_minus_zero && constant_value <= 0)) |
| 1533 : (can_overflow || bailout_on_minus_zero)) { |
1530 AssignEnvironment(mul); | 1534 AssignEnvironment(mul); |
1531 } | 1535 } |
1532 return DefineAsRegister(mul); | 1536 return DefineAsRegister(mul); |
1533 | 1537 |
1534 } else if (instr->representation().IsDouble()) { | 1538 } else if (instr->representation().IsDouble()) { |
1535 if (kArchVariant == kMips64r2) { | 1539 if (kArchVariant == kMips64r2) { |
1536 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) { | 1540 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) { |
1537 HAdd* add = HAdd::cast(instr->uses().value()); | 1541 HAdd* add = HAdd::cast(instr->uses().value()); |
1538 if (instr == add->left()) { | 1542 if (instr == add->left()) { |
1539 // This mul is the lhs of an add. The add and mul will be folded | 1543 // This mul is the lhs of an add. The add and mul will be folded |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 LOperand* function = UseRegisterAtStart(instr->function()); | 2601 LOperand* function = UseRegisterAtStart(instr->function()); |
2598 LAllocateBlockContext* result = | 2602 LAllocateBlockContext* result = |
2599 new(zone()) LAllocateBlockContext(context, function); | 2603 new(zone()) LAllocateBlockContext(context, function); |
2600 return MarkAsCall(DefineFixed(result, cp), instr); | 2604 return MarkAsCall(DefineFixed(result, cp), instr); |
2601 } | 2605 } |
2602 | 2606 |
2603 | 2607 |
2604 } } // namespace v8::internal | 2608 } } // namespace v8::internal |
2605 | 2609 |
2606 #endif // V8_TARGET_ARCH_MIPS64 | 2610 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |