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

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

Issue 1188433010: [turbofan] Move graph trimming functionality to dedicated GraphTrimmer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « src/compiler/graph-trimmer.h ('k') | src/compiler/node-marker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "src/compiler/graph-trimmer.h"
6
7 #include "src/compiler/graph.h"
8
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12
13 GraphTrimmer::GraphTrimmer(Zone* zone, Graph* graph)
14 : graph_(graph), is_live_(graph, 2), live_(zone) {
15 live_.reserve(graph->NodeCount());
16 }
17
18
19 GraphTrimmer::~GraphTrimmer() {}
20
21
22 void GraphTrimmer::TrimGraph() {
23 // Mark end node as live.
24 MarkAsLive(graph()->end());
25 // Compute transitive closure of live nodes.
26 for (size_t i = 0; i < live_.size(); ++i) {
27 for (Node* const input : live_[i]->inputs()) {
28 DCHECK_EQ(IsLive(input),
29 std::find(live_.begin(), live_.end(), input) != live_.end());
30 MarkAsLive(input);
31 }
32 }
33 // Remove dead->live edges.
34 for (Node* const live : live_) {
35 DCHECK(IsLive(live));
36 for (Edge edge : live->use_edges()) {
37 Node* const user = edge.from();
38 DCHECK_EQ(IsLive(user),
39 std::find(live_.begin(), live_.end(), user) != live_.end());
40 if (!IsLive(user)) {
41 if (FLAG_trace_turbo_reduction) {
42 OFStream os(stdout);
43 os << "DeadLink: " << *user << "(" << edge.index() << ") -> " << *live
44 << std::endl;
45 }
46 edge.UpdateTo(nullptr);
47 }
48 }
49 }
50 }
51
52 } // namespace compiler
53 } // namespace internal
54 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/graph-trimmer.h ('k') | src/compiler/node-marker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698