5 #ifndef V8_COMPILER_SCHEDULE_H_ 6 #define V8_COMPILER_SCHEDULE_H_ 10 #include "src/base/compiler-specific.h" 11 #include "src/globals.h" 12 #include "src/zone/zone-containers.h" 20 class BasicBlockInstrumentor;
23 typedef ZoneVector<BasicBlock*> BasicBlockVector;
24 typedef ZoneVector<Node*> NodeVector;
30 :
public NON_EXPORTED_BASE(ZoneObject) {
48 int ToInt()
const {
return static_cast<int>(index_); }
49 size_t ToSize()
const {
return index_; }
50 static Id FromSize(
size_t index) {
return Id(index); }
51 static Id FromInt(
int index) {
return Id(static_cast<size_t>(index)); }
54 explicit Id(
size_t index) : index_(index) {}
60 Id id()
const {
return id_; }
63 debug_info_ = debug_info;
71 BasicBlockVector& predecessors() {
return predecessors_; }
72 const BasicBlockVector& predecessors()
const {
return predecessors_; }
73 size_t PredecessorCount()
const {
return predecessors_.size(); }
74 BasicBlock* PredecessorAt(
size_t index) {
return predecessors_[index]; }
75 void ClearPredecessors() { predecessors_.clear(); }
76 void AddPredecessor(BasicBlock* predecessor);
79 BasicBlockVector& successors() {
return successors_; }
80 const BasicBlockVector& successors()
const {
return successors_; }
81 size_t SuccessorCount()
const {
return successors_.size(); }
82 BasicBlock* SuccessorAt(
size_t index) {
return successors_[index]; }
83 void ClearSuccessors() { successors_.clear(); }
84 void AddSuccessor(BasicBlock* successor);
87 typedef Node* value_type;
88 bool empty()
const {
return nodes_.empty(); }
89 size_t size()
const {
return nodes_.size(); }
90 Node* NodeAt(
size_t index) {
return nodes_[index]; }
91 size_t NodeCount()
const {
return nodes_.size(); }
93 value_type& front() {
return nodes_.front(); }
94 value_type
const& front()
const {
return nodes_.front(); }
96 typedef NodeVector::iterator iterator;
97 iterator begin() {
return nodes_.begin(); }
98 iterator end() {
return nodes_.end(); }
100 void RemoveNode(iterator it) { nodes_.erase(it); }
102 typedef NodeVector::const_iterator const_iterator;
103 const_iterator begin()
const {
return nodes_.begin(); }
104 const_iterator end()
const {
return nodes_.end(); }
106 typedef NodeVector::reverse_iterator reverse_iterator;
107 reverse_iterator rbegin() {
return nodes_.rbegin(); }
108 reverse_iterator rend() {
return nodes_.rend(); }
110 void AddNode(Node* node);
111 template <
class InputIterator>
112 void InsertNodes(iterator insertion_point, InputIterator insertion_start,
113 InputIterator insertion_end) {
114 nodes_.insert(insertion_point, insertion_start, insertion_end);
118 Control control()
const {
return control_; }
119 void set_control(Control control);
121 Node* control_input()
const {
return control_input_; }
122 void set_control_input(Node* control_input);
124 bool deferred()
const {
return deferred_; }
125 void set_deferred(
bool deferred) { deferred_ = deferred; }
127 int32_t dominator_depth()
const {
return dominator_depth_; }
128 void set_dominator_depth(int32_t depth) { dominator_depth_ = depth; }
130 BasicBlock* dominator()
const {
return dominator_; }
131 void set_dominator(BasicBlock* dominator) { dominator_ = dominator; }
133 BasicBlock* rpo_next()
const {
return rpo_next_; }
134 void set_rpo_next(BasicBlock* rpo_next) { rpo_next_ = rpo_next; }
136 BasicBlock* loop_header()
const {
return loop_header_; }
137 void set_loop_header(BasicBlock* loop_header);
139 BasicBlock* loop_end()
const {
return loop_end_; }
140 void set_loop_end(BasicBlock* loop_end);
142 int32_t loop_depth()
const {
return loop_depth_; }
143 void set_loop_depth(int32_t loop_depth);
145 int32_t loop_number()
const {
return loop_number_; }
146 void set_loop_number(int32_t loop_number) { loop_number_ = loop_number; }
148 int32_t rpo_number()
const {
return rpo_number_; }
149 void set_rpo_number(int32_t rpo_number);
152 inline bool IsLoopHeader()
const {
return loop_end_ !=
nullptr; }
153 bool LoopContains(BasicBlock* block)
const;
157 static BasicBlock* GetCommonDominator(BasicBlock* b1, BasicBlock* b2);
160 int32_t loop_number_;
163 int32_t dominator_depth_;
164 BasicBlock* dominator_;
165 BasicBlock* rpo_next_;
166 BasicBlock* loop_header_;
169 BasicBlock* loop_end_;
173 Node* control_input_;
176 BasicBlockVector successors_;
177 BasicBlockVector predecessors_;
179 AssemblerDebugInfo debug_info_;
183 DISALLOW_COPY_AND_ASSIGN(BasicBlock);
186 std::ostream& operator<<(std::ostream&,
const BasicBlock&);
187 std::ostream& operator<<(std::ostream&,
const BasicBlock::Control&);
188 std::ostream& operator<<(std::ostream&,
const BasicBlock::Id&);
194 class V8_EXPORT_PRIVATE
Schedule final :
public NON_EXPORTED_BASE(ZoneObject) {
196 explicit Schedule(
Zone* zone,
size_t node_count_hint = 0);
201 bool IsScheduled(
Node* node);
204 size_t BasicBlockCount()
const {
return all_blocks_.size(); }
205 size_t RpoBlockCount()
const {
return rpo_order_.size(); }
208 bool SameBasicBlock(
Node* a,
Node* b)
const;
257 return AddSuccessor(block, succ);
267 Zone* zone()
const {
return zone_; }
275 void EnsureCFGWellFormedness();
280 void EliminateRedundantPhiNodes();
284 void EnsureDeferredCodeSingleEntryPoint(
BasicBlock* block);
288 void PropagateDeferredMark();
306 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
const Schedule&);
312 #endif // V8_COMPILER_SCHEDULE_H_