Commit 558cee1d authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Always inline small functions directly.

Introduce a flag --max_inlined_nodes_small (defaults to 10), which gives
the upper limit of AST nodes for a function to be considered "small" by
the inlining heuristic. These functions will always be inlined
immediately, independent of the budget.

R=jarin@chromium.org
BUG=v8:6395,v8:6278,v8:6344,v8:6394

Review-Url: https://codereview.chromium.org/2883853002
Cr-Commit-Position: refs/heads/master@{#45291}
parent e658bc57
......@@ -65,6 +65,15 @@ bool CanInlineFunction(Handle<SharedFunctionInfo> shared) {
return true;
}
bool IsSmallInlineFunction(Handle<SharedFunctionInfo> shared) {
// Don't forcibly inline functions that weren't compiled yet.
if (shared->ast_node_count() == 0) return false;
// Forcibly inline small functions.
if (shared->ast_node_count() <= FLAG_max_inlined_nodes_small) return true;
return false;
}
} // namespace
Reduction JSInliningHeuristic::Reduce(Node* node) {
......@@ -91,7 +100,7 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
}
// Functions marked with %SetForceInlineFlag are immediately inlined.
bool can_inline = false, force_inline = true;
bool can_inline = false, force_inline = true, small_inline = true;
for (int i = 0; i < candidate.num_functions; ++i) {
Handle<SharedFunctionInfo> shared =
candidate.functions[i].is_null()
......@@ -103,6 +112,9 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
if (CanInlineFunction(shared)) {
can_inline = true;
}
if (!IsSmallInlineFunction(shared)) {
small_inline = false;
}
}
if (force_inline) return InlineCandidate(candidate);
if (!can_inline) return NoChange();
......@@ -154,6 +166,13 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
return NoChange();
}
// Forcibly inline small functions here.
if (small_inline) {
TRACE("Inlining small function(s) at call site #%d:%s\n", node->id(),
node->op()->mnemonic());
return InlineCandidate(candidate);
}
// In the general case we remember the candidate for later.
candidates_.insert(candidate);
return NoChange();
......
......@@ -361,6 +361,8 @@ DEFINE_INT(max_inlined_nodes, 200,
"maximum number of AST nodes considered for a single inlining")
DEFINE_INT(max_inlined_nodes_cumulative, 400,
"maximum cumulative number of AST nodes considered for inlining")
DEFINE_INT(max_inlined_nodes_small, 10,
"maximum number of AST nodes considered for small function inlining")
DEFINE_FLOAT(min_inlining_frequency, 0.15, "minimum frequency for inlining")
DEFINE_BOOL(loop_invariant_code_motion, true, "loop invariant code motion")
DEFINE_BOOL(fast_math, true, "faster (but maybe less accurate) math functions")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment