Reviewers: titzer,

Message:
PTAL

Description:
Flow engine fixes: unreachable block processing, state merging.

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

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

Affected files (+25, -21 lines):
  M src/hydrogen-check-elimination.cc
  M src/hydrogen-flow-engine.h
  M src/hydrogen-load-elimination.cc


Index: src/hydrogen-check-elimination.cc
diff --git a/src/hydrogen-check-elimination.cc b/src/hydrogen-check-elimination.cc index ae11042ba1e449b3c33b2d036ca36477165142d6..8025ff1de8eae0702fe16ef9dbfc1daffeb9f7f0 100644
--- a/src/hydrogen-check-elimination.cc
+++ b/src/hydrogen-check-elimination.cc
@@ -117,7 +117,7 @@ class HCheckTable : public ZoneObject {
   }

   // Global analysis: Copy state to successor block.
-  HCheckTable* Copy(HBasicBlock* succ, Zone* zone) {
+ HCheckTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, Zone* zone) {
     HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_);
     for (int i = 0; i < size_; i++) {
       HCheckTableEntry* old_entry = &entries_[i];
@@ -173,12 +173,13 @@ class HCheckTable : public ZoneObject {
   }

   // Global analysis: Merge this state with the other incoming state.
-  HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) {
+  void Merge(HBasicBlock* succ, HCheckTable* that,
+             HBasicBlock* that_block, Zone* zone) {
     if (that->size_ == 0) {
       // If the other state is empty, simply reset.
       size_ = 0;
       cursor_ = 0;
-      return this;
+      return;
     }
     bool compact = false;
     for (int i = 0; i < size_; i++) {
@@ -195,7 +196,6 @@ class HCheckTable : public ZoneObject {
       }
     }
     if (compact) Compact();
-    return this;
   }

   void ReduceCheckMaps(HCheckMaps* instr) {
Index: src/hydrogen-flow-engine.h
diff --git a/src/hydrogen-flow-engine.h b/src/hydrogen-flow-engine.h
index 4e1275546f611e2401e467484976f73d59b3e784..3cc6ee3e279a5dbb3369de70fbd2c6af38cfe778 100644
--- a/src/hydrogen-flow-engine.h
+++ b/src/hydrogen-flow-engine.h
@@ -124,17 +124,19 @@ class HFlowEngine {
       if (SkipNonDominatedBlock(root, block)) continue;
       State* state = StateAt(block);

-      if (block->IsLoopHeader()) {
-        // Apply loop effects before analyzing loop body.
-        ComputeLoopEffects(block)->Apply(state);
-      } else {
-        // Must have visited all predecessors before this block.
-        CheckPredecessorCount(block);
-      }
+      if (block->IsReachable()) {
+        if (block->IsLoopHeader()) {
+          // Apply loop effects before analyzing loop body.
+          ComputeLoopEffects(block)->Apply(state);
+        } else {
+          // Must have visited all predecessors before this block.
+          CheckPredecessorCount(block);
+        }

- // Go through all instructions of the current block, updating the state.
-      for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
-        state = state->Process(it.Current(), zone_);
+ // Go through all instructions of the current block, updating the state.
+        for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
+          state = state->Process(it.Current(), zone_);
+        }
       }

       // Propagate the block state forward to all successor blocks.
@@ -149,11 +151,11 @@ class HFlowEngine {
             SetStateAt(succ, state);
           } else {
             // Successor needs a copy of the state.
-            SetStateAt(succ, state->Copy(succ, zone_));
+            SetStateAt(succ, state->Copy(succ, block, zone_));
           }
         } else {
// Merge the current state with the state already at the successor.
-          SetStateAt(succ, state->Merge(succ, StateAt(succ), zone_));
+          StateAt(succ)->Merge(succ, state, block, zone_);
         }
       }
     }
@@ -185,6 +187,7 @@ class HFlowEngine {
         i = member->loop_information()->GetLastBackEdge()->block_id();
       } else {
         // Process all the effects of the block.
+        if (member->IsUnreachable()) continue;
         ASSERT(member->current_loop() == loop);
         for (HInstructionIterator it(member); !it.Done(); it.Advance()) {
           effects->Process(it.Current(), zone_);
Index: src/hydrogen-load-elimination.cc
diff --git a/src/hydrogen-load-elimination.cc b/src/hydrogen-load-elimination.cc index f2e993b18dea2305884acd01274f85edab887260..fe023ada4ea1ee79299e551e5a950040c7771f55 100644
--- a/src/hydrogen-load-elimination.cc
+++ b/src/hydrogen-load-elimination.cc
@@ -132,8 +132,10 @@ class HLoadEliminationTable : public ZoneObject {
     return this;
   }

- // Support for global analysis with HFlowEngine: Copy state to sucessor block.
-  HLoadEliminationTable* Copy(HBasicBlock* succ, Zone* zone) {
+  // Support for global analysis with HFlowEngine: Copy state to successor
+  // block.
+  HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block,
+                              Zone* zone) {
     HLoadEliminationTable* copy =
         new(zone) HLoadEliminationTable(zone, aliasing_);
     copy->EnsureFields(fields_.length());
@@ -149,8 +151,8 @@ class HLoadEliminationTable : public ZoneObject {

   // Support for global analysis with HFlowEngine: Merge this state with
   // the other incoming state.
-  HLoadEliminationTable* Merge(HBasicBlock* succ,
-      HLoadEliminationTable* that, Zone* zone) {
+  void Merge(HBasicBlock* succ, HLoadEliminationTable* that,
+             HBasicBlock* that_block, Zone* zone) {
     if (that->fields_.length() < fields_.length()) {
       // Drop fields not in the other table.
       fields_.Rewind(that->fields_.length());
@@ -176,7 +178,6 @@ class HLoadEliminationTable : public ZoneObject {
         approx = approx->next_;
       }
     }
-    return this;
   }

   friend class HLoadEliminationEffects;  // Calls Kill() and others.


--
--
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