OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <deque> | 5 #include <deque> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "src/compiler/scheduler.h" | 8 #include "src/compiler/scheduler.h" |
9 | 9 |
10 #include "src/bit-vector.h" | 10 #include "src/bit-vector.h" |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 loop = loop->prev; | 756 loop = loop->prev; |
757 // We leave the loop header on the stack; the rest of this iteration | 757 // We leave the loop header on the stack; the rest of this iteration |
758 // and later iterations will go through its outgoing edges list. | 758 // and later iterations will go through its outgoing edges list. |
759 } | 759 } |
760 | 760 |
761 // Use the next outgoing edge if there are any. | 761 // Use the next outgoing edge if there are any. |
762 int outgoing_index = | 762 int outgoing_index = |
763 static_cast<int>(frame->index - block->SuccessorCount()); | 763 static_cast<int>(frame->index - block->SuccessorCount()); |
764 LoopInfo* info = &loops_[GetLoopNumber(block)]; | 764 LoopInfo* info = &loops_[GetLoopNumber(block)]; |
765 DCHECK(loop != info); | 765 DCHECK(loop != info); |
766 if (info->outgoing != NULL && | 766 if (block != entry && info->outgoing != NULL && |
767 outgoing_index < info->outgoing->length()) { | 767 outgoing_index < info->outgoing->length()) { |
768 succ = info->outgoing->at(outgoing_index); | 768 succ = info->outgoing->at(outgoing_index); |
769 frame->index++; | 769 frame->index++; |
770 } | 770 } |
771 } | 771 } |
772 | 772 |
773 if (succ != NULL) { | 773 if (succ != NULL) { |
774 // Process the next successor. | 774 // Process the next successor. |
775 if (succ->rpo_number() == kBlockOnStack) continue; | 775 if (succ->rpo_number() == kBlockOnStack) continue; |
776 if (succ->rpo_number() == kBlockVisited2) continue; | 776 if (succ->rpo_number() == kBlockVisited2) continue; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 } else { | 864 } else { |
865 Trace("B%d has loop header B%d, (depth == %d)\n", current->id().ToInt(), | 865 Trace("B%d has loop header B%d, (depth == %d)\n", current->id().ToInt(), |
866 current->loop_header()->id().ToInt(), current->loop_depth()); | 866 current->loop_header()->id().ToInt(), current->loop_depth()); |
867 } | 867 } |
868 } | 868 } |
869 } | 869 } |
870 | 870 |
871 // Computes loop membership from the backedges of the control flow graph. | 871 // Computes loop membership from the backedges of the control flow graph. |
872 void ComputeLoopInfo(ZoneVector<SpecialRPOStackFrame>& queue, | 872 void ComputeLoopInfo(ZoneVector<SpecialRPOStackFrame>& queue, |
873 size_t num_loops, ZoneList<Backedge>* backedges) { | 873 size_t num_loops, ZoneList<Backedge>* backedges) { |
| 874 // Extend existing loop membership vectors. |
| 875 for (LoopInfo& loop : loops_) { |
| 876 BitVector* new_members = new (zone_) |
| 877 BitVector(static_cast<int>(schedule_->BasicBlockCount()), zone_); |
| 878 new_members->CopyFrom(*loop.members); |
| 879 loop.members = new_members; |
| 880 } |
| 881 |
| 882 // Extend loop information vector. |
874 loops_.resize(num_loops, LoopInfo()); | 883 loops_.resize(num_loops, LoopInfo()); |
875 | 884 |
876 // Compute loop membership starting from backedges. | 885 // Compute loop membership starting from backedges. |
877 // O(max(loop_depth) * max(|loop|) | 886 // O(max(loop_depth) * max(|loop|) |
878 for (int i = 0; i < backedges->length(); i++) { | 887 for (int i = 0; i < backedges->length(); i++) { |
879 BasicBlock* member = backedges->at(i).first; | 888 BasicBlock* member = backedges->at(i).first; |
880 BasicBlock* header = member->SuccessorAt(backedges->at(i).second); | 889 BasicBlock* header = member->SuccessorAt(backedges->at(i).second); |
881 size_t loop_num = GetLoopNumber(header); | 890 size_t loop_num = GetLoopNumber(header); |
882 if (loops_[loop_num].header == NULL) { | 891 if (loops_[loop_num].header == NULL) { |
883 loops_[loop_num].header = header; | 892 loops_[loop_num].header = header; |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { | 1503 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { |
1495 schedule_->SetBlockForNode(to, *i); | 1504 schedule_->SetBlockForNode(to, *i); |
1496 scheduled_nodes_[to->id().ToSize()].push_back(*i); | 1505 scheduled_nodes_[to->id().ToSize()].push_back(*i); |
1497 } | 1506 } |
1498 nodes->clear(); | 1507 nodes->clear(); |
1499 } | 1508 } |
1500 | 1509 |
1501 } // namespace compiler | 1510 } // namespace compiler |
1502 } // namespace internal | 1511 } // namespace internal |
1503 } // namespace v8 | 1512 } // namespace v8 |
OLD | NEW |