v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
graph-trimmer.h
Go to the documentation of this file.
1// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_GRAPH_TRIMMER_H_
6#define V8_COMPILER_GRAPH_TRIMMER_H_
7
9
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14// Forward declarations.
15class TFGraph;
16
17// Trims dead nodes from the node graph.
19 public:
20 GraphTrimmer(Zone* zone, TFGraph* graph);
22 GraphTrimmer(const GraphTrimmer&) = delete;
24
25 // Trim nodes in the {graph} that are not reachable from {graph->end()}.
26 void TrimGraph();
27
28 // Trim nodes in the {graph} that are not reachable from either {graph->end()}
29 // or any of the roots in the sequence [{begin},{end}[.
30 template <typename ForwardIterator>
31 void TrimGraph(ForwardIterator begin, ForwardIterator end) {
32 while (begin != end) {
33 Node* const node = *begin++;
34 if (!node->IsDead()) MarkAsLive(node);
35 }
36 TrimGraph();
37 }
38
39 private:
40 V8_INLINE bool IsLive(Node* const node) { return is_live_.Get(node); }
41 V8_INLINE void MarkAsLive(Node* const node) {
42 DCHECK(!node->IsDead());
43 if (!IsLive(node)) {
44 is_live_.Set(node, true);
45 live_.push_back(node);
46 }
47 }
48
49 TFGraph* graph() const { return graph_; }
50
54};
55
56} // namespace compiler
57} // namespace internal
58} // namespace v8
59
60#endif // V8_COMPILER_GRAPH_TRIMMER_H_
GraphTrimmer & operator=(const GraphTrimmer &)=delete
V8_INLINE bool IsLive(Node *const node)
void TrimGraph(ForwardIterator begin, ForwardIterator end)
V8_INLINE void MarkAsLive(Node *const node)
GraphTrimmer(const GraphTrimmer &)=delete
int end
Node::Uses::const_iterator begin(const Node::Uses &uses)
Definition node.h:708
#define DCHECK(condition)
Definition logging.h:482
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_INLINE
Definition v8config.h:500
TFGraph * graph_