Commit 2dd02967 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[compiler] Visit-order-independent inlining heuristics

When making inlining decisions in the JSInliningHeuristic, it's
possible that a Node is not a candidate on the first visit, but
becomes a candidate in later visits due to other node reductions.

These later visits should also result in the inlining decision being
made. Until now this was prevented by the visit aborting early since
the Node was added to the seen_ list on the first (unsuccessful)
visit.

This CL changes the seen_ insertion to happen only once a positive
inlining decision was made.

Change-Id: Ide7f6abd3c1d9759d7422fcd5ad9c7daff825795
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764759
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73533}
parent 4194d3bb
...@@ -156,7 +156,6 @@ Reduction JSInliningHeuristic::Reduce(Node* node) { ...@@ -156,7 +156,6 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
// Check if we already saw that {node} before, and if so, just skip it. // Check if we already saw that {node} before, and if so, just skip it.
if (seen_.find(node->id()) != seen_.end()) return NoChange(); if (seen_.find(node->id()) != seen_.end()) return NoChange();
seen_.insert(node->id());
// Check if the {node} is an appropriate candidate for inlining. // Check if the {node} is an appropriate candidate for inlining.
Candidate candidate = CollectFunctions(node, kMaxCallPolymorphism); Candidate candidate = CollectFunctions(node, kMaxCallPolymorphism);
...@@ -234,6 +233,14 @@ Reduction JSInliningHeuristic::Reduce(Node* node) { ...@@ -234,6 +233,14 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
return NoChange(); return NoChange();
} }
// Found a candidate. Insert it into the set of seen nodes s.t. we don't
// revisit in the future. Note this insertion happens here and not earlier in
// order to make inlining decisions order-independent. A node may not be a
// candidate when first seen, but later reductions may turn it into a valid
// candidate. In that case, the node should be revisited by
// JSInliningHeuristic.
seen_.insert(node->id());
// Forcibly inline small functions here. In the case of polymorphic inlining // Forcibly inline small functions here. In the case of polymorphic inlining
// candidate_is_small is set only when all functions are small. // candidate_is_small is set only when all functions are small.
if (candidate_is_small) { if (candidate_is_small) {
......
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