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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 } | 701 } |
702 | 702 |
703 | 703 |
704 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | 704 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
705 return AssignEnvironment(new(zone()) LDeoptimize); | 705 return AssignEnvironment(new(zone()) LDeoptimize); |
706 } | 706 } |
707 | 707 |
708 | 708 |
709 LInstruction* LChunkBuilder::DoShift(Token::Value op, | 709 LInstruction* LChunkBuilder::DoShift(Token::Value op, |
710 HBitwiseBinaryOperation* instr) { | 710 HBitwiseBinaryOperation* instr) { |
711 if (instr->representation().IsSmiOrTagged()) { | 711 if (instr->representation().IsTagged()) { |
712 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 712 ASSERT(instr->left()->representation().IsTagged()); |
713 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 713 ASSERT(instr->right()->representation().IsTagged()); |
714 | 714 |
715 LOperand* left = UseFixed(instr->left(), r1); | 715 LOperand* left = UseFixed(instr->left(), r1); |
716 LOperand* right = UseFixed(instr->right(), r0); | 716 LOperand* right = UseFixed(instr->right(), r0); |
717 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); | 717 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); |
718 return MarkAsCall(DefineFixed(result, r0), instr); | 718 return MarkAsCall(DefineFixed(result, r0), instr); |
719 } | 719 } |
720 | 720 |
721 ASSERT(instr->representation().IsInteger32()); | 721 ASSERT(instr->representation().IsSmiOrInteger32()); |
722 ASSERT(instr->left()->representation().IsInteger32()); | 722 ASSERT(instr->left()->representation().Equals(instr->representation())); |
723 ASSERT(instr->right()->representation().IsInteger32()); | 723 ASSERT(instr->right()->representation().Equals(instr->representation())); |
724 LOperand* left = UseRegisterAtStart(instr->left()); | 724 LOperand* left = UseRegisterAtStart(instr->left()); |
725 | 725 |
726 HValue* right_value = instr->right(); | 726 HValue* right_value = instr->right(); |
727 LOperand* right = NULL; | 727 LOperand* right = NULL; |
728 int constant_value = 0; | 728 int constant_value = 0; |
| 729 bool does_deopt = false; |
729 if (right_value->IsConstant()) { | 730 if (right_value->IsConstant()) { |
730 HConstant* constant = HConstant::cast(right_value); | 731 HConstant* constant = HConstant::cast(right_value); |
731 right = chunk_->DefineConstantOperand(constant); | 732 right = chunk_->DefineConstantOperand(constant); |
732 constant_value = constant->Integer32Value() & 0x1f; | 733 constant_value = constant->Integer32Value() & 0x1f; |
| 734 // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| 735 // truncated to smi. |
| 736 if (instr->representation().IsSmi() && constant_value > 0) { |
| 737 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
| 738 if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { |
| 739 does_deopt = true; |
| 740 break; |
| 741 } |
| 742 } |
| 743 } |
733 } else { | 744 } else { |
734 right = UseRegisterAtStart(right_value); | 745 right = UseRegisterAtStart(right_value); |
735 } | 746 } |
736 | 747 |
737 // Shift operations can only deoptimize if we do a logical shift | 748 // Shift operations can only deoptimize if we do a logical shift |
738 // by 0 and the result cannot be truncated to int32. | 749 // by 0 and the result cannot be truncated to int32. |
739 bool does_deopt = false; | |
740 if (op == Token::SHR && constant_value == 0) { | 750 if (op == Token::SHR && constant_value == 0) { |
741 if (FLAG_opt_safe_uint32_operations) { | 751 if (FLAG_opt_safe_uint32_operations) { |
742 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | 752 does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
743 } else { | 753 } else { |
744 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | 754 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
745 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { | 755 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
746 does_deopt = true; | 756 does_deopt = true; |
747 break; | 757 break; |
748 } | 758 } |
749 } | 759 } |
(...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 | 2646 |
2637 | 2647 |
2638 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2648 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2639 LOperand* object = UseRegister(instr->object()); | 2649 LOperand* object = UseRegister(instr->object()); |
2640 LOperand* index = UseRegister(instr->index()); | 2650 LOperand* index = UseRegister(instr->index()); |
2641 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2651 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2642 } | 2652 } |
2643 | 2653 |
2644 | 2654 |
2645 } } // namespace v8::internal | 2655 } } // namespace v8::internal |
OLD | NEW |