[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}
This commit is contained in:
Mythri A 2020-08-05 15:08:41 +01:00 committed by Commit Bot
parent 82fc74c91b
commit bd9609a01d

View File

@ -38,6 +38,14 @@ static const int kOSRBytecodeSizeAllowancePerTick = 48;
// 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;
#define OPTIMIZATION_REASON_LIST(V) \
V(DoNotOptimize, "do not optimize") \
V(HotAndStable, "hot and stable") \
@ -158,6 +166,12 @@ bool RuntimeProfiler::MaybeOSR(JSFunction function, InterpretedFrame* frame) {
// 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()) {