Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 100 |
| 101 // We inline at most one candidate in every iteration of the fixpoint. | 101 // We inline at most one candidate in every iteration of the fixpoint. |
| 102 // This is to ensure that we don't consume the full inlining budget | 102 // This is to ensure that we don't consume the full inlining budget |
| 103 // on things that aren't called very often. | 103 // on things that aren't called very often. |
| 104 // TODO(bmeurer): Use std::priority_queue instead of std::set here. | 104 // TODO(bmeurer): Use std::priority_queue instead of std::set here. |
| 105 while (!candidates_.empty()) { | 105 while (!candidates_.empty()) { |
| 106 if (cumulative_count_ > FLAG_max_inlined_nodes_cumulative) return; | 106 if (cumulative_count_ > FLAG_max_inlined_nodes_cumulative) return; |
| 107 auto i = candidates_.begin(); | 107 auto i = candidates_.begin(); |
| 108 Candidate candidate = *i; | 108 Candidate candidate = *i; |
| 109 candidates_.erase(i); | 109 candidates_.erase(i); |
| 110 Reduction r = inliner_.ReduceJSCall(candidate.node, candidate.function); | 110 // Make sure we don't try to inline dead candidate nodes. |
|
Michael Starzinger
2015/12/07 10:50:49
suggestion: Could also be phrased as "if (candidat
Benedikt Meurer
2015/12/07 11:25:44
Had that initially, but changed it to this.
| |
| 111 if (r.Changed()) { | 111 if (!candidate.node->IsDead()) { |
| 112 cumulative_count_ += candidate.function->shared()->ast_node_count(); | 112 Reduction r = inliner_.ReduceJSCall(candidate.node, candidate.function); |
| 113 return; | 113 if (r.Changed()) { |
| 114 cumulative_count_ += candidate.function->shared()->ast_node_count(); | |
| 115 return; | |
| 116 } | |
| 114 } | 117 } |
| 115 } | 118 } |
| 116 } | 119 } |
| 117 | 120 |
| 118 | 121 |
| 119 bool JSInliningHeuristic::CandidateCompare::operator()( | 122 bool JSInliningHeuristic::CandidateCompare::operator()( |
| 120 const Candidate& left, const Candidate& right) const { | 123 const Candidate& left, const Candidate& right) const { |
| 121 return left.node != right.node && left.calls >= right.calls; | 124 return left.node != right.node && left.calls >= right.calls; |
| 122 } | 125 } |
| 123 | 126 |
| 124 | 127 |
| 125 void JSInliningHeuristic::PrintCandidates() { | 128 void JSInliningHeuristic::PrintCandidates() { |
| 126 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); | 129 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); |
| 127 for (const Candidate& candidate : candidates_) { | 130 for (const Candidate& candidate : candidates_) { |
| 128 PrintF(" id:%d, calls:%d, size[source]:%d, size[ast]:%d / %s\n", | 131 PrintF(" id:%d, calls:%d, size[source]:%d, size[ast]:%d / %s\n", |
| 129 candidate.node->id(), candidate.calls, | 132 candidate.node->id(), candidate.calls, |
| 130 candidate.function->shared()->SourceSize(), | 133 candidate.function->shared()->SourceSize(), |
| 131 candidate.function->shared()->ast_node_count(), | 134 candidate.function->shared()->ast_node_count(), |
| 132 candidate.function->shared()->DebugName()->ToCString().get()); | 135 candidate.function->shared()->DebugName()->ToCString().get()); |
| 133 } | 136 } |
| 134 } | 137 } |
| 135 | 138 |
| 136 } // namespace compiler | 139 } // namespace compiler |
| 137 } // namespace internal | 140 } // namespace internal |
| 138 } // namespace v8 | 141 } // namespace v8 |
| OLD | NEW |