Revert "Eliminatable CheckMaps replaced with if(true) or if(false)."
authorjkummerow@chromium.org <jkummerow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 15 Jan 2014 09:53:54 +0000 (09:53 +0000)
committerjkummerow@chromium.org <jkummerow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 15 Jan 2014 09:53:54 +0000 (09:53 +0000)
This reverts r18592 for breaking the GC stress bots.

R=machenbach@chromium.org

Review URL: https://codereview.chromium.org/137783011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18611 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen-check-elimination.cc
src/hydrogen-flow-engine.h
src/hydrogen-instructions.cc
src/hydrogen.cc
src/hydrogen.h

index 90e8450c821a17081c8bbd7dc9991ee28e792070..ae11042ba1e449b3c33b2d036ca36477165142d6 100644 (file)
@@ -132,10 +132,8 @@ class HCheckTable : public ZoneObject {
 
     // Branch-sensitive analysis for certain comparisons may add more facts
     // to the state for the successor on the true branch.
-    HBasicBlock* pred_block = succ->predecessors()->at(0);
-    HControlInstruction* end = pred_block->end();
-    if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ &&
-        pred_block->IsReachable()) {
+    HControlInstruction* end = succ->predecessors()->at(0)->end();
+    if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ) {
       if (end->IsCompareMap()) {
         // Learn on the true branch of if(CompareMap(x)).
         HCompareMap* cmp = HCompareMap::cast(end);
@@ -313,27 +311,14 @@ class HCheckTable : public ZoneObject {
   void ReduceCompareMap(HCompareMap* instr) {
     MapSet maps = FindMaps(instr->value()->ActualValue());
     if (maps == NULL) return;
-
-    TRACE(("CompareMap for #%d at B%d ",
-        instr->value()->ActualValue()->id(), instr->block()->block_id()));
-
     if (maps->Contains(instr->map())) {
       if (maps->size() == 1) {
+        // TODO(titzer): replace with goto true branch
         INC_STAT(compares_true_);
-
-        TRACE(("replaced with goto B%d (true target)\n",
-               instr->SuccessorAt(0)->block_id()));
-
-        instr->block()->ReplaceControlWithGotoSuccessor(0);
-      } else {
-        TRACE(("can't be replaced with goto: ambiguous set of maps\n"));
       }
     } else {
+      // TODO(titzer): replace with goto false branch
       INC_STAT(compares_false_);
-      TRACE(("replaced with goto B%d (false target)\n",
-             instr->SuccessorAt(1)->block_id()));
-
-      instr->block()->ReplaceControlWithGotoSuccessor(1);
     }
   }
 
index 477fdb1b7fe99c89f71b53f48aa035737287efaa..4e1275546f611e2401e467484976f73d59b3e784 100644 (file)
@@ -124,19 +124,17 @@ class HFlowEngine {
       if (SkipNonDominatedBlock(root, block)) continue;
       State* state = StateAt(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);
-        }
+      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.
@@ -187,7 +185,6 @@ 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 59341c032a65042feca41112fba2fc9ef7afa460..f9e09c0c7aa146dbc1aa64e605c5220b0169f598 100644 (file)
@@ -707,6 +707,7 @@ void HInstruction::PrintMnemonicTo(StringStream* stream) {
 
 void HInstruction::Unlink() {
   ASSERT(IsLinked());
+  ASSERT(!IsControlInstruction());  // Must never move control instructions.
   ASSERT(!IsBlockEntry());  // Doesn't make sense to delete these.
   ASSERT(previous_ != NULL);
   previous_->next_ = next_;
index 1b8e4f5ddd7eac72c854524c7753a34a4f9caec3..0c2b28bf8c301baed63bb0fcb47898626d41ecd2 100644 (file)
@@ -313,30 +313,6 @@ int HBasicBlock::LoopNestingDepth() const {
 }
 
 
-void HBasicBlock::ReplaceControlWithGotoSuccessor(int succ) {
-  ASSERT(IsFinished());
-  ASSERT(end()->SuccessorCount() == 2);  // Only this case is supported yet.
-  ASSERT(succ < end()->SuccessorCount());
-
-  int unreachable_succ = 1 - succ;
-
-  // Replace control instruction with if (true) {succ} else {unreachable_succ}.
-  HBranch* new_branch = HBranch::New(
-      zone(),
-      NULL,
-      graph()->GetConstantTrue(),
-      ToBooleanStub::Types(ToBooleanStub::BOOLEAN),
-      end()->SuccessorAt(succ),
-      end()->SuccessorAt(unreachable_succ));
-
-  MarkSuccEdgeUnreachable(unreachable_succ);
-
-  end()->DeleteAndReplaceWith(end()->ActualValue());
-  new_branch->InsertAfter(last());
-  end_ = new_branch;
-}
-
-
 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
   ASSERT(IsLoopHeader());
 
@@ -355,15 +331,6 @@ void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
 }
 
 
-void HBasicBlock::MarkSuccEdgeUnreachable(int succ) {
-  ASSERT(IsFinished());
-  HBasicBlock* succ_block = end()->SuccessorAt(succ);
-
-  ASSERT(succ_block->predecessors()->length() == 1);
-  succ_block->MarkUnreachable();
-}
-
-
 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) {
   if (HasPredecessor()) {
     // Only loop header blocks can have a predecessor added after
index cb99b555f5044ba5fa62df089d185944294c28fe..22394dcb5546dc1deea36ae7df8cd93757f85c6a 100644 (file)
@@ -114,8 +114,6 @@ class HBasicBlock V8_FINAL : public ZoneObject {
   bool Dominates(HBasicBlock* other) const;
   int LoopNestingDepth() const;
 
-  void ReplaceControlWithGotoSuccessor(int succ);
-
   void SetInitialEnvironment(HEnvironment* env);
   void ClearEnvironment() {
     ASSERT(IsFinished());
@@ -202,7 +200,6 @@ class HBasicBlock V8_FINAL : public ZoneObject {
                        int position);
 
  private:
-  void MarkSuccEdgeUnreachable(int succ);
   void RegisterPredecessor(HBasicBlock* pred);
   void AddDominatedBlock(HBasicBlock* block);