v8/test/mjsunit/maglev/osr-from-ml-to-tf.js
Jakob Linke ed90ea5cf7 [maglev] Implement Maglev-to-Turbofan OSR
This implementation sticks closely to what Ignition-to-Turbofan (and now
Sparkplug-to-TF) does. OSR is detected in the TieringManager by having
optimized code available, without having entered it. The osr_urgency is
increased to enable OSR for increasing loop depths. When a candidate
JumpLoop backedge is reached, we call into runtime to trigger OSR
compilation.

JumpLoop also detects the availability of cached OSR'd code. When a
matching OSR code object is available, Maglev 1) deoptimizes s.t. the
unoptimized frame layout is reconstructed, and 2) delegates the actual
OSR tierup to the unoptimized tier. For purposes of 1), we add a new
DeoptimizeReason that causes a one-time eager deopt without invalidating
any code.

Drive-by: Annotate OSR for more --trace-opt output.

Todo: Refactor non-Sparkplug-specific bits of the BaselineAssembler
into a generic spot that both SP and ML can use.

Bug: v8:7700
Change-Id: I6ebab2df8b87f9f70ffb78162a3c1226ec545468
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3859850
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82816}
2022-08-30 11:51:28 +00:00

36 lines
880 B
JavaScript

// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --allow-natives-syntax --maglev --no-stress-opt
// Flags: --no-baseline-batch-compilation --use-osr --turbofan
let keep_going = 10000000; // A counter to avoid test hangs on failure.
let i; // The loop counter for the test function.
function f() {
let sum = i;
while (--i > 0 && !%CurrentFrameIsTurbofan() && --keep_going) {
// This loop should trigger OSR.
sum += i;
}
return sum;
}
function g() {
assertTrue(%IsMaglevEnabled());
while (!%ActiveTierIsMaglev(f) && --keep_going) {
i = 5.2;
f();
}
console.log('osr to tf', keep_going);
assertTrue(%IsTurbofanEnabled());
i = 66666666666;
f();
assertTrue(keep_going > 0);
}
%NeverOptimizeFunction(g);
g();