From 5f10c6820d9bbe50389b20cfc2bc2fe127e5b1b1 Mon Sep 17 00:00:00 2001 From: mvstanton Date: Fri, 3 Mar 2017 06:54:32 -0800 Subject: [PATCH] [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} --- src/compiler/js-inlining-heuristic.cc | 4 ++++ src/feedback-vector.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/compiler/js-inlining-heuristic.cc b/src/compiler/js-inlining-heuristic.cc index 6f99fbb183..59af71f1ae 100644 --- a/src/compiler/js-inlining-heuristic.cc +++ b/src/compiler/js-inlining-heuristic.cc @@ -164,6 +164,10 @@ void JSInliningHeuristic::Finalize() { auto i = candidates_.begin(); Candidate candidate = *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. if (!candidate.node->IsDead()) { Reduction const reduction = InlineCandidate(candidate); diff --git a/src/feedback-vector.cc b/src/feedback-vector.cc index 4003068e9b..5d84276399 100644 --- a/src/feedback-vector.cc +++ b/src/feedback-vector.cc @@ -591,6 +591,10 @@ int CallICNexus::ExtractCallCount() { float CallICNexus::ComputeCallFrequency() { double const invocation_count = vector()->invocation_count(); double const call_count = ExtractCallCount(); + if (invocation_count == 0) { + // Prevent division by 0. + return 0.0f; + } return static_cast(call_count / invocation_count); }