a5a87e1e87
Maglev is mid-tier optimising compiler designed mainly for compilation speed that can still generate good code for straightforward JS. This initial commit is an MVP for Maglev which can compile and run some very simple code, and sets up a framework that we can build upon. Design: https://docs.google.com/document/d/13CwgSL4yawxuYg3iNlM-4ZPCB8RgJya6b8H_E2F-Aek/edit# Bug: v8:7700 Change-Id: I5ae074ae099126c2c0d50864ac9b3d6fa5c9e85a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3483664 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#79247}
22 lines
468 B
JavaScript
22 lines
468 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
|
|
|
|
function f(x) {
|
|
var y = 0;
|
|
for (var i = 0; i < x; i++) {
|
|
y = 1;
|
|
}
|
|
return y;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(1, f(true));
|
|
assertEquals(0, f(false));
|
|
|
|
%OptimizeMaglevOnNextCall(f);
|
|
assertEquals(1, f(true));
|
|
assertEquals(0, f(false));
|