Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: src/compiler/scheduler.cc

Issue 761733002: Switch backedge table in scheduler to use ZoneVector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // do not belong to the loop.) 531 // do not belong to the loop.)
532 // Note a simple RPO traversal satisfies (1) but not (2). 532 // Note a simple RPO traversal satisfies (1) but not (2).
533 class SpecialRPONumberer : public ZoneObject { 533 class SpecialRPONumberer : public ZoneObject {
534 public: 534 public:
535 SpecialRPONumberer(Zone* zone, Schedule* schedule) 535 SpecialRPONumberer(Zone* zone, Schedule* schedule)
536 : zone_(zone), 536 : zone_(zone),
537 schedule_(schedule), 537 schedule_(schedule),
538 order_(NULL), 538 order_(NULL),
539 beyond_end_(NULL), 539 beyond_end_(NULL),
540 loops_(zone), 540 loops_(zone),
541 backedges_(1, zone), 541 backedges_(zone),
542 stack_(zone), 542 stack_(zone),
543 previous_block_count_(0) {} 543 previous_block_count_(0) {}
544 544
545 // Computes the special reverse-post-order for the main control flow graph, 545 // Computes the special reverse-post-order for the main control flow graph,
546 // that is for the graph spanned between the schedule's start and end blocks. 546 // that is for the graph spanned between the schedule's start and end blocks.
547 void ComputeSpecialRPO() { 547 void ComputeSpecialRPO() {
548 DCHECK(schedule_->end()->SuccessorCount() == 0); 548 DCHECK(schedule_->end()->SuccessorCount() == 0);
549 DCHECK_EQ(NULL, order_); // Main order does not exist yet. 549 DCHECK_EQ(NULL, order_); // Main order does not exist yet.
550 ComputeAndInsertSpecialRPO(schedule_->start(), schedule_->end()); 550 ComputeAndInsertSpecialRPO(schedule_->start(), schedule_->end());
551 } 551 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 int current = stack_depth - 1; 683 int current = stack_depth - 1;
684 SpecialRPOStackFrame* frame = &stack_[current]; 684 SpecialRPOStackFrame* frame = &stack_[current];
685 685
686 if (frame->block != end && 686 if (frame->block != end &&
687 frame->index < frame->block->SuccessorCount()) { 687 frame->index < frame->block->SuccessorCount()) {
688 // Process the next successor. 688 // Process the next successor.
689 BasicBlock* succ = frame->block->SuccessorAt(frame->index++); 689 BasicBlock* succ = frame->block->SuccessorAt(frame->index++);
690 if (succ->rpo_number() == kBlockVisited1) continue; 690 if (succ->rpo_number() == kBlockVisited1) continue;
691 if (succ->rpo_number() == kBlockOnStack) { 691 if (succ->rpo_number() == kBlockOnStack) {
692 // The successor is on the stack, so this is a backedge (cycle). 692 // The successor is on the stack, so this is a backedge (cycle).
693 backedges_.Add(Backedge(frame->block, frame->index - 1), zone_); 693 backedges_.push_back(Backedge(frame->block, frame->index - 1));
694 if (!HasLoopNumber(succ)) { 694 if (!HasLoopNumber(succ)) {
695 // Assign a new loop number to the header if it doesn't have one. 695 // Assign a new loop number to the header if it doesn't have one.
696 SetLoopNumber(succ, num_loops++); 696 SetLoopNumber(succ, num_loops++);
697 } 697 }
698 } else { 698 } else {
699 // Push the successor onto the stack. 699 // Push the successor onto the stack.
700 DCHECK(succ->rpo_number() == kBlockUnvisited1); 700 DCHECK(succ->rpo_number() == kBlockUnvisited1);
701 stack_depth = Push(stack_, stack_depth, succ, kBlockUnvisited1); 701 stack_depth = Push(stack_, stack_depth, succ, kBlockUnvisited1);
702 } 702 }
703 } else { 703 } else {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 current->loop_depth()); 846 current->loop_depth());
847 } else { 847 } else {
848 Trace("B%d has loop header B%d, (depth == %d)\n", current->id().ToInt(), 848 Trace("B%d has loop header B%d, (depth == %d)\n", current->id().ToInt(),
849 current->loop_header()->id().ToInt(), current->loop_depth()); 849 current->loop_header()->id().ToInt(), current->loop_depth());
850 } 850 }
851 } 851 }
852 } 852 }
853 853
854 // Computes loop membership from the backedges of the control flow graph. 854 // Computes loop membership from the backedges of the control flow graph.
855 void ComputeLoopInfo(ZoneVector<SpecialRPOStackFrame>& queue, 855 void ComputeLoopInfo(ZoneVector<SpecialRPOStackFrame>& queue,
856 size_t num_loops, ZoneList<Backedge>* backedges) { 856 size_t num_loops, ZoneVector<Backedge>* backedges) {
857 // Extend existing loop membership vectors. 857 // Extend existing loop membership vectors.
858 for (LoopInfo& loop : loops_) { 858 for (LoopInfo& loop : loops_) {
859 BitVector* new_members = new (zone_) 859 BitVector* new_members = new (zone_)
860 BitVector(static_cast<int>(schedule_->BasicBlockCount()), zone_); 860 BitVector(static_cast<int>(schedule_->BasicBlockCount()), zone_);
861 new_members->CopyFrom(*loop.members); 861 new_members->CopyFrom(*loop.members);
862 loop.members = new_members; 862 loop.members = new_members;
863 } 863 }
864 864
865 // Extend loop information vector. 865 // Extend loop information vector.
866 loops_.resize(num_loops, LoopInfo()); 866 loops_.resize(num_loops, LoopInfo());
867 867
868 // Compute loop membership starting from backedges. 868 // Compute loop membership starting from backedges.
869 // O(max(loop_depth) * max(|loop|) 869 // O(max(loop_depth) * max(|loop|)
870 for (int i = 0; i < backedges->length(); i++) { 870 for (size_t i = 0; i < backedges->size(); i++) {
871 BasicBlock* member = backedges->at(i).first; 871 BasicBlock* member = backedges->at(i).first;
872 BasicBlock* header = member->SuccessorAt(backedges->at(i).second); 872 BasicBlock* header = member->SuccessorAt(backedges->at(i).second);
873 size_t loop_num = GetLoopNumber(header); 873 size_t loop_num = GetLoopNumber(header);
874 if (loops_[loop_num].header == NULL) { 874 if (loops_[loop_num].header == NULL) {
875 loops_[loop_num].header = header; 875 loops_[loop_num].header = header;
876 loops_[loop_num].members = new (zone_) 876 loops_[loop_num].members = new (zone_)
877 BitVector(static_cast<int>(schedule_->BasicBlockCount()), zone_); 877 BitVector(static_cast<int>(schedule_->BasicBlockCount()), zone_);
878 } 878 }
879 879
880 int queue_length = 0; 880 int queue_length = 0;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 DCHECK(links == count); 1005 DCHECK(links == count);
1006 } 1006 }
1007 } 1007 }
1008 #endif // DEBUG 1008 #endif // DEBUG
1009 1009
1010 Zone* zone_; 1010 Zone* zone_;
1011 Schedule* schedule_; 1011 Schedule* schedule_;
1012 BasicBlock* order_; 1012 BasicBlock* order_;
1013 BasicBlock* beyond_end_; 1013 BasicBlock* beyond_end_;
1014 ZoneVector<LoopInfo> loops_; 1014 ZoneVector<LoopInfo> loops_;
1015 ZoneList<Backedge> backedges_; 1015 ZoneVector<Backedge> backedges_;
1016 ZoneVector<SpecialRPOStackFrame> stack_; 1016 ZoneVector<SpecialRPOStackFrame> stack_;
1017 size_t previous_block_count_; 1017 size_t previous_block_count_;
1018 }; 1018 };
1019 1019
1020 1020
1021 BasicBlockVector* Scheduler::ComputeSpecialRPO(Zone* zone, Schedule* schedule) { 1021 BasicBlockVector* Scheduler::ComputeSpecialRPO(Zone* zone, Schedule* schedule) {
1022 SpecialRPONumberer numberer(zone, schedule); 1022 SpecialRPONumberer numberer(zone, schedule);
1023 numberer.ComputeSpecialRPO(); 1023 numberer.ComputeSpecialRPO();
1024 numberer.SerializeAOIntoSchedule(); 1024 numberer.SerializeAOIntoSchedule();
1025 numberer.SerializeRPOIntoSchedule(); 1025 numberer.SerializeRPOIntoSchedule();
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { 1482 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) {
1483 schedule_->SetBlockForNode(to, *i); 1483 schedule_->SetBlockForNode(to, *i);
1484 scheduled_nodes_[to->id().ToSize()].push_back(*i); 1484 scheduled_nodes_[to->id().ToSize()].push_back(*i);
1485 } 1485 }
1486 nodes->clear(); 1486 nodes->clear();
1487 } 1487 }
1488 1488
1489 } // namespace compiler 1489 } // namespace compiler
1490 } // namespace internal 1490 } // namespace internal
1491 } // namespace v8 1491 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698