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

Side by Side Diff: src/hydrogen.h

Issue 18331004: Refactoring and cleanup of control instructions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More tweaks Created 7 years, 5 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
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 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 public: 1118 public:
1119 explicit IfBuilder(HGraphBuilder* builder, 1119 explicit IfBuilder(HGraphBuilder* builder,
1120 int position = RelocInfo::kNoPosition); 1120 int position = RelocInfo::kNoPosition);
1121 IfBuilder(HGraphBuilder* builder, 1121 IfBuilder(HGraphBuilder* builder,
1122 HIfContinuation* continuation); 1122 HIfContinuation* continuation);
1123 1123
1124 ~IfBuilder() { 1124 ~IfBuilder() {
1125 if (!finished_) End(); 1125 if (!finished_) End();
1126 } 1126 }
1127 1127
1128 HInstruction* IfCompare(
1129 HValue* left,
1130 HValue* right,
1131 Token::Value token);
1132
1133 HInstruction* IfCompareMap(HValue* left, Handle<Map> map);
1134
1135 template<class Condition> 1128 template<class Condition>
1136 HInstruction* If(HValue *p) { 1129 HInstruction* If(HValue *p) {
1137 HControlInstruction* compare = new(zone()) Condition(p); 1130 HControlInstruction* compare = new(zone()) Condition(p);
1138 AddCompare(compare); 1131 AddCompare(compare);
1139 return compare; 1132 return compare;
1140 } 1133 }
1141 1134
1142 template<class Condition, class P2> 1135 template<class Condition, class P2>
1143 HInstruction* If(HValue* p1, P2 p2) { 1136 HInstruction* If(HValue* p1, P2 p2) {
1144 HControlInstruction* compare = new(zone()) Condition(p1, p2); 1137 HControlInstruction* compare = new(zone()) Condition(p1, p2);
1145 AddCompare(compare); 1138 AddCompare(compare);
1146 return compare; 1139 return compare;
1147 } 1140 }
1148 1141
1142 template<class Condition, class P2, class P3>
1143 HInstruction* If(HValue* p1, P2 p2, P3 p3) {
1144 HControlInstruction* compare = new(zone()) Condition(p1, p2, p3);
1145 AddCompare(compare);
1146 return compare;
1147 }
1148
1149 template<class Condition, class P2> 1149 template<class Condition, class P2>
1150 HInstruction* IfNot(HValue* p1, P2 p2) { 1150 HInstruction* IfNot(HValue* p1, P2 p2) {
1151 HControlInstruction* compare = new(zone()) Condition(p1, p2); 1151 HControlInstruction* compare = new(zone()) Condition(p1, p2);
1152 AddCompare(compare); 1152 AddCompare(compare);
1153 HBasicBlock* block0 = compare->SuccessorAt(0); 1153 HBasicBlock* block0 = compare->SuccessorAt(0);
1154 HBasicBlock* block1 = compare->SuccessorAt(1); 1154 HBasicBlock* block1 = compare->SuccessorAt(1);
1155 compare->SetSuccessorAt(0, block1); 1155 compare->SetSuccessorAt(0, block1);
1156 compare->SetSuccessorAt(1, block0); 1156 compare->SetSuccessorAt(1, block0);
1157 return compare; 1157 return compare;
1158 } 1158 }
1159 1159
1160 HInstruction* OrIfCompare( 1160 template<class Condition, class P2, class P3>
1161 HValue* p1, 1161 HInstruction* IfNot(HValue* p1, P2 p2, P3 p3) {
1162 HValue* p2, 1162 HControlInstruction* compare = new(zone()) Condition(p1, p2, p3);
1163 Token::Value token) { 1163 AddCompare(compare);
1164 Or(); 1164 HBasicBlock* block0 = compare->SuccessorAt(0);
1165 return IfCompare(p1, p2, token); 1165 HBasicBlock* block1 = compare->SuccessorAt(1);
1166 } 1166 compare->SetSuccessorAt(0, block1);
1167 1167 compare->SetSuccessorAt(1, block0);
1168 HInstruction* OrIfCompareMap(HValue* left, Handle<Map> map) { 1168 return compare;
1169 Or();
1170 return IfCompareMap(left, map);
1171 } 1169 }
1172 1170
1173 template<class Condition> 1171 template<class Condition>
1174 HInstruction* OrIf(HValue *p) { 1172 HInstruction* OrIf(HValue *p) {
1175 Or(); 1173 Or();
1176 return If<Condition>(p); 1174 return If<Condition>(p);
1177 } 1175 }
1178 1176
1179 template<class Condition, class P2> 1177 template<class Condition, class P2>
1180 HInstruction* OrIf(HValue* p1, P2 p2) { 1178 HInstruction* OrIf(HValue* p1, P2 p2) {
1181 Or(); 1179 Or();
1182 return If<Condition>(p1, p2); 1180 return If<Condition>(p1, p2);
1183 } 1181 }
1184 1182
1185 HInstruction* AndIfCompare( 1183 template<class Condition, class P2, class P3>
1186 HValue* p1, 1184 HInstruction* OrIf(HValue* p1, P2 p2, P3 p3) {
1187 HValue* p2, 1185 Or();
1188 Token::Value token) { 1186 return If<Condition>(p1, p2, p3);
1189 And();
1190 return IfCompare(p1, p2, token);
1191 }
1192
1193 HInstruction* AndIfCompareMap(HValue* left, Handle<Map> map) {
1194 And();
1195 return IfCompareMap(left, map);
1196 } 1187 }
1197 1188
1198 template<class Condition> 1189 template<class Condition>
1199 HInstruction* AndIf(HValue *p) { 1190 HInstruction* AndIf(HValue *p) {
1200 And(); 1191 And();
1201 return If<Condition>(p); 1192 return If<Condition>(p);
1202 } 1193 }
1203 1194
1204 template<class Condition, class P2> 1195 template<class Condition, class P2>
1205 HInstruction* AndIf(HValue* p1, P2 p2) { 1196 HInstruction* AndIf(HValue* p1, P2 p2) {
1206 And(); 1197 And();
1207 return If<Condition>(p1, p2); 1198 return If<Condition>(p1, p2);
1208 } 1199 }
1209 1200
1201 template<class Condition, class P2, class P3>
1202 HInstruction* AndIf(HValue* p1, P2 p2, P3 p3) {
1203 And();
1204 return If<Condition>(p1, p2, p3);
1205 }
1206
1210 void Or(); 1207 void Or();
1211 void And(); 1208 void And();
1212 1209
1213 void CaptureContinuation(HIfContinuation* continuation); 1210 void CaptureContinuation(HIfContinuation* continuation);
1214 1211
1215 void Then(); 1212 void Then();
1216 void Else(); 1213 void Else();
1217 void End(); 1214 void End();
1218 1215
1219 void Deopt(); 1216 void Deopt();
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 EmbeddedVector<char, 64> filename_; 2086 EmbeddedVector<char, 64> filename_;
2090 HeapStringAllocator string_allocator_; 2087 HeapStringAllocator string_allocator_;
2091 StringStream trace_; 2088 StringStream trace_;
2092 int indent_; 2089 int indent_;
2093 }; 2090 };
2094 2091
2095 2092
2096 } } // namespace v8::internal 2093 } } // namespace v8::internal
2097 2094
2098 #endif // V8_HYDROGEN_H_ 2095 #endif // V8_HYDROGEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698