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

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

Issue 7055006: Refactoring only: Simplified LChunkBuilder:DoTest a bit, making it a simple if-then-else cascade. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 7 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 | « no previous file | src/ia32/lithium-ia32.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 1043 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
1044 LInstruction* result = new LGoto(instr->FirstSuccessor()->block_id(), 1044 LInstruction* result = new LGoto(instr->FirstSuccessor()->block_id(),
1045 instr->include_stack_check()); 1045 instr->include_stack_check());
1046 if (instr->include_stack_check()) result = AssignPointerMap(result); 1046 if (instr->include_stack_check()) result = AssignPointerMap(result);
1047 return result; 1047 return result;
1048 } 1048 }
1049 1049
1050 1050
1051 LInstruction* LChunkBuilder::DoTest(HTest* instr) { 1051 LInstruction* LChunkBuilder::DoTest(HTest* instr) {
1052 HValue* v = instr->value(); 1052 HValue* v = instr->value();
1053 if (v->EmitAtUses()) { 1053 if (!v->EmitAtUses()) {
1054 if (v->IsClassOfTest()) { 1054 return new LBranch(UseRegisterAtStart(v));
1055 HClassOfTest* compare = HClassOfTest::cast(v); 1055 } else if (v->IsClassOfTest()) {
1056 ASSERT(compare->value()->representation().IsTagged()); 1056 HClassOfTest* compare = HClassOfTest::cast(v);
1057 ASSERT(compare->value()->representation().IsTagged());
1058 return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
1059 TempRegister());
1060 } else if (v->IsCompare()) {
1061 HCompare* compare = HCompare::cast(v);
1062 Token::Value op = compare->token();
1063 HValue* left = compare->left();
1064 HValue* right = compare->right();
1065 Representation r = compare->GetInputRepresentation();
1066 if (r.IsInteger32()) {
1067 ASSERT(left->representation().IsInteger32());
1068 ASSERT(right->representation().IsInteger32());
1069 return new LCmpIDAndBranch(UseRegisterAtStart(left),
1070 UseRegisterAtStart(right));
1071 } else if (r.IsDouble()) {
1072 ASSERT(left->representation().IsDouble());
1073 ASSERT(right->representation().IsDouble());
1074 return new LCmpIDAndBranch(UseRegisterAtStart(left),
1075 UseRegisterAtStart(right));
1076 } else {
1077 ASSERT(left->representation().IsTagged());
1078 ASSERT(right->representation().IsTagged());
1079 bool reversed = op == Token::GT || op == Token::LTE;
1080 LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
1081 LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
1082 LInstruction* result = new LCmpTAndBranch(left_operand, right_operand);
1083 return MarkAsCall(result, instr);
1084 }
1085 } else if (v->IsIsSmi()) {
1086 HIsSmi* compare = HIsSmi::cast(v);
1087 ASSERT(compare->value()->representation().IsTagged());
1088 return new LIsSmiAndBranch(Use(compare->value()));
1089 } else if (v->IsIsUndetectable()) {
1090 HIsUndetectable* compare = HIsUndetectable::cast(v);
1091 ASSERT(compare->value()->representation().IsTagged());
1092 return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
1093 TempRegister());
1094 } else if (v->IsHasInstanceType()) {
1095 HHasInstanceType* compare = HHasInstanceType::cast(v);
1096 ASSERT(compare->value()->representation().IsTagged());
1097 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()));
1098 } else if (v->IsHasCachedArrayIndex()) {
1099 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
1100 ASSERT(compare->value()->representation().IsTagged());
1101 return new LHasCachedArrayIndexAndBranch(
1102 UseRegisterAtStart(compare->value()));
1103 } else if (v->IsIsNull()) {
1104 HIsNull* compare = HIsNull::cast(v);
1105 ASSERT(compare->value()->representation().IsTagged());
1106 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()));
1107 } else if (v->IsIsObject()) {
1108 HIsObject* compare = HIsObject::cast(v);
1109 ASSERT(compare->value()->representation().IsTagged());
1110 LOperand* temp = TempRegister();
1111 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), temp);
1112 } else if (v->IsCompareJSObjectEq()) {
1113 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
1114 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
1115 UseRegisterAtStart(compare->right()));
1116 } else if (v->IsCompareSymbolEq()) {
1117 HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
1118 return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
1119 UseRegisterAtStart(compare->right()));
1120 } else if (v->IsInstanceOf()) {
1121 HInstanceOf* instance_of = HInstanceOf::cast(v);
1122 LInstruction* result =
1123 new LInstanceOfAndBranch(UseFixed(instance_of->left(), r0),
1124 UseFixed(instance_of->right(), r1));
1125 return MarkAsCall(result, instr);
1126 } else if (v->IsTypeofIs()) {
1127 HTypeofIs* typeof_is = HTypeofIs::cast(v);
1128 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
1129 } else if (v->IsIsConstructCall()) {
1130 return new LIsConstructCallAndBranch(TempRegister());
1131 } else if (v->IsConstant()) {
1132 HBasicBlock* successor = HConstant::cast(v)->ToBoolean()
1133 ? instr->FirstSuccessor()
1134 : instr->SecondSuccessor();
1135 return new LGoto(successor->block_id());
1136 } else {
1137 Abort("Undefined compare before branch");
1138 return NULL;
1139 }
1140 }
1057 1141
1058 return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
1059 TempRegister());
1060 } else if (v->IsCompare()) {
1061 HCompare* compare = HCompare::cast(v);
1062 Token::Value op = compare->token();
1063 HValue* left = compare->left();
1064 HValue* right = compare->right();
1065 Representation r = compare->GetInputRepresentation();
1066 if (r.IsInteger32()) {
1067 ASSERT(left->representation().IsInteger32());
1068 ASSERT(right->representation().IsInteger32());
1069 return new LCmpIDAndBranch(UseRegisterAtStart(left),
1070 UseRegisterAtStart(right));
1071 } else if (r.IsDouble()) {
1072 ASSERT(left->representation().IsDouble());
1073 ASSERT(right->representation().IsDouble());
1074 return new LCmpIDAndBranch(UseRegisterAtStart(left),
1075 UseRegisterAtStart(right));
1076 } else {
1077 ASSERT(left->representation().IsTagged());
1078 ASSERT(right->representation().IsTagged());
1079 bool reversed = op == Token::GT || op == Token::LTE;
1080 LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
1081 LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
1082 LInstruction* result = new LCmpTAndBranch(left_operand,
1083 right_operand);
1084 return MarkAsCall(result, instr);
1085 }
1086 } else if (v->IsIsSmi()) {
1087 HIsSmi* compare = HIsSmi::cast(v);
1088 ASSERT(compare->value()->representation().IsTagged());
1089
1090 return new LIsSmiAndBranch(Use(compare->value()));
1091 } else if (v->IsIsUndetectable()) {
1092 HIsUndetectable* compare = HIsUndetectable::cast(v);
1093 ASSERT(compare->value()->representation().IsTagged());
1094
1095 return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
1096 TempRegister());
1097 } else if (v->IsHasInstanceType()) {
1098 HHasInstanceType* compare = HHasInstanceType::cast(v);
1099 ASSERT(compare->value()->representation().IsTagged());
1100 return new LHasInstanceTypeAndBranch(
1101 UseRegisterAtStart(compare->value()));
1102 } else if (v->IsHasCachedArrayIndex()) {
1103 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
1104 ASSERT(compare->value()->representation().IsTagged());
1105
1106 return new LHasCachedArrayIndexAndBranch(
1107 UseRegisterAtStart(compare->value()));
1108 } else if (v->IsIsNull()) {
1109 HIsNull* compare = HIsNull::cast(v);
1110 ASSERT(compare->value()->representation().IsTagged());
1111
1112 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()));
1113 } else if (v->IsIsObject()) {
1114 HIsObject* compare = HIsObject::cast(v);
1115 ASSERT(compare->value()->representation().IsTagged());
1116
1117 LOperand* temp = TempRegister();
1118 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), temp);
1119 } else if (v->IsCompareJSObjectEq()) {
1120 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
1121 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
1122 UseRegisterAtStart(compare->right()));
1123 } else if (v->IsCompareSymbolEq()) {
1124 HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
1125 return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
1126 UseRegisterAtStart(compare->right()));
1127 } else if (v->IsInstanceOf()) {
1128 HInstanceOf* instance_of = HInstanceOf::cast(v);
1129 LInstruction* result =
1130 new LInstanceOfAndBranch(UseFixed(instance_of->left(), r0),
1131 UseFixed(instance_of->right(), r1));
1132 return MarkAsCall(result, instr);
1133 } else if (v->IsTypeofIs()) {
1134 HTypeofIs* typeof_is = HTypeofIs::cast(v);
1135 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
1136 } else if (v->IsIsConstructCall()) {
1137 return new LIsConstructCallAndBranch(TempRegister());
1138 } else {
1139 if (v->IsConstant()) {
1140 if (HConstant::cast(v)->ToBoolean()) {
1141 return new LGoto(instr->FirstSuccessor()->block_id());
1142 } else {
1143 return new LGoto(instr->SecondSuccessor()->block_id());
1144 }
1145 }
1146 Abort("Undefined compare before branch");
1147 return NULL;
1148 }
1149 }
1150 return new LBranch(UseRegisterAtStart(v));
1151 }
1152 1142
1153 1143
1154 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { 1144 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1155 ASSERT(instr->value()->representation().IsTagged()); 1145 ASSERT(instr->value()->representation().IsTagged());
1156 LOperand* value = UseRegisterAtStart(instr->value()); 1146 LOperand* value = UseRegisterAtStart(instr->value());
1157 LOperand* temp = TempRegister(); 1147 LOperand* temp = TempRegister();
1158 return new LCmpMapAndBranch(value, temp); 1148 return new LCmpMapAndBranch(value, temp);
1159 } 1149 }
1160 1150
1161 1151
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 2196
2207 LInstruction* LChunkBuilder::DoIn(HIn* instr) { 2197 LInstruction* LChunkBuilder::DoIn(HIn* instr) {
2208 LOperand* key = UseRegisterAtStart(instr->key()); 2198 LOperand* key = UseRegisterAtStart(instr->key());
2209 LOperand* object = UseRegisterAtStart(instr->object()); 2199 LOperand* object = UseRegisterAtStart(instr->object());
2210 LIn* result = new LIn(key, object); 2200 LIn* result = new LIn(key, object);
2211 return MarkAsCall(DefineFixed(result, r0), instr); 2201 return MarkAsCall(DefineFixed(result, r0), instr);
2212 } 2202 }
2213 2203
2214 2204
2215 } } // namespace v8::internal 2205 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698