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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 explicit IfBuilder(HGraphBuilder* builder, | 1278 explicit IfBuilder(HGraphBuilder* builder, |
1279 int position = RelocInfo::kNoPosition); | 1279 int position = RelocInfo::kNoPosition); |
1280 IfBuilder(HGraphBuilder* builder, | 1280 IfBuilder(HGraphBuilder* builder, |
1281 HIfContinuation* continuation); | 1281 HIfContinuation* continuation); |
1282 | 1282 |
1283 ~IfBuilder() { | 1283 ~IfBuilder() { |
1284 if (!finished_) End(); | 1284 if (!finished_) End(); |
1285 } | 1285 } |
1286 | 1286 |
1287 template<class Condition> | 1287 template<class Condition> |
1288 HInstruction* If(HValue *p) { | 1288 Condition* If(HValue *p) { |
1289 HControlInstruction* compare = new(zone()) Condition(p); | 1289 Condition* compare = builder()->New<Condition>(p); |
1290 AddCompare(compare); | 1290 AddCompare(compare); |
1291 return compare; | 1291 return compare; |
1292 } | 1292 } |
1293 | 1293 |
1294 template<class Condition, class P2> | 1294 template<class Condition, class P2> |
1295 HInstruction* If(HValue* p1, P2 p2) { | 1295 Condition* If(HValue* p1, P2 p2) { |
1296 HControlInstruction* compare = new(zone()) Condition(p1, p2); | 1296 Condition* compare = builder()->New<Condition>(p1, p2); |
1297 AddCompare(compare); | 1297 AddCompare(compare); |
1298 return compare; | 1298 return compare; |
1299 } | 1299 } |
1300 | 1300 |
1301 template<class Condition, class P2, class P3> | 1301 template<class Condition, class P2, class P3> |
1302 HInstruction* If(HValue* p1, P2 p2, P3 p3) { | 1302 Condition* If(HValue* p1, P2 p2, P3 p3) { |
1303 HControlInstruction* compare = new(zone()) Condition(p1, p2, p3); | 1303 Condition* compare = builder()->New<Condition>(p1, p2, p3); |
1304 AddCompare(compare); | 1304 AddCompare(compare); |
1305 return compare; | 1305 return compare; |
1306 } | 1306 } |
1307 | 1307 |
1308 template<class Condition, class P2> | 1308 template<class Condition, class P2> |
1309 HInstruction* IfNot(HValue* p1, P2 p2) { | 1309 Condition* IfNot(HValue* p1, P2 p2) { |
1310 HControlInstruction* compare = new(zone()) Condition(p1, p2); | 1310 Condition* compare = builder()->New<Condition>(p1, p2); |
1311 AddCompare(compare); | 1311 AddCompare(compare); |
1312 HBasicBlock* block0 = compare->SuccessorAt(0); | 1312 HBasicBlock* block0 = compare->SuccessorAt(0); |
1313 HBasicBlock* block1 = compare->SuccessorAt(1); | 1313 HBasicBlock* block1 = compare->SuccessorAt(1); |
1314 compare->SetSuccessorAt(0, block1); | 1314 compare->SetSuccessorAt(0, block1); |
1315 compare->SetSuccessorAt(1, block0); | 1315 compare->SetSuccessorAt(1, block0); |
1316 return compare; | 1316 return compare; |
1317 } | 1317 } |
1318 | 1318 |
1319 template<class Condition, class P2, class P3> | 1319 template<class Condition, class P2, class P3> |
1320 HInstruction* IfNot(HValue* p1, P2 p2, P3 p3) { | 1320 Condition* IfNot(HValue* p1, P2 p2, P3 p3) { |
1321 HControlInstruction* compare = new(zone()) Condition(p1, p2, p3); | 1321 Condition* compare = builder()->New<Condition>(p1, p2, p3); |
1322 AddCompare(compare); | 1322 AddCompare(compare); |
1323 HBasicBlock* block0 = compare->SuccessorAt(0); | 1323 HBasicBlock* block0 = compare->SuccessorAt(0); |
1324 HBasicBlock* block1 = compare->SuccessorAt(1); | 1324 HBasicBlock* block1 = compare->SuccessorAt(1); |
1325 compare->SetSuccessorAt(0, block1); | 1325 compare->SetSuccessorAt(0, block1); |
1326 compare->SetSuccessorAt(1, block0); | 1326 compare->SetSuccessorAt(1, block0); |
1327 return compare; | 1327 return compare; |
1328 } | 1328 } |
1329 | 1329 |
1330 template<class Condition> | 1330 template<class Condition> |
1331 HInstruction* OrIf(HValue *p) { | 1331 Condition* OrIf(HValue *p) { |
1332 Or(); | 1332 Or(); |
1333 return If<Condition>(p); | 1333 return If<Condition>(p); |
1334 } | 1334 } |
1335 | 1335 |
1336 template<class Condition, class P2> | 1336 template<class Condition, class P2> |
1337 HInstruction* OrIf(HValue* p1, P2 p2) { | 1337 Condition* OrIf(HValue* p1, P2 p2) { |
1338 Or(); | 1338 Or(); |
1339 return If<Condition>(p1, p2); | 1339 return If<Condition>(p1, p2); |
1340 } | 1340 } |
1341 | 1341 |
1342 template<class Condition, class P2, class P3> | 1342 template<class Condition, class P2, class P3> |
1343 HInstruction* OrIf(HValue* p1, P2 p2, P3 p3) { | 1343 Condition* OrIf(HValue* p1, P2 p2, P3 p3) { |
1344 Or(); | 1344 Or(); |
1345 return If<Condition>(p1, p2, p3); | 1345 return If<Condition>(p1, p2, p3); |
1346 } | 1346 } |
1347 | 1347 |
1348 template<class Condition> | 1348 template<class Condition> |
1349 HInstruction* AndIf(HValue *p) { | 1349 Condition* AndIf(HValue *p) { |
1350 And(); | 1350 And(); |
1351 return If<Condition>(p); | 1351 return If<Condition>(p); |
1352 } | 1352 } |
1353 | 1353 |
1354 template<class Condition, class P2> | 1354 template<class Condition, class P2> |
1355 HInstruction* AndIf(HValue* p1, P2 p2) { | 1355 Condition* AndIf(HValue* p1, P2 p2) { |
1356 And(); | 1356 And(); |
1357 return If<Condition>(p1, p2); | 1357 return If<Condition>(p1, p2); |
1358 } | 1358 } |
1359 | 1359 |
1360 template<class Condition, class P2, class P3> | 1360 template<class Condition, class P2, class P3> |
1361 HInstruction* AndIf(HValue* p1, P2 p2, P3 p3) { | 1361 Condition* AndIf(HValue* p1, P2 p2, P3 p3) { |
1362 And(); | 1362 And(); |
1363 return If<Condition>(p1, p2, p3); | 1363 return If<Condition>(p1, p2, p3); |
1364 } | 1364 } |
1365 | 1365 |
1366 void Or(); | 1366 void Or(); |
1367 void And(); | 1367 void And(); |
1368 | 1368 |
1369 void CaptureContinuation(HIfContinuation* continuation); | 1369 void CaptureContinuation(HIfContinuation* continuation); |
1370 | 1370 |
1371 void Then(); | 1371 void Then(); |
1372 void Else(); | 1372 void Else(); |
1373 void End(); | 1373 void End(); |
1374 | 1374 |
1375 void Deopt(const char* reason); | 1375 void Deopt(const char* reason); |
1376 void ElseDeopt(const char* reason) { | 1376 void ElseDeopt(const char* reason) { |
1377 Else(); | 1377 Else(); |
1378 Deopt(reason); | 1378 Deopt(reason); |
1379 } | 1379 } |
1380 | 1380 |
1381 void Return(HValue* value); | 1381 void Return(HValue* value); |
1382 | 1382 |
1383 private: | 1383 private: |
1384 void AddCompare(HControlInstruction* compare); | 1384 void AddCompare(HControlInstruction* compare); |
1385 | 1385 |
1386 Zone* zone() { return builder_->zone(); } | 1386 HGraphBuilder* builder() const { return builder_; } |
1387 | 1387 |
1388 HGraphBuilder* builder_; | 1388 HGraphBuilder* builder_; |
1389 int position_; | 1389 int position_; |
1390 bool finished_ : 1; | 1390 bool finished_ : 1; |
1391 bool deopt_then_ : 1; | 1391 bool deopt_then_ : 1; |
1392 bool deopt_else_ : 1; | 1392 bool deopt_else_ : 1; |
1393 bool did_then_ : 1; | 1393 bool did_then_ : 1; |
1394 bool did_else_ : 1; | 1394 bool did_else_ : 1; |
1395 bool did_and_ : 1; | 1395 bool did_and_ : 1; |
1396 bool did_or_ : 1; | 1396 bool did_or_ : 1; |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 } | 2365 } |
2366 | 2366 |
2367 private: | 2367 private: |
2368 HGraphBuilder* builder_; | 2368 HGraphBuilder* builder_; |
2369 }; | 2369 }; |
2370 | 2370 |
2371 | 2371 |
2372 } } // namespace v8::internal | 2372 } } // namespace v8::internal |
2373 | 2373 |
2374 #endif // V8_HYDROGEN_H_ | 2374 #endif // V8_HYDROGEN_H_ |
OLD | NEW |