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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Everything above this line is part of the inlining heuristic. | 82 // Everything above this line is part of the inlining heuristic. |
83 // --------------------------------------------------------------------------- | 83 // --------------------------------------------------------------------------- |
84 | 84 |
85 // In the general case we remember the candidate for later. | 85 // In the general case we remember the candidate for later. |
86 candidates_.insert({function, node, calls}); | 86 candidates_.insert({function, node, calls}); |
87 return NoChange(); | 87 return NoChange(); |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 void JSInliningHeuristic::Finalize() { | 91 void JSInliningHeuristic::Finalize() { |
| 92 if (candidates_.empty()) return; // Nothing to do without candidates. |
92 if (FLAG_trace_turbo_inlining) PrintCandidates(); | 93 if (FLAG_trace_turbo_inlining) PrintCandidates(); |
93 | 94 |
94 while (!candidates_.empty()) { | 95 while (!candidates_.empty()) { |
95 if (cumulative_count_ > FLAG_max_inlined_nodes_cumulative) break; | 96 if (cumulative_count_ > FLAG_max_inlined_nodes_cumulative) break; |
96 auto i = candidates_.begin(); | 97 auto i = candidates_.begin(); |
97 Candidate const& candidate = *i; | 98 Candidate const& candidate = *i; |
98 inliner_.ReduceJSCallFunction(candidate.node, candidate.function); | 99 inliner_.ReduceJSCallFunction(candidate.node, candidate.function); |
99 cumulative_count_ += candidate.function->shared()->ast_node_count(); | 100 cumulative_count_ += candidate.function->shared()->ast_node_count(); |
100 candidates_.erase(i); | 101 candidates_.erase(i); |
101 } | 102 } |
(...skipping 13 matching lines...) Expand all Loading... |
115 candidate.node->id(), candidate.calls, | 116 candidate.node->id(), candidate.calls, |
116 candidate.function->shared()->SourceSize(), | 117 candidate.function->shared()->SourceSize(), |
117 candidate.function->shared()->ast_node_count(), | 118 candidate.function->shared()->ast_node_count(), |
118 candidate.function->shared()->DebugName()->ToCString().get()); | 119 candidate.function->shared()->DebugName()->ToCString().get()); |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 } // namespace compiler | 123 } // namespace compiler |
123 } // namespace internal | 124 } // namespace internal |
124 } // namespace v8 | 125 } // namespace v8 |
OLD | NEW |