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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 block->set_argument_count(argument_count_); | 853 block->set_argument_count(argument_count_); |
854 next_block_ = NULL; | 854 next_block_ = NULL; |
855 current_block_ = NULL; | 855 current_block_ = NULL; |
856 } | 856 } |
857 | 857 |
858 | 858 |
859 void LChunkBuilder::VisitInstruction(HInstruction* current) { | 859 void LChunkBuilder::VisitInstruction(HInstruction* current) { |
860 HInstruction* old_current = current_instruction_; | 860 HInstruction* old_current = current_instruction_; |
861 current_instruction_ = current; | 861 current_instruction_ = current; |
862 if (current->has_position()) position_ = current->position(); | 862 if (current->has_position()) position_ = current->position(); |
863 LInstruction* instr = current->CompileToLithium(this); | 863 |
| 864 LInstruction* instr = NULL; |
| 865 if (current->CanReplaceWithDummyUses()) { |
| 866 HValue* first_operand = current->OperandCount() == 0 |
| 867 ? graph()->GetConstant1() |
| 868 : current->OperandAt(0); |
| 869 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); |
| 870 for (int i = 1; i < current->OperandCount(); ++i) { |
| 871 LInstruction* dummy = |
| 872 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
| 873 dummy->set_hydrogen_value(current); |
| 874 chunk_->AddInstruction(dummy, current_block_); |
| 875 } |
| 876 } else { |
| 877 instr = current->CompileToLithium(this); |
| 878 } |
864 | 879 |
865 if (instr != NULL) { | 880 if (instr != NULL) { |
866 // Associate the hydrogen instruction first, since we may need it for | 881 // Associate the hydrogen instruction first, since we may need it for |
867 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. | 882 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. |
868 instr->set_hydrogen_value(current); | 883 instr->set_hydrogen_value(current); |
869 | 884 |
870 #if DEBUG | 885 #if DEBUG |
871 // Make sure that the lithium instruction has either no fixed register | 886 // Make sure that the lithium instruction has either no fixed register |
872 // constraints in temps or the result OR no uses that are only used at | 887 // constraints in temps or the result OR no uses that are only used at |
873 // start. If this invariant doesn't hold, the register allocator can decide | 888 // start. If this invariant doesn't hold, the register allocator can decide |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 | 1002 |
988 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 1003 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
989 *argument_index_accumulator = argument_index; | 1004 *argument_index_accumulator = argument_index; |
990 } | 1005 } |
991 | 1006 |
992 return result; | 1007 return result; |
993 } | 1008 } |
994 | 1009 |
995 | 1010 |
996 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 1011 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
997 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 1012 return new(zone()) LGoto(instr->FirstSuccessor()); |
998 } | 1013 } |
999 | 1014 |
1000 | 1015 |
1001 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 1016 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
| 1017 LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1018 if (goto_instr != NULL) return goto_instr; |
| 1019 |
1002 HValue* value = instr->value(); | 1020 HValue* value = instr->value(); |
1003 if (value->EmitAtUses()) { | |
1004 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() | |
1005 ? instr->FirstSuccessor() | |
1006 : instr->SecondSuccessor(); | |
1007 return new(zone()) LGoto(successor->block_id()); | |
1008 } | |
1009 | |
1010 LBranch* result = new(zone()) LBranch(UseRegister(value)); | 1021 LBranch* result = new(zone()) LBranch(UseRegister(value)); |
1011 // Tagged values that are not known smis or booleans require a | 1022 // Tagged values that are not known smis or booleans require a |
1012 // deoptimization environment. If the instruction is generic no | 1023 // deoptimization environment. If the instruction is generic no |
1013 // environment is needed since all cases are handled. | 1024 // environment is needed since all cases are handled. |
1014 Representation rep = value->representation(); | 1025 Representation rep = value->representation(); |
1015 HType type = value->type(); | 1026 HType type = value->type(); |
1016 ToBooleanStub::Types expected = instr->expected_input_types(); | 1027 ToBooleanStub::Types expected = instr->expected_input_types(); |
1017 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean() && | 1028 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean() && |
1018 !expected.IsGeneric()) { | 1029 !expected.IsGeneric()) { |
1019 return AssignEnvironment(result); | 1030 return AssignEnvironment(result); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 ASSERT(instr->right()->representation().IsDouble()); | 1774 ASSERT(instr->right()->representation().IsDouble()); |
1764 LOperand* left = UseRegisterAtStart(instr->left()); | 1775 LOperand* left = UseRegisterAtStart(instr->left()); |
1765 LOperand* right = UseRegisterAtStart(instr->right()); | 1776 LOperand* right = UseRegisterAtStart(instr->right()); |
1766 return new(zone()) LCompareNumericAndBranch(left, right); | 1777 return new(zone()) LCompareNumericAndBranch(left, right); |
1767 } | 1778 } |
1768 } | 1779 } |
1769 | 1780 |
1770 | 1781 |
1771 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( | 1782 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( |
1772 HCompareObjectEqAndBranch* instr) { | 1783 HCompareObjectEqAndBranch* instr) { |
| 1784 LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1785 if (goto_instr != NULL) return goto_instr; |
1773 LOperand* left = UseRegisterAtStart(instr->left()); | 1786 LOperand* left = UseRegisterAtStart(instr->left()); |
1774 LOperand* right = UseRegisterAtStart(instr->right()); | 1787 LOperand* right = UseRegisterAtStart(instr->right()); |
1775 return new(zone()) LCmpObjectEqAndBranch(left, right); | 1788 return new(zone()) LCmpObjectEqAndBranch(left, right); |
1776 } | 1789 } |
1777 | 1790 |
1778 | 1791 |
1779 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( | 1792 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( |
1780 HCompareHoleAndBranch* instr) { | 1793 HCompareHoleAndBranch* instr) { |
1781 LOperand* value = UseRegisterAtStart(instr->value()); | 1794 LOperand* value = UseRegisterAtStart(instr->value()); |
1782 return new(zone()) LCmpHoleAndBranch(value); | 1795 return new(zone()) LCmpHoleAndBranch(value); |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 | 2675 |
2663 | 2676 |
2664 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2677 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2665 LOperand* object = UseRegister(instr->object()); | 2678 LOperand* object = UseRegister(instr->object()); |
2666 LOperand* index = UseRegister(instr->index()); | 2679 LOperand* index = UseRegister(instr->index()); |
2667 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2680 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2668 } | 2681 } |
2669 | 2682 |
2670 | 2683 |
2671 } } // namespace v8::internal | 2684 } } // namespace v8::internal |
OLD | NEW |