Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1208)

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 22876009: Improve and simplify removal of unreachable code (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review feedback Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/lithium.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 block->set_argument_count(argument_count_); 902 block->set_argument_count(argument_count_);
903 next_block_ = NULL; 903 next_block_ = NULL;
904 current_block_ = NULL; 904 current_block_ = NULL;
905 } 905 }
906 906
907 907
908 void LChunkBuilder::VisitInstruction(HInstruction* current) { 908 void LChunkBuilder::VisitInstruction(HInstruction* current) {
909 HInstruction* old_current = current_instruction_; 909 HInstruction* old_current = current_instruction_;
910 current_instruction_ = current; 910 current_instruction_ = current;
911 if (current->has_position()) position_ = current->position(); 911 if (current->has_position()) position_ = current->position();
912 LInstruction* instr = current->CompileToLithium(this); 912
913 LInstruction* instr = NULL;
914 if (current->CanReplaceWithDummyUses()) {
915 HValue* first_operand = current->OperandCount() == 0
916 ? graph()->GetConstant1()
917 : current->OperandAt(0);
918 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand)));
919 for (int i = 1; i < current->OperandCount(); ++i) {
920 LInstruction* dummy =
921 new(zone()) LDummyUse(UseAny(current->OperandAt(i)));
922 dummy->set_hydrogen_value(current);
923 chunk_->AddInstruction(dummy, current_block_);
924 }
925 } else {
926 instr = current->CompileToLithium(this);
927 }
913 928
914 if (instr != NULL) { 929 if (instr != NULL) {
915 // Associate the hydrogen instruction first, since we may need it for 930 // Associate the hydrogen instruction first, since we may need it for
916 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. 931 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below.
917 instr->set_hydrogen_value(current); 932 instr->set_hydrogen_value(current);
918 933
919 #if DEBUG 934 #if DEBUG
920 // Make sure that the lithium instruction has either no fixed register 935 // Make sure that the lithium instruction has either no fixed register
921 // constraints in temps or the result OR no uses that are only used at 936 // constraints in temps or the result OR no uses that are only used at
922 // start. If this invariant doesn't hold, the register allocator can decide 937 // start. If this invariant doesn't hold, the register allocator can decide
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 return result; 1066 return result;
1052 } 1067 }
1053 1068
1054 1069
1055 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 1070 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
1056 return new(zone()) LGoto(instr->FirstSuccessor()); 1071 return new(zone()) LGoto(instr->FirstSuccessor());
1057 } 1072 }
1058 1073
1059 1074
1060 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { 1075 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
1061 HValue* value = instr->value(); 1076 LInstruction* goto_instr = CheckElideControlInstruction(instr);
1062 if (value->EmitAtUses()) { 1077 if (goto_instr != NULL) return goto_instr;
1063 ASSERT(value->IsConstant());
1064 ASSERT(!value->representation().IsDouble());
1065 HBasicBlock* successor = HConstant::cast(value)->BooleanValue()
1066 ? instr->FirstSuccessor()
1067 : instr->SecondSuccessor();
1068 return new(zone()) LGoto(successor);
1069 }
1070 1078
1071 ToBooleanStub::Types expected = instr->expected_input_types(); 1079 ToBooleanStub::Types expected = instr->expected_input_types();
1072 1080
1073 // Tagged values that are not known smis or booleans require a 1081 // Tagged values that are not known smis or booleans require a
1074 // deoptimization environment. If the instruction is generic no 1082 // deoptimization environment. If the instruction is generic no
1075 // environment is needed since all cases are handled. 1083 // environment is needed since all cases are handled.
1084 HValue* value = instr->value();
1076 Representation rep = value->representation(); 1085 Representation rep = value->representation();
1077 HType type = value->type(); 1086 HType type = value->type();
1078 if (!rep.IsTagged() || type.IsSmi() || type.IsBoolean()) { 1087 if (!rep.IsTagged() || type.IsSmi() || type.IsBoolean()) {
1079 return new(zone()) LBranch(UseRegister(value), NULL); 1088 return new(zone()) LBranch(UseRegister(value), NULL);
1080 } 1089 }
1081 1090
1082 bool needs_temp = expected.NeedsMap() || expected.IsEmpty(); 1091 bool needs_temp = expected.NeedsMap() || expected.IsEmpty();
1083 LOperand* temp = needs_temp ? TempRegister() : NULL; 1092 LOperand* temp = needs_temp ? TempRegister() : NULL;
1084 1093
1085 // The Generic stub does not have a deopt, so we need no environment. 1094 // The Generic stub does not have a deopt, so we need no environment.
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 left = UseRegisterAtStart(instr->left()); 1746 left = UseRegisterAtStart(instr->left());
1738 right = UseRegisterAtStart(instr->right()); 1747 right = UseRegisterAtStart(instr->right());
1739 } 1748 }
1740 return new(zone()) LCompareNumericAndBranch(left, right); 1749 return new(zone()) LCompareNumericAndBranch(left, right);
1741 } 1750 }
1742 } 1751 }
1743 1752
1744 1753
1745 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( 1754 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch(
1746 HCompareObjectEqAndBranch* instr) { 1755 HCompareObjectEqAndBranch* instr) {
1756 LInstruction* goto_instr = CheckElideControlInstruction(instr);
1757 if (goto_instr != NULL) return goto_instr;
1747 LOperand* left = UseRegisterAtStart(instr->left()); 1758 LOperand* left = UseRegisterAtStart(instr->left());
1748 LOperand* right = UseOrConstantAtStart(instr->right()); 1759 LOperand* right = UseOrConstantAtStart(instr->right());
1749 return new(zone()) LCmpObjectEqAndBranch(left, right); 1760 return new(zone()) LCmpObjectEqAndBranch(left, right);
1750 } 1761 }
1751 1762
1752 1763
1753 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( 1764 LInstruction* LChunkBuilder::DoCompareHoleAndBranch(
1754 HCompareHoleAndBranch* instr) { 1765 HCompareHoleAndBranch* instr) {
1755 LOperand* value = UseRegisterAtStart(instr->value()); 1766 LOperand* value = UseRegisterAtStart(instr->value());
1756 return new(zone()) LCmpHoleAndBranch(value); 1767 return new(zone()) LCmpHoleAndBranch(value);
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2741 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2731 LOperand* object = UseRegister(instr->object()); 2742 LOperand* object = UseRegister(instr->object());
2732 LOperand* index = UseTempRegister(instr->index()); 2743 LOperand* index = UseTempRegister(instr->index());
2733 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2744 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2734 } 2745 }
2735 2746
2736 2747
2737 } } // namespace v8::internal 2748 } } // namespace v8::internal
2738 2749
2739 #endif // V8_TARGET_ARCH_IA32 2750 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/lithium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698