| Index: src/hydrogen.h
|
| diff --git a/src/hydrogen.h b/src/hydrogen.h
|
| index b27701c4af5513d619156c44926ef2b170ec33eb..af79aa35f7ac540fb5357fd442572d400ceff660 100644
|
| --- a/src/hydrogen.h
|
| +++ b/src/hydrogen.h
|
| @@ -941,7 +941,12 @@ class FunctionState V8_FINAL {
|
|
|
| class HIfContinuation V8_FINAL {
|
| public:
|
| - HIfContinuation() { continuation_captured_ = false; }
|
| + HIfContinuation() : continuation_captured_(false) {}
|
| + HIfContinuation(HBasicBlock* true_branch,
|
| + HBasicBlock* false_branch,
|
| + int position = RelocInfo::kNoPosition)
|
| + : continuation_captured_(true), true_branch_(true_branch),
|
| + false_branch_(false_branch), position_(position) {}
|
| ~HIfContinuation() { ASSERT(!continuation_captured_); }
|
|
|
| void Capture(HBasicBlock* true_branch,
|
| @@ -970,6 +975,10 @@ class HIfContinuation V8_FINAL {
|
| return IsTrueReachable() || IsFalseReachable();
|
| }
|
|
|
| + HBasicBlock* true_branch() const { return true_branch_; }
|
| + HBasicBlock* false_branch() const { return false_branch_; }
|
| +
|
| + private:
|
| bool continuation_captured_;
|
| HBasicBlock* true_branch_;
|
| HBasicBlock* false_branch_;
|
| @@ -1374,8 +1383,50 @@ class HGraphBuilder {
|
| void Or();
|
| void And();
|
|
|
| + // Captures the current state of this IfBuilder in the specified
|
| + // continuation and ends this IfBuilder.
|
| void CaptureContinuation(HIfContinuation* continuation);
|
|
|
| + // Joins the specified continuation from this IfBuilder and ends this
|
| + // IfBuilder. This appends a Goto instruction from the true branch of
|
| + // this IfBuilder to the true branch of the continuation unless the
|
| + // true branch of this IfBuilder is already finished. And vice versa
|
| + // for the false branch.
|
| + //
|
| + // The basic idea is as follows: You have several nested IfBuilder's
|
| + // that you want to join based on two possible outcomes (i.e. success
|
| + // and failure, or whatever). You can do this easily using this method
|
| + // now, for example:
|
| + //
|
| + // HIfContinuation cont(graph()->CreateBasicBlock(),
|
| + // graph()->CreateBasicBlock());
|
| + // ...
|
| + // IfBuilder if_whatever(this);
|
| + // if_whatever.If<Condition>(arg);
|
| + // if_whatever.Then();
|
| + // ...
|
| + // if_whatever.Else();
|
| + // ...
|
| + // if_whatever.JoinContinuation(&cont);
|
| + // ...
|
| + // IfBuilder if_something(this);
|
| + // if_something.If<Condition>(arg1, arg2);
|
| + // if_something.Then();
|
| + // ...
|
| + // if_something.Else();
|
| + // ...
|
| + // if_something.JoinContinuation(&cont);
|
| + // ...
|
| + // IfBuilder if_finally(this, &cont);
|
| + // if_finally.Then();
|
| + // // continues after then code of if_whatever or if_something.
|
| + // ...
|
| + // if_finally.Else();
|
| + // // continues after else code of if_whatever or if_something.
|
| + // ...
|
| + // if_finally.End();
|
| + void JoinContinuation(HIfContinuation* continuation);
|
| +
|
| void Then();
|
| void Else();
|
| void End();
|
|
|