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/compilation-info.h" | 7 #include "src/compilation-info.h" |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return 0; | 42 return 0; |
43 } | 43 } |
44 | 44 |
45 bool CanInlineFunction(Handle<JSFunction> function) { | 45 bool CanInlineFunction(Handle<JSFunction> function) { |
46 // Built-in functions are handled by the JSBuiltinReducer. | 46 // Built-in functions are handled by the JSBuiltinReducer. |
47 if (function->shared()->HasBuiltinFunctionId()) return false; | 47 if (function->shared()->HasBuiltinFunctionId()) return false; |
48 | 48 |
49 // Don't inline builtins. | 49 // Don't inline builtins. |
50 if (function->shared()->IsBuiltin()) return false; | 50 if (function->shared()->IsBuiltin()) return false; |
51 | 51 |
52 // Quick check on source code length to avoid parsing large candidate. | |
53 if (function->shared()->SourceSize() > FLAG_max_inlined_source_size) { | |
54 return false; | |
55 } | |
56 | |
57 // Quick check on the size of the AST to avoid parsing large candidate. | 52 // Quick check on the size of the AST to avoid parsing large candidate. |
58 if (function->shared()->ast_node_count() > FLAG_max_inlined_nodes) { | 53 if (function->shared()->ast_node_count() > FLAG_max_inlined_nodes) { |
59 return false; | 54 return false; |
60 } | 55 } |
61 | 56 |
62 // Avoid inlining across the boundary of asm.js code. | 57 // Avoid inlining across the boundary of asm.js code. |
63 if (function->shared()->asm_function()) return false; | 58 if (function->shared()->asm_function()) return false; |
64 return true; | 59 return true; |
65 } | 60 } |
66 | 61 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 275 } |
281 } | 276 } |
282 | 277 |
283 void JSInliningHeuristic::PrintCandidates() { | 278 void JSInliningHeuristic::PrintCandidates() { |
284 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); | 279 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); |
285 for (const Candidate& candidate : candidates_) { | 280 for (const Candidate& candidate : candidates_) { |
286 PrintF(" #%d:%s, frequency:%g\n", candidate.node->id(), | 281 PrintF(" #%d:%s, frequency:%g\n", candidate.node->id(), |
287 candidate.node->op()->mnemonic(), candidate.frequency); | 282 candidate.node->op()->mnemonic(), candidate.frequency); |
288 for (int i = 0; i < candidate.num_functions; ++i) { | 283 for (int i = 0; i < candidate.num_functions; ++i) { |
289 Handle<JSFunction> function = candidate.functions[i]; | 284 Handle<JSFunction> function = candidate.functions[i]; |
290 PrintF(" - size[source]:%d, size[ast]:%d, name: %s\n", | 285 PrintF(" - size:%d, name: %s\n", function->shared()->ast_node_count(), |
291 function->shared()->SourceSize(), | |
292 function->shared()->ast_node_count(), | |
293 function->shared()->DebugName()->ToCString().get()); | 286 function->shared()->DebugName()->ToCString().get()); |
294 } | 287 } |
295 } | 288 } |
296 } | 289 } |
297 | 290 |
298 Graph* JSInliningHeuristic::graph() const { return jsgraph()->graph(); } | 291 Graph* JSInliningHeuristic::graph() const { return jsgraph()->graph(); } |
299 | 292 |
300 CommonOperatorBuilder* JSInliningHeuristic::common() const { | 293 CommonOperatorBuilder* JSInliningHeuristic::common() const { |
301 return jsgraph()->common(); | 294 return jsgraph()->common(); |
302 } | 295 } |
303 | 296 |
304 SimplifiedOperatorBuilder* JSInliningHeuristic::simplified() const { | 297 SimplifiedOperatorBuilder* JSInliningHeuristic::simplified() const { |
305 return jsgraph()->simplified(); | 298 return jsgraph()->simplified(); |
306 } | 299 } |
307 | 300 |
308 } // namespace compiler | 301 } // namespace compiler |
309 } // namespace internal | 302 } // namespace internal |
310 } // namespace v8 | 303 } // namespace v8 |
OLD | NEW |