v8/test/mjsunit/maglev/tier-to-ml-to-tf.js
Jakob Linke 0bc4b452af [maglev] Implement Maglev-to-Turbofan tiering
ML-TF tiering remains very similar to Ignition-TF tiering:

- When the interrupt budget is exhausted, enter the TieringManager
  which potentially decides to tier up and sets the appropriate
  TieringState on the FeedbackVector.
- The prologue on ML function entry recognizes the TieringState (and
  also available cached TF code) and starts compilation and/or jumps
  into optimized code.

TODOs:

- ML-to-TF OSR is not yet supported.
- ML code is no longer cached on the FeedbackVector.
- Tracing is rudimentary.
- The generated function-entry prologue is fairly large and must be
  either minimized or extracted into a builtin.
- Tiering involving Sparkplug is not entirely robust yet (Sparkplug
  code may be installed with unexpected timing).

Bug: v8:7700
Change-Id: I86b0692477f51b9967f318a4093bc874344120b3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3629149
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82351}
2022-08-10 14:00:53 +00:00

47 lines
1.1 KiB
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
function f(x) {
var y = 0;
for (var i = 0; i < x; i++) {
y = 1;
}
return y;
}
let keep_going = 100000; // A counter to avoid test hangs on failure.
function g() {
// Test that normal tiering (without OptimizeFooOnNextCall) works.
// We test the entire pipeline, i.e. Ignition-SP-ML-TF.
f(10);
// TODO(v8:7700): Enable.
/*
if (%IsSparkplugEnabled()) {
while (!%ActiveTierIsSparkplug(f) && --keep_going) f(10);
assertTrue(%ActiveTierIsSparkplug(f));
}
if (%IsMaglevEnabled()) {
while (!%ActiveTierIsMaglev(f) && --keep_going) f(10);
assertTrue(%ActiveTierIsMaglev(f));
}
*/
if (%IsTurbofanEnabled()) {
while (!%ActiveTierIsTurbofan(f) && --keep_going) f(10);
assertTrue(%ActiveTierIsTurbofan(f));
f(10);
assertTrue(%ActiveTierIsTurbofan(f));
}
}
%NeverOptimizeFunction(g);
g();