OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 if (instr->representation().IsSmiOrInteger32()) { | 1525 if (instr->representation().IsSmiOrInteger32()) { |
1526 // Check to see if it would be advantageous to use an lea instruction rather | 1526 // Check to see if it would be advantageous to use an lea instruction rather |
1527 // than an add. This is the case when no overflow check is needed and there | 1527 // than an add. This is the case when no overflow check is needed and there |
1528 // are multiple uses of the add's inputs, so using a 3-register add will | 1528 // are multiple uses of the add's inputs, so using a 3-register add will |
1529 // preserve all input values for later uses. | 1529 // preserve all input values for later uses. |
1530 bool use_lea = LAddI::UseLea(instr); | 1530 bool use_lea = LAddI::UseLea(instr); |
1531 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1531 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1532 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1532 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1533 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1533 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1534 HValue* right_candidate = instr->BetterRightOperand(); | 1534 HValue* right_candidate = instr->BetterRightOperand(); |
1535 LOperand* right = use_lea | 1535 LOperand* right; |
1536 ? UseRegisterOrConstantAtStart(right_candidate) | 1536 if (instr->representation().IsSmi()) { |
1537 : UseOrConstantAtStart(right_candidate); | 1537 // We cannot add a tagged immediate to a tagged value, |
| 1538 // so we request it in a register. |
| 1539 right = UseRegisterAtStart(right_candidate); |
| 1540 } else { |
| 1541 right = use_lea ? UseRegisterOrConstantAtStart(right_candidate) |
| 1542 : UseOrConstantAtStart(right_candidate); |
| 1543 } |
1538 LAddI* add = new(zone()) LAddI(left, right); | 1544 LAddI* add = new(zone()) LAddI(left, right); |
1539 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); | 1545 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
1540 LInstruction* result = use_lea | 1546 LInstruction* result = use_lea ? DefineAsRegister(add) |
1541 ? DefineAsRegister(add) | 1547 : DefineSameAsFirst(add); |
1542 : DefineSameAsFirst(add); | |
1543 if (can_overflow) { | 1548 if (can_overflow) { |
1544 result = AssignEnvironment(result); | 1549 result = AssignEnvironment(result); |
1545 } | 1550 } |
1546 return result; | 1551 return result; |
1547 } else if (instr->representation().IsExternal()) { | 1552 } else if (instr->representation().IsExternal()) { |
1548 ASSERT(instr->left()->representation().IsExternal()); | 1553 ASSERT(instr->left()->representation().IsExternal()); |
1549 ASSERT(instr->right()->representation().IsInteger32()); | 1554 ASSERT(instr->right()->representation().IsInteger32()); |
1550 ASSERT(!instr->CheckFlag(HValue::kCanOverflow)); | 1555 ASSERT(!instr->CheckFlag(HValue::kCanOverflow)); |
1551 bool use_lea = LAddI::UseLea(instr); | 1556 bool use_lea = LAddI::UseLea(instr); |
1552 LOperand* left = UseRegisterAtStart(instr->left()); | 1557 LOperand* left = UseRegisterAtStart(instr->left()); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 LOperand* index = UseTempRegister(instr->index()); | 2603 LOperand* index = UseTempRegister(instr->index()); |
2599 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); | 2604 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); |
2600 LInstruction* result = DefineSameAsFirst(load); | 2605 LInstruction* result = DefineSameAsFirst(load); |
2601 return AssignPointerMap(result); | 2606 return AssignPointerMap(result); |
2602 } | 2607 } |
2603 | 2608 |
2604 | 2609 |
2605 } } // namespace v8::internal | 2610 } } // namespace v8::internal |
2606 | 2611 |
2607 #endif // V8_TARGET_ARCH_X64 | 2612 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |