Commit 5f10c682 authored by mvstanton's avatar mvstanton Committed by Commit bot

[Turbofan] Don't inline if we never saw a function.

Also prevent division by zero.

R=tebbi@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2731723002
Cr-Commit-Position: refs/heads/master@{#43590}
parent 5f79c923
...@@ -164,6 +164,10 @@ void JSInliningHeuristic::Finalize() { ...@@ -164,6 +164,10 @@ void JSInliningHeuristic::Finalize() {
auto i = candidates_.begin(); auto i = candidates_.begin();
Candidate candidate = *i; Candidate candidate = *i;
candidates_.erase(i); candidates_.erase(i);
// Only include candidates that we've successfully called before.
// The candidate list is sorted, so we can exit at the first occurance of
// frequency 0 in the list.
if (candidate.frequency <= 0.0) return;
// Make sure we don't try to inline dead candidate nodes. // Make sure we don't try to inline dead candidate nodes.
if (!candidate.node->IsDead()) { if (!candidate.node->IsDead()) {
Reduction const reduction = InlineCandidate(candidate); Reduction const reduction = InlineCandidate(candidate);
......
...@@ -591,6 +591,10 @@ int CallICNexus::ExtractCallCount() { ...@@ -591,6 +591,10 @@ int CallICNexus::ExtractCallCount() {
float CallICNexus::ComputeCallFrequency() { float CallICNexus::ComputeCallFrequency() {
double const invocation_count = vector()->invocation_count(); double const invocation_count = vector()->invocation_count();
double const call_count = ExtractCallCount(); double const call_count = ExtractCallCount();
if (invocation_count == 0) {
// Prevent division by 0.
return 0.0f;
}
return static_cast<float>(call_count / invocation_count); return static_cast<float>(call_count / invocation_count);
} }
......
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