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

Side by Side Diff: src/compiler/js-inlining-heuristic.cc

Issue 1430553003: [turbofan] Use sorted set in JSInliningHeuristic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo of doom. Created 5 years, 1 month 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/js-inlining-heuristic.h ('k') | no next file » | 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 #include "src/compiler/js-inlining-heuristic.h" 5 #include "src/compiler/js-inlining-heuristic.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/dead-code-elimination.h" // TODO(mstarzinger): Remove! 8 #include "src/compiler/dead-code-elimination.h" // TODO(mstarzinger): Remove!
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (p.feedback().IsValid()) { 65 if (p.feedback().IsValid()) {
66 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); 66 CallICNexus nexus(p.feedback().vector(), p.feedback().slot());
67 calls = nexus.ExtractCallCount(); 67 calls = nexus.ExtractCallCount();
68 } 68 }
69 69
70 // --------------------------------------------------------------------------- 70 // ---------------------------------------------------------------------------
71 // Everything above this line is part of the inlining heuristic. 71 // Everything above this line is part of the inlining heuristic.
72 // --------------------------------------------------------------------------- 72 // ---------------------------------------------------------------------------
73 73
74 // In the general case we remember the candidate for later. 74 // In the general case we remember the candidate for later.
75 candidates_.push_back({function, node, calls}); 75 candidates_.insert({function, node, calls});
76 return NoChange(); 76 return NoChange();
77 } 77 }
78 78
79 79
80 void JSInliningHeuristic::ProcessCandidates() { 80 void JSInliningHeuristic::ProcessCandidates() {
81 if (candidates_.empty()) return; // Nothing to do without candidates. 81 if (candidates_.empty()) return; // Nothing to do without candidates.
82 std::sort(candidates_.begin(), candidates_.end(), Compare);
83 if (FLAG_trace_turbo_inlining) PrintCandidates(); 82 if (FLAG_trace_turbo_inlining) PrintCandidates();
84 83
85 int cumulative_count = 0; 84 int cumulative_count = 0;
86 for (const Candidate& candidate : candidates_) { 85 for (const Candidate& candidate : candidates_) {
87 if (cumulative_count > FLAG_max_inlined_nodes_cumulative) break; 86 if (cumulative_count > FLAG_max_inlined_nodes_cumulative) break;
88 inliner_.ReduceJSCallFunction(candidate.node, candidate.function); 87 inliner_.ReduceJSCallFunction(candidate.node, candidate.function);
89 cumulative_count += candidate.function->shared()->ast_node_count(); 88 cumulative_count += candidate.function->shared()->ast_node_count();
90 } 89 }
91 90
92 // TODO(mstarzinger): Temporary workaround to eliminate dead control from the 91 // TODO(mstarzinger): Temporary workaround to eliminate dead control from the
93 // graph being introduced by the inliner. Make this part of the pipeline. 92 // graph being introduced by the inliner. Make this part of the pipeline.
94 GraphReducer graph_reducer(local_zone_, jsgraph_->graph(), jsgraph_->Dead()); 93 GraphReducer graph_reducer(local_zone_, jsgraph_->graph(), jsgraph_->Dead());
95 DeadCodeElimination dead_code_elimination(&graph_reducer, jsgraph_->graph(), 94 DeadCodeElimination dead_code_elimination(&graph_reducer, jsgraph_->graph(),
96 jsgraph_->common()); 95 jsgraph_->common());
97 graph_reducer.AddReducer(&dead_code_elimination); 96 graph_reducer.AddReducer(&dead_code_elimination);
98 graph_reducer.ReduceGraph(); 97 graph_reducer.ReduceGraph();
99 } 98 }
100 99
101 100
102 // static 101 bool JSInliningHeuristic::CandidateCompare::operator()(
103 bool JSInliningHeuristic::Compare(const Candidate& left, 102 const Candidate& left, const Candidate& right) const {
104 const Candidate& right) { 103 return left.node != right.node && left.calls >= right.calls;
105 return left.calls > right.calls;
106 } 104 }
107 105
108 106
109 void JSInliningHeuristic::PrintCandidates() { 107 void JSInliningHeuristic::PrintCandidates() {
110 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); 108 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size());
111 for (const Candidate& candidate : candidates_) { 109 for (const Candidate& candidate : candidates_) {
112 PrintF(" id:%d, calls:%d, size[source]:%d, size[ast]:%d / %s\n", 110 PrintF(" id:%d, calls:%d, size[source]:%d, size[ast]:%d / %s\n",
113 candidate.node->id(), candidate.calls, 111 candidate.node->id(), candidate.calls,
114 candidate.function->shared()->SourceSize(), 112 candidate.function->shared()->SourceSize(),
115 candidate.function->shared()->ast_node_count(), 113 candidate.function->shared()->ast_node_count(),
116 candidate.function->shared()->DebugName()->ToCString().get()); 114 candidate.function->shared()->DebugName()->ToCString().get());
117 } 115 }
118 } 116 }
119 117
120 } // namespace compiler 118 } // namespace compiler
121 } // namespace internal 119 } // namespace internal
122 } // namespace v8 120 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-inlining-heuristic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698