Reviewers: mvstanton,

Message:
Hey Michael,
Here's the "join continuation" support for the IfBuilder I've told you about
yesterday. PTAL
-- Benedikt

Description:
Allow IfBuilder's to join existing (captured) continuations.

Please review this at https://codereview.chromium.org/23452049/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+41, -1 lines):
  M src/hydrogen.h
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index b5cebbe327e10f9612bfd8cdee581ed7fc80b0d2..a3bd9fde0e8f67c8552f6fe34698b2a6efd34821 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -804,6 +804,28 @@ void HGraphBuilder::IfBuilder::CaptureContinuation(
 }


+void HGraphBuilder::IfBuilder::JoinContinuation(HIfContinuation* continuation) {
+  ASSERT(!finished_);
+  ASSERT(!captured_);
+  HBasicBlock* true_block = last_true_block_ == NULL
+      ? first_true_block_
+      : last_true_block_;
+  HBasicBlock* false_block = did_else_ && (first_false_block_ != NULL)
+      ? builder_->current_block()
+      : first_false_block_;
+  if (true_block != NULL && !true_block->IsFinished()) {
+    ASSERT(continuation->IsTrueReachable());
+    true_block->GotoNoSimulate(continuation->true_branch());
+  }
+  if (false_block != NULL && !false_block->IsFinished()) {
+    ASSERT(continuation->IsFalseReachable());
+    false_block->GotoNoSimulate(continuation->false_branch());
+  }
+  captured_ = true;
+  End();
+}
+
+
 void HGraphBuilder::IfBuilder::Then() {
   ASSERT(!captured_);
   ASSERT(!finished_);
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index b27701c4af5513d619156c44926ef2b170ec33eb..3081c221b98853d89e5d6dc7243264c4ef419504 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,17 @@ 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.
+    void JoinContinuation(HIfContinuation* continuation);
+
     void Then();
     void Else();
     void End();


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to