[nci] Allow OSR to NCI code in testing modes

In the --turbo-nci-as-highest-tier testing mode, allow NCI codegen for
OSR to increase coverage and simplify logic.

Bug: v8:8888
Change-Id: I254939928f92bf675dbf2b78cdd5b5dce802d972
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2339460
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69262}
diff --git a/src/codegen/compiler.cc b/src/codegen/compiler.cc
index e3425d0..572e05d 100644
--- a/src/codegen/compiler.cc
+++ b/src/codegen/compiler.cc
@@ -1037,10 +1037,8 @@
   DCHECK(shared->is_compiled());
   function->feedback_vector().set_profiler_ticks(0);
 
-  if (CodeKindIsNativeContextIndependentJSFunction(code_kind)) {
-    // We don't generate NCI code for OSR.
-    DCHECK_EQ(osr_offset, BailoutId::None());
-
+  if (CodeKindIsNativeContextIndependentJSFunction(code_kind) &&
+      osr_offset == BailoutId::None()) {
     // Don't generate NCI code when we've already done so in the past.
     Handle<Code> cached_code;
     if (GetCodeFromCompilationCache(isolate, shared).ToHandle(&cached_code)) {
@@ -2902,7 +2900,7 @@
   DCHECK(!osr_offset.IsNone());
   DCHECK_NOT_NULL(osr_frame);
   return GetOptimizedCode(function, ConcurrencyMode::kNotConcurrent,
-                          CodeKindForOSR(), osr_offset, osr_frame);
+                          CodeKindForTopTier(), osr_offset, osr_frame);
 }
 
 // static
diff --git a/src/objects/code-kind.h b/src/objects/code-kind.h
index 6020470..62538d5 100644
--- a/src/objects/code-kind.h
+++ b/src/objects/code-kind.h
@@ -72,8 +72,6 @@
                                         : CodeKind::OPTIMIZED_FUNCTION;
 }
 
-inline CodeKind CodeKindForOSR() { return CodeKind::OPTIMIZED_FUNCTION; }
-
 }  // namespace internal
 }  // namespace v8