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

Side by Side Diff: src/compiler/graph-trimmer.h

Issue 1698883003: [turbofan] Robustify the GraphTrimmer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | src/compiler/graph-trimmer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 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_GRAPH_TRIMMER_H_ 5 #ifndef V8_COMPILER_GRAPH_TRIMMER_H_
6 #define V8_COMPILER_GRAPH_TRIMMER_H_ 6 #define V8_COMPILER_GRAPH_TRIMMER_H_
7 7
8 #include "src/compiler/node-marker.h" 8 #include "src/compiler/node-marker.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 10 matching lines...) Expand all
21 GraphTrimmer(Zone* zone, Graph* graph); 21 GraphTrimmer(Zone* zone, Graph* graph);
22 ~GraphTrimmer(); 22 ~GraphTrimmer();
23 23
24 // Trim nodes in the {graph} that are not reachable from {graph->end()}. 24 // Trim nodes in the {graph} that are not reachable from {graph->end()}.
25 void TrimGraph(); 25 void TrimGraph();
26 26
27 // Trim nodes in the {graph} that are not reachable from either {graph->end()} 27 // Trim nodes in the {graph} that are not reachable from either {graph->end()}
28 // or any of the roots in the sequence [{begin},{end}[. 28 // or any of the roots in the sequence [{begin},{end}[.
29 template <typename ForwardIterator> 29 template <typename ForwardIterator>
30 void TrimGraph(ForwardIterator begin, ForwardIterator end) { 30 void TrimGraph(ForwardIterator begin, ForwardIterator end) {
31 while (begin != end) MarkAsLive(*begin++); 31 while (begin != end) {
32 Node* const node = *begin++;
33 if (!node->IsDead()) MarkAsLive(node);
34 }
32 TrimGraph(); 35 TrimGraph();
33 } 36 }
34 37
35 private: 38 private:
36 V8_INLINE bool IsLive(Node* const node) { return is_live_.Get(node); } 39 V8_INLINE bool IsLive(Node* const node) { return is_live_.Get(node); }
37 V8_INLINE void MarkAsLive(Node* const node) { 40 V8_INLINE void MarkAsLive(Node* const node) {
38 if (!node->IsDead() && !IsLive(node)) { 41 DCHECK(!node->IsDead());
42 if (!IsLive(node)) {
39 is_live_.Set(node, true); 43 is_live_.Set(node, true);
40 live_.push_back(node); 44 live_.push_back(node);
41 } 45 }
42 } 46 }
43 47
44 Graph* graph() const { return graph_; } 48 Graph* graph() const { return graph_; }
45 49
46 Graph* const graph_; 50 Graph* const graph_;
47 NodeMarker<bool> is_live_; 51 NodeMarker<bool> is_live_;
48 NodeVector live_; 52 NodeVector live_;
49 53
50 DISALLOW_COPY_AND_ASSIGN(GraphTrimmer); 54 DISALLOW_COPY_AND_ASSIGN(GraphTrimmer);
51 }; 55 };
52 56
53 } // namespace compiler 57 } // namespace compiler
54 } // namespace internal 58 } // namespace internal
55 } // namespace v8 59 } // namespace v8
56 60
57 #endif // V8_COMPILER_GRAPH_TRIMMER_H_ 61 #endif // V8_COMPILER_GRAPH_TRIMMER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/graph-trimmer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698