Reviewers: Sven,

Description:
Add a function to compute loop nesting level to HBasicBlock.

Please review this at http://codereview.chromium.org/7857031/

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

Affected files:
  M     src/hydrogen.h
  M     src/hydrogen.cc


Index: src/hydrogen.cc
===================================================================
--- src/hydrogen.cc     (revision 9206)
+++ src/hydrogen.cc     (working copy)
@@ -220,6 +220,17 @@
 }


+int HBasicBlock::LoopNestingDepth() const {
+  const HBasicBlock* current = this;
+  int result  = (current->IsLoopHeader()) ? 1 : 0;
+  while (current->parent_loop_header() != NULL) {
+    current = current->parent_loop_header();
+    result++;
+  }
+  return result;
+}
+
+
 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
   ASSERT(IsLoopHeader());

@@ -6567,6 +6578,8 @@
       PrintBlockProperty("dominator", current->dominator()->block_id());
     }

+    PrintIntProperty("loop_depth", current->LoopNestingDepth());
+
     if (chunk != NULL) {
       int first_index = current->first_instruction_index();
       int last_index = current->last_instruction_index();
Index: src/hydrogen.h
===================================================================
--- src/hydrogen.h      (revision 9206)
+++ src/hydrogen.h      (working copy)
@@ -102,6 +102,7 @@
   void RemovePhi(HPhi* phi);
   void AddInstruction(HInstruction* instr);
   bool Dominates(HBasicBlock* other) const;
+  int LoopNestingDepth() const;

   void SetInitialEnvironment(HEnvironment* env);
   void ClearEnvironment() { last_environment_ = NULL; }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to