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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 return does_deopt ? AssignEnvironment(result) : result; | 775 return does_deopt ? AssignEnvironment(result) : result; |
776 } | 776 } |
777 | 777 |
778 | 778 |
779 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 779 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
780 HArithmeticBinaryOperation* instr) { | 780 HArithmeticBinaryOperation* instr) { |
781 ASSERT(instr->representation().IsDouble()); | 781 ASSERT(instr->representation().IsDouble()); |
782 ASSERT(instr->left()->representation().IsDouble()); | 782 ASSERT(instr->left()->representation().IsDouble()); |
783 ASSERT(instr->right()->representation().IsDouble()); | 783 ASSERT(instr->right()->representation().IsDouble()); |
784 ASSERT(op != Token::MOD); | 784 ASSERT(op != Token::MOD); |
785 LOperand* left = UseRegisterAtStart(instr->left()); | 785 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
786 LOperand* right = UseRegisterAtStart(instr->right()); | 786 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
787 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | 787 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
788 return DefineSameAsFirst(result); | 788 return DefineSameAsFirst(result); |
789 } | 789 } |
790 | 790 |
791 | 791 |
792 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 792 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
793 HArithmeticBinaryOperation* instr) { | 793 HArithmeticBinaryOperation* instr) { |
794 ASSERT(op == Token::ADD || | 794 ASSERT(op == Token::ADD || |
795 op == Token::DIV || | 795 op == Token::DIV || |
796 op == Token::MOD || | 796 op == Token::MOD || |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | 1302 LInstruction* LChunkBuilder::DoShl(HShl* instr) { |
1303 return DoShift(Token::SHL, instr); | 1303 return DoShift(Token::SHL, instr); |
1304 } | 1304 } |
1305 | 1305 |
1306 | 1306 |
1307 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1307 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
1308 if (instr->representation().IsInteger32()) { | 1308 if (instr->representation().IsInteger32()) { |
1309 ASSERT(instr->left()->representation().IsInteger32()); | 1309 ASSERT(instr->left()->representation().IsInteger32()); |
1310 ASSERT(instr->right()->representation().IsInteger32()); | 1310 ASSERT(instr->right()->representation().IsInteger32()); |
1311 | 1311 |
1312 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1312 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1313 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1313 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1314 return DefineSameAsFirst(new(zone()) LBitI(left, right)); | 1314 return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
1315 } else { | 1315 } else { |
1316 ASSERT(instr->representation().IsTagged()); | 1316 ASSERT(instr->representation().IsTagged()); |
1317 ASSERT(instr->left()->representation().IsTagged()); | 1317 ASSERT(instr->left()->representation().IsTagged()); |
1318 ASSERT(instr->right()->representation().IsTagged()); | 1318 ASSERT(instr->right()->representation().IsTagged()); |
1319 | 1319 |
1320 LOperand* left = UseFixed(instr->left(), rdx); | 1320 LOperand* left = UseFixed(instr->left(), rdx); |
1321 LOperand* right = UseFixed(instr->right(), rax); | 1321 LOperand* right = UseFixed(instr->right(), rax); |
1322 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1322 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
1323 return MarkAsCall(DefineFixed(result, rax), instr); | 1323 return MarkAsCall(DefineFixed(result, rax), instr); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1466 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); | 1466 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); |
1467 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); | 1467 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
1468 } | 1468 } |
1469 } | 1469 } |
1470 | 1470 |
1471 | 1471 |
1472 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1472 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
1473 if (instr->representation().IsInteger32()) { | 1473 if (instr->representation().IsInteger32()) { |
1474 ASSERT(instr->left()->representation().IsInteger32()); | 1474 ASSERT(instr->left()->representation().IsInteger32()); |
1475 ASSERT(instr->right()->representation().IsInteger32()); | 1475 ASSERT(instr->right()->representation().IsInteger32()); |
1476 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1476 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1477 LOperand* right = UseOrConstant(instr->MostConstantOperand()); | 1477 LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
1478 LMulI* mul = new(zone()) LMulI(left, right); | 1478 LMulI* mul = new(zone()) LMulI(left, right); |
1479 if (instr->CheckFlag(HValue::kCanOverflow) || | 1479 if (instr->CheckFlag(HValue::kCanOverflow) || |
1480 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1480 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1481 AssignEnvironment(mul); | 1481 AssignEnvironment(mul); |
1482 } | 1482 } |
1483 return DefineSameAsFirst(mul); | 1483 return DefineSameAsFirst(mul); |
1484 } else if (instr->representation().IsDouble()) { | 1484 } else if (instr->representation().IsDouble()) { |
1485 return DoArithmeticD(Token::MUL, instr); | 1485 return DoArithmeticD(Token::MUL, instr); |
1486 } else { | 1486 } else { |
1487 ASSERT(instr->representation().IsTagged()); | 1487 ASSERT(instr->representation().IsTagged()); |
(...skipping 18 matching lines...) Expand all Loading... | |
1506 return DoArithmeticD(Token::SUB, instr); | 1506 return DoArithmeticD(Token::SUB, instr); |
1507 } else { | 1507 } else { |
1508 ASSERT(instr->representation().IsTagged()); | 1508 ASSERT(instr->representation().IsTagged()); |
1509 return DoArithmeticT(Token::SUB, instr); | 1509 return DoArithmeticT(Token::SUB, instr); |
1510 } | 1510 } |
1511 } | 1511 } |
1512 | 1512 |
1513 | 1513 |
1514 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1514 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
1515 if (instr->representation().IsInteger32()) { | 1515 if (instr->representation().IsInteger32()) { |
1516 // Check to see if it would be advantageous to use an lea instruction rather | |
1517 // than an add. This is the case when no overflow check is needed and are | |
1518 // multiple uses of the add's inputs, so using a 3-register add will | |
1519 // preserve all input values for later uses. | |
1520 bool use_lea = LAddI::UseLea(instr); | |
1516 ASSERT(instr->left()->representation().IsInteger32()); | 1521 ASSERT(instr->left()->representation().IsInteger32()); |
1517 ASSERT(instr->right()->representation().IsInteger32()); | 1522 ASSERT(instr->right()->representation().IsInteger32()); |
1518 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1523 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1519 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1524 HValue* right_candidate = instr->BetterRightOperand(); |
1525 LOperand* right = use_lea | |
1526 ? UseRegisterOrConstantAtStart(right_candidate) | |
1527 : UseOrConstantAtStart(right_candidate); | |
1520 LAddI* add = new(zone()) LAddI(left, right); | 1528 LAddI* add = new(zone()) LAddI(left, right); |
1521 LInstruction* result = DefineSameAsFirst(add); | 1529 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
1530 LInstruction* result = NULL; | |
1531 if (use_lea) { | |
1532 result = DefineAsRegister(add); | |
1533 } else { | |
1534 result = DefineSameAsFirst(add); | |
1535 } | |
1536 if (can_overflow) { | |
1537 result = AssignEnvironment(result); | |
1538 } | |
1522 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1539 if (instr->CheckFlag(HValue::kCanOverflow)) { |
Jakob Kummerow
2013/05/07 11:53:58
This condition is now a dupe of the above.
danno
2013/05/08 08:37:18
Done.
| |
1523 result = AssignEnvironment(result); | 1540 result = AssignEnvironment(result); |
1524 } | 1541 } |
1525 return result; | 1542 return result; |
1526 } else if (instr->representation().IsDouble()) { | 1543 } else if (instr->representation().IsDouble()) { |
1527 return DoArithmeticD(Token::ADD, instr); | 1544 return DoArithmeticD(Token::ADD, instr); |
1528 } else { | 1545 } else { |
1529 ASSERT(instr->representation().IsTagged()); | 1546 ASSERT(instr->representation().IsTagged()); |
1530 return DoArithmeticT(Token::ADD, instr); | 1547 return DoArithmeticT(Token::ADD, instr); |
1531 } | 1548 } |
1532 return NULL; | 1549 return NULL; |
1533 } | 1550 } |
1534 | 1551 |
1535 | 1552 |
1536 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1553 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
1537 LOperand* left = NULL; | 1554 LOperand* left = NULL; |
1538 LOperand* right = NULL; | 1555 LOperand* right = NULL; |
1539 if (instr->representation().IsInteger32()) { | 1556 if (instr->representation().IsInteger32()) { |
1540 ASSERT(instr->left()->representation().IsInteger32()); | 1557 ASSERT(instr->left()->representation().IsInteger32()); |
1541 ASSERT(instr->right()->representation().IsInteger32()); | 1558 ASSERT(instr->right()->representation().IsInteger32()); |
1542 left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1559 left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1543 right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1560 right = UseOrConstantAtStart(instr->BetterRightOperand()); |
1544 } else { | 1561 } else { |
1545 ASSERT(instr->representation().IsDouble()); | 1562 ASSERT(instr->representation().IsDouble()); |
1546 ASSERT(instr->left()->representation().IsDouble()); | 1563 ASSERT(instr->left()->representation().IsDouble()); |
1547 ASSERT(instr->right()->representation().IsDouble()); | 1564 ASSERT(instr->right()->representation().IsDouble()); |
1548 left = UseRegisterAtStart(instr->left()); | 1565 left = UseRegisterAtStart(instr->left()); |
1549 right = UseRegisterAtStart(instr->right()); | 1566 right = UseRegisterAtStart(instr->right()); |
1550 } | 1567 } |
1551 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); | 1568 LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); |
1552 return DefineSameAsFirst(minmax); | 1569 return DefineSameAsFirst(minmax); |
1553 } | 1570 } |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2556 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2573 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2557 LOperand* object = UseRegister(instr->object()); | 2574 LOperand* object = UseRegister(instr->object()); |
2558 LOperand* index = UseTempRegister(instr->index()); | 2575 LOperand* index = UseTempRegister(instr->index()); |
2559 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2576 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2560 } | 2577 } |
2561 | 2578 |
2562 | 2579 |
2563 } } // namespace v8::internal | 2580 } } // namespace v8::internal |
2564 | 2581 |
2565 #endif // V8_TARGET_ARCH_X64 | 2582 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |