[osr] Fix an invalid DCHECK in %CompileOptimizedOSR

This particular branch in CompileOptimizedOSR relies on a precise
invocation count at counts 0 and 1. The invocation count is unreliable
not only in the previously described situation (--always-opt), but also
e.g. when forcing optimization on the first execution through other
means like %OptimizeFunctionOnNextCall. Let's simply rewrite the
condition to explicitly exclude kIsInProgress.

Fixed: chromium:1314536
Change-Id: I27432f689c866bad3b407df7bbf276ec32c25c0d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3578644
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79913}
This commit is contained in:
Jakob Gruber 2022-04-11 13:19:52 +02:00 committed by V8 LUCI CQ
parent 4e046ceaf3
commit 5e431b9838

View File

@ -307,11 +307,8 @@ RUNTIME_FUNCTION(Runtime_CompileOptimizedOSR) {
}
if (function->feedback_vector().invocation_count() <= 1 &&
!IsNone(function->tiering_state()) && V8_LIKELY(!FLAG_always_opt)) {
// Note: Why consider FLAG_always_opt? Because it makes invocation_count
// unreliable at low counts: the first entry may already be optimized, and
// thus won't increment invocation_count.
//
!IsNone(function->tiering_state()) &&
!IsInProgress(function->tiering_state())) {
// With lazy feedback allocation we may not have feedback for the
// initial part of the function that was executed before we allocated a
// feedback vector. Reset any tiering states for such functions.
@ -321,7 +318,6 @@ RUNTIME_FUNCTION(Runtime_CompileOptimizedOSR) {
// feedback. We cannot do this currently since we OSR only after we mark
// a function for optimization. We should instead change it to be based
// based on number of ticks.
DCHECK(!IsInProgress(function->tiering_state()));
function->reset_tiering_state();
}