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

Side by Side Diff: src/hydrogen.h

Issue 23452049: Allow IfBuilder's to join existing (captured) continuations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed nit Created 7 years, 3 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/hydrogen.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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 934
935 HArgumentsObject* arguments_object_; 935 HArgumentsObject* arguments_object_;
936 HArgumentsElements* arguments_elements_; 936 HArgumentsElements* arguments_elements_;
937 937
938 FunctionState* outer_; 938 FunctionState* outer_;
939 }; 939 };
940 940
941 941
942 class HIfContinuation V8_FINAL { 942 class HIfContinuation V8_FINAL {
943 public: 943 public:
944 HIfContinuation() { continuation_captured_ = false; } 944 HIfContinuation() : continuation_captured_(false) {}
945 HIfContinuation(HBasicBlock* true_branch,
946 HBasicBlock* false_branch,
947 int position = RelocInfo::kNoPosition)
948 : continuation_captured_(true), true_branch_(true_branch),
949 false_branch_(false_branch), position_(position) {}
945 ~HIfContinuation() { ASSERT(!continuation_captured_); } 950 ~HIfContinuation() { ASSERT(!continuation_captured_); }
946 951
947 void Capture(HBasicBlock* true_branch, 952 void Capture(HBasicBlock* true_branch,
948 HBasicBlock* false_branch, 953 HBasicBlock* false_branch,
949 int position) { 954 int position) {
950 ASSERT(!continuation_captured_); 955 ASSERT(!continuation_captured_);
951 true_branch_ = true_branch; 956 true_branch_ = true_branch;
952 false_branch_ = false_branch; 957 false_branch_ = false_branch;
953 position_ = position; 958 position_ = position;
954 continuation_captured_ = true; 959 continuation_captured_ = true;
955 } 960 }
956 961
957 void Continue(HBasicBlock** true_branch, 962 void Continue(HBasicBlock** true_branch,
958 HBasicBlock** false_branch, 963 HBasicBlock** false_branch,
959 int* position) { 964 int* position) {
960 ASSERT(continuation_captured_); 965 ASSERT(continuation_captured_);
961 *true_branch = true_branch_; 966 *true_branch = true_branch_;
962 *false_branch = false_branch_; 967 *false_branch = false_branch_;
963 if (position != NULL) *position = position_; 968 if (position != NULL) *position = position_;
964 continuation_captured_ = false; 969 continuation_captured_ = false;
965 } 970 }
966 971
967 bool IsTrueReachable() { return true_branch_ != NULL; } 972 bool IsTrueReachable() { return true_branch_ != NULL; }
968 bool IsFalseReachable() { return false_branch_ != NULL; } 973 bool IsFalseReachable() { return false_branch_ != NULL; }
969 bool TrueAndFalseReachable() { 974 bool TrueAndFalseReachable() {
970 return IsTrueReachable() || IsFalseReachable(); 975 return IsTrueReachable() || IsFalseReachable();
971 } 976 }
972 977
978 HBasicBlock* true_branch() const { return true_branch_; }
979 HBasicBlock* false_branch() const { return false_branch_; }
980
981 private:
973 bool continuation_captured_; 982 bool continuation_captured_;
974 HBasicBlock* true_branch_; 983 HBasicBlock* true_branch_;
975 HBasicBlock* false_branch_; 984 HBasicBlock* false_branch_;
976 int position_; 985 int position_;
977 }; 986 };
978 987
979 988
980 class HGraphBuilder { 989 class HGraphBuilder {
981 public: 990 public:
982 explicit HGraphBuilder(CompilationInfo* info) 991 explicit HGraphBuilder(CompilationInfo* info)
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1376
1368 template<class Condition, class P2, class P3> 1377 template<class Condition, class P2, class P3>
1369 Condition* AndIf(HValue* p1, P2 p2, P3 p3) { 1378 Condition* AndIf(HValue* p1, P2 p2, P3 p3) {
1370 And(); 1379 And();
1371 return If<Condition>(p1, p2, p3); 1380 return If<Condition>(p1, p2, p3);
1372 } 1381 }
1373 1382
1374 void Or(); 1383 void Or();
1375 void And(); 1384 void And();
1376 1385
1386 // Captures the current state of this IfBuilder in the specified
1387 // continuation and ends this IfBuilder.
1377 void CaptureContinuation(HIfContinuation* continuation); 1388 void CaptureContinuation(HIfContinuation* continuation);
1378 1389
1390 // Joins the specified continuation from this IfBuilder and ends this
1391 // IfBuilder. This appends a Goto instruction from the true branch of
1392 // this IfBuilder to the true branch of the continuation unless the
1393 // true branch of this IfBuilder is already finished. And vice versa
1394 // for the false branch.
1395 //
1396 // The basic idea is as follows: You have several nested IfBuilder's
1397 // that you want to join based on two possible outcomes (i.e. success
1398 // and failure, or whatever). You can do this easily using this method
1399 // now, for example:
1400 //
1401 // HIfContinuation cont(graph()->CreateBasicBlock(),
1402 // graph()->CreateBasicBlock());
1403 // ...
1404 // IfBuilder if_whatever(this);
1405 // if_whatever.If<Condition>(arg);
1406 // if_whatever.Then();
1407 // ...
1408 // if_whatever.Else();
1409 // ...
1410 // if_whatever.JoinContinuation(&cont);
1411 // ...
1412 // IfBuilder if_something(this);
1413 // if_something.If<Condition>(arg1, arg2);
1414 // if_something.Then();
1415 // ...
1416 // if_something.Else();
1417 // ...
1418 // if_something.JoinContinuation(&cont);
1419 // ...
1420 // IfBuilder if_finally(this, &cont);
1421 // if_finally.Then();
1422 // // continues after then code of if_whatever or if_something.
1423 // ...
1424 // if_finally.Else();
1425 // // continues after else code of if_whatever or if_something.
1426 // ...
1427 // if_finally.End();
1428 void JoinContinuation(HIfContinuation* continuation);
1429
1379 void Then(); 1430 void Then();
1380 void Else(); 1431 void Else();
1381 void End(); 1432 void End();
1382 1433
1383 void Deopt(const char* reason); 1434 void Deopt(const char* reason);
1384 void ElseDeopt(const char* reason) { 1435 void ElseDeopt(const char* reason) {
1385 Else(); 1436 Else();
1386 Deopt(reason); 1437 Deopt(reason);
1387 } 1438 }
1388 1439
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2378 } 2429 }
2379 2430
2380 private: 2431 private:
2381 HGraphBuilder* builder_; 2432 HGraphBuilder* builder_;
2382 }; 2433 };
2383 2434
2384 2435
2385 } } // namespace v8::internal 2436 } } // namespace v8::internal
2386 2437
2387 #endif // V8_HYDROGEN_H_ 2438 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698