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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 DefineSameAsFirst(new(zone()) LShiftI(op, left, right, does_deopt)); | 802 DefineSameAsFirst(new(zone()) LShiftI(op, left, right, does_deopt)); |
803 return does_deopt ? AssignEnvironment(result) : result; | 803 return does_deopt ? AssignEnvironment(result) : result; |
804 } | 804 } |
805 | 805 |
806 | 806 |
807 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 807 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
808 HArithmeticBinaryOperation* instr) { | 808 HArithmeticBinaryOperation* instr) { |
809 ASSERT(instr->representation().IsDouble()); | 809 ASSERT(instr->representation().IsDouble()); |
810 ASSERT(instr->left()->representation().IsDouble()); | 810 ASSERT(instr->left()->representation().IsDouble()); |
811 ASSERT(instr->right()->representation().IsDouble()); | 811 ASSERT(instr->right()->representation().IsDouble()); |
| 812 ASSERT(op != Token::MOD); |
812 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 813 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
813 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); | 814 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand()); |
814 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | 815 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
815 // We call a C function for double modulo. It can't trigger a GC. | |
816 if (op == Token::MOD) return MarkAsCall(DefineAsRegister(result), instr); | |
817 return DefineSameAsFirst(result); | 816 return DefineSameAsFirst(result); |
818 } | 817 } |
819 | 818 |
820 | 819 |
821 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 820 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
822 HArithmeticBinaryOperation* instr) { | 821 HArithmeticBinaryOperation* instr) { |
823 ASSERT(op == Token::ADD || | 822 ASSERT(op == Token::ADD || |
824 op == Token::DIV || | 823 op == Token::DIV || |
825 op == Token::MOD || | 824 op == Token::MOD || |
826 op == Token::MUL || | 825 op == Token::MUL || |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 (left->CanBeNegative() && | 1556 (left->CanBeNegative() && |
1558 instr->CanBeZero() && | 1557 instr->CanBeZero() && |
1559 instr->CheckFlag(HValue::kBailoutOnMinusZero))) | 1558 instr->CheckFlag(HValue::kBailoutOnMinusZero))) |
1560 ? AssignEnvironment(result) | 1559 ? AssignEnvironment(result) |
1561 : result; | 1560 : result; |
1562 } | 1561 } |
1563 } else if (instr->representation().IsSmiOrTagged()) { | 1562 } else if (instr->representation().IsSmiOrTagged()) { |
1564 return DoArithmeticT(Token::MOD, instr); | 1563 return DoArithmeticT(Token::MOD, instr); |
1565 } else { | 1564 } else { |
1566 ASSERT(instr->representation().IsDouble()); | 1565 ASSERT(instr->representation().IsDouble()); |
1567 return DoArithmeticD(Token::MOD, instr); | 1566 // We call a C function for double modulo. It can't trigger a GC. We need |
| 1567 // to use fixed result register for the call. |
| 1568 // TODO(fschneider): Allow any register as input registers. |
| 1569 LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD, |
| 1570 UseFixedDouble(left, xmm2), |
| 1571 UseFixedDouble(right, xmm1)); |
| 1572 return MarkAsCall(DefineFixedDouble(mod, xmm1), instr); |
1568 } | 1573 } |
1569 } | 1574 } |
1570 | 1575 |
1571 | 1576 |
1572 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1577 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
1573 if (instr->representation().IsSmiOrInteger32()) { | 1578 if (instr->representation().IsSmiOrInteger32()) { |
1574 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1579 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1575 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1580 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1576 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1581 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
1577 LOperand* right = UseOrConstant(instr->BetterRightOperand()); | 1582 LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2749 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2745 LOperand* object = UseRegister(instr->object()); | 2750 LOperand* object = UseRegister(instr->object()); |
2746 LOperand* index = UseTempRegister(instr->index()); | 2751 LOperand* index = UseTempRegister(instr->index()); |
2747 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2752 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2748 } | 2753 } |
2749 | 2754 |
2750 | 2755 |
2751 } } // namespace v8::internal | 2756 } } // namespace v8::internal |
2752 | 2757 |
2753 #endif // V8_TARGET_ARCH_IA32 | 2758 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |