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

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 14856015: Bias commutative single-use register inputs and support lea adds (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 7 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/ia32/lithium-ia32.h ('k') | src/mips/lithium-mips.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 // 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 return does_deopt ? AssignEnvironment(result) : result; 827 return does_deopt ? AssignEnvironment(result) : result;
828 } 828 }
829 829
830 830
831 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, 831 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
832 HArithmeticBinaryOperation* instr) { 832 HArithmeticBinaryOperation* instr) {
833 ASSERT(instr->representation().IsDouble()); 833 ASSERT(instr->representation().IsDouble());
834 ASSERT(instr->left()->representation().IsDouble()); 834 ASSERT(instr->left()->representation().IsDouble());
835 ASSERT(instr->right()->representation().IsDouble()); 835 ASSERT(instr->right()->representation().IsDouble());
836 ASSERT(op != Token::MOD); 836 ASSERT(op != Token::MOD);
837 LOperand* left = UseRegisterAtStart(instr->left()); 837 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
838 LOperand* right = UseRegisterAtStart(instr->right()); 838 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand());
839 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); 839 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
840 return DefineSameAsFirst(result); 840 return DefineSameAsFirst(result);
841 } 841 }
842 842
843 843
844 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, 844 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op,
845 HArithmeticBinaryOperation* instr) { 845 HArithmeticBinaryOperation* instr) {
846 ASSERT(op == Token::ADD || 846 ASSERT(op == Token::ADD ||
847 op == Token::DIV || 847 op == Token::DIV ||
848 op == Token::MOD || 848 op == Token::MOD ||
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 LInstruction* LChunkBuilder::DoShl(HShl* instr) { 1385 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1386 return DoShift(Token::SHL, instr); 1386 return DoShift(Token::SHL, instr);
1387 } 1387 }
1388 1388
1389 1389
1390 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { 1390 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1391 if (instr->representation().IsInteger32()) { 1391 if (instr->representation().IsInteger32()) {
1392 ASSERT(instr->left()->representation().IsInteger32()); 1392 ASSERT(instr->left()->representation().IsInteger32());
1393 ASSERT(instr->right()->representation().IsInteger32()); 1393 ASSERT(instr->right()->representation().IsInteger32());
1394 1394
1395 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); 1395 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1396 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); 1396 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1397 return DefineSameAsFirst(new(zone()) LBitI(left, right)); 1397 return DefineSameAsFirst(new(zone()) LBitI(left, right));
1398 } else { 1398 } else {
1399 ASSERT(instr->representation().IsTagged()); 1399 ASSERT(instr->representation().IsTagged());
1400 ASSERT(instr->left()->representation().IsTagged()); 1400 ASSERT(instr->left()->representation().IsTagged());
1401 ASSERT(instr->right()->representation().IsTagged()); 1401 ASSERT(instr->right()->representation().IsTagged());
1402 1402
1403 LOperand* context = UseFixed(instr->context(), esi); 1403 LOperand* context = UseFixed(instr->context(), esi);
1404 LOperand* left = UseFixed(instr->left(), edx); 1404 LOperand* left = UseFixed(instr->left(), edx);
1405 LOperand* right = UseFixed(instr->right(), eax); 1405 LOperand* right = UseFixed(instr->right(), eax);
1406 LArithmeticT* result = 1406 LArithmeticT* result =
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); 1553 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right);
1554 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); 1554 return MarkAsCall(DefineFixedDouble(result, xmm1), instr);
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 1558
1559 LInstruction* LChunkBuilder::DoMul(HMul* instr) { 1559 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1560 if (instr->representation().IsInteger32()) { 1560 if (instr->representation().IsInteger32()) {
1561 ASSERT(instr->left()->representation().IsInteger32()); 1561 ASSERT(instr->left()->representation().IsInteger32());
1562 ASSERT(instr->right()->representation().IsInteger32()); 1562 ASSERT(instr->right()->representation().IsInteger32());
1563 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); 1563 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1564 LOperand* right = UseOrConstant(instr->MostConstantOperand()); 1564 LOperand* right = UseOrConstant(instr->BetterRightOperand());
1565 LOperand* temp = NULL; 1565 LOperand* temp = NULL;
1566 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1566 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1567 temp = TempRegister(); 1567 temp = TempRegister();
1568 } 1568 }
1569 LMulI* mul = new(zone()) LMulI(left, right, temp); 1569 LMulI* mul = new(zone()) LMulI(left, right, temp);
1570 if (instr->CheckFlag(HValue::kCanOverflow) || 1570 if (instr->CheckFlag(HValue::kCanOverflow) ||
1571 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1571 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1572 AssignEnvironment(mul); 1572 AssignEnvironment(mul);
1573 } 1573 }
1574 return DefineSameAsFirst(mul); 1574 return DefineSameAsFirst(mul);
(...skipping 22 matching lines...) Expand all
1597 return DoArithmeticD(Token::SUB, instr); 1597 return DoArithmeticD(Token::SUB, instr);
1598 } else { 1598 } else {
1599 ASSERT(instr->representation().IsTagged()); 1599 ASSERT(instr->representation().IsTagged());
1600 return DoArithmeticT(Token::SUB, instr); 1600 return DoArithmeticT(Token::SUB, instr);
1601 } 1601 }
1602 } 1602 }
1603 1603
1604 1604
1605 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { 1605 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1606 if (instr->representation().IsInteger32()) { 1606 if (instr->representation().IsInteger32()) {
1607 // Check to see if it would be advantageous to use an lea instruction rather
1608 // than an add. This is the case when no overflow check is needed and there
1609 // are multiple uses of the add's inputs, so using a 3-register add will
1610 // preserve all input values for later uses.
1611 bool use_lea = LAddI::UseLea(instr);
1607 ASSERT(instr->left()->representation().IsInteger32()); 1612 ASSERT(instr->left()->representation().IsInteger32());
1608 ASSERT(instr->right()->representation().IsInteger32()); 1613 ASSERT(instr->right()->representation().IsInteger32());
1609 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); 1614 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1610 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); 1615 HValue* right_candidate = instr->BetterRightOperand();
1616 LOperand* right = use_lea
1617 ? UseRegisterOrConstantAtStart(right_candidate)
1618 : UseOrConstantAtStart(right_candidate);
1611 LAddI* add = new(zone()) LAddI(left, right); 1619 LAddI* add = new(zone()) LAddI(left, right);
1612 LInstruction* result = DefineSameAsFirst(add); 1620 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
1613 if (instr->CheckFlag(HValue::kCanOverflow)) { 1621 LInstruction* result = use_lea
1622 ? DefineAsRegister(add)
1623 : DefineSameAsFirst(add);
1624 if (can_overflow) {
1614 result = AssignEnvironment(result); 1625 result = AssignEnvironment(result);
1615 } 1626 }
1616 return result; 1627 return result;
1617 } else if (instr->representation().IsDouble()) { 1628 } else if (instr->representation().IsDouble()) {
1618 return DoArithmeticD(Token::ADD, instr); 1629 return DoArithmeticD(Token::ADD, instr);
1619 } else { 1630 } else {
1620 ASSERT(instr->representation().IsTagged()); 1631 ASSERT(instr->representation().IsTagged());
1621 return DoArithmeticT(Token::ADD, instr); 1632 return DoArithmeticT(Token::ADD, instr);
1622 } 1633 }
1623 } 1634 }
1624 1635
1625 1636
1626 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { 1637 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1627 LOperand* left = NULL; 1638 LOperand* left = NULL;
1628 LOperand* right = NULL; 1639 LOperand* right = NULL;
1629 if (instr->representation().IsInteger32()) { 1640 if (instr->representation().IsInteger32()) {
1630 ASSERT(instr->left()->representation().IsInteger32()); 1641 ASSERT(instr->left()->representation().IsInteger32());
1631 ASSERT(instr->right()->representation().IsInteger32()); 1642 ASSERT(instr->right()->representation().IsInteger32());
1632 left = UseRegisterAtStart(instr->LeastConstantOperand()); 1643 left = UseRegisterAtStart(instr->BetterLeftOperand());
1633 right = UseOrConstantAtStart(instr->MostConstantOperand()); 1644 right = UseOrConstantAtStart(instr->BetterRightOperand());
1634 } else { 1645 } else {
1635 ASSERT(instr->representation().IsDouble()); 1646 ASSERT(instr->representation().IsDouble());
1636 ASSERT(instr->left()->representation().IsDouble()); 1647 ASSERT(instr->left()->representation().IsDouble());
1637 ASSERT(instr->right()->representation().IsDouble()); 1648 ASSERT(instr->right()->representation().IsDouble());
1638 left = UseRegisterAtStart(instr->left()); 1649 left = UseRegisterAtStart(instr->left());
1639 right = UseRegisterAtStart(instr->right()); 1650 right = UseRegisterAtStart(instr->right());
1640 } 1651 }
1641 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); 1652 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right);
1642 return DefineSameAsFirst(minmax); 1653 return DefineSameAsFirst(minmax);
1643 } 1654 }
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2776 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2766 LOperand* object = UseRegister(instr->object()); 2777 LOperand* object = UseRegister(instr->object());
2767 LOperand* index = UseTempRegister(instr->index()); 2778 LOperand* index = UseTempRegister(instr->index());
2768 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2779 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2769 } 2780 }
2770 2781
2771 2782
2772 } } // namespace v8::internal 2783 } } // namespace v8::internal
2773 2784
2774 #endif // V8_TARGET_ARCH_IA32 2785 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/mips/lithium-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698