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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // In the general case we remember the candidate for later. | 91 // In the general case we remember the candidate for later. |
| 92 candidates_.insert({function, node, calls}); | 92 candidates_.insert({function, node, calls}); |
| 93 return NoChange(); | 93 return NoChange(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 void JSInliningHeuristic::Finalize() { | 97 void JSInliningHeuristic::Finalize() { |
| 98 if (candidates_.empty()) return; // Nothing to do without candidates. | 98 if (candidates_.empty()) return; // Nothing to do without candidates. |
| 99 if (FLAG_trace_turbo_inlining) PrintCandidates(); | 99 if (FLAG_trace_turbo_inlining) PrintCandidates(); |
| 100 | 100 |
| 101 while (!candidates_.empty()) { | 101 if (cumulative_count_ > FLAG_max_inlined_nodes_cumulative) return; |
|
Michael Starzinger
2015/11/12 13:00:16
nit: Can we add a comment here explaining the logi
Benedikt Meurer
2015/11/12 13:05:40
Done.
| |
| 102 if (cumulative_count_ > FLAG_max_inlined_nodes_cumulative) break; | 102 auto i = candidates_.begin(); |
| 103 auto i = candidates_.begin(); | 103 Candidate const& candidate = *i; |
| 104 Candidate const& candidate = *i; | 104 inliner_.ReduceJSCall(candidate.node, candidate.function); |
| 105 inliner_.ReduceJSCall(candidate.node, candidate.function); | 105 cumulative_count_ += candidate.function->shared()->ast_node_count(); |
| 106 cumulative_count_ += candidate.function->shared()->ast_node_count(); | 106 candidates_.erase(i); |
| 107 candidates_.erase(i); | |
| 108 } | |
| 109 } | 107 } |
| 110 | 108 |
| 111 | 109 |
| 112 bool JSInliningHeuristic::CandidateCompare::operator()( | 110 bool JSInliningHeuristic::CandidateCompare::operator()( |
| 113 const Candidate& left, const Candidate& right) const { | 111 const Candidate& left, const Candidate& right) const { |
| 114 return left.node != right.node && left.calls >= right.calls; | 112 return left.node != right.node && left.calls >= right.calls; |
| 115 } | 113 } |
| 116 | 114 |
| 117 | 115 |
| 118 void JSInliningHeuristic::PrintCandidates() { | 116 void JSInliningHeuristic::PrintCandidates() { |
| 119 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); | 117 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); |
| 120 for (const Candidate& candidate : candidates_) { | 118 for (const Candidate& candidate : candidates_) { |
| 121 PrintF(" id:%d, calls:%d, size[source]:%d, size[ast]:%d / %s\n", | 119 PrintF(" id:%d, calls:%d, size[source]:%d, size[ast]:%d / %s\n", |
| 122 candidate.node->id(), candidate.calls, | 120 candidate.node->id(), candidate.calls, |
| 123 candidate.function->shared()->SourceSize(), | 121 candidate.function->shared()->SourceSize(), |
| 124 candidate.function->shared()->ast_node_count(), | 122 candidate.function->shared()->ast_node_count(), |
| 125 candidate.function->shared()->DebugName()->ToCString().get()); | 123 candidate.function->shared()->DebugName()->ToCString().get()); |
| 126 } | 124 } |
| 127 } | 125 } |
| 128 | 126 |
| 129 } // namespace compiler | 127 } // namespace compiler |
| 130 } // namespace internal | 128 } // namespace internal |
| 131 } // namespace v8 | 129 } // namespace v8 |
| OLD | NEW |