[turboprop] Change heuristics for OSRing in TurboProp

Change the heuristics for OSRing in TurboProp. Currently we OSR if
a funciton is already optimized / marked for optimization but is still
running optimized code. Since TurboProp optimizes much earlier than
TurboFan using the same heuristics would cause us to OSR more often
than required. This cl adds an additional check on the number of ticks
to make sure the function is hot enough for OSRing.

Bug: v8:9684
Change-Id: I7a1c8229182a928fd85efb23e2d385413c5209ef
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2339098
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69252}
diff --git a/src/execution/runtime-profiler.cc b/src/execution/runtime-profiler.cc
index ff1d10b..1ce85f0 100644
--- a/src/execution/runtime-profiler.cc
+++ b/src/execution/runtime-profiler.cc
@@ -38,6 +38,14 @@
 // the very first time it is seen on the stack.
 static const int kMaxBytecodeSizeForEarlyOpt = 90;
+// Number of times a function has to be seen on the stack before it is
+// OSRed in TurboProp
+// This value is chosen so TurboProp OSRs at similar time as TurboFan. The
+// current interrupt budger of TurboFan is approximately 10 times that of
+// TurboProp and we wait for 3 ticks (2 for marking for optimization and an
+// additional tick to mark it for OSR) and hence this is set to 3 * 10.
+static const int kProfilerTicksForTurboPropOSR = 3 * 10;
   V(DoNotOptimize, "do not optimize") \
   V(HotAndStable, "hot and stable")   \
@@ -158,6 +166,12 @@
   // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller
   // than kMaxToplevelSourceSize.
+  // Turboprop optimizes quite early. So don't attempt to OSR if the loop isn't
+  // hot enough.
+  if (FLAG_turboprop && ticks < kProfilerTicksForTurboPropOSR) {
+    return false;
+  }
   if (function.IsMarkedForOptimization() ||
       function.IsMarkedForConcurrentOptimization() ||
       function.HasOptimizedCode()) {