539b50f5ae
When disabled, Turbofan is fully excluded from the compilation result. This is expected to reduce V8's contribution to chromium's binary size by roughly 20%. If Turbofan is disabled, Maglev and Webassembly must also be disabled (since both depend on TF). Note this new configuration (v8_enable_turbofan=false) is not yet used anywhere - we'll probably enable it for lite_mode bots in an upcoming CL for test coverage. Changes in detail: - Split out all src/compiler files from the main source sets. This was mostly done already, here we only clean up the few files that were left. - Define a new main TF entry point in turbofan.h. `NewCompilationJob` replaces `Pipeline::NewCompilationJob`. - When TF is enabled, turbofan-enabled.cc implements the above. - When disabled, turbofan-disabled stubs out the above with a runtime FATAL message. - The build process is modified s.t. mksnapshot always has TF available since it's needed to generate builtins. When disabled, TF is removed from other components, in particular it is no longer included in v8_compiler and transitively in v8_base. - When disabled, v8_for_testing no longer has v8_initializers available. These were only needed for test-serialize.cc, which is now excluded from this build mode. - When disabled, remove all related cctest/ und unittest/ files from the build. Bug: v8:13629 Change-Id: I63ab7632f03d0ee4a787cfc01574b5fdb08fd80b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4128529 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Auto-Submit: Jakob Linke <jgruber@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Jakob Linke <jgruber@chromium.org> Cr-Commit-Position: refs/heads/main@{#85210}
153 lines
3.5 KiB
JavaScript
153 lines
3.5 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 --turbofan --no-always-turbofan
|
|
|
|
(function optimize() {
|
|
function f() {
|
|
return 'abc'.includes('a');
|
|
}
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(true, f());
|
|
assertEquals(true, f());
|
|
assertEquals(true, f());
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(true, f());
|
|
assertOptimized(f);
|
|
|
|
function f2() {
|
|
return 'abc'.includes('a', 1);
|
|
}
|
|
%PrepareFunctionForOptimization(f2);
|
|
assertEquals(false, f2());
|
|
assertEquals(false, f2());
|
|
assertEquals(false, f2());
|
|
%OptimizeFunctionOnNextCall(f2);
|
|
assertEquals(false, f2());
|
|
assertOptimized(f2);
|
|
|
|
function f3() {
|
|
return 'abc'.includes('b');
|
|
}
|
|
%PrepareFunctionForOptimization(f3);
|
|
assertEquals(true, f3());
|
|
assertEquals(true, f3());
|
|
assertEquals(true, f3());
|
|
%OptimizeFunctionOnNextCall(f3);
|
|
assertEquals(true, f3());
|
|
assertOptimized(f3);
|
|
|
|
function f4() {
|
|
return 'abcbc'.includes('bc', 2);
|
|
}
|
|
%PrepareFunctionForOptimization(f4);
|
|
assertEquals(true, f4());
|
|
assertEquals(true, f4());
|
|
assertEquals(true, f4());
|
|
%OptimizeFunctionOnNextCall(f4);
|
|
assertEquals(true, f4());
|
|
assertOptimized(f4);
|
|
|
|
function f5() {
|
|
return 'abcbc'.includes('b', -1);
|
|
}
|
|
%PrepareFunctionForOptimization(f5);
|
|
assertEquals(true, f5());
|
|
assertEquals(true, f5());
|
|
assertEquals(true, f5());
|
|
%OptimizeFunctionOnNextCall(f5);
|
|
assertEquals(true, f5());
|
|
assertOptimized(f5);
|
|
|
|
function f6() {
|
|
return 'abcbc'.includes('b', -10737418);
|
|
}
|
|
%PrepareFunctionForOptimization(f6);
|
|
assertEquals(true, f6());
|
|
assertEquals(true, f6());
|
|
assertEquals(true, f6());
|
|
%OptimizeFunctionOnNextCall(f6);
|
|
assertEquals(true, f6());
|
|
assertOptimized(f6);
|
|
})();
|
|
|
|
(function optimizeOSR() {
|
|
function f() {
|
|
var result;
|
|
for (var i = 0; i < 100000; i++) {
|
|
result = 'abc'.includes('a');
|
|
}
|
|
return result;
|
|
}
|
|
assertEquals(true, f());
|
|
|
|
function f2() {
|
|
var result;
|
|
for (var i = 0; i < 100000; i++) {
|
|
result = 'abc'.includes('a', 1);
|
|
}
|
|
return result;
|
|
}
|
|
assertEquals(false, f2());
|
|
|
|
function f3() {
|
|
var result;
|
|
for (var i = 0; i < 100000; i++) {
|
|
result = 'abc'.includes('b');
|
|
}
|
|
return result;
|
|
}
|
|
assertEquals(true, f3());
|
|
|
|
function f4() {
|
|
var result;
|
|
for (var i = 0; i < 100000; i++) {
|
|
result = 'abcbc'.includes('bc', 2);
|
|
}
|
|
return result;
|
|
}
|
|
assertEquals(true, f4());
|
|
})();
|
|
|
|
(function bailout() {
|
|
function f(str) {
|
|
return String.prototype.includes.call(str, 'a')
|
|
}
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(true, f('abc'));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(true, f({
|
|
toString: () => {
|
|
return 'abc'
|
|
}
|
|
}));
|
|
assertUnoptimized(f);
|
|
|
|
function f2(str) {
|
|
return 'abc'.includes(str)
|
|
}
|
|
%PrepareFunctionForOptimization(f2);
|
|
assertEquals(true, f2('a'));
|
|
%OptimizeFunctionOnNextCall(f2);
|
|
assertEquals(true, f2({
|
|
toString: () => {
|
|
return 'a'
|
|
}
|
|
}));
|
|
assertUnoptimized(f2);
|
|
|
|
function f3(index) {
|
|
return 'abc'.includes('a', index)
|
|
}
|
|
%PrepareFunctionForOptimization(f3);
|
|
assertEquals(true, f3(0));
|
|
%OptimizeFunctionOnNextCall(f3);
|
|
assertEquals(true, f3({
|
|
valueOf: () => {
|
|
return 0
|
|
}
|
|
}));
|
|
assertUnoptimized(f3);
|
|
})();
|