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 #ifndef V8_COMPILER_SCHEDULE_H_ | 5 #ifndef V8_COMPILER_SCHEDULE_H_ |
6 #define V8_COMPILER_SCHEDULE_H_ | 6 #define V8_COMPILER_SCHEDULE_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
| 10 #include "src/base/compiler-specific.h" |
| 11 #include "src/globals.h" |
10 #include "src/zone/zone-containers.h" | 12 #include "src/zone/zone-containers.h" |
11 | 13 |
12 namespace v8 { | 14 namespace v8 { |
13 namespace internal { | 15 namespace internal { |
14 namespace compiler { | 16 namespace compiler { |
15 | 17 |
16 // Forward declarations. | 18 // Forward declarations. |
17 class BasicBlock; | 19 class BasicBlock; |
18 class BasicBlockInstrumentor; | 20 class BasicBlockInstrumentor; |
19 class Node; | 21 class Node; |
20 | 22 |
21 | 23 |
22 typedef ZoneVector<BasicBlock*> BasicBlockVector; | 24 typedef ZoneVector<BasicBlock*> BasicBlockVector; |
23 typedef ZoneVector<Node*> NodeVector; | 25 typedef ZoneVector<Node*> NodeVector; |
24 | 26 |
25 | 27 |
26 // A basic block contains an ordered list of nodes and ends with a control | 28 // A basic block contains an ordered list of nodes and ends with a control |
27 // node. Note that if a basic block has phis, then all phis must appear as the | 29 // node. Note that if a basic block has phis, then all phis must appear as the |
28 // first nodes in the block. | 30 // first nodes in the block. |
29 class BasicBlock final : public ZoneObject { | 31 class V8_EXPORT_PRIVATE BasicBlock final |
| 32 : public NON_EXPORTED_BASE(ZoneObject) { |
30 public: | 33 public: |
31 // Possible control nodes that can end a block. | 34 // Possible control nodes that can end a block. |
32 enum Control { | 35 enum Control { |
33 kNone, // Control not initialized yet. | 36 kNone, // Control not initialized yet. |
34 kGoto, // Goto a single successor block. | 37 kGoto, // Goto a single successor block. |
35 kCall, // Call with continuation as first successor, exception | 38 kCall, // Call with continuation as first successor, exception |
36 // second. | 39 // second. |
37 kBranch, // Branch if true to first successor, otherwise second. | 40 kBranch, // Branch if true to first successor, otherwise second. |
38 kSwitch, // Table dispatch to one of the successor blocks. | 41 kSwitch, // Table dispatch to one of the successor blocks. |
39 kDeoptimize, // Return a value from this method. | 42 kDeoptimize, // Return a value from this method. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 }; | 173 }; |
171 | 174 |
172 std::ostream& operator<<(std::ostream&, const BasicBlock::Control&); | 175 std::ostream& operator<<(std::ostream&, const BasicBlock::Control&); |
173 std::ostream& operator<<(std::ostream&, const BasicBlock::Id&); | 176 std::ostream& operator<<(std::ostream&, const BasicBlock::Id&); |
174 | 177 |
175 | 178 |
176 // A schedule represents the result of assigning nodes to basic blocks | 179 // A schedule represents the result of assigning nodes to basic blocks |
177 // and ordering them within basic blocks. Prior to computing a schedule, | 180 // and ordering them within basic blocks. Prior to computing a schedule, |
178 // a graph has no notion of control flow ordering other than that induced | 181 // a graph has no notion of control flow ordering other than that induced |
179 // by the graph's dependencies. A schedule is required to generate code. | 182 // by the graph's dependencies. A schedule is required to generate code. |
180 class Schedule final : public ZoneObject { | 183 class V8_EXPORT_PRIVATE Schedule final : public NON_EXPORTED_BASE(ZoneObject) { |
181 public: | 184 public: |
182 explicit Schedule(Zone* zone, size_t node_count_hint = 0); | 185 explicit Schedule(Zone* zone, size_t node_count_hint = 0); |
183 | 186 |
184 // Return the block which contains {node}, if any. | 187 // Return the block which contains {node}, if any. |
185 BasicBlock* block(Node* node) const; | 188 BasicBlock* block(Node* node) const; |
186 | 189 |
187 bool IsScheduled(Node* node); | 190 bool IsScheduled(Node* node); |
188 BasicBlock* GetBlockById(BasicBlock::Id block_id); | 191 BasicBlock* GetBlockById(BasicBlock::Id block_id); |
189 | 192 |
190 size_t BasicBlockCount() const { return all_blocks_.size(); } | 193 size_t BasicBlockCount() const { return all_blocks_.size(); } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 Zone* zone_; | 278 Zone* zone_; |
276 BasicBlockVector all_blocks_; // All basic blocks in the schedule. | 279 BasicBlockVector all_blocks_; // All basic blocks in the schedule. |
277 BasicBlockVector nodeid_to_block_; // Map from node to containing block. | 280 BasicBlockVector nodeid_to_block_; // Map from node to containing block. |
278 BasicBlockVector rpo_order_; // Reverse-post-order block list. | 281 BasicBlockVector rpo_order_; // Reverse-post-order block list. |
279 BasicBlock* start_; | 282 BasicBlock* start_; |
280 BasicBlock* end_; | 283 BasicBlock* end_; |
281 | 284 |
282 DISALLOW_COPY_AND_ASSIGN(Schedule); | 285 DISALLOW_COPY_AND_ASSIGN(Schedule); |
283 }; | 286 }; |
284 | 287 |
285 std::ostream& operator<<(std::ostream&, const Schedule&); | 288 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, const Schedule&); |
286 | 289 |
287 } // namespace compiler | 290 } // namespace compiler |
288 } // namespace internal | 291 } // namespace internal |
289 } // namespace v8 | 292 } // namespace v8 |
290 | 293 |
291 #endif // V8_COMPILER_SCHEDULE_H_ | 294 #endif // V8_COMPILER_SCHEDULE_H_ |
OLD | NEW |