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

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

Issue 1120083004: [turbofan] Free TurboFan from the claws of ZoneList. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months 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 "src/compiler/scheduler.h" 5 #include "src/compiler/scheduler.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/adapters.h" 9 #include "src/base/adapters.h"
10 #include "src/bit-vector.h" 10 #include "src/bit-vector.h"
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 620 }
621 621
622 // Print and verify the special reverse-post-order. 622 // Print and verify the special reverse-post-order.
623 void PrintAndVerifySpecialRPO() { 623 void PrintAndVerifySpecialRPO() {
624 #if DEBUG 624 #if DEBUG
625 if (FLAG_trace_turbo_scheduler) PrintRPO(); 625 if (FLAG_trace_turbo_scheduler) PrintRPO();
626 VerifySpecialRPO(); 626 VerifySpecialRPO();
627 #endif 627 #endif
628 } 628 }
629 629
630 const ZoneList<BasicBlock*>& GetOutgoingBlocks(BasicBlock* block) { 630 const ZoneVector<BasicBlock*>& GetOutgoingBlocks(BasicBlock* block) {
631 if (HasLoopNumber(block)) { 631 if (HasLoopNumber(block)) {
632 LoopInfo const& loop = loops_[GetLoopNumber(block)]; 632 LoopInfo const& loop = loops_[GetLoopNumber(block)];
633 if (loop.outgoing) return *loop.outgoing; 633 if (loop.outgoing) return *loop.outgoing;
634 } 634 }
635 return empty_; 635 return empty_;
636 } 636 }
637 637
638 private: 638 private:
639 typedef std::pair<BasicBlock*, size_t> Backedge; 639 typedef std::pair<BasicBlock*, size_t> Backedge;
640 640
641 // Numbering for BasicBlock::rpo_number for this block traversal: 641 // Numbering for BasicBlock::rpo_number for this block traversal:
642 static const int kBlockOnStack = -2; 642 static const int kBlockOnStack = -2;
643 static const int kBlockVisited1 = -3; 643 static const int kBlockVisited1 = -3;
644 static const int kBlockVisited2 = -4; 644 static const int kBlockVisited2 = -4;
645 static const int kBlockUnvisited1 = -1; 645 static const int kBlockUnvisited1 = -1;
646 static const int kBlockUnvisited2 = kBlockVisited1; 646 static const int kBlockUnvisited2 = kBlockVisited1;
647 647
648 struct SpecialRPOStackFrame { 648 struct SpecialRPOStackFrame {
649 BasicBlock* block; 649 BasicBlock* block;
650 size_t index; 650 size_t index;
651 }; 651 };
652 652
653 struct LoopInfo { 653 struct LoopInfo {
654 BasicBlock* header; 654 BasicBlock* header;
655 ZoneList<BasicBlock*>* outgoing; 655 ZoneVector<BasicBlock*>* outgoing;
656 BitVector* members; 656 BitVector* members;
657 LoopInfo* prev; 657 LoopInfo* prev;
658 BasicBlock* end; 658 BasicBlock* end;
659 BasicBlock* start; 659 BasicBlock* start;
660 660
661 void AddOutgoing(Zone* zone, BasicBlock* block) { 661 void AddOutgoing(Zone* zone, BasicBlock* block) {
662 if (outgoing == NULL) { 662 if (outgoing == NULL) {
663 outgoing = new (zone) ZoneList<BasicBlock*>(2, zone); 663 outgoing = new (zone->New(sizeof(ZoneVector<BasicBlock*>)))
664 ZoneVector<BasicBlock*>(zone);
664 } 665 }
665 outgoing->Add(block, zone); 666 outgoing->push_back(block);
666 } 667 }
667 }; 668 };
668 669
669 int Push(ZoneVector<SpecialRPOStackFrame>& stack, int depth, 670 int Push(ZoneVector<SpecialRPOStackFrame>& stack, int depth,
670 BasicBlock* child, int unvisited) { 671 BasicBlock* child, int unvisited) {
671 if (child->rpo_number() == unvisited) { 672 if (child->rpo_number() == unvisited) {
672 stack[depth].block = child; 673 stack[depth].block = child;
673 stack[depth].index = 0; 674 stack[depth].index = 0;
674 child->set_rpo_number(kBlockOnStack); 675 child->set_rpo_number(kBlockOnStack);
675 return depth + 1; 676 return depth + 1;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 order = loop->end; 785 order = loop->end;
785 block->set_rpo_number(kBlockVisited2); 786 block->set_rpo_number(kBlockVisited2);
786 // Pop the loop stack and continue visiting outgoing edges within 787 // Pop the loop stack and continue visiting outgoing edges within
787 // the context of the outer loop, if any. 788 // the context of the outer loop, if any.
788 loop = loop->prev; 789 loop = loop->prev;
789 // We leave the loop header on the stack; the rest of this iteration 790 // We leave the loop header on the stack; the rest of this iteration
790 // and later iterations will go through its outgoing edges list. 791 // and later iterations will go through its outgoing edges list.
791 } 792 }
792 793
793 // Use the next outgoing edge if there are any. 794 // Use the next outgoing edge if there are any.
794 int outgoing_index = 795 size_t outgoing_index = frame->index - block->SuccessorCount();
795 static_cast<int>(frame->index - block->SuccessorCount());
796 LoopInfo* info = &loops_[GetLoopNumber(block)]; 796 LoopInfo* info = &loops_[GetLoopNumber(block)];
797 DCHECK(loop != info); 797 DCHECK(loop != info);
798 if (block != entry && info->outgoing != NULL && 798 if (block != entry && info->outgoing != NULL &&
799 outgoing_index < info->outgoing->length()) { 799 outgoing_index < info->outgoing->size()) {
800 succ = info->outgoing->at(outgoing_index); 800 succ = info->outgoing->at(outgoing_index);
801 frame->index++; 801 frame->index++;
802 } 802 }
803 } 803 }
804 804
805 if (succ != NULL) { 805 if (succ != NULL) {
806 // Process the next successor. 806 // Process the next successor.
807 if (succ->rpo_number() == kBlockOnStack) continue; 807 if (succ->rpo_number() == kBlockOnStack) continue;
808 if (succ->rpo_number() == kBlockVisited2) continue; 808 if (succ->rpo_number() == kBlockVisited2) continue;
809 DCHECK(succ->rpo_number() == kBlockUnvisited2); 809 DCHECK(succ->rpo_number() == kBlockUnvisited2);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 #endif // DEBUG 1048 #endif // DEBUG
1049 1049
1050 Zone* zone_; 1050 Zone* zone_;
1051 Schedule* schedule_; 1051 Schedule* schedule_;
1052 BasicBlock* order_; 1052 BasicBlock* order_;
1053 BasicBlock* beyond_end_; 1053 BasicBlock* beyond_end_;
1054 ZoneVector<LoopInfo> loops_; 1054 ZoneVector<LoopInfo> loops_;
1055 ZoneVector<Backedge> backedges_; 1055 ZoneVector<Backedge> backedges_;
1056 ZoneVector<SpecialRPOStackFrame> stack_; 1056 ZoneVector<SpecialRPOStackFrame> stack_;
1057 size_t previous_block_count_; 1057 size_t previous_block_count_;
1058 ZoneList<BasicBlock*> const empty_; 1058 ZoneVector<BasicBlock*> const empty_;
1059 }; 1059 };
1060 1060
1061 1061
1062 BasicBlockVector* Scheduler::ComputeSpecialRPO(Zone* zone, Schedule* schedule) { 1062 BasicBlockVector* Scheduler::ComputeSpecialRPO(Zone* zone, Schedule* schedule) {
1063 SpecialRPONumberer numberer(zone, schedule); 1063 SpecialRPONumberer numberer(zone, schedule);
1064 numberer.ComputeSpecialRPO(); 1064 numberer.ComputeSpecialRPO();
1065 numberer.SerializeRPOIntoSchedule(); 1065 numberer.SerializeRPOIntoSchedule();
1066 numberer.PrintAndVerifySpecialRPO(); 1066 numberer.PrintAndVerifySpecialRPO();
1067 return schedule->rpo_order(); 1067 return schedule->rpo_order();
1068 } 1068 }
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 for (Node* const node : *nodes) { 1684 for (Node* const node : *nodes) {
1685 schedule_->SetBlockForNode(to, node); 1685 schedule_->SetBlockForNode(to, node);
1686 scheduled_nodes_[to->id().ToSize()].push_back(node); 1686 scheduled_nodes_[to->id().ToSize()].push_back(node);
1687 } 1687 }
1688 nodes->clear(); 1688 nodes->clear();
1689 } 1689 }
1690 1690
1691 } // namespace compiler 1691 } // namespace compiler
1692 } // namespace internal 1692 } // namespace internal
1693 } // namespace v8 1693 } // 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