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(1))); | |
Jakob Kummerow
2013/10/01 11:59:20
OperandAt(i)
danno
2013/10/23 11:46:51
Done.
| |
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 #if DEBUG | 881 #if DEBUG |
867 // Make sure that the lithium instruction has either no fixed register | 882 // Make sure that the lithium instruction has either no fixed register |
868 // constraints in temps or the result OR no uses that are only used at | 883 // constraints in temps or the result OR no uses that are only used at |
869 // start. If this invariant doesn't hold, the register allocator can decide | 884 // start. If this invariant doesn't hold, the register allocator can decide |
870 // to insert a split of a range immediately before the instruction due to an | 885 // to insert a split of a range immediately before the instruction due to an |
871 // already allocated register needing to be used for the instruction's fixed | 886 // already allocated register needing to be used for the instruction's fixed |
872 // register constraint. In this case, The register allocator won't see an | 887 // register constraint. In this case, The register allocator won't see an |
873 // interference between the split child and the use-at-start (it would if | 888 // interference between the split child and the use-at-start (it would if |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 | 999 |
985 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 1000 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
986 *argument_index_accumulator = argument_index; | 1001 *argument_index_accumulator = argument_index; |
987 } | 1002 } |
988 | 1003 |
989 return result; | 1004 return result; |
990 } | 1005 } |
991 | 1006 |
992 | 1007 |
993 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 1008 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
994 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 1009 return new(zone()) LGoto(instr->FirstSuccessor()); |
995 } | 1010 } |
996 | 1011 |
997 | 1012 |
998 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 1013 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
1014 LInstruction* goto_instr = CheckElideControlInstruction(instr); | |
1015 if (goto_instr != NULL) return goto_instr; | |
1016 | |
999 HValue* value = instr->value(); | 1017 HValue* value = instr->value(); |
1000 if (value->EmitAtUses()) { | |
1001 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() | |
1002 ? instr->FirstSuccessor() | |
1003 : instr->SecondSuccessor(); | |
1004 return new(zone()) LGoto(successor->block_id()); | |
1005 } | |
1006 | |
1007 LBranch* result = new(zone()) LBranch(UseRegister(value)); | 1018 LBranch* result = new(zone()) LBranch(UseRegister(value)); |
1008 // Tagged values that are not known smis or booleans require a | 1019 // Tagged values that are not known smis or booleans require a |
1009 // deoptimization environment. If the instruction is generic no | 1020 // deoptimization environment. If the instruction is generic no |
1010 // environment is needed since all cases are handled. | 1021 // environment is needed since all cases are handled. |
1011 Representation rep = value->representation(); | 1022 Representation rep = value->representation(); |
1012 HType type = value->type(); | 1023 HType type = value->type(); |
1013 ToBooleanStub::Types expected = instr->expected_input_types(); | 1024 ToBooleanStub::Types expected = instr->expected_input_types(); |
1014 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean() && | 1025 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean() && |
1015 !expected.IsGeneric()) { | 1026 !expected.IsGeneric()) { |
1016 return AssignEnvironment(result); | 1027 return AssignEnvironment(result); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1760 ASSERT(instr->right()->representation().IsDouble()); | 1771 ASSERT(instr->right()->representation().IsDouble()); |
1761 LOperand* left = UseRegisterAtStart(instr->left()); | 1772 LOperand* left = UseRegisterAtStart(instr->left()); |
1762 LOperand* right = UseRegisterAtStart(instr->right()); | 1773 LOperand* right = UseRegisterAtStart(instr->right()); |
1763 return new(zone()) LCompareNumericAndBranch(left, right); | 1774 return new(zone()) LCompareNumericAndBranch(left, right); |
1764 } | 1775 } |
1765 } | 1776 } |
1766 | 1777 |
1767 | 1778 |
1768 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( | 1779 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( |
1769 HCompareObjectEqAndBranch* instr) { | 1780 HCompareObjectEqAndBranch* instr) { |
1781 LInstruction* goto_instr = CheckElideControlInstruction(instr); | |
1782 if (goto_instr != NULL) return goto_instr; | |
1770 LOperand* left = UseRegisterAtStart(instr->left()); | 1783 LOperand* left = UseRegisterAtStart(instr->left()); |
1771 LOperand* right = UseRegisterAtStart(instr->right()); | 1784 LOperand* right = UseRegisterAtStart(instr->right()); |
1772 return new(zone()) LCmpObjectEqAndBranch(left, right); | 1785 return new(zone()) LCmpObjectEqAndBranch(left, right); |
1773 } | 1786 } |
1774 | 1787 |
1775 | 1788 |
1776 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( | 1789 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( |
1777 HCompareHoleAndBranch* instr) { | 1790 HCompareHoleAndBranch* instr) { |
1778 LOperand* value = UseRegisterAtStart(instr->value()); | 1791 LOperand* value = UseRegisterAtStart(instr->value()); |
1779 return new(zone()) LCmpHoleAndBranch(value); | 1792 return new(zone()) LCmpHoleAndBranch(value); |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2659 | 2672 |
2660 | 2673 |
2661 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2674 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2662 LOperand* object = UseRegister(instr->object()); | 2675 LOperand* object = UseRegister(instr->object()); |
2663 LOperand* index = UseRegister(instr->index()); | 2676 LOperand* index = UseRegister(instr->index()); |
2664 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2677 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2665 } | 2678 } |
2666 | 2679 |
2667 | 2680 |
2668 } } // namespace v8::internal | 2681 } } // namespace v8::internal |
OLD | NEW |