Index: src/compiler/graph.h |
diff --git a/src/compiler/graph.h b/src/compiler/graph.h |
index 958a15d282c01b03ad7402b97e89e937541800a0..a694a0b414a578b24b9e0f4f2cc6edb29c8472c6 100644 |
--- a/src/compiler/graph.h |
+++ b/src/compiler/graph.h |
@@ -28,11 +28,30 @@ typedef uint32_t Mark; |
// out-of-line data associated with each node. |
typedef uint32_t NodeId; |
- |
-class Graph : public ZoneObject { |
+class Graph final : public ZoneObject { |
public: |
explicit Graph(Zone* zone); |
+ // Scope used when creating a subgraph for inlining. Automatically preserves |
+ // the original start and end nodes of the graph, and resets them when you |
+ // leave the scope. |
+ class SubgraphScope final { |
+ public: |
+ explicit SubgraphScope(Graph* graph) |
+ : graph_(graph), start_(graph->start()), end_(graph->end()) {} |
+ ~SubgraphScope() { |
+ graph_->SetStart(start_); |
+ graph_->SetEnd(end_); |
+ } |
+ |
+ private: |
+ Graph* const graph_; |
+ Node* const start_; |
+ Node* const end_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SubgraphScope); |
+ }; |
+ |
// Base implementation used by all factory methods. |
Node* NewNodeUnchecked(const Operator* op, int input_count, |
Node* const* inputs, bool incomplete = false); |